/* Gateway console: design system + app shell.
   Monochrome accents on neutral surfaces; hairline borders do the grouping and shadows are reserved
   for floating layers (menus, dialogs, toasts). Variance low, motion subtle (120-200ms, reduced-motion safe).
   Radius scale: 6 chips, 8 controls, 12 cards, 16 dialogs, 999 pills.
   Token names (--bg, --surface, --sunken, --ink*, --line*) are also what usage.css maps its plugin tokens to. */

/* Fonts are bundled (fonts/, SIL OFL) so the console never calls a font CDN. Inter = interface, Newsreader = the
   serif used for the wordmark and page titles, the way Claude pairs a serif with a clean sans. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-ext-wght.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("fonts/newsreader-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("fonts/newsreader-latin-ext-wght.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;
  --side-hover: #eeeeee;
  --side-active: var(--accent-soft);
  --bg: #ffffff;
  --sidebar: #f8f8f8;
  --surface: #ffffff;
  --sunken: #f4f4f4;
  --hover: rgba(0, 0, 0, .06);
  --ink: #202020;
  --ink-2: #444444;
  --ink-3: #5c5c5c;
  --line: #e4e4e4;
  --line-strong: #cdcdcd;
  --control-line: #808080;
  --accent: #242424;
  --accent-hover: #111111;
  --accent-ink: #ffffff;
  --accent-soft: #ededed;
  --accent-text: #242424;
  --ring: var(--accent);
  --ok: #177245;
  --ok-soft: #e3f2ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #f8eed6;
  --info: #2a5fa5;
  --info-soft: #e6eefa;
  --c-in: #3b82f6;
  --c-out: #10b981;
  --c-cr: #626262;
  --c-cw: #f59e0b;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-pop: 0 12px 32px -8px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .08);
  --scrim: rgba(0, 0, 0, .45);
  --r-sm: 6px;
  --r: 8px;
  --r-card: 12px;
  --r-lg: 16px;
  --side-w: 256px;
  --top-h: 56px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
/* Dark palette is declared twice (explicit + prefers-color-scheme) because CSS cannot share a block between a
   media query and an attribute selector without a preprocessor. Keep both in sync. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515;
  --sidebar: #1b1b1b;
  --side-hover: rgba(255, 255, 255, .05);
  --side-active: var(--accent-soft);
  --surface: #202020;
  --sunken: #282828;
  --hover: rgba(255, 255, 255, .06);
  --ink: #f5f5f5;
  --ink-2: #cdcdcd;
  --ink-3: #a5a5a5;
  --line: #343434;
  --line-strong: #4b4b4b;
  --control-line: #858585;
  --accent: #dedede;
  --accent-hover: #f0f0f0;
  --accent-ink: #202020;
  --accent-soft: #333333;
  --accent-text: #f0f0f0;
  --ring: var(--accent);
  --ok: #4cc38a;
  --ok-soft: #12261c;
  --bad: #f2766b;
  --bad-soft: #2b1512;
  --warn: #e0b04a;
  --warn-soft: #2a2110;
  --info: #6aa6ee;
  --info-soft: #14202f;
  --c-in: #60a5fa;
  --c-out: #34d399;
  --c-cr: #c4c4c4;
  --c-cw: #fbbf24;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-pop: 0 16px 40px -8px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .62);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #151515;
    --sidebar: #1b1b1b;
    --side-hover: rgba(255, 255, 255, .05);
    --side-active: var(--accent-soft);
    --surface: #202020;
    --sunken: #282828;
    --hover: rgba(255, 255, 255, .06);
    --ink: #f5f5f5;
    --ink-2: #cdcdcd;
    --ink-3: #a5a5a5;
    --line: #343434;
    --line-strong: #4b4b4b;
    --control-line: #858585;
    --accent: #dedede;
    --accent-hover: #f0f0f0;
    --accent-ink: #202020;
    --accent-soft: #333333;
    --accent-text: #f0f0f0;
    --ring: var(--accent);
    --ok: #4cc38a;
    --ok-soft: #12261c;
    --bad: #f2766b;
    --bad-soft: #2b1512;
    --warn: #e0b04a;
    --warn-soft: #2a2110;
    --info: #6aa6ee;
    --info-soft: #14202f;
    --c-in: #60a5fa;
    --c-out: #34d399;
    --c-cr: #c4c4c4;
    --c-cw: #fbbf24;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-pop: 0 16px 40px -8px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .5);
    --scrim: rgba(0, 0, 0, .62);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, dl, dd, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-feature-settings: "calt" 0; }
.num, .mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ico { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 15px; height: 15px; }
.ico.lg { width: 22px; height: 22px; }
.scroll-y { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 0 13px; border-radius: var(--r);
  background: var(--surface); color: var(--ink); border: 1px solid var(--control-line);
  font-size: 13px; font-weight: 550; white-space: nowrap; line-height: 1;
  transition: background-color .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease), transform .14s var(--ease), box-shadow .14s var(--ease);
  box-shadow: var(--shadow-1);
}
.btn:hover:not(:disabled) { background: var(--sunken); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: none; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-strong)); }
.btn.danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: var(--accent-ink); }
.btn.danger.solid:hover:not(:disabled) { filter: brightness(1.08); background: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn[aria-pressed="true"]:not(.primary) { background: var(--sunken); }
.btn .spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.field .err { font-size: 12px; color: var(--bad); font-weight: 550; }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 11px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--control-line); border-radius: var(--r);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--ring); outline-offset: 2px; border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input:disabled, .select:disabled { opacity: .55; cursor: not-allowed; background: var(--sunken); }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d7b9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.select.sm, .input.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.select.sm { padding-right: 28px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ico { position: absolute; left: 11px; color: var(--ink-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix > span { position: absolute; left: 11px; color: var(--ink-3); font-family: var(--mono); pointer-events: none; }
.input-affix > .input { padding-left: 24px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; width: fit-content; min-height: 28px; }
.switch input { position: absolute; left: 0; top: 2px; width: 38px; height: 24px; margin: 0; opacity: 0; cursor: pointer; }
.switch .track { position: relative; flex-shrink: 0; width: 38px; height: 22px; border-radius: 999px; background: var(--control-line); transition: background-color .18s var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { background: var(--accent-ink); transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled, .switch input:disabled ~ * { cursor: not-allowed; opacity: .6; }
.switch .state { font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-width: 22px; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; min-height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--sunken); color: var(--ink-2);
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.chip { /* status code */
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 20px; padding: 0 7px;
  border-radius: var(--r-sm); font: 600 12px var(--mono); font-variant-numeric: tabular-nums;
}
.chip.ok { color: var(--ok); background: var(--ok-soft); }
.chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.mid { color: var(--ink-2); background: var(--sunken); }
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--ink-3); font: 600 11px var(--sans);
}

