:root {
  --bg: #0b0f17;
  --panel: #121826;
  --line: #243044;
  --text: #e8eefc;
  --muted: #8b9bb8;
  --accent: #5b8cff;
  --accent2: #7c5cff;
  --ok: #3dd68c;
  --danger: #ff6b7a;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font);
  color: var(--text); background:
    radial-gradient(1200px 600px at 10% -10%, #1a1040 0%, transparent 50%),
    radial-gradient(900px 500px at 100% 0%, #0d2848 0%, transparent 45%),
    var(--bg);
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; }
.logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.pill {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.03);
}
.pill.on { color: var(--ok); border-color: rgba(61,214,140,.35); }
.grid {
  display: grid; gap: 14px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
}
.card {
  background: rgba(18,24,38,.92); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.card h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input[type=text], input[type=password] {
  flex: 1; min-width: 160px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: #0a101c; color: var(--text);
  padding: 0 12px; font-size: 16px; outline: none;
}
input:focus { border-color: var(--accent); }
button, a.btn {
  height: 40px; border: 0; border-radius: 10px; padding: 0 14px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
button.secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
button:disabled { opacity: .45; cursor: not-allowed; }
.chat-card { grid-column: 1 / -1; display: flex; flex-direction: column; min-height: 420px; }
.chat-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  justify-content: space-between; margin-bottom: 10px;
}
.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
}
.seg button {
  height: 32px; border-radius: 0; background: transparent; color: var(--muted);
  font-weight: 500; box-shadow: none;
}
.seg button.active { background: rgba(91,140,255,.2); color: var(--text); }
.msgs {
  flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; background: #0a101c; display: flex; flex-direction: column; gap: 10px;
  min-height: 280px; max-height: 48vh;
}
.bubble {
  max-width: 85%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.bubble.user { align-self: flex-end; background: rgba(91,140,255,.25); }
.bubble.bot { align-self: flex-start; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.bubble.sys { align-self: center; color: var(--muted); font-size: 12px; background: transparent; }
.composer { display: flex; gap: 8px; margin-top: 10px; }
.composer input { flex: 1; }
footer { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card { width: min(420px, 100%); }
[hidden] { display: none !important; }
