/* NorDerm Office — design system.
   True-dark graphite surfaces, hairline borders, one restrained accent, precise type.
   Everything is self-hosted (CSP: no external fonts, no inline styles). */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #0B0D10;
  --surface-0: #0E1013;
  --surface-1: #111418;
  --surface-2: #171B21;
  --surface-3: #1D222A;

  /* lines */
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .11);
  --line-3: rgba(255, 255, 255, .18);

  /* text (all >= 4.5:1 on every surface above) */
  --text: #E6E8EB;
  --dim: #9BA3AF;
  --faint: #7F8995;

  /* the single accent + semantic colours (used for state, never decoration) */
  --accent: #5FD3F3;
  --accent-strong: #87DEF5;
  --accent-soft: rgba(95, 211, 243, .10);
  --accent-line: rgba(95, 211, 243, .38);
  --on-accent: #06141A;
  --ok: #6CCB9A;
  --warn: #E5B567;
  --bad: #E5837F;
  --ok-soft: rgba(108, 203, 154, .11);
  --warn-soft: rgba(229, 181, 103, .11);
  --bad-soft: rgba(229, 131, 127, .11);

  /* type */
  --sans: Inter, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Mono", "JetBrains Mono", ui-monospace, Consolas, monospace;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;

  /* 4/8 grid */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* shape and motion */
  --r1: 6px; --r2: 10px; --r3: 14px;
  --shadow-pop: 0 24px 64px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t1: 120ms; --t2: 180ms;

  /* layout */
  --topbar-h: 56px;
  --rail-w: 232px;
  --content-w: 1240px;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 400 var(--fs-md)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  overflow: hidden;
}
::selection { background: rgba(95, 211, 243, .28); }
a { color: var(--accent); text-decoration: none; transition: color var(--t1) var(--ease); }
a:hover { color: var(--accent-strong); }
h1, h2, h3, h4, h5, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: var(--fs-lg); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: 0; }
.muted { color: var(--dim); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.strong { font-weight: 600; color: var(--text); }
.icon { flex: none; display: block; }
.caption {
  font: 600 var(--fs-xs)/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 0;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .10); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .2); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

.skip-link {
  position: fixed; left: var(--s4); top: -64px; z-index: 100; padding: var(--s2) var(--s4); background: var(--accent); color: var(--on-accent);
  border-radius: var(--r1); font-weight: 600; transition: top var(--t2) var(--ease);
}
.skip-link:focus { top: var(--s2); color: var(--on-accent); }

/* ------------------------------------------------------------------ boot, sign-in */
#root { height: 100%; }
#root.boot { display: grid; place-items: center; }
.boot-mark { font: 500 var(--fs-sm)/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--dim); animation: breathe 2.4s ease-in-out infinite; }
.noscript { padding: var(--s6); color: var(--text); }
@keyframes breathe { 50% { opacity: .45; } }

.auth-screen { position: relative; height: 100%; display: grid; place-items: center; overflow: hidden; background: var(--bg); }
.auth-screen .layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, rgba(11, 13, 16, .15) 0%, rgba(11, 13, 16, .86) 70%); pointer-events: none; }
.auth-card {
  position: relative; width: min(400px, calc(100vw - 32px)); padding: var(--s6); display: grid; gap: var(--s4);
  background: rgba(17, 20, 24, .92); border: 1px solid var(--line-2); border-radius: var(--r3); box-shadow: var(--shadow-pop);
}
.auth-card h1 { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -.02em; }
.auth-card p { margin: 0; font-size: var(--fs-sm); }
.auth-logo { display: flex; align-items: center; gap: var(--s2); font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .24em; }
.auth-logo em { font-style: normal; color: var(--accent); }
.auth-lang { position: absolute; top: var(--s4); right: var(--s4); z-index: 2; }

/* ------------------------------------------------------------------ shell */
#root.app {
  display: grid; height: 100%;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: "top top" "rail stage";
}

