/* ms-memory web UI. Design system follows the ServerWatch UI (tokens, components, rhythm).
   Sections: 1 Tokens · 2 Base · 3 Shell · 4 Layout · 5 Forms · 6 Buttons/Menus · 7 Chips
   · 8 Tables · 9 Notices/Empty states · 10 Components · 11 Domain (live, topics, messages)
   · 12 Responsive. Colour values live in section 1 only. */

/* ============================================================== 1 Tokens */

:root {
  color-scheme: light dark;
  --bg: #f4f5fa;
  --bg-glow: rgb(109 94 252 / .10);
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --surface-3: #e6e8f1;
  --text: #171a24;
  --muted: #5e6578;
  --border: #dfe2ec;
  --border-strong: #c9cedd;
  --accent: #5b4bf0;
  --accent-2: #8b5cf6;
  --accent-soft: rgb(91 75 240 / .10);
  --accent-text: #ffffff;
  --ok: #138a57;
  --ok-soft: rgb(19 138 87 / .12);
  --warn: #a86500;
  --warn-soft: rgb(168 101 0 / .13);
  --danger: #cf3431;
  --danger-soft: rgb(207 52 49 / .11);
  --danger-text: #ffffff;
  --ok-ink: #0e6e45;
  --warn-ink: #8a5200;
  --danger-ink: #b02a27;
  --accent-ink: #4a3bd8;
  --shadow: 0 1px 2px rgb(20 24 40 / .05), 0 4px 14px rgb(20 24 40 / .06);
  --shadow-lg: 0 10px 30px rgb(20 24 40 / .14), 0 2px 8px rgb(20 24 40 / .08);
  --logo-1: #6d5efc;
  --logo-2: #b06cf6;
  --c1: var(--accent);
  --c2: var(--accent-2);
  --c3: var(--warn);
  --c4: var(--ok);
  --c5: var(--danger);
  --c6: color-mix(in srgb, var(--accent) 50%, var(--ok));
  --c7: color-mix(in srgb, var(--warn) 55%, var(--danger));
  --term-bg: #0d1017;
  --term-fg: #d5dbe8;
  --term-muted: #8b93a7;
  --term-err: #ff8a85;
  --term-warn: #f0c060;
  --term-link: #a79dff;
  --qr-bg: #ffffff;
  --qr-fg: #000000;

  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.25rem; --sp-6: 2rem;
  --radius-xs: .375rem; --radius-sm: 9px; --radius-md: .75rem; --radius: 14px; --radius-pill: 999px;
  --ctl-h: 2.5rem; --ctl-h-sm: 2.05rem;
  --z-dropdown: 30; --z-sticky: 40; --z-popover: 50; --z-toast: 60; --z-skip: 100;
  --page-w: 84rem; --gutter: 1.25rem; --top-h: 3.75rem;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  --focus-ring: 0 0 0 3px var(--accent-soft);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --fade-x: linear-gradient(90deg, transparent, #000 1rem, #000 calc(100% - 1rem), transparent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1016;
    --bg-glow: rgb(139 124 255 / .14);
    --surface: #171a23;
    --surface-2: #1f232e;
    --surface-3: #2a2f3d;
    --text: #e9ebf3;
    --muted: #9aa1b5;
    --border: #2a2f3d;
    --border-strong: #3a4052;
    --accent: #8f82ff;
    --accent-2: #b28cff;
    --accent-soft: rgb(143 130 255 / .14);
    --accent-text: #10121a;
    --ok: #4cc58a;
    --ok-soft: rgb(76 197 138 / .14);
    --warn: #e5a93f;
    --warn-soft: rgb(229 169 63 / .14);
    --danger: #f07571;
    --danger-soft: rgb(240 117 113 / .14);
    --danger-text: #14161a;
    --ok-ink: #4cc58a;
    --warn-ink: #e5a93f;
    --danger-ink: #f07571;
    --accent-ink: #a79dff;
    --shadow: 0 1px 2px rgb(0 0 0 / .28), 0 6px 18px rgb(0 0 0 / .32);
    --shadow-lg: 0 16px 40px rgb(0 0 0 / .55), 0 2px 8px rgb(0 0 0 / .35);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1016;
  --bg-glow: rgb(139 124 255 / .14);
  --surface: #171a23;
  --surface-2: #1f232e;
  --surface-3: #2a2f3d;
  --text: #e9ebf3;
  --muted: #9aa1b5;
  --border: #2a2f3d;
  --border-strong: #3a4052;
  --accent: #8f82ff;
  --accent-2: #b28cff;
  --accent-soft: rgb(143 130 255 / .14);
  --accent-text: #10121a;
  --ok: #4cc58a;
  --ok-soft: rgb(76 197 138 / .14);
  --warn: #e5a93f;
  --warn-soft: rgb(229 169 63 / .14);
  --danger: #f07571;
  --danger-soft: rgb(240 117 113 / .14);
  --danger-text: #14161a;
  --ok-ink: #4cc58a;
  --warn-ink: #e5a93f;
  --danger-ink: #f07571;
  --accent-ink: #a79dff;
  --shadow: 0 1px 2px rgb(0 0 0 / .28), 0 6px 18px rgb(0 0 0 / .32);
  --shadow-lg: 0 16px 40px rgb(0 0 0 / .55), 0 2px 8px rgb(0 0 0 / .35);
}

/* ============================================================== 2 Base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(60rem 28rem at 50% -8rem, var(--bg-glow), transparent), var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font: 15px/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
code, pre, .mono { font-family: var(--font-mono); font-size: .85em; }
code { background: var(--surface-2); border-radius: var(--radius-xs); padding: .1em .35em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

.i { width: 1.1em; height: 1.1em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
     stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; }
.wrapany { overflow-wrap: anywhere; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.row.center { justify-content: center; }
.nowrap { flex-wrap: nowrap; }
td.nowrap { white-space: nowrap; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack > * + * { margin-top: 0 !important; }
.is-hidden, [hidden] { display: none !important; }

.skip { position: absolute; left: var(--sp-3); top: -3rem; z-index: var(--z-skip); background: var(--surface);
        padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.skip:focus { top: var(--sp-3); }

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 100% { box-shadow: 0 0 0 .5rem transparent; } }
@keyframes skel { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }

/* ============================================================== 3 Shell */

.top {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.top-in { max-width: var(--page-w); margin: 0 auto; padding: var(--sp-3) var(--gutter);
          display: flex; align-items: center; gap: var(--sp-4); }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { width: 2rem; height: 2rem; border-radius: .6rem; display: grid; place-items: center; color: #fff;
        background: linear-gradient(135deg, var(--logo-1), var(--logo-2)); box-shadow: 0 4px 12px rgb(109 94 252 / .35); }
.logo .i { width: 1.15rem; height: 1.15rem; }
.nav { display: flex; gap: var(--sp-1); flex: 1 1 auto; min-width: 0; }
.nav-link { display: inline-flex; align-items: center; gap: var(--sp-2); padding: .4rem .85rem; border-radius: var(--radius-pill);
            color: var(--muted); font-weight: 550; white-space: nowrap; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.count { min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; border-radius: var(--radius-pill); display: inline-grid; place-items: center;
         font-size: .72rem; font-weight: 700; background: var(--ok); color: var(--surface); }
.top-actions { display: flex; align-items: center; gap: var(--sp-1); }

.conn { display: inline-flex; align-items: center; gap: var(--sp-2); padding: .3rem .75rem; border-radius: var(--radius-pill);
        background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.conn:hover { text-decoration: none; color: var(--text); }
.conn.is-live { color: var(--ok-ink); background: var(--ok-soft); }
.conn.is-off { color: var(--danger-ink); background: var(--danger-soft); }
.ver { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: var(--radius-pill); position: relative;
       font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.ver:hover, .ver[aria-current] { text-decoration: none; color: var(--text); }
.ver .i { width: .95em; height: .95em; }
.ver.is-new { color: var(--accent-ink); background: var(--accent-soft); }
.ver.is-new::after { content: ""; position: absolute; top: .1rem; right: .1rem; width: .5rem; height: .5rem; border-radius: 50%;
                     background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }

.dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.working { background: var(--ok); animation: ping 1.6s infinite; }
.dot.idle { background: var(--warn); }
.dot.ended { background: var(--border-strong); }
.dot.off { background: var(--danger); }

.banner { max-width: var(--page-w); margin: var(--sp-3) auto 0; padding: 0 var(--gutter); }

.page { max-width: var(--page-w); margin: 0 auto; padding: var(--sp-5) var(--gutter) var(--sp-6); animation: fadein .25s var(--ease); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head p { color: var(--muted); margin-top: var(--sp-1); }
.page-head .btn { height: var(--ctl-h-sm); padding: 0 .8rem; font-size: .88rem; }
.crumbs { display: flex; align-items: center; gap: var(--sp-1); font-size: .85rem; color: var(--muted); margin-bottom: var(--sp-2); flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

/* ============================================================== 4 Layout */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 1.15rem 1.35rem; box-shadow: var(--shadow); min-width: 0; }
.card > * + *, .card-body > * + * { margin-top: var(--sp-3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: .82rem; }
.card-head .btn { height: var(--ctl-h-sm); padding: 0 .75rem; font-size: .85rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 1.05rem 1.35rem 0; }
.card.flush > * + * { margin-top: var(--sp-3); }
a.card { display: block; color: inherit; transition: transform .15s var(--ease), border-color .15s; }
a.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }

.page > * + * { margin-top: var(--sp-4); }
.page > .page-head + * { margin-top: 0; }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
.cols-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr)); align-items: start; }
.cols-main { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; }
.cols-main > aside { display: flex; flex-direction: column; gap: var(--sp-4); position: sticky; top: calc(var(--top-h) + var(--sp-4)); }
.cols-side { display: grid; gap: var(--sp-4); grid-template-columns: 24rem minmax(0, 1fr); align-items: start; }
.cols-side > aside { position: sticky; top: calc(var(--top-h) + var(--sp-4)); max-height: calc(100vh - var(--top-h) - 2 * var(--sp-4)); overflow: auto; border-radius: var(--radius); }

/* ============================================================== 5 Forms */

.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.field > span { font-size: .88rem; font-weight: 500; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: var(--ctl-h); padding: 0 .8rem; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 9rem; padding: .65rem .8rem; resize: vertical; line-height: 1.5; }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: var(--focus-ring); }
select.input { width: auto; padding-right: 2rem; }
.row > select.input, .savebar select.input { width: auto; max-width: 16rem; height: var(--ctl-h-sm); font-size: .88rem; }
.input.otp { font-family: var(--font-mono); font-size: 1.35rem; letter-spacing: .5em; text-align: center; height: 3rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
.search { position: relative; flex: 1 1 18rem; max-width: 34rem; }
.search .i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 2.4rem; }
.search .input.lg { height: 3rem; font-size: 1.02rem; }
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.form-err { color: var(--danger-ink); font-weight: 600; font-size: .9rem; min-height: 0; }
.form-err:empty { display: none; }
form.stack { gap: var(--sp-4); }

/* ============================================================== 6 Buttons & menus */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--ctl-h); padding: 0 1rem; font: inherit; font-weight: 550; font-size: .92rem; white-space: nowrap;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s, background .15s, transform .08s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { color: var(--accent-text); border-color: transparent;
               background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent-2) 70%, var(--accent)));
               box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-primary:hover { border-color: transparent; filter: brightness(.94); }