/* ---------- Segmented control & tabs ---------- */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; }
.seg button {
  min-height: 28px; padding: 0 11px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-3); font-size: 12.5px; font-weight: 600; transition: background-color .14s var(--ease), color .14s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); }
.tabs button {
  min-height: 38px; padding: 0 2px; margin-bottom: -1px; background: transparent; border: 0; border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 600; color: var(--ink-3); transition: color .14s var(--ease), border-color .14s var(--ease);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Cards, tables, empty ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); min-width: 0; }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 16px 20px 0; }
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 650; letter-spacing: -.005em; }
.card-head p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 14px 20px 18px; }
.card-foot { padding: 11px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--ink-3); font-size: 12.5px; }

.table-wrap { overflow: auto; max-width: 100%; }
.table { font-size: 13px; }
.table th, .table td { padding: 11px 16px; text-align: left; white-space: nowrap; vertical-align: middle; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  color: var(--ink-3); font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.table tbody tr + tr td { border-top: 1px solid var(--line); }
.table tbody tr { transition: background-color .12s var(--ease); }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr[data-row] { cursor: pointer; }
.table th.r, .table td.r { text-align: right; }
.table td.m { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table td.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.table td.dim { color: var(--ink-2); }
.table-wrap.flush { border-top: 1px solid var(--line); margin-top: 14px; }
.card-head + .table-wrap { margin-top: 14px; border-top: 1px solid var(--line); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 44px 24px; color: var(--ink-3); }
.empty .empty-ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--sunken); color: var(--ink-3); margin-bottom: 6px; }
.empty h3 { font-size: 14.5px; font-weight: 650; color: var(--ink); }
.empty p { max-width: 46ch; font-size: 13px; }
.empty .btn { margin-top: 10px; }