.topbar {
  grid-area: top; display: flex; align-items: center; gap: var(--s5); padding: 0 var(--s5);
  background: var(--surface-0); border-bottom: 1px solid var(--line); z-index: 20;
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .24em; color: var(--text); white-space: nowrap; }
.wordmark:hover { color: var(--text); }
.wordmark em { font-style: normal; color: var(--accent); }
.wordmark-mark, .logo-dot {
  width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--accent); display: inline-block; position: relative; flex: none;
}
.wordmark-mark::after { content: ""; position: absolute; inset: 1.5px; border-radius: 50%; background: var(--accent); }
.topbar-meta { display: flex; align-items: center; gap: var(--s2); color: var(--dim); font-size: var(--fs-sm); white-space: nowrap; min-width: 0; }
.topbar-time { color: var(--text); }
.topbar-place { overflow: hidden; text-overflow: ellipsis; }
.topbar-place:not(:empty)::before { content: "·"; margin-right: var(--s2); color: var(--faint); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.topbar-cost, .topbar-badge {
  display: inline-flex; align-items: center; gap: var(--s2); height: 32px; padding: 0 var(--s3); border: 1px solid var(--line);
  border-radius: var(--r1); color: var(--dim); font-size: var(--fs-sm); white-space: nowrap;
  transition: border-color var(--t1) var(--ease), color var(--t1) var(--ease), background var(--t1) var(--ease);
}
.topbar-cost:hover, .topbar-badge:hover { border-color: var(--line-3); color: var(--text); }
.topbar-cap { color: var(--faint); }
.topbar-cost-text { color: var(--text); font-size: var(--fs-sm); }
.meter { width: 40px; height: 3px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width var(--t2) var(--ease); }
.topbar-cost.warn .meter i { background: var(--warn); }
.topbar-badge b {
  min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 9px;
  background: var(--surface-3); color: var(--dim); font: 600 var(--fs-xs)/1 var(--mono);
}
.topbar-badge.on { color: var(--text); border-color: var(--accent-line); }
.topbar-badge.on b { background: var(--accent); color: var(--on-accent); }
.topbar-badge.errors.on { border-color: rgba(229, 131, 127, .5); }
.topbar-badge.errors.on b { background: var(--bad); color: #1B0B0A; }

.lang-switch { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: var(--r1); background: var(--surface-1); }
.lang-switch button {
  min-width: 34px; height: 26px; padding: 0 var(--s2); border: 0; border-radius: 4px; background: transparent; color: var(--dim);
  font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .06em; cursor: pointer; transition: background var(--t1) var(--ease), color var(--t1) var(--ease);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

/* rail */
.rail {
  grid-area: rail; display: flex; flex-direction: column; padding: var(--s3) var(--s3) var(--s3); overflow-y: auto;
  background: var(--surface-0); border-right: 1px solid var(--line);
}
.rail-items { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail-group { margin: var(--s4) var(--s3) var(--s1); font: 600 var(--fs-xs)/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.rail-group:first-child { margin-top: var(--s1); }
.rail a[data-view] {
  position: relative; display: flex; align-items: center; gap: var(--s3); height: 36px; padding: 0 var(--s3); border-radius: var(--r1);
  color: var(--dim); font-size: var(--fs-md); transition: background var(--t1) var(--ease), color var(--t1) var(--ease);
}
.rail a[data-view]:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.rail a[data-view].active { background: var(--accent-soft); color: var(--text); }
.rail a[data-view].active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent); }
.rail a[data-view].active .icon { color: var(--accent); }
.rail-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: none; margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; place-items: center; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font: 600 var(--fs-xs)/1 var(--mono);
}
.badge.on { display: inline-grid; }
.badge.bad { background: var(--bad); color: #1B0B0A; }
.rail-foot { display: grid; gap: 2px; padding-top: var(--s3); margin-top: var(--s3); border-top: 1px solid var(--line); }
.conn { display: flex; align-items: center; gap: var(--s3); height: 28px; padding: 0 var(--s3); color: var(--faint); font-size: var(--fs-sm); }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); flex: none; margin: 0 5.5px; }
.conn.off i { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: breathe 1.4s ease-in-out infinite; }
.rail-logout {
  display: flex; align-items: center; gap: var(--s3); height: 36px; padding: 0 var(--s3); border: 0; border-radius: var(--r1);
  background: transparent; color: var(--dim); cursor: pointer; text-align: left; font-size: var(--fs-md);
}
.rail-logout:hover { background: rgba(255, 255, 255, .04); color: var(--text); }

.stage { grid-area: stage; position: relative; overflow: auto; background: var(--bg); min-width: 0; min-height: 0; }
.view { max-width: var(--content-w); margin: 0 auto; padding: var(--s7) var(--s7) var(--s8); animation: view-in var(--t2) var(--ease); }
.view:focus { outline: none; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s6); }
.view-title h1 { font-size: var(--fs-2xl); font-weight: 500; letter-spacing: -.03em; line-height: 1.2; }
.view-title p { margin-top: var(--s2); max-width: 680px; color: var(--dim); font-size: var(--fs-md); line-height: 1.6; }
.view-actions { display: flex; gap: var(--s2); flex: none; }

/* ------------------------------------------------------------------ buttons, inputs */
.btn, button.primary, button.danger, button.success {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 36px; padding: 0 var(--s4);
  border: 1px solid var(--line-2); border-radius: var(--r1); background: var(--surface-2); color: var(--text); font-weight: 500; font-size: var(--fs-md);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--t1) var(--ease), border-color var(--t1) var(--ease), color var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--line-3); color: var(--text); }
.btn:active, button.primary:active, button.danger:active, button.success:active { transform: translateY(1px); }
.btn.primary, button.primary, button.success, .btn.success { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover, button.primary:hover, button.success:hover, .btn.success:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
button.success, .btn.success { background: var(--ok); border-color: var(--ok); color: #07140D; }
button.success:hover, .btn.success:hover { background: #86D8AE; border-color: #86D8AE; color: #07140D; }
button.danger, .btn.danger { background: transparent; border-color: rgba(229, 131, 127, .45); color: var(--bad); }
button.danger:hover, .btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
button:disabled, .btn:disabled, input:disabled, select:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: var(--r1); background: transparent; color: var(--dim); cursor: pointer; }
.icon-btn:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.icon-btn.tiny { width: 20px; height: 20px; margin-left: var(--s1); }
.btn.wide, button.wide { width: 100%; }
.btn.small, button.small { height: 28px; padding: 0 var(--s3); font-size: var(--fs-sm); }

input, select, textarea {
  width: 100%; min-height: 36px; padding: 7px var(--s3); background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--r1);
  color: var(--text); transition: border-color var(--t1) var(--ease), background var(--t1) var(--ease), box-shadow var(--t1) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--line-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; padding-right: 32px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--surface-2); color: var(--text); }
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
textarea[readonly] { color: var(--dim); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
input[type="search"]::-webkit-search-cancel-button { filter: invert(.7); }

.field { display: grid; gap: 6px; margin-bottom: var(--s4); min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 500; color: var(--dim); }
.field small { color: var(--faint); font-size: var(--fs-sm); line-height: 1.5; }
.form-error { margin: 0; padding: var(--s2) var(--s3); border-radius: var(--r1); background: var(--bad-soft); color: var(--bad); font-size: var(--fs-sm); }
.form-error:empty { display: none; }
.form-error.bad, .bad { color: var(--bad); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: var(--s2); }
.row > .grow, .grow { flex: 1; min-width: 160px; }
.row > .field { margin-bottom: var(--s4); }
.switch { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; cursor: pointer; font-size: var(--fs-md); }

/* ------------------------------------------------------------------ cards, chips, small parts */
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s5); min-width: 0; }
.card > h3, .card-head h3 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--s1); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); }
.card-head p { font-size: var(--fs-sm); max-width: 560px; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.view-gap { height: var(--s4); }

.empty { display: grid; justify-items: center; gap: var(--s2); padding: var(--s7) var(--s5); text-align: center; color: var(--dim); border: 1px dashed var(--line-2); border-radius: var(--r2); }
.empty b { color: var(--text); font-weight: 600; font-size: var(--fs-md); }
.empty span { max-width: 420px; font-size: var(--fs-sm); }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--faint); margin-bottom: var(--s1); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 22px; padding: 1px var(--s2); border: 1px solid var(--line-2);
  border-radius: 999px; background: var(--surface-2); color: var(--dim); font-size: var(--fs-xs); font-weight: 500; line-height: 1.4; white-space: nowrap;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; }