.btn-danger { color: var(--danger-text); background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); filter: brightness(.94); }
.btn-danger-ghost { color: var(--danger-ink); }
.btn-danger-ghost:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-small { height: var(--ctl-h-sm); padding: 0 .75rem; font-size: .85rem; }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-icon.sm { width: var(--ctl-h-sm); height: var(--ctl-h-sm); }

details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + .35rem); z-index: var(--z-dropdown); min-width: 13rem;
            background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg); padding: var(--sp-1); animation: pop .12s var(--ease); }
.menu-pop button, .menu-pop a { display: flex; width: 100%; align-items: center; gap: var(--sp-2); padding: .5rem .7rem;
            border: 0; background: none; font: inherit; font-size: .9rem; color: var(--text); border-radius: var(--radius-xs);
            cursor: pointer; text-align: left; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .danger { color: var(--danger-ink); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-1) 0; }

/* ============================================================== 7 Chips & badges */

.chip, .badge {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; height: 1.6rem; padding: 0 .6rem;
  border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted);
  font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 0;
}
.chip .i, .badge .i { width: .95em; height: .95em; }
.c-info { background: var(--accent-soft); color: var(--accent-ink); }
.c-ok { background: var(--ok-soft); color: var(--ok-ink); }
.c-warn { background: var(--warn-soft); color: var(--warn-ink); }
.c-crit { background: var(--danger-soft); color: var(--danger-ink); }
.c-mute { background: var(--surface-2); color: var(--muted); }
a.chip:hover { text-decoration: none; box-shadow: inset 0 0 0 1px var(--accent); }
.chip.app::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); min-width: 0; }
.tid { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); flex-wrap: wrap; }
.seg-b { height: calc(var(--ctl-h-sm) - 6px); padding: 0 .75rem; border: 0; border-radius: var(--radius-xs); background: none;
         font: inherit; font-size: .86rem; font-weight: 550; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.seg-b:hover { color: var(--text); }
.seg-b[aria-pressed="true"] { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); }
.seg-b .n { font-size: .75rem; color: var(--muted); font-weight: 600; }