.skeleton { display: block; border-radius: 6px; height: 12px; background: linear-gradient(90deg, var(--sunken) 0%, color-mix(in srgb, var(--line) 85%, var(--sunken)) 50%, var(--sunken) 100%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s linear infinite; } }
@keyframes shimmer { to { background-position: -200% 0; } }

.progress { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.progress > i { display: block; height: 100%; width: calc(var(--w, 0) * 1%); border-radius: inherit; background: var(--accent); transition: width .4s var(--ease); }
.progress[data-tone="ok"] > i { background: var(--ok); }
.progress[data-tone="warn"] > i { background: var(--warn); }
.progress[data-tone="bad"] > i { background: var(--bad); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-left-width: 3px; border-radius: var(--r-card); background: var(--surface); }
.banner strong { display: block; font-size: 13px; }
.banner p { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.banner[data-tone="bad"] { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); border-left-color: var(--bad); }
.banner[data-tone="bad"] strong, .banner[data-tone="bad"] > .ico { color: var(--bad); }
.banner[data-tone="warn"] { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); border-left-color: var(--warn); }
.banner[data-tone="warn"] strong, .banner[data-tone="warn"] > .ico { color: var(--warn); }
.banner[data-tone="info"] { border-left-color: var(--info); }
.banner[data-tone="info"] > .ico { color: var(--info); }
.banner .grow { flex: 1; min-width: 0; }