a.chip:hover { color: var(--text); border-color: var(--line-3); }
.chip.ok { background: var(--ok-soft); border-color: rgba(108, 203, 154, .3); color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: rgba(229, 181, 103, .3); color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: rgba(229, 131, 127, .3); color: var(--bad); }
.chip.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip.internal { background: transparent; border-style: dashed; color: var(--faint); }
.chip.kind { text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
.chip.src.kb { color: var(--accent); }
.chip.src.web { color: #B8C4F5; }
.chip.src.mail { color: #E6C3F0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { height: 28px; padding: 0 var(--s3); border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--dim); font-size: var(--fs-sm); cursor: pointer; transition: all var(--t1) var(--ease); }
.chip-toggle:hover { color: var(--text); border-color: var(--line-3); }
.chip-toggle.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s4); }
.filters select { width: auto; min-width: 180px; }
.filters input[type="search"] { width: 240px; }
.chips-row { margin-bottom: var(--s3); }

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); margin: var(--s5) 0 var(--s4); overflow-x: auto; overflow-y: hidden; }
.tab { position: relative; height: 40px; padding: 0 var(--s4); border: 0; background: transparent; color: var(--dim); font-weight: 500; cursor: pointer; white-space: nowrap; transition: color var(--t1) var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: var(--s2); right: var(--s2); bottom: 0; height: 2px; border-radius: 2px; background: var(--accent); }
.tab small { margin-left: 6px; padding: 1px 6px; border-radius: 9px; background: var(--surface-3); color: var(--dim); font: 600 var(--fs-xs)/1.4 var(--mono); }

.avatar {
  position: relative; flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-2); font-size: 17px; line-height: 1;
}
.avatar.sm { width: 24px; height: 24px; font-size: 12px; }
.avatar.xl { width: 52px; height: 52px; font-size: 26px; }
.avatar.owner-avatar { font: 600 11px var(--sans); color: var(--text); border-color: var(--line-3); }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; box-shadow: 0 0 0 2px var(--surface-1); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.s-idle { background: var(--ok); }
.dot.s-thinking { background: var(--accent); animation: breathe 1.4s ease-in-out infinite; }
.dot.s-tool { background: var(--warn); animation: breathe 1s ease-in-out infinite; }
.dot.s-waiting { background: #9AA7F2; }
.dot.s-resting { background: var(--faint); }
.swatch-dot, .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); margin-right: var(--s2); flex: none; }

.bar { position: relative; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.bar > i { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: 4px; background: var(--accent); transition: width var(--t2) var(--ease), left var(--t2) var(--ease); }
.bar.centered::after { content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: var(--line-3); }
.bar.thin { height: 3px; margin-top: var(--s2); }
.bar.warn > i { background: var(--warn); }
.progress-bar { height: 6px; margin: var(--s3) 0 var(--s4); }
.progress { height: 3px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--t1) linear; }
.pulse-text { animation: breathe 1.6s ease-in-out infinite; }

.skeleton-block { display: grid; gap: var(--s3); padding: var(--s2) 0; }
.skeleton { display: block; height: 52px; border-radius: var(--r1); background: linear-gradient(90deg, var(--surface-1) 0%, var(--surface-2) 50%, var(--surface-1) 100%); background-size: 200% 100%; animation: shimmer 1.6s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.plain-list { display: grid; gap: var(--s2); }
.plain-list li { padding-left: var(--s3); position: relative; font-size: var(--fs-sm); color: var(--dim); line-height: 1.55; }
.plain-list li::before { content: ""; position: absolute; left: 0; top: .7em; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.plain-list li b { color: var(--text); font-weight: 500; }
.kvs { display: grid; gap: 4px; }
.kv { display: flex; gap: var(--s2); font-size: var(--fs-sm); }
.kv .k { color: var(--faint); flex: none; }
.kv .k::after { content: ":"; }
.val { color: var(--dim); }

.notice { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r1); background: var(--surface-1); color: var(--dim); font-size: var(--fs-sm); margin-bottom: var(--s3); }
.notice .icon { color: var(--accent); }
.notice.warn { background: var(--warn-soft); border-color: rgba(229, 181, 103, .3); color: var(--warn); }
.notice.warn .icon { color: var(--warn); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-1); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { padding: var(--s3) var(--s4); text-align: left; font: 600 var(--fs-xs)/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); vertical-align: top; color: var(--dim); }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr { transition: background var(--t1) var(--ease); }
.table tbody tr:hover { background: rgba(255, 255, 255, .02); }
.table td.name a { color: var(--text); font-weight: 500; }
.table td.name a:hover { color: var(--accent); }
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.table .narrow { width: 1%; white-space: nowrap; }
.table.evidence { border: 1px solid var(--line); border-radius: var(--r1); overflow: hidden; }
.status-pill { display: inline-block; padding: 1px var(--s2); border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; background: var(--surface-3); color: var(--dim); }
.status-pill.ready { background: var(--ok-soft); color: var(--ok); }
.status-pill.processing { background: var(--warn-soft); color: var(--warn); }
.status-pill.failed { background: var(--bad-soft); color: var(--bad); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.kpi { padding: var(--s5); background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r2); }
.kpi.alert { display: grid; gap: var(--s2); align-content: center; justify-items: start; border-color: rgba(229, 181, 103, .3); }
.big-number { font: 500 30px/1.15 var(--sans); letter-spacing: -.03em; font-feature-settings: "tnum"; margin-top: var(--s2); }
.big-number small { margin-left: var(--s2); font-size: var(--fs-sm); font-weight: 400; color: var(--faint); letter-spacing: 0; }