/* ============================================================== 8 Tables */

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.card.flush > .table-wrap { border-radius: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { background: var(--surface-2); text-transform: uppercase; font-size: .76rem; letter-spacing: .06em; color: var(--muted);
          font-weight: 600; text-align: left; padding: .6rem .8rem; white-space: nowrap; }
.tbl td { padding: .65rem .8rem; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover td { background: var(--accent-soft); }
.tbl tr.click { cursor: pointer; }
.tbl td.acts { text-align: right; white-space: nowrap; }
.tbl td.cb, .tbl th.cb { width: 2.5rem; padding-right: 0; }
.tbl tr.is-sel td { background: var(--accent-soft); }
.tbl .title { font-weight: 600; color: var(--text); }
.tbl .t-cell { min-width: 14rem; max-width: 34rem; }
.t-hit { display: block; margin-top: .35rem; padding: .35rem .55rem; width: 100%; text-align: left; font: inherit; font-size: .84rem;
         color: var(--muted); background: var(--surface-2); border: 0; border-radius: var(--radius-xs); cursor: pointer; overflow-wrap: anywhere; }
.t-hit:hover { color: var(--text); }
.tbl .sub { font-size: .8rem; color: var(--muted); }

/* ============================================================== 9 Notices & states */

.alert-box { display: flex; gap: var(--sp-3); align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm);
             background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); font-size: .9rem; }
