/* Richi visual system: tokens → primitives → layout → views → motion. Local only, no external fonts. */
:root {
  color-scheme: dark;
  --bg: #08090b;
  --bg-raised: #0c0e11;
  --surface-1: #111318;
  --surface-2: #161920;
  --surface-3: #1d2129;
  --surface-4: #252a33;
  --line: rgba(255, 255, 255, .065);
  --line-strong: rgba(255, 255, 255, .11);
  --text: #eceef2;
  --text-2: #b9bec8;
  --muted: #858c98;
  --faint: #5a616d;
  --accent: #c4f27a;
  --accent-ink: #142009;
  --ok: #5cd49b;
  --work: #7e9dff;
  --warn: #f0b660;
  --error: #f17c7c;
  --protect: #b59dff;
  --idle: #6c737f;
  --blue: #7e9dff;
  --violet: #b59dff;
  --mint: #5cd49b;
  --tone: var(--idle);
  --mix: white;
  --wash: rgba(255, 255, 255, .04);
  --hero-top: #12151a;
  --shadow-strong: rgba(0, 0, 0, .85);
  --accent-text: #c4f27a;
  --flow-line: rgba(255, 255, 255, .1);
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar: 236px;
  --nav-height: 64px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Light theme: explicit choice, or the system preference unless dark was chosen. */
:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-raised: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef2;
  --surface-4: #e2e5ea;
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .14);
  --text: #11151b;
  --text-2: #3b4350;
  --muted: #687080;
  --faint: #9aa1ad;
  --accent: #c4f27a;
  --accent-ink: #142009;
  --accent-text: #3d7a0c;
  --ok: #1d9a62;
  --work: #3c62e0;
  --warn: #c07a10;
  --error: #d04444;
  --protect: #7657e0;
  --idle: #8a919c;
  --blue: #3c62e0;
  --violet: #7657e0;
  --mint: #1d9a62;
  --mix: black;
  --wash: rgba(15, 23, 42, .04);
  --hero-top: #ffffff;
  --shadow-strong: rgba(15, 23, 42, .16);
  --flow-line: rgba(15, 23, 42, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
  --bg: #f5f6f8;
  --bg-raised: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef2;
  --surface-4: #e2e5ea;
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .14);
  --text: #11151b;
  --text-2: #3b4350;
  --muted: #687080;
  --faint: #9aa1ad;
  --accent: #c4f27a;
  --accent-ink: #142009;
  --accent-text: #3d7a0c;
  --ok: #1d9a62;
  --work: #3c62e0;
  --warn: #c07a10;
  --error: #d04444;
  --protect: #7657e0;
  --idle: #8a919c;
  --blue: #3c62e0;
  --violet: #7657e0;
  --mint: #1d9a62;
  --mix: black;
  --wash: rgba(15, 23, 42, .04);
  --hero-top: #ffffff;
  --shadow-strong: rgba(15, 23, 42, .16);
  --flow-line: rgba(15, 23, 42, .12);
  color-scheme: light;
  }
}
.ok { --tone: var(--ok); }
.work { --tone: var(--work); }
.warn { --tone: var(--warn); }
.error { --tone: var(--error); }
.protect { --tone: var(--protect); }
.idle { --tone: var(--idle); }
.accent { --tone: var(--accent); }
.blue { --tone: var(--blue); }
.violet { --tone: var(--violet); }
.mint { --tone: var(--mint); }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); overflow-x: hidden; transition: background-color .3s, color .3s; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button, a, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.15; }
h2 { font-size: 15px; font-weight: 620; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 620; letter-spacing: -.01em; }
h4 { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
code { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.5; }
.mono { font-family: var(--mono); font-size: .9em; letter-spacing: -.01em; overflow-wrap: anywhere; font-variant-ligatures: none; }
.eyebrow { font-size: 11px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Status primitives */
.dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
.dot.ok, .dot.work, .dot.error { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent); }
.dot.work { animation: blink 1.6s ease-in-out infinite; }
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 24px; max-width: 100%; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  color: color-mix(in srgb, var(--tone) 82%, var(--mix)); background: color-mix(in srgb, var(--tone) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent); }
.chip > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.chip .icon { width: 12px; height: 12px; stroke-width: 2; }
.chip .dot { width: 6px; height: 6px; box-shadow: none; }
.chip.idle { color: var(--text-2); background: var(--wash); border-color: var(--line-strong); }
.chip .timer { margin-left: 2px; font-size: 11px; color: var(--text); }
.timer { font-variant-numeric: tabular-nums; }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid transparent; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s, opacity .15s; }
.button .icon { width: 16px; height: 16px; }
.button:disabled { opacity: .45; }
.button:active:enabled { transform: scale(.98); }
.button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 6px 18px -8px color-mix(in srgb, var(--accent) 60%, transparent); }
.button.primary:hover:enabled { background: #d3f79a; }
.button.primary:disabled { background: var(--surface-4); color: var(--muted); box-shadow: none; opacity: 1; }
.button.secondary { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.button.secondary:hover:enabled { background: var(--surface-4); border-color: rgba(255, 255, 255, .18); }
.button.subtle { background: transparent; color: var(--text-2); }
.button.subtle:hover:enabled { background: var(--surface-3); color: var(--text); }
.button.compact { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); transition: background .15s, color .15s; }
.icon-button:hover { background: var(--surface-3); color: var(--text); }
.icon-button .icon { width: 15px; height: 15px; }
.icon-button.copied { color: var(--ok); }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%), var(--bg); }
.login-card { width: min(100%, 420px); padding: 32px; border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1)); box-shadow: 0 30px 80px -40px var(--shadow-strong); }
.login-card .eyebrow { margin-top: 20px; }
.login-card h1 { margin: 10px 0 8px; font-size: 26px; }
.login-card > .muted { line-height: 1.6; }
.login-policy { display: flex; align-items: center; gap: 8px; margin: 22px 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg); font-size: 12.5px; font-weight: 600; }
.login-card .button.primary { width: 100%; min-height: 44px; font-size: 14px; }
.form-message { min-height: 20px; margin-top: 12px; color: var(--warn); font-size: 13px; }
details#enroll-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
details#enroll-details summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
details#enroll-details > p { margin: 10px 0; }
#enroll-form { display: grid; gap: 8px; }
#enroll-form label { font-size: 12px; color: var(--muted); }
#enroll-form input { min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); }
#enroll-form input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.login-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; font-size: 11px; color: var(--faint); }
.login-foot span { letter-spacing: .12em; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 21px; line-height: 1; letter-spacing: -.04em; box-shadow: 0 1px 0 rgba(255, 255, 255, .4) inset, 0 8px 22px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.brand-mark span { color: color-mix(in srgb, var(--accent-ink) 55%, var(--accent)); }
.brand-mark.small-mark { width: 30px; height: 30px; border-radius: 9px; font-size: 16px; }

/* Shell */
.shell { min-height: 100vh; }
.column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 650; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.sidebar { position: fixed; z-index: 30; display: flex; flex-direction: column; background: var(--bg-raised); }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px; }
.brand-text { display: flex; flex-direction: column; font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.15; }
.brand-text small { font-size: 10.5px; font-weight: 550; color: var(--muted); letter-spacing: .02em; }
.nav { display: flex; }
.nav a, .nav-more { position: relative; display: flex; align-items: center; color: var(--muted); border: 0; background: none; transition: color .15s, background .15s; }
.nav a:hover, .nav-more:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); }
.nav-caption, .sheet-caption { font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.nav-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 600; text-align: center; }
.nav-live { margin-left: auto; display: inline-flex; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.sidebar-foot small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line-strong); font-size: 12px; font-weight: 700; color: var(--text-2); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px); }
.workspace-main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px) saturate(140%); border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--faint); }
.mobile-brand { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topbar-actions .icon-button { width: auto; height: 34px; padding: 0 10px; gap: 7px; display: inline-flex; font-size: 13px; color: var(--text-2); }
.connection { display: inline-flex; align-items: center; gap: 7px; height: 28px; margin-right: 6px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-1); font-size: 12px; color: var(--text-2); white-space: nowrap; --tone: var(--idle); }
.connection[data-state="live"] { --tone: var(--ok); }
.connection[data-state="warn"] { --tone: var(--warn); }
.connection[data-state="error"] { --tone: var(--error); }
.connection .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent); }
.connection[data-state="live"] .dot { animation: breathe 2.8s ease-in-out infinite; }
.connection[data-state="warn"] .dot { animation: blink 1s ease-in-out infinite; }
main { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 32px 40px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-heading p { margin-top: 6px; font-size: 13.5px; }
main[data-view="overview"] .page-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }

/* Notices */
.notice, .command-strip, .stale-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--tone) 26%, transparent); background: color-mix(in srgb, var(--tone) 8%, var(--surface-1)); }
.notice { --tone: var(--work); margin-bottom: 16px; animation: drop .25s var(--ease); }
.notice .icon, .command-strip > .icon, .stale-banner .icon { width: 16px; height: 16px; color: var(--tone); }
.warning-notice, .stale-banner { --tone: var(--warn); }
.success-notice { --tone: var(--ok); }
.command-copy { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.command-copy strong { font-size: 13px; font-weight: 600; }
.command-strip code { font-size: 11.5px; }
.spinner { flex: none; width: 15px; height: 15px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--tone) 25%, transparent); border-top-color: var(--tone); animation: spin .8s linear infinite; }

/* Layout */
.view { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.panel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-1); }
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 12px; margin-bottom: 14px; }
.panel-title { flex: 1 1 160px; min-width: 0; }
.panel-title p { margin-top: 3px; }
.panel-link { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; flex: none; padding: 4px 6px 4px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); transition: color .15s, background .15s; }
.panel-link:hover { color: var(--text); background: var(--surface-3); }
.panel-link .icon { width: 14px; height: 14px; }
.control-panel { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 3%, var(--surface-1)), var(--surface-1) 40%); }
.control-stack { display: flex; flex-direction: column; gap: 16px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--muted); text-align: center; font-size: 13px; }
.empty .icon { width: 22px; height: 22px; color: var(--faint); }
.list { display: flex; flex-direction: column; gap: 2px; }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 10px; margin: 0 -10px; border-radius: 10px; transition: background .15s, transform .1s; }
a.list-row:hover { background: var(--surface-2); }
a.list-row:active { transform: scale(.99); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-main strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-icon { flex: none; width: 8px; height: 8px; margin: 0 7px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 14%, transparent); }
.row-glyph { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; color: var(--tone); background: color-mix(in srgb, var(--tone) 11%, transparent); }
.row-glyph .icon { width: 16px; height: 16px; }
.facts { margin: 0; display: flex; flex-direction: column; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 38px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv dt { flex: none; font-size: 12.5px; color: var(--muted); }
.kv dd { min-width: 0; margin: 0; font-size: 13px; text-align: right; overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; min-width: 0; }
.stack.end { align-items: flex-end; }
.stack small { font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Agent marks and live activity */
.mark { position: relative; display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; font-weight: 700; font-size: 15px;
  --mark: var(--idle); color: color-mix(in srgb, var(--mark) 85%, var(--mix)); border: 1px solid color-mix(in srgb, var(--mark) 30%, transparent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--mark) 22%, var(--surface-2)), color-mix(in srgb, var(--mark) 6%, var(--surface-2))); }