/* toasts, modal */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 90; display: grid; gap: var(--s2); width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--r2);
  box-shadow: var(--shadow-pop); font-size: var(--fs-sm); animation: toast-in var(--t2) var(--ease); transition: opacity var(--t2), transform var(--t2);
}
.toast-dot { width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.ok .toast-dot { background: var(--ok); }
.toast.error .toast-dot { background: var(--bad); }
.toast.error { border-color: rgba(229, 131, 127, .35); }
.toast.leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--s5); background: rgba(5, 6, 8, .66); animation: fade-in var(--t2) var(--ease); }
.modal { width: min(520px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--r3); box-shadow: var(--shadow-pop); animation: modal-in var(--t2) var(--ease); }
.modal.wide { width: min(720px, 100%); }
.modal > header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
.modal > header h3 { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.modal-body { padding: var(--s5); display: grid; gap: var(--s3); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* ------------------------------------------------------------------ brain */
.view.view-brain { position: absolute; inset: 0; max-width: none; margin: 0; padding: 0; overflow: hidden; animation: none; }
.view-brain .layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud { position: absolute; z-index: 2; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-tl { top: var(--s6); left: var(--s6); display: grid; gap: 2px; }
.hud-time { font: 300 40px/1.1 var(--mono); letter-spacing: -.02em; color: var(--text); }
.hud-date { color: var(--dim); font-size: var(--fs-sm); }
.hud-summary { margin-top: var(--s3); display: grid; gap: 2px; color: var(--dim); font-size: var(--fs-sm); }
.hud-summary .alert { color: var(--accent); }
.hud-bl { left: var(--s6); bottom: var(--s6); max-width: min(480px, 46%); }
.ticker { display: grid; gap: 6px; }
.ticker li { display: flex; gap: var(--s3); align-items: baseline; font-size: var(--fs-sm); color: var(--dim); opacity: var(--o, 1); }
.ticker li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; align-self: center; }
.ticker li time { color: var(--faint); font-size: var(--fs-xs); flex: none; }
.ticker li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker li.fresh { animation: ticker-in 360ms var(--ease); color: var(--text); }
@keyframes ticker-in { from { opacity: 0; transform: translateY(4px); } }
.hud-br { right: var(--s6); bottom: var(--s6); max-width: 42%; }
.agent-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.agent-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: 999px; background: rgba(17, 20, 24, .82);
  color: var(--dim); font-size: var(--fs-sm); cursor: pointer; transition: border-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.agent-chip:hover { border-color: var(--line-3); color: var(--text); }
.node-tip {
  position: absolute; left: 0; top: 0; z-index: 4; width: 280px; padding: var(--s3) var(--s4); pointer-events: none; display: grid; gap: 4px;
  background: rgba(17, 20, 24, .96); border: 1px solid var(--line-2); border-radius: var(--r2); box-shadow: var(--shadow-pop);
}
.tip-name { display: flex; align-items: center; gap: var(--s2); font-weight: 600; }
.tip-title { color: var(--dim); font-size: var(--fs-sm); }
.tip-status { color: var(--faint); font-size: var(--fs-xs); }
.tip-thought { margin-top: 2px; padding-left: var(--s3); border-left: 2px solid var(--line-3); color: var(--dim); font-size: var(--fs-sm); font-style: italic; }
.tip-hint { margin-top: 2px; color: var(--faint); font-size: var(--fs-xs); }

/* ------------------------------------------------------------------ drawer */
#drawer-host { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 40; pointer-events: none; }
.drawer {
  pointer-events: auto; width: min(440px, 100vw); height: 100%; display: flex; flex-direction: column; background: var(--surface-1);
  border-left: 1px solid var(--line-2); box-shadow: -24px 0 60px rgba(0, 0, 0, .4); animation: drawer-in var(--t2) var(--ease);
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer > header { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.drawer .who { flex: 1; min-width: 0; }
.drawer .who h3 { font-size: var(--fs-lg); }
.drawer .who p { color: var(--dim); font-size: var(--fs-sm); line-height: 1.4; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s5); display: grid; gap: var(--s5); align-content: start; }
.drawer > footer { display: flex; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.status-line b { font-weight: 600; }
.gauges { display: grid; gap: var(--s3); }
.gauges.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.gauge { display: grid; gap: 6px; min-width: 0; }
.gauge-top { display: flex; justify-content: space-between; gap: var(--s2); font-size: var(--fs-sm); color: var(--dim); }
.gauge-top b { color: var(--text); font-weight: 500; }
.mood-word { font-size: var(--fs-sm); color: var(--dim); }
.mood-word b { color: var(--text); font-weight: 500; }
.drawer-section { display: grid; gap: var(--s2); }
.drawer-section h4 { display: flex; align-items: baseline; gap: var(--s2); font: 600 var(--fs-xs)/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.drawer-section h4 small { font: 400 var(--fs-xs) var(--sans); letter-spacing: 0; text-transform: none; color: var(--faint); }
.drawer-section p { font-size: var(--fs-md); }
.drawer-section blockquote { margin: 0; padding-left: var(--s3); border-left: 2px solid var(--line-3); color: var(--dim); font-style: italic; font-size: var(--fs-sm); line-height: 1.6; }
.inner-block + .inner-block { margin-top: var(--s3); }
.inner-block h5 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: 4px; }
.relations li b { display: inline-flex; align-items: center; gap: 6px; }
.relations li b::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--faint)); }
.rel-bars { display: inline-flex; gap: var(--s3); margin-left: var(--s2); }
.rel { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--faint); }
.rel-bar { display: inline-block; width: 36px; height: 3px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.rel-bar u { display: block; height: 100%; width: var(--w, 0); background: var(--ok); text-decoration: none; }
.rel.hostility .rel-bar u, .rel.threat .rel-bar u { background: var(--bad); }
.self-sections { display: grid; gap: 1px; border: 1px solid var(--line); border-radius: var(--r1); overflow: hidden; background: var(--line); }
.self-sections details { background: var(--surface-1); }
.self-sections summary { padding: var(--s3) var(--s4); cursor: pointer; font-size: var(--fs-sm); color: var(--text); list-style: none; transition: background var(--t1) var(--ease); }
.self-sections summary::-webkit-details-marker { display: none; }
.self-sections summary::before { content: "›"; display: inline-block; width: 14px; color: var(--faint); transition: transform var(--t1) var(--ease); }
.self-sections details[open] summary::before { transform: rotate(90deg); }
.self-sections summary:hover { background: rgba(255, 255, 255, .03); }
.self-sections details p { padding: 0 var(--s4) var(--s4) calc(var(--s4) + 14px); font-size: var(--fs-sm); line-height: 1.65; }

/* ------------------------------------------------------------------ chats */
.view.view-chats { height: 100%; display: flex; flex-direction: column; padding-bottom: var(--s5); }
.view-chats .view-head { margin-bottom: var(--s4); }
.chats { flex: 1; min-height: 0; display: grid; grid-template-columns: 296px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-1); overflow: hidden; }
.chat-list { overflow-y: auto; padding: var(--s3); border-right: 1px solid var(--line); background: var(--surface-0); display: flex; flex-direction: column; gap: 2px; }
.chat-list .caption { padding: var(--s2) var(--s2) var(--s1); }
.chat-list .caption.sep { margin-top: var(--s4); }
.chat-item { position: relative; display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s2) var(--s3); border: 0; border-radius: var(--r1); background: transparent; color: var(--text); text-align: left; cursor: pointer; transition: background var(--t1) var(--ease); }
.chat-item:hover { background: rgba(255, 255, 255, .04); }
.chat-item.active { background: var(--surface-2); }
.chat-item.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--c, var(--accent)); }
.chat-item .meta { flex: 1; min-width: 0; }
.chat-item .name { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-weight: 500; font-size: var(--fs-md); }
.chat-item .name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .snippet { color: var(--faint); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .unread { min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 9px; background: var(--accent); color: var(--on-accent); font: 600 var(--fs-xs)/1 var(--mono); }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.thread-head .who { flex: 1; min-width: 0; }
.thread-head h2 { font-size: var(--fs-lg); }
.thread-head p { color: var(--dim); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread > .composer { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); background: var(--surface-1); }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s4) var(--s5) var(--s6); display: flex; flex-direction: column; gap: var(--s4); }
.day-sep { display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0; color: var(--faint); font: 600 var(--fs-xs)/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { display: grid; gap: 6px; max-width: 78%; }
.msg.owner { align-self: flex-end; justify-items: end; }
.msg .info { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); font-size: var(--fs-xs); color: var(--faint); }
.msg .info b { color: var(--dim); font-weight: 600; font-size: var(--fs-sm); }
.msg .bubble { padding: var(--s3) var(--s4); border-radius: var(--r2); background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.msg.agent .bubble { border-top-left-radius: 4px; box-shadow: inset 2px 0 0 var(--c, var(--line-2)); }
.msg.owner .bubble { background: var(--accent-soft); border-color: var(--accent-line); border-top-right-radius: 4px; }
.msg.internal .bubble { background: transparent; border-style: dashed; border-color: var(--line-2); color: var(--dim); box-shadow: none; }
.typing { display: flex; align-items: center; gap: 4px; color: var(--faint); font-size: var(--fs-sm); }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); animation: breathe 1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.typing span { margin-left: var(--s2); }
.composer { display: grid; gap: var(--s2); }
.composer-row { display: flex; align-items: flex-end; gap: var(--s2); }
.composer textarea { flex: 1; min-height: 40px; max-height: 180px; resize: none; padding: 9px var(--s3); }
.attached { display: flex; flex-wrap: wrap; gap: var(--s2); }
.attached:empty { display: none; }
.tag-note { color: var(--faint); font-size: var(--fs-xs); }