.alert-box > .i { color: var(--danger-ink); margin-top: .15rem; }
.alert-box.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.alert-box.warn > .i { color: var(--warn-ink); }
.alert-box.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.alert-box.ok > .i { color: var(--ok-ink); }
.alert-box.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.alert-box.info > .i { color: var(--accent-ink); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
         padding: var(--sp-6) var(--sp-4); color: var(--muted); }
.empty > .i { width: 2.4rem; height: 2.4rem; stroke-width: 1.4; opacity: .7; }
.empty b { color: var(--text); font-size: .98rem; }
.empty p { max-width: 32rem; font-size: .9rem; }
.empty.compact { padding: var(--sp-5) var(--sp-3); }
.empty.compact > .i { width: 1.8rem; height: 1.8rem; }
.empty.is-ok > .i { color: var(--ok-ink); opacity: 1; }
.empty.err > .i { color: var(--danger-ink); opacity: 1; }

.spinner { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.skel { background: var(--surface-3); border-radius: var(--radius-sm); animation: skel 1.4s ease-in-out infinite; }
.skel-card { height: 7rem; border-radius: var(--radius); }

.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end; }
.toast { display: flex; align-items: center; gap: var(--sp-2); max-width: 26rem; padding: .7rem 1rem; background: var(--surface);
         border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
         box-shadow: var(--shadow-lg); font-size: .9rem; animation: slidein .2s var(--ease); }
.toast.t-ok { border-left-color: var(--ok); }
.toast.t-ok .i { color: var(--ok-ink); }
.toast.t-error { border-left-color: var(--danger); }
.toast.t-error .i { color: var(--danger-ink); }

details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--muted); font-size: .8em; width: .8em; flex: none; }
details.fold[open] > summary::before { content: "▾"; }

/* Dialogs */
dialog.dlg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
             box-shadow: var(--shadow-lg); padding: 0; width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
