/* AI Center — design tokens, layout and components (light + dark). */

:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-art: radial-gradient(1100px 520px at 85% -12%, rgba(99, 102, 241, .10), transparent 62%),
            radial-gradient(900px 460px at -12% 8%, rgba(6, 182, 212, .07), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --surface-3: #e6e9f2;
  --line: #e2e5ee;
  --line-2: #d0d5e2;
  --text: #0d1222;
  --text-2: #454d66;
  --muted: #6b7389;
  --accent: #4f46e5;
  --accent-ink: #4338ca;
  --accent-soft: rgba(79, 70, 229, .10);
  --accent-line: rgba(79, 70, 229, .32);
  --cyan: #0e7490;
  --cyan-soft: rgba(8, 145, 178, .10);
  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: rgba(12, 163, 12, .10);
  --warn: #fab219;
  --warn-ink: #7a4f00;
  --warn-soft: rgba(250, 178, 25, .16);
  --bad: #d03b3b;
  --bad-ink: #b42323;
  --bad-soft: rgba(208, 59, 59, .10);
  --viz-1: #2a78d6;
  --viz-1b: #86b6ef;
  --viz-grid: #e9ebf1;
  --viz-axis: #c3c8d6;
  --code-bg: #0b1020;
  --code-ink: #dbe2ff;
  --shadow: 0 1px 2px rgba(13, 18, 34, .05), 0 4px 16px rgba(13, 18, 34, .045);
  --shadow-lg: 0 12px 40px rgba(13, 18, 34, .16);
  --glow: 0 0 0 0 transparent;
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --side-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #080c17;
    --bg-art: radial-gradient(1100px 560px at 85% -14%, rgba(99, 102, 241, .16), transparent 62%),
              radial-gradient(900px 480px at -12% 6%, rgba(34, 211, 238, .08), transparent 60%);
    --surface: #10172a;
    --surface-2: #151d33;
    --surface-3: #1c2640;
    --line: #222c45;
    --line-2: #2e3a5a;
    --text: #e7eaf4;
    --text-2: #b3bad0;
    --muted: #8a93ad;
    --accent: #8b93ff;
    --accent-ink: #aab0ff;
    --accent-soft: rgba(139, 147, 255, .14);
    --accent-line: rgba(139, 147, 255, .40);
    --cyan: #22d3ee;
    --cyan-soft: rgba(34, 211, 238, .12);
    --good-ink: #3fcf5a;
    --good-soft: rgba(12, 163, 12, .18);
    --warn-ink: #fbc34a;
    --warn-soft: rgba(250, 178, 25, .14);
    --bad-ink: #f07a7a;
    --bad-soft: rgba(208, 59, 59, .18);
    --viz-1: #3987e5;
    --viz-1b: #1c5cab;
    --viz-grid: #1c2540;
    --viz-axis: #2e3a5a;
    --code-bg: #070b16;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 22px rgba(0, 0, 0, .22);
    --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
    --glow: 0 0 0 1px rgba(139, 147, 255, .05);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080c17;
  --bg-art: radial-gradient(1100px 560px at 85% -14%, rgba(99, 102, 241, .16), transparent 62%),
            radial-gradient(900px 480px at -12% 6%, rgba(34, 211, 238, .08), transparent 60%);
  --surface: #10172a;
  --surface-2: #151d33;
  --surface-3: #1c2640;
  --line: #222c45;
  --line-2: #2e3a5a;
  --text: #e7eaf4;
  --text-2: #b3bad0;
  --muted: #8a93ad;
  --accent: #8b93ff;
  --accent-ink: #aab0ff;
  --accent-soft: rgba(139, 147, 255, .14);
  --accent-line: rgba(139, 147, 255, .40);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, .12);
  --good-ink: #3fcf5a;
  --good-soft: rgba(12, 163, 12, .18);
  --warn-ink: #fbc34a;
  --warn-soft: rgba(250, 178, 25, .14);
  --bad-ink: #f07a7a;
  --bad-soft: rgba(208, 59, 59, .18);
  --viz-1: #3987e5;
  --viz-1b: #1c5cab;
  --viz-grid: #1c2540;
  --viz-axis: #2e3a5a;
  --code-bg: #070b16;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 22px rgba(0, 0, 0, .22);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
  --glow: 0 0 0 1px rgba(139, 147, 255, .05);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 15px/1.55 var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-art);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4, h5 { line-height: 1.25; margin: 0; }