.mark.codex { --mark: #9fb4ff; }
.mark.claude { --mark: #e58b65; }
.mark.grok { --mark: #9aa1ad; }
.mark.large { width: 46px; height: 46px; border-radius: 14px; font-size: 19px; }
.mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
.mark.tiny { width: 22px; height: 22px; border-radius: 7px; font-size: 11px; }
.mark.live::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 1.5px solid var(--work); opacity: 0;
  animation: halo 2.4s ease-out infinite; animation-delay: var(--phase, 0ms); }
.activity { display: inline-flex; align-items: center; gap: 3px; height: 20px; flex: none; color: var(--tone); }
.activity i { display: block; width: 3px; height: 100%; border-radius: 3px; background: currentColor; opacity: .35; transform: scaleY(.22); transform-origin: center; }
.activity.ok i { opacity: .55; transform: scaleY(.22); }
.activity.warn i { transform: scaleY(.4); opacity: .5; }
.activity.error i { transform: scaleY(.16); opacity: .6; }
.activity.work i { opacity: .9; animation: wave 1.6s ease-in-out infinite; animation-delay: calc(var(--phase, 0ms) + var(--i, 0) * -180ms); }

/* Overview hero */
.hero { --tone: var(--ok); position: relative; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 20px; padding: 26px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: radial-gradient(90% 120% at 0% 0%, color-mix(in srgb, var(--tone) 10%, transparent), transparent 60%), linear-gradient(180deg, var(--hero-top), var(--surface-1)); }
.hero.warn { --tone: var(--warn); }
.hero.error { --tone: var(--error); }
.hero::after { content: ""; position: absolute; inset: 0 0 auto; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--tone) 40%, transparent), transparent); }
.hero-status { display: flex; flex-direction: column; min-width: 0; }
.hero-headline { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.hero-headline h2 { font-size: 30px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; }
.beacon { position: relative; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 18px color-mix(in srgb, var(--tone) 60%, transparent); }
.beacon::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 1.5px solid var(--tone); opacity: 0; animation: halo 2.8s ease-out infinite; animation-delay: var(--phase, 0ms); }
.hero-text { margin-top: 8px; color: var(--text-2); font-size: 14px; }
.hero-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; padding-top: 24px; }
.hero-fact { min-width: 0; padding: 2px 16px; border-left: 1px solid var(--line-strong); }
.hero-fact:first-child { padding-left: 0; border-left: 0; }
.hero-fact dt { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hero-fact dd { margin: 6px 0 2px; font-size: 16px; font-weight: 620; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-fact small { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fact-live { display: inline-flex; align-items: center; gap: 8px; }
.live-card { --tone: var(--ok); display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 18px; border-radius: var(--r-lg);
  border: 1px solid color-mix(in srgb, var(--tone) 18%, var(--line)); background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 20px 40px -30px var(--shadow-strong); transition: border-color .3s; }
.live-card.work { box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 0 0 1px color-mix(in srgb, var(--work) 10%, transparent), 0 20px 50px -24px color-mix(in srgb, var(--work) 35%, transparent); }
.live-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.live-label { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.live-body { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.live-copy { min-width: 0; }
.live-name { display: block; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.live-line { margin: 3px 0 2px; font-size: 16px; font-weight: 620; letter-spacing: -.01em; }
.live-body .timer { font-size: 22px; font-weight: 500; color: var(--text); letter-spacing: -.02em; }
.live-card .activity { width: 100%; height: 28px; gap: 0; justify-content: space-between; margin-top: auto; }
.live-card .activity i { width: 3px; }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metrics.large { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-1); }
.metric-head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.metric-head .icon { width: 15px; height: 15px; }
.metric-value { margin-top: 10px; font-size: 24px; font-weight: 620; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.metric-sub { margin-top: 3px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric .spark, .metric .meter, .metric .spark-empty { margin-top: auto; padding-top: 0; }
.metric > :nth-child(4) { margin-top: 12px; }
.metrics.large .metric { padding: 18px 18px 14px; }
.metrics.large .metric-value { font-size: 28px; }
.spark { display: block; width: 100%; height: 34px; overflow: visible; }
.metrics.large .spark { height: 64px; }
.spark-line { fill: none; stroke: var(--tone); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-line.secondary { stroke-dasharray: 3 3; opacity: .8; }
.stop-accent { stop-color: var(--accent); }
.stop-blue { stop-color: var(--blue); }
.stop-violet { stop-color: var(--violet); }
.stop-mint { stop-color: var(--mint); }
.spark-empty { display: flex; align-items: flex-end; height: 34px; font-size: 11.5px; color: var(--faint); border-bottom: 1px dashed var(--line-strong); padding-bottom: 6px; }
.meter { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter span { position: absolute; inset: 0 auto 0 0; width: var(--value); border-radius: inherit; background: var(--tone); transition: width .6s var(--ease); }
.metric .meter { margin-bottom: 14px; }
.metrics.large .metric .meter { margin-bottom: 29px; }

/* Agent switch and composer */
.switch-block { display: flex; flex-direction: column; gap: 8px; }
.switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.switch-option { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 52px; padding: 9px 12px; border-radius: 10px; text-align: left;
  border: 1px solid transparent; background: transparent; transition: background .18s, border-color .18s, transform .1s, opacity .18s; }
.switch-option:hover:enabled { background: var(--surface-2); border-color: var(--line-strong); }
.switch-option:active:enabled { transform: scale(.98); }
.switch-option:disabled { opacity: .5; }
.switch-option.selected { opacity: 1; background: linear-gradient(180deg, var(--surface-3), var(--surface-2)); border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 6px 16px -10px var(--shadow-strong); }
.switch-option.pending { opacity: 1; border-color: color-mix(in srgb, var(--work) 50%, transparent); animation: pending 1.4s ease-in-out infinite; }
.switch-copy { display: flex; flex-direction: column; min-width: 0; }
.switch-copy strong { font-size: 13.5px; font-weight: 620; }
.switch-copy small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-option.selected small { color: var(--accent-text); }
.switch-check { margin-left: auto; width: 15px; height: 15px; color: var(--muted); }
.switch-option.selected .switch-check { color: var(--accent); stroke-width: 2.2; }
.switch-note { font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.switch-note.warn { color: var(--warn); }
.task-form { display: flex; flex-direction: column; gap: 8px; }
.composer-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.task-form textarea { width: 100%; min-height: 92px; padding: 12px 14px; resize: vertical; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--bg); line-height: 1.55; transition: border-color .15s, box-shadow .15s; }
.task-form textarea::placeholder { color: var(--faint); }
.task-form textarea:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.composer-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.composer-agent { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12.5px; font-weight: 600; }
.composer-agent .mark { width: 24px; height: 24px; border-radius: 50%; font-size: 11px; }
.composer-hint { flex: 1; min-width: 160px; color: var(--muted); }
.composer-hint.warn { color: var(--warn); }
.task-form .button.primary { margin-left: auto; }

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 16px; }
.project-card { position: relative; display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-1); }
.project-card.featured { padding: 24px; background: radial-gradient(70% 90% at 100% 0%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%), var(--surface-1); }
.project-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.project-head > .chips { margin-left: auto; }
.project-title { flex: 1 1 160px; min-width: 0; }
.project-title h3 { font-size: 16px; }
.project-card.featured .project-title h3 { font-size: 20px; letter-spacing: -.02em; }
.path { margin-top: 3px; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-glyph { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; color: var(--tone); background: color-mix(in srgb, var(--tone) 11%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 18%, transparent); }
.project-card.featured .project-glyph { width: 44px; height: 44px; border-radius: 13px; }
.facts-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 14px 0; border-block: 1px solid var(--line); }
.facts-grid .kv { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 6px; min-height: 0; padding: 2px 16px; border: 0; border-left: 1px solid var(--line); }
.facts-grid .kv:first-child { padding-left: 0; border-left: 0; }
.facts-grid dd { text-align: left; font-size: 14px; font-weight: 550; max-width: 100%; }
.facts-grid .id-cell { justify-content: flex-start; }
.inline-agent { display: inline-flex; align-items: center; gap: 8px; }
.card-section { display: flex; flex-direction: column; gap: 12px; }
.card-section + .card-section { padding-top: 16px; border-top: 1px solid var(--line); }
.card-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.project-card.protected { --tone: var(--protect); border-color: color-mix(in srgb, var(--protect) 28%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--protect) 8%, var(--surface-1)), var(--surface-1) 55%); }
.project-card.protected::before { content: ""; position: absolute; inset: 0 20px auto; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--protect) 60%, transparent), transparent); }
.protect-banner { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--protect) 85%, var(--mix)); }
.protect-banner .icon { width: 15px; height: 15px; }
.project-card.protected .card-foot { color: color-mix(in srgb, var(--protect) 35%, var(--muted)); border-color: color-mix(in srgb, var(--protect) 14%, transparent); }

