/* Numen Hall web chat — minimal original styling (E8). No framework. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #5b8cff;
  --user: #2a3550;
  --assistant: #20242e;
}
* { box-sizing: border-box; }
/* The view toggles panels with the `hidden` attribute. `.login`/`.app` set
   `display: grid`, which outranks the UA `[hidden] { display: none }` rule, so
   without this a hidden panel keeps rendering (login + chat stack and you scroll
   past a dead form). Make `hidden` authoritative. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.muted { color: var(--muted); }
.error { color: #ff6b6b; min-height: 1.2em; margin: 0.4em 0 0; }
button { cursor: pointer; font: inherit; }
.link {
  background: none; border: none; color: var(--accent); padding: 0; text-align: left;
}
/* Secondary login actions (Forgot password?, Back to sign in). */
.login-aux { margin: 0; text-align: center; }
.login-aux .link { text-align: center; font-size: 0.9em; }

/* Login */
.login { display: grid; place-items: center; height: 100%; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
/* Brand lockup is an SVG, so it stays crisp at any width; cap by height and let
   width scale with the ~3.44:1 aspect ratio. */
.login-brand { margin: 0 0 4px; line-height: 0; }
.login-brand img { height: 44px; width: auto; max-width: 100%; display: block; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 9px 10px; font: inherit;
}
/* Password field with a reveal/hide toggle. The input keeps the panel styling;
   the toggle sits inside the field box, so the input loses its own border and
   the wrapper carries it. */
.pw-field { position: relative; display: flex; }
.pw-field input { flex: 1; padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 6px; border-radius: 6px;
}
.pw-toggle svg { display: block; }
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card button[type="submit"] {
  background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px; margin-top: 6px;
}

/* App layout */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px; gap: 10px; overflow: hidden; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.brand-logo { height: 26px; width: auto; max-width: 180px; display: block; }
.session-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.session-list li {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; cursor: pointer;
}
.session-list li.active { border-color: var(--accent); }
.session-list .s-title { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-list .s-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Chat pane */
.chat { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.origin { font-size: 12px; color: var(--muted); }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72ch; padding: 9px 12px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); }
.msg.assistant { align-self: flex-start; background: var(--assistant); border: 1px solid var(--line); }
.msg.system, .msg.tool { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.msg .role { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.send { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.send textarea {
  flex: 1; resize: vertical; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); padding: 9px 10px; font: inherit;
}
.send button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0 18px;
}
.send button:disabled { opacity: 0.5; cursor: default; }
#chat-error { padding: 0 18px 10px; }

/* Sidebar action row (Refresh / Settings). */
.sidebar-actions { display: flex; gap: 14px; }

/* --- Setup wizard (NUM-48) --------------------------------------------------- */
.wizard-card { width: min(560px, 94vw); gap: 16px; }
.wizard-card h2 { margin: 0 0 2px; font-size: 18px; }

/* Stepper across the top of the wizard. */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; justify-content: space-between; }
.stepper .step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; font-size: 11px; color: var(--muted); }
.stepper .dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.stepper .step.active .dot { border-color: var(--accent); color: var(--text); }
.stepper .step.active .step-label { color: var(--text); }
.stepper .step.done .dot { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Provider preset chips. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); padding: 5px 12px; font-size: 13px;
}
.chip.active { border-color: var(--accent); color: #fff; background: var(--user); }

/* Model-config form fields (shared by wizard + settings). */
.model-form { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 9px 10px; font: inherit;
}
select.field { appearance: none; }

.wizard-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.wizard-actions button, .settings button:not(.link) {
  background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font: inherit;
}
.wizard-actions button.secondary, .settings button.secondary {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
}
.wizard-actions button:disabled { opacity: 0.5; cursor: default; }

.test-out { font-size: 13px; margin: 2px 0 0; min-height: 1.2em; }
.test-out.ok { color: #4ccb8a; }
.test-out.err { color: #ff6b6b; }
.code-block {
  display: block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; color: var(--text);
}
.note { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; }

/* --- Settings overlay -------------------------------------------------------- */
.settings {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: grid; place-items: center; z-index: 20; padding: 20px;
}
.settings-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; width: min(560px, 94vw); max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.settings-head { display: flex; justify-content: space-between; align-items: center; }
.settings-head h2 { margin: 0; font-size: 20px; }
.settings-section { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.settings-section h3 { margin: 0; font-size: 15px; }
.settings-section p { margin: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