dialog.dlg.wide { width: min(60rem, calc(100vw - 2rem)); }
dialog.dlg[open] { animation: pop .16s var(--ease); display: flex; flex-direction: column; }
dialog.dlg::backdrop { background: color-mix(in srgb, var(--bg) 60%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dlg-head { display: flex; align-items: center; gap: var(--sp-3); padding: 1.1rem 1.35rem .6rem; }
.dlg-head h2 { flex: 1 1 auto; min-width: 0; }
.dlg-body { padding: .4rem 1.35rem 1rem; overflow: auto; }
.dlg-body > * + * { margin-top: var(--sp-3); }
.dlg-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: .9rem 1.35rem 1.15rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ============================================================== 10 Components */

.kpis { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); }
.kpi { position: relative; display: block; padding: 1rem 1.15rem 1rem 1.3rem; background: var(--surface); border: 1px solid var(--border);
       border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: .9rem; bottom: .9rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.kpi.k-ok::before { background: var(--ok); }
.kpi.k-warn::before { background: var(--warn); }
.kpi.k-crit::before { background: var(--danger); }
.kpi.k-mute::before { background: var(--border-strong); }
a.kpi { transition: transform .15s var(--ease), border-color .15s; }
a.kpi:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.kpi .kl { display: flex; align-items: center; gap: var(--sp-2); font-size: .82rem; color: var(--muted); font-weight: 550; }
.kpi .kv { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin-top: .35rem; letter-spacing: -.02em; }
.kpi .ks { font-size: .8rem; color: var(--muted); margin-top: .15rem; }

.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .85rem; margin-bottom: -1px; border: 0;
       border-bottom: 2px solid transparent; background: none; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab .n { font-size: .72rem; font-weight: 700; padding: 0 .4rem; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted); }
.tab[aria-selected="true"] .n { background: var(--accent-soft); color: var(--accent-ink); }

.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem var(--sp-3); align-items: center; }
.bar .bl { font-size: .9rem; }
.bar .bv { font-size: .82rem; color: var(--muted); }
.bar .track { grid-column: 1 / -1; height: .5rem; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; }
.bar .fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; transition: width .4s var(--ease); }
a.bar { color: inherit; padding: .35rem .5rem; margin: 0 -.5rem; border-radius: var(--radius-xs); }
a.bar:hover { background: var(--surface-2); text-decoration: none; }
.bars { display: flex; flex-direction: column; gap: var(--sp-1); }

.chart-box { position: relative; height: 15rem; }
.chart-box.sm { height: 13rem; }

.heat { display: grid; grid-template-columns: 2rem repeat(24, minmax(0, 1fr)); gap: 3px; font-size: .7rem; color: var(--muted); }
.heat .cell { height: 1.15rem; border-radius: 3px; background: var(--surface-2); }
.heat .hl { text-align: left; }
.heat .lbl { align-self: center; }

pre.cmd, .term { background: var(--term-bg); color: var(--term-fg); border-radius: var(--radius-sm); padding: .75rem .9rem;
                 font-family: var(--font-mono); font-size: .82rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
                 margin: 0; max-height: 28rem; overflow: auto; }
pre.cmd { user-select: all; border-left: 3px solid var(--accent); }
/* pre.cmd resets its margin; restore the card rhythm when it follows other content. */
.card > * + pre.cmd, .card-body > * + pre.cmd { margin-top: var(--sp-3); }
.copyline { display: flex; align-items: stretch; gap: var(--sp-2); }
.copyline > code { flex: 1 1 auto; display: flex; align-items: center; padding: .5rem .75rem; font-size: .88rem; overflow-wrap: anywhere; border-radius: var(--radius-sm); }
.copyline .btn { height: auto; min-height: var(--ctl-h-sm); }
.resume .copyline { flex-direction: column; }
.resume .copyline .btn { justify-content: center; }
.secret { font-family: var(--font-mono); text-align: center; letter-spacing: .1em; font-size: .9rem; color: var(--muted); }
.qr { display: grid; place-items: center; }
.qr img { background: var(--qr-bg); padding: .6rem; border-radius: var(--radius-sm); width: 12rem; height: 12rem; image-rendering: pixelated; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem var(--sp-4); font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.savebar { position: sticky; bottom: var(--sp-3); z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--sp-3);
           flex-wrap: wrap; padding: .7rem 1rem; background: var(--surface); border: 1px solid var(--accent);
           border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .15s var(--ease); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-5) var(--gutter); }