/* ------------------------------------------------------------------ team */
.tiers { display: grid; gap: var(--s6); }
.tier { display: grid; gap: var(--s3); }
.tier-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s4); }
.agent-card {
  position: relative; display: grid; gap: var(--s3); align-content: start; padding: var(--s5); text-align: left; cursor: pointer;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r2); color: var(--text);
  transition: border-color var(--t2) var(--ease), background var(--t2) var(--ease);
}
.agent-card::before { content: ""; position: absolute; top: -1px; left: var(--s5); width: 32px; height: 2px; border-radius: 0 0 2px 2px; background: var(--c, var(--line-3)); }
.agent-card:hover { border-color: var(--line-3); background: var(--surface-2); }
.agent-card .top { display: flex; align-items: center; gap: var(--s3); }
.agent-card .ident { min-width: 0; }
.agent-card h3 { font-size: var(--fs-lg); }
.agent-card .state { color: var(--dim); font-size: var(--fs-sm); }
.agent-card .role { color: var(--dim); font-size: var(--fs-sm); line-height: 1.55; min-height: 3.1em; }
.agent-card .now { display: grid; gap: 4px; padding: var(--s3) var(--s4); border-radius: var(--r1); background: var(--surface-0); border: 1px solid var(--line); }
.agent-card .now p { font-size: var(--fs-sm); color: var(--text); line-height: 1.5; }
.agent-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); color: var(--faint); }
.agent-card .more { color: var(--accent); opacity: 0; transform: translateX(-4px); transition: all var(--t2) var(--ease); }
.agent-card:hover .more, .agent-card:focus-visible .more { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ tasks */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: var(--s4); align-items: start; }
.kcol { padding: var(--s3); background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--r2); min-height: 200px; transition: border-color var(--t1) var(--ease), background var(--t1) var(--ease); }
.kcol.over { border-color: var(--accent-line); background: var(--accent-soft); }
.kcol h3 { display: flex; align-items: center; justify-content: space-between; padding: var(--s1) var(--s2) var(--s3); font: 600 var(--fs-xs)/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.kcol h3 b { min-width: 22px; padding: 1px 6px; text-align: center; border-radius: 9px; background: var(--surface-3); font: 600 var(--fs-xs)/1.4 var(--mono); }
.kcol[data-status="blocked"] h3 span { color: var(--warn); }
.kcol[data-status="done"] h3 span { color: var(--ok); }
.kcards { display: grid; gap: var(--s2); }
.kempty { padding: var(--s4) var(--s2); color: var(--faint); font-size: var(--fs-sm); text-align: center; }
.task-card {
  position: relative; display: grid; gap: var(--s2); padding: var(--s3) var(--s4); background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r1); cursor: pointer;
  transition: border-color var(--t1) var(--ease), background var(--t1) var(--ease), opacity var(--t1);
}
.task-card::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--c, var(--line-3)); }
.task-card:hover { border-color: var(--line-3); background: var(--surface-2); }
.task-card.dragging { opacity: .4; }
.task-card.mine { background: var(--accent-soft); border-color: var(--accent-line); }
.task-card.mine::before { background: var(--accent); }
.task-card .chip.accent { justify-self: start; }
.task-card .t { font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }
.task-card .bottom { display: flex; align-items: center; gap: var(--s2); color: var(--faint); font-size: var(--fs-xs); flex-wrap: wrap; }
.task-card .bottom .who { color: var(--dim); font-size: var(--fs-sm); }
.task-card .sp, .draft-actions .sp { flex: 1; }
.prio-tag { padding: 0 6px; border-radius: 4px; font-weight: 600; background: var(--warn-soft); color: var(--warn); }
.prio-tag.urgent { background: var(--bad-soft); color: var(--bad); }
.due.overdue { color: var(--bad); }
.timeline { display: grid; gap: var(--s2); max-height: 260px; overflow-y: auto; padding-top: var(--s2); border-top: 1px solid var(--line); }
.timeline .ev { display: flex; gap: var(--s3); font-size: var(--fs-sm); color: var(--dim); }
.timeline .ev time { flex: none; width: 96px; color: var(--faint); font-family: var(--mono); font-size: var(--fs-xs); padding-top: 2px; }
.meta-row { margin-bottom: var(--s2); }