p { margin: 0; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

.ic { width: 18px; height: 18px; flex: none; stroke-width: 1.8; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1 1 auto; }
.mt { margin-top: 12px; }
.mt-lg { margin-top: 22px; }
.mb { margin-bottom: 12px; }
.row-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; }
.kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- boot & loading ---------- */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }
.boot-orb {
  width: 56px; height: 56px; border-radius: 50%;
  background: conic-gradient(from 0deg, #6366f1, #06b6d4, #6366f1);
  -webkit-mask: radial-gradient(circle, transparent 56%, #000 57%);
  mask: radial-gradient(circle, transparent 56%, #000 57%);
  animation: spin 1.3s linear infinite;
}
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 28px 4px; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
.btn .spin { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 14px 10px 12px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 14px; color: var(--text); text-decoration: none; }
.brand img { width: 36px; height: 36px; }
.brand b { font-size: 16.5px; letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin: 16px 10px 5px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 550; font-size: 14.5px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav a.on .ic { color: var(--accent); }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 4px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-2); padding: 0 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 24px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-search { position: relative; flex: 1 1 auto; max-width: 540px; }
.top-search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.top-search input { padding-left: 36px; border-radius: 12px; background: var(--surface); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); text-decoration: none; white-space: nowrap;
}
.pill:hover { border-color: var(--accent-line); color: var(--text); }
.pill .meter { width: 54px; }
.pill.busy .spin { width: 13px; height: 13px; }
.main { padding: 22px 24px 64px; max-width: 1280px; width: 100%; margin: 0 auto; }
.menu-btn { display: none !important; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(5, 8, 20, .45); z-index: 40; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(84vw, 300px); z-index: 50;
    transform: translateX(-104%); transition: transform .2s ease; background: var(--surface); box-shadow: var(--shadow-lg);
  }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; }
  .menu-btn { display: inline-flex !important; }
  .top { padding: 8px 16px; }
  .main { padding: 16px 16px 64px; }
  .hide-sm { display: none !important; }
}