.card.login { width: min(25rem, 100%); padding: 2rem 1.9rem; animation: pop .2s var(--ease); display: flex; flex-direction: column; gap: var(--sp-4); }
.card.login > * + * { margin-top: 0; }
.card.login.wide { width: min(30rem, 100%); }
.login-head { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; }
.login-head .logo { width: 3.2rem; height: 3.2rem; border-radius: 1rem; }
.login-head .logo .i { width: 1.7rem; height: 1.7rem; }
.login-head p { color: var(--muted); font-size: .9rem; }
.steps { margin: 0; padding-left: 1.2rem; font-size: .9rem; color: var(--muted); display: flex; flex-direction: column; gap: var(--sp-1); }

/* Markdown */
.md { overflow-wrap: anywhere; }
.md > * + * { margin-top: .6em; }
.md h4 { font-size: 1rem; margin-top: 1em; }
.md ul, .md ol { padding-left: 1.3rem; margin-bottom: 0; }
.md pre { background: var(--term-bg); color: var(--term-fg); border-radius: var(--radius-sm); padding: .7rem .85rem; overflow: auto; font-size: .82rem; }
.md pre code { background: none; padding: 0; color: inherit; }
.md table { border-collapse: collapse; font-size: .88rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: .3rem .55rem; text-align: left; }
.md th { background: var(--surface-2); }
.md blockquote { margin-left: 0; padding-left: .8rem; border-left: 3px solid var(--border-strong); color: var(--muted); }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 .1em; }

/* ============================================================== 11 Domain */

/* Live */
.live-grid { display: flex; flex-direction: column; gap: var(--sp-3); }
.sess { --st: var(--border-strong); border-left: 4px solid var(--st); display: flex; flex-direction: column; gap: var(--sp-2); padding-top: .8rem; padding-bottom: .8rem; }
.sess > * + * { margin-top: 0; }
.sess.working { --st: var(--ok); }
.sess.idle { --st: var(--warn); }
.sess.ended { opacity: .78; }
.sess .s-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.sess .s-head > .chip { flex: none; }
.sess .s-title { font-weight: 650; color: var(--text); flex: 1 1 auto; min-width: 0; }
.sess .s-meta { display: inline-flex; align-items: center; gap: .3rem; flex: none; max-width: 40%; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess .s-line { display: flex; align-items: baseline; gap: var(--sp-3); font-size: .86rem; min-width: 0; }
.sess .s-prompt { flex: 1 1 auto; min-width: 0; }
.sess .s-prompt b { color: var(--muted); font-weight: 600; }
.sess .s-now { flex: none; display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.sess .s-now.is-now { color: var(--ok-ink); }
.feed { display: flex; flex-direction: column; }
.feed-item { display: grid; grid-template-columns: 1.9rem minmax(0, 1fr); gap: var(--sp-3); padding: .65rem 1.35rem; border-top: 1px solid var(--border); }
.feed-item.is-new { animation: flash 2.5s ease-out; }
.feed-item .ic { width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.feed-item .ic.user { background: var(--accent-soft); color: var(--accent-ink); }
.feed-item .ic.assistant { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); }
.feed-item .ic.tool { background: var(--warn-soft); color: var(--warn-ink); }
.feed-item .tx { font-size: .88rem; overflow-wrap: anywhere; }
.feed-item .m { font-size: .76rem; color: var(--muted); margin-top: .1rem; }

.mini-list { display: flex; flex-direction: column; }
.mini { display: flex; align-items: center; gap: var(--sp-3); padding: .6rem 1.35rem; border-top: 1px solid var(--border); color: inherit; }
.mini:hover { background: var(--accent-soft); text-decoration: none; }
.mini .t { flex: 1 1 auto; min-width: 0; }
.mini .t b { display: block; font-weight: 600; }

/* Topics list */
.grp-row td { background: var(--surface-2); padding-top: .5rem; padding-bottom: .5rem; cursor: pointer; }
.tbl tbody tr.grp-row:hover td { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
.grp-row .caret { display: inline-block; width: .9rem; color: var(--muted); transition: transform .15s var(--ease); }
.grp-row.open .caret { transform: rotate(90deg); }
.grp-row .gname { font-weight: 650; }
.grp-row .n { font-size: .75rem; color: var(--muted); font-weight: 600; }
.grp-row .auto { font-size: .72rem; }

/* Topic detail */
.t-title { width: 100%; font: inherit; font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); background: transparent;
           border: 1px solid transparent; border-radius: var(--radius-sm); padding: .1rem .4rem; margin-left: -.45rem; }
.t-title:hover { border-color: var(--border); }
.t-title:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: var(--focus-ring); }
.resume { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%); }