/* ------------------------------------------------------------------ knowledge */
.dropzone {
  display: grid; justify-items: center; gap: var(--s1); padding: var(--s6) var(--s5); text-align: center; cursor: pointer;
  border: 1px dashed var(--line-3); border-radius: var(--r2); background: var(--surface-0); transition: border-color var(--t2) var(--ease), background var(--t2) var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--accent); margin-bottom: var(--s2); }
.dropzone b { font-weight: 600; }
.dz-hint { color: var(--dim); font-size: var(--fs-sm); max-width: 520px; }
.dz-formats { color: var(--faint); font-size: var(--fs-xs); margin-top: var(--s1); }
.upload-list { display: grid; gap: var(--s2); }
.upload-list:not(:empty) { margin-top: var(--s3); }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: var(--s1) var(--s3); padding: var(--s3) var(--s4); background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r1); font-size: var(--fs-sm); }
.upload-item .progress { grid-column: 1 / -1; }
.upload-name { display: flex; align-items: center; gap: var(--s2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.upload-item .bad { color: var(--bad); }
.search-box { display: flex; gap: var(--s2); margin-bottom: var(--s4); }
.result { padding: var(--s4) var(--s5); background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r2); margin-bottom: var(--s3); }
.result .head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.result .head b { font-weight: 600; }
.result p { color: var(--dim); font-size: var(--fs-md); line-height: 1.65; }
mark { padding: 0 2px; border-radius: 3px; background: rgba(95, 211, 243, .2); color: var(--text); }
.onboarding { margin-bottom: var(--s4); }
.onb-percent { text-align: right; flex: none; }
.onb-percent b { display: block; font: 500 28px/1 var(--sans); letter-spacing: -.03em; }
.onb-percent small { color: var(--faint); font-size: var(--fs-xs); }
.onb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s1) var(--s5); }
.onb-list li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.onb-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; }
.onb-ready .onb-dot { background: var(--ok); border-color: var(--ok); }
.onb-partial .onb-dot { border-color: var(--warn); background: linear-gradient(90deg, var(--warn) 50%, transparent 50%); }
.onb-asked .onb-dot { border-color: var(--accent); }
.onb-name { flex: 1; color: var(--text); }
.onb-status { color: var(--faint); }
.onb-foot { margin-top: var(--s4); font-size: var(--fs-sm); }