/* IDs */
.id-cell { display: flex; align-items: flex-start; justify-content: flex-end; gap: 4px; min-width: 0; }
.id-details { min-width: 0; }
.id-details summary { display: inline-flex; align-items: center; min-height: 30px; cursor: pointer; list-style: none; font-size: 12.5px; color: var(--text-2);
  text-decoration: underline dotted color-mix(in srgb, var(--muted) 60%, transparent); text-underline-offset: 3px; }
.id-details summary::-webkit-details-marker { display: none; }
.id-details summary:hover { color: var(--text); }
.id-full { display: block; margin-top: 4px; padding: 7px 9px; border-radius: var(--r-xs); background: var(--bg); border: 1px solid var(--line); font-size: 11.5px; color: var(--text-2); word-break: break-all; text-align: left; }

/* Agents */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.agent-card { --tone: var(--ok); position: relative; display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-1); overflow: hidden; transition: border-color .3s; }
.agent-card.work { border-color: color-mix(in srgb, var(--work) 30%, transparent); }
.agent-card.work::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, transparent, var(--work), transparent); background-size: 200% 100%; animation: sweep 2.4s linear infinite; }
.agent-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.agent-title { flex: 1 1 110px; min-width: 0; }
.agent-title h3 { font-size: 17px; }
.agent-live { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.agent-live .timer { margin-left: auto; font-size: 13px; color: var(--text); }
.agent-live .activity { height: 18px; }

/* Accounts */
.account-groups { display: flex; flex-direction: column; gap: 20px; }
.account-group { display: flex; flex-direction: column; gap: 8px; }
.group-title { font-size: 11px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.account-list { display: flex; flex-direction: column; gap: 8px; }
.account-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); transition: border-color .15s, background .15s; }
.account-row:hover { border-color: var(--line-strong); }
.account-row.dirty { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 4%, var(--surface-2)); }
.account-main { min-width: 0; }
.account-name-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.account-name { width: 100%; field-sizing: content; max-width: 100%; min-width: 0; min-height: 34px; padding: 3px 8px; margin-left: -8px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  font-size: 15px; font-weight: 620; letter-spacing: -.01em; text-overflow: ellipsis; transition: border-color .15s, background .15s; }
.account-name:hover { border-color: var(--line-strong); }
.account-name:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.account-edit { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; color: var(--faint); cursor: text; }
.account-edit .icon { width: 14px; height: 14px; }
.account-row:hover .account-edit { color: var(--muted); }
.account-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 1px; font-size: 12px; color: var(--muted); }
.account-meta code { font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--bg); color: var(--text-2); }
.account-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.account-side small { font-size: 11.5px; }
.account-row:not(.dirty) button[type="submit"] { display: none; }