.timeline { display: flex; flex-direction: column; gap: var(--sp-3); overflow-anchor: none; } /* scroll position is kept by topic.js */
.msg { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--sp-3); }
.msg .av { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.msg.user .av { background: var(--accent-soft); color: var(--accent-ink); }
.msg.assistant .av { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); }
.msg.tool .av { background: var(--warn-soft); color: var(--warn-ink); }
.msg .bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow); min-width: 0; }
.msg.user .bubble { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.msg.tool .bubble, .msg.thinking .bubble { padding: .45rem .8rem; box-shadow: none; background: var(--surface-2); }
.msg .mh { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.msg .mh b { color: var(--text); font-size: .86rem; }
.msg summary { font-size: .85rem; min-width: 0; }
.msg summary .ellipsis { flex: 1 1 auto; }
.msg details[open] > summary { margin-bottom: var(--sp-2); }
.sess-sep { display: flex; align-items: center; gap: var(--sp-3); font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sess-sep::before, .sess-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.note { border-left: 3px solid var(--ok); padding-left: var(--sp-3); }
.note + .note { margin-top: var(--sp-4); }
.note.fact { border-left-color: var(--accent); }
.note .mh { display: flex; align-items: center; gap: var(--sp-2); font-size: .8rem; color: var(--muted); margin-bottom: .3rem; flex-wrap: wrap; }

/* Search */
.hit { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-top: 1px solid var(--border);
       padding: .85rem 1.35rem; color: inherit; cursor: pointer; }
.hit:hover { background: var(--accent-soft); text-decoration: none; }
.hit .hh { display: flex; align-items: center; gap: var(--sp-2); font-size: .82rem; color: var(--muted); flex-wrap: wrap; margin-bottom: .2rem; }
.hit .hh b { color: var(--text); font-size: .92rem; }
.hit .hs { font-size: .9rem; overflow-wrap: anywhere; }

/* ============================================================== 12 Responsive */

@media (max-width: 62rem) {
  .top-in { flex-wrap: wrap; row-gap: var(--sp-2); }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: var(--fade-x); mask-image: var(--fade-x); padding: 0 .5rem; }
  .nav::-webkit-scrollbar { display: none; }
  .top-actions { margin-left: auto; }
  .cols-main { grid-template-columns: minmax(0, 1fr); }
  .cols-main > aside { position: static; }
  .cols-side { grid-template-columns: minmax(0, 1fr); }
  .cols-side > aside { position: static; max-height: none; order: 2; }
}
@media (max-width: 52rem) {
  :root { --gutter: .9rem; }
  h1, .t-title { font-size: 1.5rem; }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .hide-md { display: none !important; }
}
@media (max-width: 40rem) {
  .top { position: static; }
  .page-head > .row, .page-head > .btn { width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .kv { font-size: 1.5rem; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dd { margin-bottom: var(--sp-2); }
  .card { padding: 1rem 1rem; }
  .card.flush > .card-head { padding: 1rem 1rem 0; }
  .feed-item, .mini, .hit { padding-left: 1rem; padding-right: 1rem; }
  .hide-sm { display: none !important; }
  .sess .s-meta { display: none; }
  .sess .s-line { flex-direction: column; align-items: stretch; gap: .15rem; }
  .conn .lbl { display: none; }
  .toasts { left: var(--sp-3); right: var(--sp-3); align-items: stretch; }
}
@media (hover: none) {
  .btn, .seg-b, .nav-link { min-height: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- release notes */
.news-list { list-style: none; padding: 0; margin-bottom: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.news-item { display: grid; grid-template-columns: 6.5rem 1fr; gap: var(--sp-3); align-items: baseline; line-height: 1.5; }
.news-tag { justify-content: center; text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; font-weight: 700; }
@media (max-width: 40rem) {
  .news-item { grid-template-columns: 1fr; gap: var(--sp-1); }
  .news-tag { justify-self: start; }
}