/* ------------------------------------------------------------------ drafts */
.drafts { display: grid; gap: var(--s4); }
.draft { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.draft.decided { opacity: .78; }
.draft-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.draft-title { display: grid; gap: var(--s2); justify-items: start; min-width: 0; }
.draft-title h3 { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.draft-by { color: var(--dim); font-size: var(--fs-sm); white-space: nowrap; }
.draft-body { display: grid; gap: var(--s5); padding: var(--s5); }
.draft-text { display: grid; gap: var(--s2); justify-items: start; }
.draft-text textarea { min-height: 160px; background: var(--surface-0); }
.draft-images { display: flex; flex-wrap: wrap; gap: var(--s3); }
.draft-images img { display: block; max-width: 300px; max-height: 300px; border-radius: var(--r1); border: 1px solid var(--line-2); object-fit: cover; }
.evidence-block { display: grid; gap: var(--s2); }
.draft-actions { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--surface-0); }

/* ------------------------------------------------------------------ mail */
.mail-list { display: grid; border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; background: var(--surface-1); }
.mail-item + .mail-item { border-top: 1px solid var(--line); }
.mail-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s4); width: 100%; padding: var(--s4) var(--s5); border: 0; background: transparent; text-align: left; cursor: pointer;
  transition: background var(--t1) var(--ease);
}
.mail-head:hover { background: rgba(255, 255, 255, .025); }
.mail-head .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-head .when { color: var(--faint); font-size: var(--fs-xs); align-self: center; }
.mail-head .subj { grid-column: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-head .chips { grid-column: 2; grid-row: 2; justify-content: flex-end; }
.mail-head .snip { grid-column: 1 / -1; color: var(--faint); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-body { padding: var(--s4) var(--s5) var(--s5); border-top: 1px solid var(--line); background: var(--surface-0); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--dim); font-size: var(--fs-md); line-height: 1.65; }
.wizard-card { margin-bottom: var(--s4); }
.wizard-card h3 + p { margin-bottom: var(--s5); }
.steps { display: flex; gap: var(--s5); margin-bottom: var(--s5); flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: var(--s2); color: var(--faint); font-size: var(--fs-sm); }
.step-n { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-3); font: 600 var(--fs-xs)/1 var(--mono); }
.step.active { color: var(--text); }
.step.active .step-n { border-color: var(--accent); color: var(--accent); }
.step.done .step-n { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.candidate { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s2); border: 1px solid var(--line-2); border-radius: var(--r1); cursor: pointer; font-size: var(--fs-sm); }
.candidate:hover { border-color: var(--line-3); }