/* Sessions */
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.session-card { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.session-head { display: flex; align-items: center; gap: 12px; }
.session-title { flex: 1; min-width: 0; }
.session-id { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); }
.session-id .label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.session-id .id-cell { justify-content: space-between; }
.session-id .id-details summary { font-size: 14px; color: var(--text); }

/* Activity */
.job-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.job-stat { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12.5px; color: var(--muted); }
.job-stat strong { color: var(--text); font-variant-numeric: tabular-nums; }
.job-list { display: flex; flex-direction: column; container-type: inline-size; }
.job-row { position: relative; display: grid; grid-template-columns: 74px minmax(110px, .9fr) minmax(0, 1.2fr) 82px auto 84px; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; text-align: left; font-size: 13px; transition: background .15s; }
.job-row:last-child { border-bottom: 0; }
.job-row:hover { background: var(--surface-2); border-radius: 10px; }
.job-row:active { background: var(--surface-3); }
.job-row.work::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--work); }
.job-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-agent { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.job-agent strong { font-weight: 600; }
.job-project { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.job-source { font-size: 12px; color: var(--muted); }
.job-duration { justify-self: end; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-duration .timer { color: var(--work); font-size: 12.5px; }

/* Rows adapt to the panel width, so the narrow overview column and phones share one compact layout. */
@container (max-width: 640px) {
  .job-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "agent agent status" "time project duration"; gap: 4px 10px; padding: 12px 6px; }
  .job-time { grid-area: time; }
  .job-agent { grid-area: agent; }
  .job-project { grid-area: project; font-size: 12.5px; color: var(--muted); }
  .job-source { display: none; }
  .job-row > .chip { grid-area: status; justify-self: end; }
  .job-duration { grid-area: duration; }
}

/* Safety */
.safety-banner { --tone: var(--ok); display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: var(--r-xl);
  border: 1px solid color-mix(in srgb, var(--tone) 24%, transparent); background: radial-gradient(80% 140% at 0% 50%, color-mix(in srgb, var(--tone) 10%, transparent), transparent 70%), var(--surface-1); }
.safety-banner.warn { --tone: var(--warn); }
.safety-banner h2 { font-size: 18px; }
.safety-banner p { margin-top: 4px; font-size: 13px; }
.safety-emblem { display: inline-grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px; color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 25%, transparent); }
.safety-emblem .icon { width: 24px; height: 24px; }
.safety-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.safety-tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-1); }
.safety-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.safety-tile strong { font-size: 14px; font-weight: 620; }
.security-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.6; }
.security-copy .button { margin-top: 4px; }

/* Skeleton */
.skel { border-radius: var(--r-lg); border: 1px solid var(--line); background: linear-gradient(100deg, var(--surface-1) 30%, var(--surface-2) 50%, var(--surface-1) 70%); background-size: 300% 100%; animation: shimmer 1.6s ease-in-out infinite; }
.skel-hero { height: 220px; border-radius: var(--r-xl); }
.skel-tile { height: 112px; }
.skel-panel { height: 280px; }

/* Dialog */
dialog { width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); padding: 22px; border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  background: var(--surface-1); color: var(--text); box-shadow: 0 40px 100px -30px var(--shadow-strong); }
dialog[open] { animation: pop .22s var(--ease); }
dialog::backdrop { background: rgba(4, 5, 7, .66); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-heading h2 { font-size: 17px; }
.dialog-status { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); }
#job-content .kv dd { font-size: 12.5px; }

