@font-face { font-family: Geist; src: url(/web/fonts/Geist-Variable.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url(/web/fonts/GeistMono-Variable.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

/* one neutral (cool slate), one accent (cobalt); radius scale: 8px controls, 12px panels, pill only for the segmented control */
:root {
  --bg: #f4f5f7;
  --surface: #fbfbfc;
  --surface-2: #eef0f3;
  --line: #dfe2e7;
  --text: #16181d;
  --muted: #5b6270;
  --accent: #2f52c4;
  --accent-ink: #f7f8fc;
  --accent-soft: #e5eaf9;
  --ok: #1f7a4d;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --danger: #b4232f;
  --shadow: 0 1px 2px rgb(22 30 50 / .06), 0 8px 24px rgb(22 30 50 / .06);
  --r: 8px;
  --r-lg: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #161a20;
    --surface-2: #1d222a;
    --line: #2a303a;
    --text: #e6e8ec;
    --muted: #9aa2b1;
    --accent: #8ea6f2;
    --accent-ink: #0f1115;
    --accent-soft: #1f2843;
    --ok: #5cc28f;
    --warn: #e2b04a;
    --warn-soft: #2b2416;
    --danger: #f07a83;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 Geist, system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.mono, code { font-family: 'Geist Mono', ui-monospace, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.i { display: inline-block; width: 1.15em; height: 1.15em; flex: none; background: currentColor;
  -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; height: 38px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background .15s, transform .1s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 550; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* login */
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100dvh; }
.login-side { background: var(--accent); color: var(--accent-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: clamp(2rem, 3.4vw, 3rem); line-height: 1.08; letter-spacing: -.02em; margin: 0; max-width: 14ch; font-weight: 600; }
.login-side p { max-width: 40ch; opacity: .85; margin: 16px 0 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.login-main { display: grid; place-items: center; padding: 32px 16px; }
.login form { width: min(360px, 100%); display: grid; gap: 18px; }
.login h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.01em; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 550; font-size: .9rem; }
.field input, .field select { height: 40px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.4em; margin: 0; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.rail { border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.rail .brand { padding: 4px 10px 20px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); color: var(--muted); text-decoration: none; }
.nav:hover { background: var(--surface-2); color: var(--text); }
.nav[aria-current='page'] { background: var(--accent-soft); color: var(--text); font-weight: 550; }
.nav[aria-current='page'] .i { color: var(--accent); }
.rail-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: .9rem; }
main { padding: 32px clamp(16px, 4vw, 48px); max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.75rem; letter-spacing: -.02em; font-weight: 600; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 65ch; }

/* overview */
.conn { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 32px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.conn .panel h2 { margin: 0 0 4px; font-size: 1.15rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 550; font-size: .9rem; }
.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.live.off { color: var(--danger); }
.stat { font-size: 2.4rem; font-weight: 600; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mod { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 10px; align-content: start; }
.mod-top { display: flex; align-items: center; gap: 10px; }
.mod-icon { width: 36px; height: 36px; border-radius: var(--r); display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.mod.ok .mod-icon { background: var(--accent-soft); color: var(--accent); }
.mod h3 { margin: 0; font-size: 1rem; }
.mod p { margin: 0; font-size: .88rem; color: var(--muted); }
.mod-foot { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); background: var(--warn-soft); }
.tag.accent { color: var(--accent); background: var(--accent-soft); }

/* skeleton */
.sk { background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%;
  border-radius: 6px; animation: sk 1.3s ease-in-out infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } * { transition: none !important; } }

/* permissions */
.perm-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.perm { display: grid; grid-template-columns: 36px 1fr auto; gap: 14px; align-items: center; padding: 16px 20px; }
.perm + .perm { border-top: 1px solid var(--line); }
.perm h3 { margin: 0; font-size: 1rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.perm p { margin: 2px 0 0; font-size: .88rem; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 550; }
.seg button[aria-pressed='true'][data-level='write'] { color: var(--warn); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.savebar { position: sticky; bottom: 16px; margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); font-size: .9rem; margin-bottom: 20px; }
.note.warn { background: var(--warn-soft); color: var(--text); }
.note.warn .i { color: var(--warn); }
.note p { margin: 0; }

/* chat */
.chat { display: grid; grid-template-rows: auto 1fr auto; height: calc(100dvh - 64px); max-width: 860px; }
.chat-head { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; padding-bottom: 12px; }
.chat-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; font-weight: 600; }
.chat-head .field { min-width: 240px; }
.log { overflow-y: auto; padding: 8px 2px 24px; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--accent-soft); padding: 10px 14px; border-radius: var(--r-lg); max-width: 80%; white-space: pre-wrap; }
.msg.assistant .md { overflow-x: auto; }
.md p { margin: 0 0 .7em; } .md p:last-child { margin-bottom: 0; }
.md table { border-collapse: collapse; font-size: .9rem; margin: .5em 0; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { color: var(--muted); font-weight: 550; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: var(--r); overflow-x: auto; }
.steps { display: grid; gap: 4px; margin-bottom: 8px; }
.step { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--muted); }
.step .i { width: 1em; height: 1em; }
.step.err { color: var(--danger); }
.typing { display: flex; gap: 6px; }
.typing .sk { width: 120px; height: 10px; }
.empty { margin: auto 0; display: grid; gap: 14px; max-width: 560px; }
.empty h2 { margin: 0; font-size: 1.2rem; }
.prompts { display: grid; gap: 8px; }
.prompts button { text-align: left; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.prompts button:hover { border-color: var(--accent); }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
.composer textarea { border: 0; background: transparent; resize: none; min-height: 44px; max-height: 200px; padding: 8px; outline: none; }
.err-text { color: var(--danger); }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 28px 16px; gap: 24px; }
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail .brand { padding: 0 8px 0 0; }
  .rail-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .rail-foot .who { display: none; }
  main { padding: 20px 16px; }
  .conn { grid-template-columns: 1fr; }
  .perm { grid-template-columns: 36px 1fr; }
  .perm .seg { grid-column: 1 / -1; justify-self: start; }
  .chat { height: calc(100dvh - 100px); }
}

/* MCP access tokens */
.panel.stack { display: grid; gap: 14px; margin-bottom: 20px; }
.panel.stack h2 { margin: 0; font-size: 1.15rem; }
.panel.stack .note { margin: 0; }
.token-form { display: flex; gap: 12px 16px; align-items: flex-end; flex-wrap: wrap; }
.token-form .field { flex: 1 1 260px; }
.check { display: inline-flex; align-items: center; gap: 8px; height: 40px; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.copy { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 4px 4px 4px 12px; }
.copy code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .85rem; }
.copy .btn { flex: none; height: 32px; }