/* ------------------------------------------------------------------ usage */
.chart { display: block; width: 100%; height: auto; margin-top: var(--s3); }
.chart text { fill: var(--faint); font: 11px var(--sans); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-rect { fill: rgba(155, 163, 175, .38); transition: fill var(--t1) var(--ease); }
.chart .bar-rect:hover { fill: rgba(155, 163, 175, .6); }
.chart .bar-rect.today { fill: var(--accent); }
.chart .budget { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 4; opacity: .8; }
.chart text.budget-label { fill: var(--warn); }
.agent-bars { display: grid; gap: var(--s3); margin-top: var(--s3); }
.agent-bars .line { display: grid; grid-template-columns: minmax(120px, 160px) minmax(0, 1fr) 64px; align-items: center; gap: var(--s3); font-size: var(--fs-sm); }
.agent-bars .who { display: flex; align-items: center; min-width: 0; color: var(--dim); }
.agent-bars .who .swatch { background: var(--c, var(--faint)); }
.agent-bars .bar { height: 6px; }
.agent-bars .bar > i { background: rgba(155, 163, 175, .55); }
.agent-bars b { text-align: right; font-weight: 500; }

/* ------------------------------------------------------------------ log */
.system-errors { margin-bottom: var(--s4); }
.log-list { display: grid; }
.log-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: var(--s4); align-items: start; padding: var(--s3) 0; border-top: 1px solid var(--line); }
.log-row:first-child { border-top: 0; }
.log-row time { color: var(--faint); font-size: var(--fs-xs); display: grid; gap: 2px; }
.log-row time small { font-family: var(--sans); }
.log-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-sm); color: var(--dim); }
.log-main b { color: var(--text); font-weight: 500; font-size: var(--fs-md); overflow-wrap: anywhere; }
.log-main p { font-size: var(--fs-sm); }
.log-detail { margin-top: 2px; color: var(--faint); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.log-tags { display: flex; gap: 6px; }
.log-row.critical .log-main b { color: var(--bad); }
.log-row.fresh { box-shadow: -12px 0 0 -10px var(--bad); }
.log-row .swatch-dot { background: var(--c, var(--faint)); }
.event-row { grid-template-columns: 132px minmax(0, 1fr); align-items: center; }
.event-row .log-main { flex-direction: row; align-items: center; color: var(--text); }

/* ------------------------------------------------------------------ settings */
.settings-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--s6); align-items: start; }
.settings-nav { position: sticky; top: 0; display: grid; gap: 2px; }
.settings-nav button { height: 34px; padding: 0 var(--s3); border: 0; border-radius: var(--r1); background: transparent; color: var(--dim); text-align: left; cursor: pointer; font-size: var(--fs-md); transition: all var(--t1) var(--ease); }
.settings-nav button:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.settings-body { display: grid; gap: var(--s7); min-width: 0; }
.settings-group { display: grid; gap: var(--s4); scroll-margin-top: var(--s5); }
.group-title { font: 600 var(--fs-xs)/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding-bottom: var(--s2); border-bottom: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.setting .card-head { margin-bottom: var(--s3); }
.setting .card-head h3 { font-size: var(--fs-md); }
.choice-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s2); }
.choice-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { display: grid; gap: 2px; padding: var(--s3) var(--s4); text-align: left; border: 1px solid var(--line-2); border-radius: var(--r1); background: var(--surface-0); color: var(--text); cursor: pointer; transition: all var(--t1) var(--ease); }
.choice:hover:not(:disabled) { border-color: var(--line-3); background: var(--surface-2); }
.choice.active { border-color: var(--accent-line); background: var(--accent-soft); }
.choice b { font-weight: 600; }
.choice small { color: var(--dim); font-size: var(--fs-xs); line-height: 1.45; }
.live-clock { display: grid; gap: 2px; padding: var(--s4); margin-bottom: var(--s4); border: 1px solid var(--line); border-radius: var(--r1); background: var(--surface-0); }
.live-clock .mono { font-size: 28px; font-weight: 300; line-height: 1.1; }
.live-clock small { color: var(--dim); font-size: var(--fs-sm); }
.geo-results { display: grid; margin: calc(var(--s2) * -1) 0 var(--s4); border: 1px solid var(--line-2); border-radius: var(--r1); overflow: hidden; background: var(--surface-2); }
.geo-results button { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.geo-results button:first-child { border-top: 0; }
.geo-results button:hover { background: rgba(255, 255, 255, .05); }
.geo-results small { color: var(--faint); }
.key-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s4); font-size: var(--fs-sm); }
.role-rows { display: grid; gap: var(--s2); margin: var(--s3) 0; }
.role-row { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: var(--s3); align-items: center; font-size: var(--fs-sm); color: var(--dim); }
.user-list { display: grid; margin-top: var(--s2); }
.user-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.disclosure { margin-top: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s3); }
.disclosure > summary { cursor: pointer; color: var(--accent); font-size: var(--fs-md); padding: var(--s2) 0; list-style: none; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure[open] > summary { margin-bottom: var(--s3); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .view { padding: var(--s6) var(--s6) var(--s7); }
  .kanban { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 1024px) {
  :root { --rail-w: 64px; }
  .rail { padding: var(--s3) var(--s2); align-items: center; }
  .rail-label, .rail-group { display: none; }
  .rail a[data-view], .rail-logout { width: 44px; justify-content: center; padding: 0; position: relative; }
  .rail a[data-view].active::before { left: -8px; }
  .rail a[data-view] .badge { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; font-size: 10px; }
  .conn { padding: 0; width: 44px; justify-content: center; }
  .conn i { margin: 0; }
  .rail-items { align-items: center; }
  .topbar { gap: var(--s4); padding: 0 var(--s4); }
  .topbar-cap, .topbar-meta .topbar-place { display: none; }
  .topbar-badge span { display: none; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; display: flex; flex-wrap: wrap; gap: var(--s2); }
  .settings-nav button { background: var(--surface-1); border: 1px solid var(--line); }
  .settings-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .chats { grid-template-columns: 240px minmax(0, 1fr); }
  .hud-time { font-size: 32px; }
}
@media (max-width: 768px) {
  :root { --topbar-h: 52px; }
  body { overflow: auto; }
  #root.app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar-h) minmax(0, 1fr) 56px; grid-template-areas: "top" "stage" "rail"; }
  .rail { flex-direction: row; padding: 0 var(--s2); border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; justify-content: flex-start; }
  .rail-items { flex-direction: row; gap: 2px; align-items: center; flex: none; }
  .rail-foot { display: flex; flex-direction: row; margin: 0 0 0 var(--s2); padding: 0; border: 0; align-items: center; }
  .rail a[data-view].active::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 2px; }
  .conn { display: none; }
  .topbar-meta, .topbar-cost { display: none; }
  .view { padding: var(--s5) var(--s4) var(--s6); }
  .view-head { flex-direction: column; align-items: stretch; gap: var(--s3); }
  .view-title h1 { font-size: 24px; }
  #drawer-host { top: 0; bottom: 56px; }
  .drawer { width: 100vw; }
  .chats { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .chat-list { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s2); }
  .chat-list .caption { display: none; }
  .chat-item { width: auto; flex: none; padding: var(--s2); }
  .chat-item .meta { display: none; }
  .msg { max-width: 92%; }
  .kanban { grid-template-columns: minmax(0, 1fr); }
  .tier-cards { grid-template-columns: minmax(0, 1fr); }
  .hud-tl { top: var(--s4); left: var(--s4); }
  .hud-bl { left: var(--s4); bottom: 76px; max-width: calc(100% - 32px); }
  .hud-br { display: none; }
  .log-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .agent-bars .line { grid-template-columns: minmax(80px, 110px) minmax(0, 1fr) 56px; }
  .role-row { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  .draft-head { flex-direction: column; }
  .toasts { bottom: 68px; }
}

/* ---- access: waiting for approval, new-device banner, environment section */
.block { display: block; }
.auth-wait { display: flex; align-items: center; gap: var(--s3); color: var(--text); }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.device-host { position: fixed; top: 64px; right: var(--s5); z-index: 80; display: grid; gap: var(--s2); width: min(420px, calc(100vw - 32px)); }
.device-banner { display: grid; gap: var(--s3); padding: var(--s4); background: var(--surface-2); border: 1px solid var(--accent-line); border-radius: var(--r2); box-shadow: var(--shadow-pop); }
.device-banner-text { display: grid; gap: 2px; min-width: 0; }
.device-banner-text small { color: var(--dim); overflow-wrap: anywhere; }
.device-row { flex-wrap: wrap; }
.env-section { grid-column: 1 / -1; }
.env-form { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; margin-bottom: var(--s3); }
.env-form input { flex: 1; min-width: 200px; width: auto; }
.env-grid { margin-top: var(--s3); }
@media (max-width: 768px) {
  .device-host { top: 56px; right: var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .chip, .btn, button.primary, .tab.active::after { border: 1px solid CanvasText; }
}

/* the office's main switch */
.topbar-power { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; transition: border-color .15s, background .15s; }
.topbar-power .dot { width: 8px; height: 8px; border-radius: 50%; background: #5fe3a1; box-shadow: 0 0 0 3px rgba(95,227,161,.15); }
.topbar-power.paused .dot { background: #f2a35e; box-shadow: 0 0 0 3px rgba(242,163,94,.18); }
.topbar-power:hover { border-color: var(--accent); }
.topbar-power:disabled { opacity: .6; cursor: progress; }