/* ---------- Menus, tooltips, toasts ---------- */
.menu {
  position: fixed; z-index: 90; min-width: 188px; padding: 5px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-pop);
}
@media (prefers-reduced-motion: no-preference) { .menu { animation: pop .14s var(--ease); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu button, .menu a {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px;
  background: transparent; text-align: left; font-size: 13px; font-weight: 500; color: var(--ink);
}
.menu button:hover, .menu a:hover, .menu [data-active="true"] { background: var(--hover); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 2px; }
.menu .danger { color: var(--bad); }
.menu .ico { color: var(--ink-3); }
.menu .danger .ico { color: var(--bad); }

.toasts { position: fixed; z-index: 120; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; background: var(--ink); color: var(--bg);
  border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 13px; font-weight: 500;
}
.toast[data-tone="ok"] .ico { color: #4cc38a; }
.toast[data-tone="bad"] .ico { color: #f2766b; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: pop .2s var(--ease); } }

/* ---------- Dialogs & drawer ---------- */
dialog { padding: 0; border: 0; background: transparent; color: var(--ink); max-width: 100vw; max-height: 100dvh; }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.modal { width: min(520px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.modal.wide { width: min(680px, calc(100vw - 32px)); }
@media (prefers-reduced-motion: no-preference) { dialog[open] .modal { animation: pop .18s var(--ease); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.modal-head p { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.modal-body { padding: 16px 22px 20px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--sunken) 55%, var(--surface)); border-radius: 0 0 var(--r-lg) var(--r-lg); }
dialog.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; }
dialog.drawer .modal { width: min(480px, 100vw); height: 100dvh; max-height: 100dvh; border-radius: var(--r-lg) 0 0 var(--r-lg); border-right: 0; }
dialog.drawer .modal-foot { border-radius: 0; }
@media (prefers-reduced-motion: no-preference) { dialog.drawer[open] .modal { animation: slide-in .22s var(--ease); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

.code {
  position: relative; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-card);
  font: 12.5px/1.65 var(--mono); color: var(--ink); overflow: hidden;
}
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; white-space: pre; }
.code .copy { position: absolute; top: 8px; right: 8px; }
.code .kw { color: var(--accent-text); }
.code-tabs { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; transition: grid-template-columns .2s var(--ease); }
.app[data-collapsed="true"] { --side-w: 68px; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; min-width: 0;
  background: var(--sidebar); border-right: 1px solid var(--line); z-index: 40;
}
/* Sidebar: symbol + serif wordmark, a single prominent action, flat items with a soft active fill, and the
   account at the bottom. No boxes, no uppercase labels. */
.side-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 6px 18px; min-height: var(--top-h); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { width: 28px; height: 28px; display: grid; place-items: center; flex-shrink: 0; }
.logo .brand-mark { width: 26px; height: 26px; }
.brand-text { display: flex; min-width: 0; line-height: 1; }
.brand-text b { font: 500 24px/1 var(--serif); letter-spacing: -.025em; color: var(--ink); white-space: nowrap; padding-bottom: 3px; }

.side-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 8px 12px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-label { padding: 6px 12px 4px; font-size: 12px; font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 34px; padding: 0 12px; margin: 1px 0;
  border-radius: 8px; color: var(--ink); font-size: 14px; font-weight: 450; letter-spacing: -.003em; white-space: nowrap;
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.nav-item .ico { color: var(--ink-2); stroke-width: 1.6; transition: color .12s var(--ease); }
.nav-item:hover { background: var(--side-hover); }
.nav-item[aria-current="page"] { background: var(--side-active); font-weight: 500; }
.nav-item[aria-current="page"] .ico { color: var(--ink); }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item.new { margin-bottom: 8px; font-weight: 500; }
.nav-item.new .plus { width: 24px; height: 24px; margin: 0 -3px 0 -3px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); transition: background-color .12s var(--ease); }
.nav-item.new .plus .ico { width: 14px; height: 14px; stroke: var(--accent-ink); stroke-width: 2.4; }
.nav-item.new:hover .plus { background: var(--accent-hover); }
.nav-count { font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 0 2px; font-variant-numeric: tabular-nums; }
.nav-count.warn { color: var(--warn); background: var(--warn-soft); border-radius: 999px; padding: 0 7px; font-weight: 600; }
.nav-live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.nav-ext { color: var(--ink-3); }

.side-foot { padding: 8px 8px 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.side-card { padding: 4px 12px 8px; }
.side-card .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.side-card .k { font-size: 12px; color: var(--ink-3); font-weight: 450; }
.side-card .v { font: 500 13px var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.side-card .spark { margin-top: 6px; display: block; width: 100%; height: 26px; }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; min-width: 0; margin-top: 2px; }
.user-btn:hover { background: var(--side-hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; }
.user-btn .avatar { background: var(--ink); color: var(--bg); font-weight: 600; letter-spacing: .01em; }
.user-btn .meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; flex: 1; }
.user-btn .meta b { font-size: 13.5px; font-weight: 500; }
.user-btn .meta span { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn > .ico { color: var(--ink-3); }

.app[data-collapsed="true"] .brand-text,
.app[data-collapsed="true"] .nav-label,
.app[data-collapsed="true"] .nav-item .grow,
.app[data-collapsed="true"] .nav-count,
.app[data-collapsed="true"] .nav-ext,
.app[data-collapsed="true"] .side-card,
.app[data-collapsed="true"] .user-btn .meta,
.app[data-collapsed="true"] .user-btn > .ico { display: none; }
.app[data-collapsed="true"] .nav-label { display: block; height: 10px; padding: 0; font-size: 0; }
.app[data-collapsed="true"] .nav-item { justify-content: center; padding: 0; }
.app[data-collapsed="true"] .nav-item .nav-live { position: absolute; top: 7px; right: 10px; }
.app[data-collapsed="true"] .side-brand { padding: 14px 0 10px; justify-content: center; flex-direction: column; gap: 10px; }
.app[data-collapsed="true"] .user-btn { justify-content: center; padding: 8px 0; }
.app[data-collapsed="true"] .collapse-btn .ico { transform: scaleX(-1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 32px; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.language-switcher {
  min-height: 34px; max-width: 100%; border: 1px solid var(--control-line); border-radius: var(--r);
  padding: 4px 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer;
}
.language-switcher:hover { border-color: var(--ink-3); }
.language-switcher:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-language { display: flex; justify-content: center; }
.top-left, .top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-3); min-width: 0; white-space: nowrap; }
.crumbs b { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 650; }
.crumbs .ico { width: 14px; height: 14px; }
.menu-btn { display: none; flex-shrink: 0; }
.top-right > :not(.search-btn) { flex-shrink: 0; }
.search-btn {
  display: inline-flex; align-items: center; gap: 9px; min-height: 34px; padding: 0 8px 0 11px; width: 260px; max-width: 32vw;
  border: 1px solid var(--control-line); border-radius: var(--r); background: var(--surface); color: var(--ink-3); font-size: 13px;
}
.search-btn:hover { border-color: var(--ink-3); color: var(--ink-2); }
.search-btn .grow { flex: 1; text-align: left; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink-3); background: var(--surface); }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.live-pill[data-state="live"] { color: var(--ink-2); }
.live-pill[data-state="live"] i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.live-pill[data-state="bad"] i { background: var(--bad); }
.live-pill[data-state="paused"] i { background: var(--warn); }

.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 32px 72px; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.page-head h1 { font: 500 30px/1.15 var(--serif); letter-spacing: -.02em; }
.page-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page.fill { max-width: none; padding: 0; gap: 0; height: calc(100dvh - var(--top-h)); }
@media (prefers-reduced-motion: no-preference) { .page > * { animation: rise .32s var(--ease) backwards; } .page > *:nth-child(2) { animation-delay: .04s; } .page > *:nth-child(3) { animation-delay: .08s; } .page > *:nth-child(n+4) { animation-delay: .12s; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.scrim { display: none; }

@media (max-width: 1040px) {
  .search-btn { width: 40px; padding: 0; justify-content: center; }
  .search-btn .grow, .search-btn kbd { display: none; }
}
@media (max-width: 900px) {
  .app, .app[data-collapsed="true"] { grid-template-columns: minmax(0, 1fr); --side-w: 276px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); transform: translateX(-102%); transition: transform .24s var(--ease); box-shadow: var(--shadow-pop); }
  .app[data-nav-open="true"] .sidebar { transform: none; }
  .app[data-nav-open="true"] .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); }
  .app[data-collapsed="true"] .brand-text, .app[data-collapsed="true"] .nav-label, .app[data-collapsed="true"] .nav-item .grow,
  .app[data-collapsed="true"] .nav-count, .app[data-collapsed="true"] .nav-ext,
  .app[data-collapsed="true"] .side-card, .app[data-collapsed="true"] .user-btn .meta, .app[data-collapsed="true"] .user-btn > .ico { display: revert; }
  .app[data-collapsed="true"] .nav-item { justify-content: flex-start; padding: 0 10px; }
  .collapse-btn { display: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px 56px; }
  .live-pill span { display: none; }
  .live-pill { padding: 0 9px; }
}
@media (max-width: 530px) {
  .topbar { gap: 6px; padding-inline: 10px; }
  .top-left, .top-right { gap: 6px; }
  .top-right { flex-shrink: 0; }
  .crumbs > span, .crumbs > .ico { display: none; }
}
@media (max-width: 360px) {
  .topbar .crumbs { display: none; }
}

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 520px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 18px; }
.login-card .brand { justify-content: center; margin-bottom: 4px; gap: 10px; }
.login-card .logo, .login-card .logo .brand-mark { width: 32px; height: 32px; }
.login-card .brand-text b { font-size: 30px; }
.login-card h1 { font: 500 26px/1.2 var(--serif); letter-spacing: -.02em; text-align: center; }
.login-card p.lead { font-size: 13.5px; color: var(--ink-3); text-align: center; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.login-foot { text-align: center; font-size: 12px; color: var(--ink-3); }

/* ---------- Command palette ---------- */
dialog.palette { margin: 12vh auto 0; }
.palette-box { width: min(560px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-pop); overflow: hidden; }
.palette-box .input-group { border-bottom: 1px solid var(--line); }
.palette-box .input { border: 0; border-radius: 0; min-height: 50px; font-size: 15px; box-shadow: none !important; }
.palette-box .input-group > .ico { left: 16px; }
.palette-box .input-group > .input { padding-left: 44px; }
.palette-list { max-height: 340px; overflow-y: auto; padding: 6px; }
.palette-list .grp { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.palette-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 13.5px; color: var(--ink); }
.palette-item .ico { color: var(--ink-3); }
.palette-item[aria-selected="true"] { background: var(--accent-soft); }
.palette-item[aria-selected="true"] .ico { color: var(--accent); }
.palette-item .hint { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); background: color-mix(in srgb, var(--sunken) 50%, var(--surface)); }
.palette-empty { padding: 28px; text-align: center; color: var(--ink-3); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