/* Desktop: sidebar */
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr);
    background: linear-gradient(90deg, var(--bg-raised) calc(var(--sidebar) - 1px), var(--line) calc(var(--sidebar) - 1px), var(--line) var(--sidebar), transparent var(--sidebar)); }
  .sidebar { position: sticky; top: 0; height: 100vh; padding: 18px 14px; border-right: 1px solid var(--line); }
  .project-head > .chips { margin-top: 4px; }
  .nav { flex: 1; flex-direction: column; gap: 2px; margin-top: 26px; }
  .nav-caption { padding: 0 10px 8px; }
  .nav-caption-system { order: 8; margin-top: auto; padding-top: 16px; }
  .nav a { gap: 11px; min-height: 38px; padding: 0 10px; border-radius: 9px; font-size: 13.5px; font-weight: 520; }
  .nav a .icon { width: 17px; height: 17px; }
  .nav a:hover { background: var(--surface-2); }
  .nav a[aria-current="page"] { background: var(--surface-3); box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset; }
  .nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
  .nav a[aria-current="page"] .icon { color: var(--accent); }
  .nav-more, .sheet-caption { display: none !important; }
  .nav-sheet { display: contents; }
  .nav [data-view="overview"] { order: 1; }
  .nav [data-view="projects"] { order: 2; }
  .nav [data-view="agents"] { order: 3; }
  .nav [data-view="accounts"] { order: 4; }
  .nav [data-view="sessions"] { order: 5; }
  .nav [data-view="jobs"] { order: 6; }
  .nav [data-view="server"] { order: 7; }
  .nav [data-view="security"] { order: 9; }
  .sidebar-foot { margin-top: 12px; padding: 12px 8px 2px; border-top: 1px solid var(--line); }
  .sheet-backdrop { display: none !important; }
}
@media (min-width: 1024px) and (max-width: 1360px) {
  main { padding: 24px 24px 36px; }
  .hero { grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr); }
  .hero-headline h2 { font-size: 26px; }
  .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; }
  .hero-fact:nth-child(3) { padding-left: 0; border-left: 0; }
}
@media (max-width: 1180px) {
  .grid-2, .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); }
  .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; }
  .facts-grid .kv:nth-child(3) { padding-left: 0; border-left: 0; }
  .safety-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet and phone: top bar + bottom navigation */
@media (max-width: 1023.98px) {
  .sidebar { inset: auto 0 0 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-strong);
    background: color-mix(in srgb, var(--bg-raised) 92%, transparent); backdrop-filter: blur(16px) saturate(140%); }
  .brand, .sidebar-foot, .nav-caption { display: none; }
  .nav { justify-content: space-around; gap: 2px; }
  .nav-main, .nav-more { flex: 1; flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; min-width: 0; padding: 4px 2px; border-radius: 12px; font-size: 10.5px; font-weight: 600; }
  .nav-main .icon, .nav-more .icon { width: 21px; height: 21px; }
  .nav-main span, .nav-more span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-main[aria-current="page"], .nav-more.active { color: var(--accent); }
  .nav-main[aria-current="page"]::before, .nav-more.active::before { content: ""; position: absolute; top: -7px; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--accent); }
  .nav-main:active, .nav-more:active { background: var(--surface-2); }
  .nav-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; padding: 0 5px; font-size: 9.5px; line-height: 15px; background: var(--surface-4); }
  .nav-live { position: absolute; top: 6px; left: calc(50% + 9px); }
  .nav-sheet { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom)); z-index: 31; display: none; flex-direction: column; gap: 2px;
    padding: 10px; border-radius: var(--r-xl); border: 1px solid var(--line-strong); background: var(--surface-1); box-shadow: 0 -20px 60px -20px var(--shadow-strong); }
  .nav.sheet-open .nav-sheet { display: flex; animation: sheet .22s var(--ease); }
  .sheet-caption, .nav-sheet .nav-caption-system { display: block; padding: 8px 10px 6px; }
  .nav-extra { gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 12px; font-size: 14.5px; font-weight: 550; color: var(--text-2); }
  .nav-extra:active, .nav-extra:hover { background: var(--surface-2); }
  .nav-extra[aria-current="page"] { background: var(--surface-3); color: var(--text); }
  .nav-extra[aria-current="page"] .icon { color: var(--accent); }
  .topbar { height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top); }
  .mobile-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
  .mobile-brand::after { content: "Richi"; font-size: 15px; letter-spacing: -.01em; }
  .breadcrumb { display: none; }
  .button-label { display: none; }
  .topbar-actions .icon-button { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 10px; }
  .topbar-actions .icon-button .icon { width: 18px; height: 18px; }
  main { padding: 20px 16px calc(var(--nav-height) + 36px + env(safe-area-inset-bottom)); }
  .page-heading { margin-bottom: 16px; }
  h1 { font-size: 24px; }
  .page-footer { flex-direction: column; gap: 4px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .metrics.large { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; padding-top: 20px; }
  .hero-fact:nth-child(3) { padding-left: 0; border-left: 0; }
  dialog { width: 100%; max-width: none; max-height: 86vh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  dialog[open] { animation: sheet .26s var(--ease); }
}
@media (max-width: 640px) {
  .hero-headline { gap: 12px; margin-top: 12px; }
  .hero-headline h2 { font-size: 22px; }
  .hero-text { font-size: 13.5px; }
  .hero-fact dd { font-size: 15px; }
  .live-line { font-size: 15px; }
  .panel { padding: 16px; border-radius: 14px; }
  .project-card, .agent-card, .project-card.featured { padding: 16px; }
  .project-card.featured .project-title h3 { font-size: 18px; }
  .facts-grid { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 4px 0; }
  .facts-grid .kv { flex-direction: row; align-items: center; justify-content: space-between; padding: 9px 0; border-left: 0; border-bottom: 1px solid var(--line); }
  .facts-grid .kv:last-child { border-bottom: 0; }
  .facts-grid dd { text-align: right; font-size: 13px; }
  .facts-grid .id-cell { justify-content: flex-end; }
  .switch { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .switch-option { flex-direction: column; align-items: flex-start; gap: 8px; min-height: 84px; padding: 10px; }
  .switch-check { position: absolute; top: 10px; right: 10px; }
  .composer-hint { order: 3; flex-basis: 100%; }
  .page-heading > .chip { display: none; }
  .safety-grid { grid-template-columns: minmax(0, 1fr); }
  .project-head > .chips { order: 3; flex-basis: 100%; margin-left: 0; }
  .task-form .button.primary { min-height: 40px; }
  .account-row { grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; }
  .account-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; }
  .account-row button[type="submit"] { grid-column: 1 / -1; }
  .safety-banner { align-items: flex-start; padding: 16px; }
  .live-body { grid-template-columns: auto minmax(0, 1fr); }
  .live-body .timer { grid-column: 1 / -1; font-size: 20px; }
  .command-strip code { display: none; }
}
@media (max-width: 380px) {
  .nav-main, .nav-more { padding: 4px 0; font-size: 10px; letter-spacing: -.01em; }
}
@media (max-width: 420px) {
  #connection-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .connection { width: 28px; padding: 0; justify-content: center; }
  .metric { padding: 12px 14px 10px; }
  .metric-value { font-size: 21px; }
  .metrics.large .metric-value { font-size: 23px; }
  .switch-copy small { white-space: normal; }
}
@media (max-width: 1023.98px) {
  .button { min-height: 40px; }
  .icon-button { width: 36px; height: 36px; }
  .id-details summary { min-height: 36px; }
  .list-row { min-height: 56px; }
}
@media (pointer: coarse) {
  .button { min-height: 44px; }
  .button.compact { min-height: 36px; }
  .icon-button { width: 36px; height: 36px; }
  .id-details summary { min-height: 36px; }
}

/* Motion: short, calm, and entirely optional. */
.view.entering { animation: rise .32s var(--ease) both; animation-delay: var(--enter-delay, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes sheet { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes wave { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
@keyframes halo { 0% { opacity: .55; transform: scale(.94); } 70%, 100% { opacity: 0; transform: scale(1.22); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent); } 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--tone) 6%, transparent); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes sweep { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes pending { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--work) 0%, transparent); } 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--work) 14%, transparent); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .activity.work i { transform: scaleY(var(--rest, .6)); }
  .mark.live::after { opacity: .5; transform: none; }
}