/* ---------- page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 18px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin-top: 5px; color: var(--text-2); max-width: 78ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); text-decoration: none; margin-bottom: 10px; cursor: pointer; background: none; border: 0; padding: 0; }
.crumb:hover { color: var(--text); }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow), var(--glow); padding: 16px 18px; min-width: 0; }
.card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 15.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { color: var(--accent); }
.card-head a.more, .card-head .more { font-size: 13px; text-decoration: none; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: -6px; margin-bottom: 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
}

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  display: block; position: relative; padding: 14px 16px; border-radius: var(--radius); text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow), var(--glow); min-width: 0;
}
a.tile:hover { border-color: var(--accent-line); }
.tile-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.tile-label .ic { color: var(--muted); width: 15px; height: 15px; }
.tile-value { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin-top: 4px; }
.tile-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tile .meter { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; position: relative;
  transition: background .12s, border-color .12s, filter .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #5b54f0, #3b6fe0); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .25); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad-ink); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
.btn.primary.is-busy::after { border-color: #fff; border-top-color: transparent; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint, .hint { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=url], input[type=time], select, textarea {
  font-size: 14.5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 7px 11px; min-height: 38px; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s, background .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
textarea.code, input.code { font-family: var(--mono); font-size: 13px; }
select { cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.form-error { color: var(--bad-ink); font-size: 13.5px; min-height: 1.2em; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: background .15s; }
.switch span::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
/* Wide controls wrap below the text on narrow screens instead of squeezing it. */
.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.setting-row:first-child { border-top: 0; }
.setting-row .txt { min-width: 0; flex: 1 1 160px; }
.setting-row .txt b { display: block; font-size: 14.5px; font-weight: 600; }
.setting-row .txt span { display: block; font-size: 12.5px; color: var(--muted); }
.setting-row .ctl { flex: none; max-width: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* The switch's hidden checkbox must keep the switch's own size. */
.setting-row .ctl input:not([type=checkbox]), .setting-row .ctl select { width: auto; min-width: 92px; }

/* ---------- filters, segmented, tabs ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-height: 34px; padding: 5px 10px; font-size: 13.5px; }
.filters form { display: flex; flex: 1 1 240px; min-width: 200px; }
.filters form input { width: 100%; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 8px; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* ---------- chips, badges, scores ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; text-decoration: none; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
a.chip:hover, button.chip:hover { border-color: var(--accent-line); color: var(--text); }
button.chip { cursor: pointer; }
.chip.tag::before { content: "#"; opacity: .5; }
.chip.cat { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.chip.cyan { background: var(--cyan-soft); color: var(--cyan); border-color: transparent; }
.chip.good { background: var(--good-soft); color: var(--good-ink); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad-ink); border-color: transparent; }
.chip small { opacity: .65; font-weight: 600; }
.chip .x { margin-left: 2px; opacity: .7; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--accent); color: #fff; }
.score {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 27px; padding: 0 7px; border-radius: 8px;
  font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.score.s-hot { background: linear-gradient(135deg, #f97316, #e11d48); color: #fff; border-color: transparent; }
.score.s-strong { background: linear-gradient(135deg, #6366f1, #0ea5e9); color: #fff; border-color: transparent; }
.score.s-mid { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; flex: none; }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.info { background: var(--accent); }

/* ---------- notices & empty ---------- */
.notice { display: flex; gap: 11px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 12px; font-size: 14px; }
.notice > .ic { margin-top: 2px; }
.notice.info { background: var(--accent-soft); border-color: var(--accent-line); }
.notice.info > .ic { color: var(--accent); }
.notice.warn { background: var(--warn-soft); border-color: rgba(250, 178, 25, .45); }
.notice.warn > .ic { color: var(--warn-ink); }
.notice.bad { background: var(--bad-soft); border-color: rgba(208, 59, 59, .4); }
.notice.bad > .ic { color: var(--bad-ink); }
.notice.good { background: var(--good-soft); border-color: rgba(12, 163, 12, .35); }
.notice-body { flex: 1 1 auto; min-width: 0; }
.notice-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty > .ic { width: 34px; height: 34px; opacity: .55; }
.empty p { margin: 8px auto 0; max-width: 52ch; }
.empty .btn { margin-top: 12px; }

/* ---------- item cards ---------- */
.items { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow), var(--glow);
  transition: opacity .25s, transform .25s, border-color .12s;
}
.item:hover { border-color: var(--line-2); }
.item.is-gone { opacity: 0; transform: translateX(16px); }
.item-side { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 1px; }
.item-body { min-width: 0; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; font-size: 12.5px; color: var(--muted); }
.item-meta a { color: var(--muted); text-decoration: none; }
.item-meta a:hover { color: var(--text); }
.item-meta a.chip { color: var(--accent-ink); }
.item-title { font-size: 16px; font-weight: 650; margin: 4px 0 1px; line-height: 1.38; overflow-wrap: anywhere; }
.item-title a { color: var(--text); text-decoration: none; }
.item-title a:hover { color: var(--accent-ink); }
.item.is-read .item-title a { color: var(--text-2); }
.item-orig { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; overflow-wrap: anywhere; }
.item-sum { margin-top: 5px; color: var(--text-2); font-size: 14.5px; }
.item-why { margin-top: 7px; font-size: 13.5px; color: var(--text-2); padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.item-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.item-actions { margin-left: auto; display: flex; gap: 1px; }
.iact {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; position: relative;
}
.iact:hover { background: var(--surface-2); color: var(--text); }
.iact.on { color: var(--accent); }
.iact.star.on { color: #f59e0b; }
.iact.star.on .ic { fill: currentColor; }
.iact.is-busy .ic { opacity: .3; }
.metric { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) {
  .item { grid-template-columns: minmax(0, 1fr); padding: 12px 13px; }
  .item-side { flex-direction: row; }
  .item-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
}

/* compact rows */
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: start; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row .score { min-width: 34px; height: 24px; font-size: 12.5px; }
.row-title { display: block; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; line-height: 1.38; overflow-wrap: anywhere; }
a.row-title:hover { color: var(--accent-ink); }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.load-more { display: flex; justify-content: center; margin-top: 14px; }

/* ---------- prose (Markdown) ---------- */
.prose { font-size: 15.5px; line-height: 1.72; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 20px; margin: 1.5em 0 .5em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 17px; margin: 1.35em 0 .4em; }
.prose h4, .prose h5, .prose h6 { font-size: 15.5px; margin: 1.2em 0 .3em; }
.prose h2, .prose h3, .prose h4 { scroll-margin-top: 80px; }
.prose p { margin: .6em 0; }
.prose ul, .prose ol { margin: .5em 0; padding-left: 1.45em; }
.prose li { margin: .28em 0; }
.prose li.task { list-style: none; margin-left: -1.2em; }
.prose a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .06em .36em; }
.prose pre { background: var(--code-bg); color: var(--code-ink); border-radius: 12px; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; border: 1px solid var(--line); }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose blockquote { margin: .9em 0; padding: .45em 1em; border-left: 3px solid var(--cyan); background: var(--cyan-soft); border-radius: 0 10px 10px 0; color: var(--text-2); }
.prose blockquote p { margin: .35em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose strong { font-weight: 650; }
.prose.compact { font-size: 14.5px; line-height: 1.62; }
.prose.compact h2 { font-size: 16.5px; margin-top: 1.1em; }
.prose.compact h3 { font-size: 15px; }
a.ref {
  display: inline-block; vertical-align: 1px; height: 20px; line-height: 19px; padding: 0 7px; margin: 0 1px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; text-decoration: none !important; background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid transparent; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
a.ref:hover { border-color: var(--accent-line); }
a.ref-guide { background: var(--cyan-soft); color: var(--cyan); }
.fade-box { position: relative; max-height: 440px; overflow: hidden; }
.fade-box::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 90px; background: linear-gradient(transparent, var(--surface)); pointer-events: none; }

/* tables */
.table-wrap, .tbl-wrap { overflow-x: auto; margin: .8em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tbl-wrap { margin: 0; }
.md-table, .tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
.md-table th, .md-table td, .tbl th, .tbl td { padding: 8px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md-table th, .tbl th { background: var(--surface-2); font-weight: 650; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.md-table tr:last-child td, .tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .act { text-align: right; white-space: nowrap; }
.tbl td.name { min-width: 220px; }
.tbl td .sub { display: block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tbl tr.off td { opacity: .6; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- charts ---------- */
.viz { position: relative; }
.cols { position: relative; height: var(--h, 150px); margin: 8px 0 24px 36px; display: flex; align-items: flex-end; border-bottom: 1px solid var(--viz-axis); }
.cols-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--viz-grid); pointer-events: none; }
.cols-grid.zero { border-top-color: transparent; }
.cols-grid span { position: absolute; left: -36px; top: -8px; width: 30px; text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; outline: none; isolation: isolate; }
.col::before { content: ""; position: absolute; inset: 0 1px; border-radius: 6px; background: transparent; z-index: -1; }
.col:hover::before, .col:focus-visible::before { background: var(--accent-soft); }
.col .bar { width: min(24px, 66%); background: var(--viz-1); flex: none; }
.col .bar.cap { border-radius: 4px 4px 0 0; }
.col .bar.s2 { background: var(--viz-1b); }
.col-x { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--viz-1); }
.legend i.s2 { background: var(--viz-1b); }
.viz-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.viz-table { margin-top: 4px; max-height: 320px; overflow: auto; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); text-decoration: none; border-radius: 6px; outline: none; }
.hbar:hover .hbar-label, .hbar:focus-visible .hbar-label { color: var(--text); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: flex; align-items: center; gap: 7px; height: 20px; border-left: 1px solid var(--viz-axis); }
.hbar-fill { height: 12px; background: var(--viz-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.warn { background: var(--warn-soft); }
.meter.warn > i { background: var(--warn); }
.meter.bad { background: var(--bad-soft); }
.meter.bad > i { background: var(--bad); }
.meter.thin { height: 5px; }
.tip {
  position: fixed; z-index: 300; pointer-events: none; max-width: 270px; padding: 8px 11px; border-radius: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  font-size: 12.5px; line-height: 1.5; opacity: 0; transform: translateY(4px); transition: opacity .1s, transform .1s;
}
.tip.show { opacity: 1; transform: none; }
.tip b { display: block; font-weight: 650; margin-bottom: 2px; }
.tip i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; background: var(--viz-1); }
.tip i.s2 { background: var(--viz-1b); }
@media (forced-colors: active) {
  .col .bar, .hbar-fill, .meter > i { forced-color-adjust: none; background: CanvasText; }
  .col .bar.s2 { background: GrayText; }
}

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-left: 4px solid var(--accent); box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out; transition: opacity .3s;
}
.toast > .ic { margin-top: 1px; color: var(--accent); }
.toast.good { border-left-color: var(--good); }
.toast.good > .ic { color: var(--good-ink); }
.toast.bad { border-left-color: var(--bad); }
.toast.bad > .ic { color: var(--bad-ink); }
.toast.warn { border-left-color: var(--warn); }
.toast.warn > .ic { color: var(--warn-ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; z-index: 350; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 8, 20, .55); backdrop-filter: blur(3px); }
.modal-x { position: absolute; right: 12px; top: 12px; }
.modal { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 20px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); }
.modal.wide { width: min(980px, 100%); }
.modal-title { font-size: 17px; font-weight: 650; margin-bottom: 12px; padding-right: 30px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: min(430px, 100%); padding: 28px 26px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.auth-card.wide { width: min(520px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.auth-brand img { width: 46px; height: 46px; }
.auth-brand h1 { font-size: 21px; }
.auth-card > p { color: var(--text-2); }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.qr { display: block; width: 216px; height: 216px; margin: 12px auto 6px; border-radius: 12px; background: #fff; padding: 6px; }
.secret-code { font-family: var(--mono); font-size: 13.5px; letter-spacing: .06em; word-break: break-all; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; text-align: center; user-select: all; }
input.otp { font-family: var(--mono); font-size: 22px; letter-spacing: .4em; text-align: center; }

/* ---------- ask ---------- */
.ask { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.ask-side { position: sticky; top: 74px; max-height: calc(100vh - 96px); overflow: auto; padding: 12px; }
.thread-link { display: block; padding: 8px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 13.5px; line-height: 1.4; }
.thread-link:hover { background: var(--surface-2); color: var(--text); }
.thread-link.on { background: var(--accent-soft); color: var(--accent-ink); }
.thread-link small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.chat { display: flex; flex-direction: column; gap: 14px; min-height: 40vh; }
.msg.user {
  align-self: flex-end; max-width: min(85%, 700px); padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 16px 16px 4px 16px;
}
.msg.assistant { padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; box-shadow: var(--shadow); }
.msg.pending { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.msg-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.composer { position: sticky; bottom: 0; padding: 16px 0 6px; background: linear-gradient(transparent, var(--bg) 26%); }
.composer form { display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); }
.composer textarea { border: 0; background: transparent; min-height: 46px; max-height: 260px; box-shadow: none !important; resize: none; }
.composer .hint { margin: 6px 4px 0; }
.suggest { display: flex; flex-direction: column; gap: 8px; }
.suggest button {
  text-align: left; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 14px;
}
.suggest button:hover { border-color: var(--accent-line); color: var(--text); }
@media (max-width: 900px) {
  .ask { grid-template-columns: minmax(0, 1fr); }
  .ask-side { position: static; max-height: none; order: 2; }
}

/* ---------- lab ---------- */
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.idea { display: flex; flex-direction: column; gap: 9px; }
.idea h3 { font-size: 16px; line-height: 1.38; }
.idea h3 a { color: var(--text); text-decoration: none; }
.idea h3 a:hover { color: var(--accent-ink); }
.idea-scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.idea-score small { display: block; font-size: 11.5px; color: var(--muted); }
.idea-score b { font-size: 14px; font-variant-numeric: tabular-nums; }
.idea-score .meter { margin-top: 3px; }
.idea-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.idea-foot select { width: auto; min-height: 30px; padding: 3px 8px; font-size: 13px; }
.lab-gen { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-gen input { flex: 1 1 280px; width: auto; }

/* ---------- guides ---------- */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.guide-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; }
.guide-card:hover { border-color: var(--accent-line); }
.guide-card h3 { font-size: 15.5px; line-height: 1.38; }
.guide-card p { color: var(--text-2); font-size: 14px; }
.guide-card .meta { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.guide-layout { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 26px; align-items: start; }
.toc { position: sticky; top: 74px; font-size: 13.5px; max-height: calc(100vh - 100px); overflow: auto; }
.toc b { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.toc a { display: block; padding: 4px 10px; color: var(--text-2); text-decoration: none; border-left: 2px solid var(--line); cursor: pointer; line-height: 1.4; }
.toc a.sub { padding-left: 20px; font-size: 13px; }
.toc a:hover { color: var(--text); border-left-color: var(--accent); }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.editor textarea { min-height: max(320px, 62vh); font-family: var(--mono); font-size: 13.5px; }
.editor .preview { max-height: max(320px, 62vh); overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
@media (max-width: 1000px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .editor { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- steps (onboarding) ---------- */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.steps li::before {
  content: counter(step); width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}
.steps li.done::before { content: "✓"; background: var(--good-soft); color: var(--good-ink); }
.steps li.done span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.code-line { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; overflow-x: auto; white-space: nowrap; }

/* ---------- log ---------- */
.log { display: flex; flex-direction: column; }
.log-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.log-row:first-child { border-top: 0; }
.log-row time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.proposal { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.proposal + .proposal { margin-top: 10px; }
.proposal h3 { font-size: 15px; }
.proposal .reason { color: var(--text-2); font-size: 14px; }
.proposal pre { margin: 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 6px 9px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .side, .top, .item-actions, .page-actions, .composer, #toasts { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
}