/* ---- Stage 10A: theme toggle, flow map, agent glyphs, typing ---- */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
}
.panel-head.compact { margin-bottom: 8px; }
.safety-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.safety-strip .chip { min-height: 28px; padding: 3px 11px; }
a.safety-strip { border-radius: 12px; }

/* Flow map: sources -> Core -> agents -> projects, drawn as one SVG. */
.flow { position: relative; padding: 18px 20px 14px; overflow: hidden; }
.flow svg { display: block; width: 100%; height: auto; overflow: visible; }
.flow-link { fill: none; stroke: var(--flow-line); stroke-width: 1.5; }
.flow-link.blocked { stroke-dasharray: 3 5; }
.flow-link.ready { stroke: color-mix(in srgb, var(--ok) 32%, var(--flow-line)); }
.flow-pulse { fill: none; stroke: var(--tone); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 10 190; opacity: 0;
  animation: flow-dash 2.4s linear infinite; animation-delay: var(--phase, 0ms); }
.flow-pulse.on { opacity: .9; }
.flow-pulse.idle-on { opacity: .35; animation-duration: 4.8s; }
.flow-dot { fill: var(--tone); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--tone) 70%, transparent)); offset-rotate: 0deg;
  animation: flow-move 2.4s cubic-bezier(.45, .05, .55, .95) infinite; animation-delay: var(--phase, 0ms); }
.flow-node rect { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; transition: fill .3s, stroke .3s; }
.flow-node.core rect { fill: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); stroke: color-mix(in srgb, var(--accent) 45%, transparent); }
.flow-node.work rect { stroke: var(--work); fill: color-mix(in srgb, var(--work) 10%, var(--surface-2)); }
.flow-node.ok rect { stroke: color-mix(in srgb, var(--ok) 40%, transparent); }
.flow-node.warn rect { stroke-dasharray: 4 3; stroke: color-mix(in srgb, var(--warn) 55%, transparent); }
.flow-node.protect rect { stroke: color-mix(in srgb, var(--protect) 45%, transparent); fill: color-mix(in srgb, var(--protect) 7%, var(--surface-2)); }
.flow-node text { fill: var(--text); font-family: var(--font); font-size: 13px; font-weight: 620; dominant-baseline: middle; }
.flow-node text.sub { fill: var(--muted); font-size: 10.5px; font-weight: 550; }
.flow-node .node-dot { fill: var(--tone); }
.flow-node.work .node-ring { fill: none; stroke: var(--work); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: ring 2s ease-out infinite; }
@keyframes flow-dash { from { stroke-dashoffset: 200; } to { stroke-dashoffset: 0; } }
@keyframes flow-move { from { offset-distance: 0%; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } to { offset-distance: 100%; opacity: 0; } }
@keyframes ring { from { opacity: .7; transform: scale(.6); } to { opacity: 0; transform: scale(1.8); } }

/* Agent glyphs: Claude thinks (brain), Codex types (keyboard), Grok sparks. */
.glyph { position: relative; display: inline-grid; place-items: center; flex: none; width: 64px; height: 64px; border-radius: 18px; color: var(--glyph);
  --glyph: var(--idle); background: color-mix(in srgb, var(--glyph) 12%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--glyph) 28%, transparent); }
.glyph.codex { --glyph: #8fa6ff; }
.glyph.claude { --glyph: #e58b65; }
.glyph.grok { --glyph: #a3aab6; }
:root[data-theme="light"] .glyph.codex { --glyph: #4d67d8; }
:root[data-theme="light"] .glyph.claude { --glyph: #c4643c; }
:root[data-theme="light"] .glyph.grok { --glyph: #5d6573; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .glyph.codex { --glyph: #4d67d8; }
  :root:not([data-theme="dark"]) .glyph.claude { --glyph: #c4643c; }
  :root:not([data-theme="dark"]) .glyph.grok { --glyph: #5d6573; }
}
.glyph svg { width: 42px; height: 42px; overflow: visible; }
.glyph.small { width: 40px; height: 40px; border-radius: 12px; }
.glyph.small svg { width: 26px; height: 26px; }
.glyph .g-stroke { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.glyph .g-key { fill: currentColor; opacity: .22; }
.glyph .g-node { fill: currentColor; opacity: .35; }
.glyph .g-spark { fill: currentColor; opacity: .5; transform-box: fill-box; transform-origin: center; }
.glyph.live { box-shadow: 0 0 0 1px color-mix(in srgb, var(--glyph) 30%, transparent), 0 10px 30px -12px color-mix(in srgb, var(--glyph) 70%, transparent); }
.glyph.live::after { content: ""; position: absolute; inset: -5px; border-radius: 22px; border: 1.5px solid var(--glyph); opacity: 0; animation: halo 2.4s ease-out infinite; animation-delay: var(--phase, 0ms); }
.glyph.small.live::after { border-radius: 15px; inset: -4px; }
.glyph.live .g-key { animation: key 1.2s steps(1) infinite; animation-delay: calc(var(--phase, 0ms) + var(--d, 0) * 1ms); }
.glyph.live .g-node { animation: synapse 1.8s ease-in-out infinite; animation-delay: calc(var(--phase, 0ms) + var(--d, 0) * 1ms); }
.glyph.live .g-spark { animation: spark 1.6s ease-in-out infinite; animation-delay: calc(var(--phase, 0ms) + var(--d, 0) * 1ms); }
.glyph.live .g-path { stroke-dasharray: 4 6; animation: think 1.6s linear infinite; }
@keyframes key { 0% { opacity: .95; } 18%, 100% { opacity: .22; } }
@keyframes synapse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes spark { 0%, 100% { opacity: .3; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes think { to { stroke-dashoffset: -20; } }

/* Typewriter: our own fixed status text, revealed by width in ch steps. */
.typing { display: inline-flex; align-items: center; min-width: 0; max-width: 100%; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.typing .typed { display: inline-block; overflow: hidden; white-space: nowrap; width: calc(var(--n) * 1ch); max-width: 100%; }
.typing.live .typed { animation: type calc(var(--n) * 90ms + 1600ms) steps(var(--n)) infinite; animation-delay: var(--phase, 0ms); }
.typing .caret { width: 2px; height: 1.1em; margin-left: 2px; background: var(--tone, var(--work)); }
.typing.live .caret { animation: blink .9s steps(1) infinite; }
.typing:not(.live) .caret { display: none; }
@keyframes type { 0% { width: 0; } 70%, 100% { width: calc(var(--n) * 1ch); } }

/* Live AI card, minimal version */
.live-body.glyph-body { grid-template-columns: auto minmax(0, 1fr) auto; }
.live-card .typing { margin-top: 4px; }
.agent-live .typing { flex: 1; }
.agent-head .glyph { margin: -2px 0; }

/* Other projects as compact rows */
.project-list { display: flex; flex-direction: column; gap: 2px; }
.project-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.project-row:last-child { border-bottom: 0; }
.project-row .row-main small { color: var(--muted); }

/* Desktop hover lift */
@media (hover: hover) {
  .metric, .agent-card, .session-card, .project-card, .safety-tile { transition: transform .2s var(--ease), border-color .2s, box-shadow .2s; }
  .metric:hover, .agent-card:hover, .session-card:hover, .safety-tile:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 12px 30px -20px var(--shadow-strong); }
}
@media (max-width: 640px) {
  .glyph { width: 52px; height: 52px; border-radius: 15px; }
  .glyph svg { width: 34px; height: 34px; }
  .flow { padding: 14px 10px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .flow-dot { display: none; }
  .flow-pulse.on { opacity: .9; stroke-dasharray: none; }
  .typing.live .typed { width: calc(var(--n) * 1ch); }
}

.hero-facts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hero-facts.three .hero-fact:nth-child(3) { padding-left: 16px; border-left: 1px solid var(--line-strong); }
.facts-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.facts-grid.three .kv:nth-child(3) { padding-left: 16px; border-left: 1px solid var(--line); }
.projects-split { align-items: stretch; }
.agent-idle { display: inline-flex; align-items: center; gap: 12px; }
.page-heading { margin-bottom: 18px; }
.hero { min-height: 0; }
.hero-headline { margin-top: 2px; }
.hero-facts { padding-top: 22px; }
@media (max-width: 1360px) and (min-width: 1024px) {
  .hero-facts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1023.98px) {
  .hero-facts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
}
@media (max-width: 640px) {
  .facts-grid.three { grid-template-columns: minmax(0, 1fr); }
  .facts-grid.three .kv:nth-child(3) { padding-left: 0; border-left: 0; }
  .hero-facts.three .hero-fact { padding: 2px 10px; }
  .hero-facts.three .hero-fact:first-child { padding-left: 0; }
  .hero-fact dd { font-size: 14px; }
}

.hero-status { justify-content: center; }
.hero-facts { margin-top: 0; }
.flow svg.narrow .flow-node text { font-size: 12px; }
.flow svg.narrow .flow-node text.sub { font-size: 9.5px; }
