/* JAMMA OS deck styles.
   The :root block below is copied VERBATIM from design/tokens.css.
   design/tokens.css stays the single source of truth; if a value changes there,
   re-copy this block. Every value in this stylesheet comes from these variables
   or the 4px spacing scale. No em-dashes, no off-scale numbers, no second accent. */

/* ===== tokens (verbatim from design/tokens.css :root) ===== */
:root {
  /* neutral ramp (page -> text) */
  --bg-0: #07090F;        /* page base, near-black blue-charcoal */
  --bg-1: #0B0E16;        /* deck background */
  --bg-2: #10141F;        /* panel */
  --bg-3: #161B29;        /* raised panel / hover */
  --line-0: #1B2130;      /* hairline border */
  --line-1: #262E42;      /* strong border / focus ring base */
  --ink-3: #4A5468;       /* disabled / faint */
  --ink-2: #77829B;       /* secondary text */
  --ink-1: #C7CEDD;       /* primary text */
  --ink-0: #EEF1F8;       /* headline / figures */

  /* the accent (one job: alive + primary action) */
  --green: #34D399;
  --green-dim: #1B6B4F;
  --green-glow: rgba(52, 211, 153, 0.16);

  /* semantic signals (functional only, never decoration) */
  --red: #F87171;
  --red-glow: rgba(248, 113, 113, 0.16);
  --amber: #FBBF24;
  --amber-glow: rgba(251, 191, 36, 0.14);
  --cyan: #67E8F9;        /* info ticks in the signal tape only */
  --violet: #A78BFA;      /* brain: project nodes */
  --blue: #60A5FA;        /* brain: reminder nodes (time-based) */
  --rose: #FB7185;        /* brain: contact nodes (people/leads) */
  --orange: #FB923C;      /* brain: question nodes (to research) */
  --slate: #94A3B8;       /* brain: note nodes (facts to remember) */

  /* type */
  --font-display: "Clash Display", "Space Grotesk", system-ui, sans-serif;
  --font-body: "General Sans", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  /* scale ~1.25: 12 / 14 / 16 / 20 / 25 / 31 / 39 / 49 */
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 20px;
  --fs-xl: 25px; --fs-2xl: 31px; --fs-3xl: 39px; --fs-hero: 49px;
  --lh-body: 1.5; --lh-display: 1.1;
  --track-display: -0.02em; --track-caps: 0.08em;

  /* spacing scale (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-6: 24px; --s-8: 32px; --s-12: 48px; --s-16: 64px;

  /* shape + elevation (borders over shadows; glows are semantic, not decor) */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --glow-live: 0 0 0 1px var(--green-dim), 0 0 12px var(--green-glow);
  --glow-alert: 0 0 0 1px rgba(248, 113, 113, 0.4), 0 0 12px var(--red-glow);

  /* motion (subtle, last; respect prefers-reduced-motion) */
  --t-fast: 120ms ease-out;
  --t-med: 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-slow: 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --pulse-period: 2.4s;
}

/* ===== fonts (self-hosted, no external requests, swap fallbacks from tokens) ===== */
@font-face { font-family: "Clash Display"; src: url("/fonts/ClashDisplay-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Clash Display"; src: url("/fonts/ClashDisplay-Semibold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "General Sans"; src: url("/fonts/GeneralSans-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "General Sans"; src: url("/fonts/GeneralSans-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "General Sans"; src: url("/fonts/GeneralSans-Semibold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

/* ===== reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--green-glow); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-1) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-1); border-radius: 999px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; }

/* ===== app shell (grid) ===== */
#app {
  display: grid;
  grid-template-columns: 56px 1fr 280px;
  grid-template-rows: 48px 1fr;
  grid-template-areas: "rail top top" "rail main tape";
  height: 100vh; height: 100dvh;
  background: var(--bg-1);
}
.rail { grid-area: rail; }
.topstrip { grid-area: top; }
.main { grid-area: main; overflow: auto; padding: var(--s-6); }
.tape { grid-area: tape; overflow: auto; }
.tabbar { display: none; }
.main-inner { max-width: 1160px; margin: 0 auto; }

/* ===== left rail ===== */
.rail {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-1);
  padding: var(--s-3) 0;
  background: var(--bg-0);
  border-right: 1px solid var(--line-0);
}
.rail-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  transition: color var(--t-fast), background var(--t-fast);
}
.rail-btn:hover { color: var(--ink-0); background: var(--bg-2); }
.rail-btn.active { color: var(--green); background: var(--bg-2); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
}
.rail-btn .tip {
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: var(--s-1) var(--s-2);
  background: var(--bg-3); color: var(--ink-0);
  border: 1px solid var(--line-1); border-radius: var(--r-sm);
  font-size: var(--fs-xs); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
  z-index: 40; box-shadow: var(--shadow-2);
}
.rail-btn:hover .tip, .rail-btn:focus-visible .tip { opacity: 1; }
.rail-div { width: 24px; height: 1px; background: var(--line-0); margin: var(--s-2) 0; }
.rail-spacer { flex: 1; }

/* ===== top strip ===== */
.topstrip {
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-4);
  background: var(--bg-0);
  border-bottom: 1px solid var(--line-0);
}
.brand { display: flex; align-items: center; gap: var(--s-2); }
.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green-glow);
  animation: breathe var(--pulse-period) ease-in-out infinite;
}
.brand-word {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--fs-sm); letter-spacing: var(--track-caps);
  text-transform: uppercase; color: var(--ink-0);
}
.nodes { display: flex; align-items: center; gap: var(--s-3); }
.node { display: flex; align-items: center; gap: var(--s-1); font-size: var(--fs-xs); color: var(--ink-2); }
.node-label { letter-spacing: 0.04em; }
.spacer { flex: 1; }
.netmonth { display: flex; align-items: baseline; gap: var(--s-1); font-size: var(--fs-md); font-weight: 500; }
.netmonth .nm-unit { font-size: var(--fs-xs); color: var(--ink-2); }
.conn {
  display: flex; align-items: center; gap: var(--s-1);
  padding: var(--s-1) var(--s-2); border-radius: 999px;
  font-size: var(--fs-xs); font-family: var(--font-mono); letter-spacing: 0.04em;
  border: 1px solid var(--line-1); color: var(--ink-2);
}
.conn--live { color: var(--green); border-color: var(--green-dim); }
.conn--poll { color: var(--amber); border-color: var(--amber); }
.conn--offline { color: var(--red); border-color: var(--red); }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 0; background: transparent;
  border-radius: var(--r-sm); color: var(--ink-2); transition: color var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { color: var(--ink-0); background: var(--bg-2); }
.tape-toggle { display: none; }

/* ===== right signal tape ===== */
.tape {
  display: flex; flex-direction: column;
  background: var(--bg-0);
  border-left: 1px solid var(--line-0);
}
.tape-head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line-0);
  color: var(--ink-2); font-size: var(--fs-xs);
  letter-spacing: var(--track-caps); text-transform: uppercase;
  position: sticky; top: 0; background: var(--bg-0); z-index: 2;
}
.tape-head .count { margin-left: auto; font-family: var(--font-mono); }
.tape-list { list-style: none; margin: 0; padding: var(--s-2); display: flex; flex-direction: column; }
.tape-line {
  display: grid; grid-template-columns: 52px 1fr; gap: var(--s-2);
  padding: var(--s-2); border-radius: var(--r-sm);
  font-size: var(--fs-xs); border-left: 2px solid var(--line-0);
}
.tape-line + .tape-line { margin-top: 2px; }
.tape-line .t-time { font-family: var(--font-mono); color: var(--ink-3); }
.tape-line .t-text { color: var(--ink-1); word-break: break-word; }
.tape-line.k-report, .tape-line.k-verified, .tape-line.k-money, .tape-line.k-step-done { border-left-color: var(--green-dim); }
.tape-line.k-report .t-text, .tape-line.k-verified .t-text, .tape-line.k-money .t-text { color: var(--ink-0); }
.tape-line.k-chat, .tape-line.k-dispatched, .tape-line.k-step-start { border-left-color: var(--cyan); }
.tape-line.k-blocked, .tape-line.k-failed { border-left-color: var(--red); }
.tape-line.k-blocked .t-text { color: var(--red); }
.tape-line.k-system { border-left-color: var(--line-1); }
.tape-line.flash { animation: flash var(--t-slow) ease-out; }

/* ===== generic building blocks ===== */
.view { display: flex; flex-direction: column; gap: var(--s-6); }
.view-head { display: flex; align-items: baseline; gap: var(--s-3); }
.view-title { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-xl); letter-spacing: var(--track-display); color: var(--ink-0); }
.view-sub { font-size: var(--fs-xs); color: var(--ink-2); }

.card {
  background: var(--bg-2); border: 1px solid var(--line-0);
  border-radius: var(--r-lg); padding: var(--s-4);
}
.card--raised { background: var(--bg-3); }
.card-head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); }
.card-title { font-size: var(--fs-xs); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--ink-2); }
.card-age { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-3); font-family: var(--font-mono); }
.card.flare { animation: flare var(--t-slow) ease-out; border-color: rgba(248,113,113,0.4); }
.card.broken { border-color: var(--red); box-shadow: var(--glow-alert); }
.card.dim { opacity: 0.62; }

.fig { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-0); }
.fig.tick { animation: tick var(--t-med) ease-out; }
.t-green { color: var(--green); }
.t-red { color: var(--red); }
.t-amber { color: var(--amber); }
.t-cyan { color: var(--cyan); }
.t-ink0 { color: var(--ink-0); }
.t-ink2 { color: var(--ink-2); }
.t-ink3 { color: var(--ink-3); }

/* dots */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); }
.dot--green { background: var(--green); }
.dot--red { background: var(--red); }
.dot--amber { background: var(--amber); }
.dot--dim { background: var(--ink-3); }
.dot--pulse { animation: pulse var(--pulse-period) ease-in-out infinite; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2); border-radius: 999px;
  font-size: var(--fs-xs); font-family: var(--font-mono); letter-spacing: 0.03em;
  border: 1px solid var(--line-1); color: var(--ink-2); background: var(--bg-1);
  white-space: nowrap;
}
.chip--green { color: var(--green); border-color: var(--green-dim); }
.chip--amber { color: var(--amber); border-color: rgba(251,191,36,0.4); }
.chip--red { color: var(--red); border-color: rgba(248,113,113,0.4); }
.chip--cyan { color: var(--cyan); border-color: rgba(103,232,249,0.35); }
.chip--violet { color: var(--violet); border-color: rgba(167,139,250,0.4); }
.chip--blue { color: var(--blue); border-color: rgba(96,165,250,0.4); }
.chip--rose { color: var(--rose); border-color: rgba(251,113,133,0.4); }
.chip--orange { color: var(--orange); border-color: rgba(251,146,60,0.4); }
.chip--slate { color: var(--slate); border-color: rgba(148,163,184,0.4); }
.chip--dim { color: var(--ink-3); }
.t-violet { color: var(--violet); }
.t-blue { color: var(--blue); }
.t-rose { color: var(--rose); }
.t-orange { color: var(--orange); }
.t-slate { color: var(--slate); }

/* ===== mission: node row ===== */
.node-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.node-card { display: flex; flex-direction: column; gap: var(--s-3); }
.node-card .nc-head { display: flex; align-items: center; gap: var(--s-2); }
.node-card .nc-name { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-lg); color: var(--ink-0); letter-spacing: var(--track-display); }
.node-card .nc-state { margin-left: auto; font-size: var(--fs-xs); font-family: var(--font-mono); }
.node-card.live { box-shadow: var(--glow-live); }
.node-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.node-stat { display: flex; flex-direction: column; gap: 2px; }
.node-stat .ns-val { font-family: var(--font-mono); font-size: var(--fs-md); color: var(--ink-0); }
.node-stat .ns-label { font-size: var(--fs-xs); color: var(--ink-3); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-4); align-items: start; }
.grid-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }

/* goals */
.status-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-3); }
.goal-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-top: 1px solid var(--line-0); }
.goal-row:first-of-type { border-top: 0; }
.goal-row .g-outcome { flex: 1; font-size: var(--fs-sm); color: var(--ink-1); }
.goal-row.done .g-outcome { color: var(--ink-3); }
.goal-row .g-id { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); }

/* dispatch quad */
.quad { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
.quad-cell { display: flex; flex-direction: column; gap: 2px; padding: var(--s-2); background: var(--bg-1); border-radius: var(--r-sm); }
.quad-cell .q-val { font-family: var(--font-mono); font-size: var(--fs-lg); color: var(--ink-0); }
.quad-cell .q-label { font-size: var(--fs-xs); color: var(--ink-3); }

/* farm */
.acct-row { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) 0; border-top: 1px solid var(--line-0); font-size: var(--fs-sm); min-width: 0; }
.acct-row:first-of-type { border-top: 0; }
.acct-row .a-handle { font-family: var(--font-mono); color: var(--ink-1); min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-row .a-lane { color: var(--ink-3); font-size: var(--fs-xs); margin-left: auto; flex: none; }
.lane-rollups { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.kv { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-1) 0; font-size: var(--fs-sm); }
.kv .k { color: var(--ink-2); }
.kv .v { font-family: var(--font-mono); color: var(--ink-0); }

/* ===== money ===== */
.hero { display: flex; flex-direction: column; gap: var(--s-2); }
.hero-row { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.hero-fig { font-family: var(--font-mono); font-size: var(--fs-hero); font-weight: 500; line-height: var(--lh-display); letter-spacing: var(--track-display); }
.hero-unit { font-size: var(--fs-lg); color: var(--ink-2); }
.spark { margin-top: var(--s-2); }
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s-4); }
.stat { display: flex; flex-direction: column; gap: var(--s-1); }
.stat .s-val { font-family: var(--font-mono); font-size: var(--fs-xl); color: var(--ink-0); }
.stat .s-label { font-size: var(--fs-xs); color: var(--ink-3); }
.rail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-4); }
.rail-card { display: flex; flex-direction: column; gap: var(--s-2); min-height: 108px; }
.rail-card .rc-head { display: flex; align-items: center; gap: var(--s-2); }
.rail-card .rc-name { font-size: var(--fs-sm); color: var(--ink-1); font-weight: 500; }
.rail-card .rc-fig { font-family: var(--font-mono); font-size: var(--fs-lg); color: var(--ink-0); }
.rail-card .rc-foot { margin-top: auto; display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--ink-3); }
.rail-card .rc-note { font-size: var(--fs-xs); color: var(--ink-2); }
.rail-card .rc-err { font-size: var(--fs-xs); color: var(--red); }
.meter { height: 6px; border-radius: 999px; background: var(--bg-1); overflow: hidden; border: 1px solid var(--line-0); }
.meter > span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.meter.over > span { background: var(--amber); }

/* ===== board ===== */
.board-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); align-items: start; }
.col { display: flex; flex-direction: column; gap: var(--s-2); }
.col-head { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--ink-2); padding: 0 var(--s-1); }
.col-head .col-count { margin-left: auto; font-family: var(--font-mono); color: var(--ink-3); }
.quick-add { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); background: var(--bg-2); border: 1px solid var(--line-0); border-radius: var(--r-md); }
.quick-add input { flex: 1; border: 0; background: transparent; outline: none; font-size: var(--fs-sm); }
.quick-add input::placeholder { color: var(--ink-3); }
.blocked-strip { border-color: var(--red); box-shadow: var(--glow-alert); }
.task {
  background: var(--bg-2); border: 1px solid var(--line-0); border-radius: var(--r-md);
  padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.task:hover { border-color: var(--line-1); }
.task.open { border-color: var(--green-dim); }
.task .tk-top { display: flex; align-items: flex-start; gap: var(--s-2); }
.task .tk-title { flex: 1; font-size: var(--fs-sm); color: var(--ink-0); }
.task .tk-meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.avatar { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-family: var(--font-mono); background: var(--bg-3); color: var(--ink-1); border: 1px solid var(--line-1); flex: none; }
.avatar.j { color: var(--green); border-color: var(--green-dim); }
.task .tk-age { font-size: var(--fs-xs); color: var(--ink-3); font-family: var(--font-mono); }
.task-detail { border-top: 1px solid var(--line-0); padding-top: var(--s-2); display: flex; flex-direction: column; gap: var(--s-2); }
.task-detail .td-note { font-size: var(--fs-sm); color: var(--ink-1); }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.hist li { font-size: var(--fs-xs); color: var(--ink-2); font-family: var(--font-mono); }
.moves { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.btn {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: var(--s-1) var(--s-3); border-radius: var(--r-sm);
  border: 1px solid var(--line-1); background: var(--bg-3); color: var(--ink-1);
  font-size: var(--fs-xs); transition: border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { border-color: var(--green-dim); color: var(--ink-0); }
.btn--green { color: var(--green); border-color: var(--green-dim); }
.btn--red { color: var(--red); border-color: rgba(248,113,113,0.4); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.spine-goals { margin-top: var(--s-2); }

/* ===== chat ===== */
.chat-view { display: flex; flex-direction: column; height: 100%; gap: var(--s-4); }
.transcript { flex: 1; display: flex; flex-direction: column; gap: var(--s-3); overflow: auto; padding-right: var(--s-1); }
.msg { max-width: 76%; display: flex; flex-direction: column; gap: var(--s-1); }
.msg .m-body { padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; }
.msg .m-time { font-size: var(--fs-xs); color: var(--ink-3); font-family: var(--font-mono); }
.msg.aaron { align-self: flex-end; align-items: flex-end; }
.msg.aaron .m-body { background: var(--bg-3); color: var(--ink-0); border: 1px solid var(--line-1); }
.msg.aaron.pending .m-body { border-color: var(--amber); animation: pending-pulse var(--pulse-period) ease-in-out infinite; }
.msg.jamma { align-self: flex-start; align-items: flex-start; }
.msg.jamma .m-body { background: var(--bg-2); color: var(--ink-1); border: 1px solid var(--line-0); }
.msg.info { align-self: stretch; max-width: 100%; }
.msg.info .m-body { background: var(--bg-1); border: 1px solid var(--green-dim); color: var(--ink-1); border-left-width: 2px; }
.composer { display: flex; gap: var(--s-2); align-items: flex-end; border-top: 1px solid var(--line-0); padding-top: var(--s-3); }
.composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 160px;
  background: var(--bg-2); border: 1px solid var(--line-0); border-radius: var(--r-md);
  padding: var(--s-3); outline: none; font-size: var(--fs-sm);
}
.composer textarea:focus { border-color: var(--line-1); }
.composer .send { width: 44px; height: 44px; border-radius: var(--r-md); border: 1px solid var(--green-dim); background: var(--bg-3); color: var(--green); display: flex; align-items: center; justify-content: center; }
.composer .send:hover { background: var(--green-glow); }
.composer.off textarea { opacity: 0.6; }
.composer-note { font-size: var(--fs-xs); color: var(--amber); padding-top: var(--s-2); }

/* ===== settings ===== */
.set-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); align-items: start; }
.flag-row { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) 0; border-top: 1px solid var(--line-0); }
.flag-row:first-of-type { border-top: 0; }
.cadence-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.cadence-table td { padding: var(--s-2) 0; border-top: 1px solid var(--line-0); }
.cadence-table td:last-child { text-align: right; font-family: var(--font-mono); color: var(--ink-0); }
.dock-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); }
.dock { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border: 1px dashed var(--line-1); border-radius: var(--r-md); color: var(--ink-3); background: transparent; cursor: default; }
.dock .d-name { font-size: var(--fs-sm); color: var(--ink-2); }

/* ===== empty / error / skeleton ===== */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-8) var(--s-4); text-align: center; color: var(--ink-2); }
.empty .icon { width: 28px; height: 28px; color: var(--ink-3); }
.empty .e-sub { font-size: var(--fs-xs); color: var(--ink-3); }
.errbox { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding: var(--s-8) var(--s-4); text-align: center; color: var(--ink-2); }
.errbox .icon { color: var(--amber); width: 28px; height: 28px; }
.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-sm); }
.skel-row { height: 14px; margin: var(--s-2) 0; }
.skel-block { height: 96px; border-radius: var(--r-lg); }

/* ===== animations (all killed under reduced motion) ===== */
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.8); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--green-glow); } 50% { box-shadow: 0 0 0 4px transparent; } }
@keyframes pending-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--amber-glow); } 50% { box-shadow: 0 0 0 3px transparent; } }
@keyframes flash { 0% { background: var(--green-glow); border-left-color: var(--green); } 100% { background: transparent; } }
@keyframes tick { 0% { transform: scale(1.12); color: var(--green); } 100% { transform: scale(1); } }
@keyframes flare { 0% { box-shadow: var(--glow-alert); } 100% { box-shadow: none; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== health repair ===== */
.health-alert { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }
.repair { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.repair-status { font-size: var(--fs-xs); }

/* ===== BRAIN (intake) ===== */
.brain-capture { display: flex; flex-direction: column; gap: var(--s-2); }
.bc-row { display: flex; gap: var(--s-2); align-items: flex-end; }
.brain-input {
  flex: 1; resize: none; min-height: 46px; max-height: 160px;
  background: var(--bg-1); border: 1px solid var(--line-0); border-radius: var(--r-md);
  color: var(--ink-0); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); line-height: 1.5;
}
.brain-input:focus-visible { outline: none; border-color: var(--green-dim); }
.brain-send { white-space: nowrap; align-self: stretch; padding-left: var(--s-3); padding-right: var(--s-3); }
.bc-foot { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; font-size: var(--fs-xs); }
.brain-status { display: flex; align-items: center; gap: var(--s-1); }

.brain-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.bfilter {
  border: 1px solid var(--line-0); background: var(--bg-2); color: var(--ink-2);
  border-radius: 999px; padding: 3px var(--s-3); font-size: var(--fs-xs); letter-spacing: 0.01em;
}
.bfilter.on { color: var(--ink-0); border-color: var(--line-1); background: var(--bg-3); }
.bfilter.on.t-green { color: var(--green); border-color: var(--green-dim); }
.bfilter.on.t-amber { color: var(--amber); border-color: rgba(251,191,36,0.4); }
.bfilter.on.t-cyan { color: var(--cyan); border-color: rgba(103,232,249,0.35); }
.bfilter.on.t-violet { color: var(--violet); border-color: rgba(167,139,250,0.4); }

.brain-map-card { display: flex; justify-content: center; padding: var(--s-3); }
.brain-map { width: 100%; max-width: 460px; height: auto; display: block; }
.bm-anchor-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.75; }
.bm-node { cursor: pointer; transition: opacity var(--t-fast); }
.bm-node:focus-visible { outline: none; }
.bm-node:hover circle, .bm-node.on circle { opacity: 1; }

.brain-list { display: flex; flex-direction: column; gap: var(--s-2); }
.brain-node {
  background: var(--bg-2); border: 1px solid var(--line-0); border-radius: var(--r-md);
  padding: var(--s-3); cursor: pointer; transition: border-color var(--t-fast);
}
.brain-node:hover { border-color: var(--line-1); }
.brain-node.open { border-color: var(--line-1); background: var(--bg-3); }
.bn-head { display: flex; align-items: center; gap: var(--s-2); }
.bn-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); }
.bn-dot[data-t="idea"] { background: var(--amber); }
.bn-dot[data-t="todo"] { background: var(--green); }
.bn-dot[data-t="resource"] { background: var(--cyan); }
.bn-dot[data-t="project"] { background: var(--violet); }
.bn-dot[data-t="reminder"] { background: var(--blue); }
.bn-dot[data-t="contact"] { background: var(--rose); }
.bn-dot[data-t="question"] { background: var(--orange); }
.bn-dot[data-t="note"] { background: var(--slate); }
.bfilter.on.t-rose { color: var(--rose); border-color: rgba(251,113,133,0.4); }
.bfilter.on.t-orange { color: var(--orange); border-color: rgba(251,146,60,0.4); }
.bfilter.on.t-slate { color: var(--slate); border-color: rgba(148,163,184,0.4); }
.bn-due { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-family: var(--font-mono); font-size: var(--fs-xs); margin-top: var(--s-1); }
.bfilter.on.t-blue { color: var(--blue); border-color: rgba(96,165,250,0.4); }
.bn-title { flex: 1; font-weight: 500; color: var(--ink-0); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-age { color: var(--ink-3); flex: none; }
.bn-clear { flex: none; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: var(--r-sm); border: 1px solid var(--line-0); background: var(--bg-1); color: var(--ink-3); }
.bn-clear:hover { color: var(--green); border-color: var(--green-dim); }
.bn-clear:disabled { opacity: 0.4; }
.bn-summary { color: var(--ink-2); font-size: var(--fs-sm); margin-top: var(--s-1); }
.bn-tags { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: var(--s-2); }
.bn-tag { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); background: var(--bg-1); border-radius: var(--r-sm); padding: 1px 6px; }
.bn-text { color: var(--ink-1); font-size: var(--fs-sm); margin-top: var(--s-2); white-space: pre-wrap; word-break: break-word; }
.bn-action { display: flex; align-items: center; gap: var(--s-1); margin-top: var(--s-2); color: var(--green); font-size: var(--fs-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .brand-dot { opacity: 1; }
}

/* ===== responsive: tablet (<=1100px) tape collapses to overlay ===== */
@media (max-width: 1100px) {
  #app {
    grid-template-columns: 56px 1fr;
    grid-template-areas: "rail top" "rail main";
  }
  .tape {
    position: fixed; top: 48px; right: 0; bottom: 0; width: 280px;
    transform: translateX(100%); transition: transform var(--t-med); z-index: 30;
    box-shadow: var(--shadow-2);
  }
  #app.tape-open .tape { transform: none; }
  .tape-toggle { display: flex; }
}

/* ===== responsive: phone (<=720px) rail -> bottom tabs, tape -> Feed tab ===== */
@media (max-width: 720px) {
  /* match the shell bg so any viewport gap never reads as a black band, and
     clamp horizontal overflow so the phone never expands the layout viewport
     and loads zoomed out (pinch-to-fit). */
  html, body { background: var(--bg-1); overflow-x: hidden; max-width: 100%; }
  #app {
    /* minmax(0,1fr): the column may shrink below its content's min width, so an
       unshrinkable child (e.g. the top strip) can never widen the whole layout. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 48px 1fr;
    grid-template-areas: "top" "main";
    height: auto; min-height: 100vh; min-height: 100dvh;
    width: 100%; max-width: 100%; overflow-x: hidden;
  }
  /* the top strip must fit the phone: keep the node + conn dots, drop their text
     labels so nothing overflows and clips the logout button. */
  .topstrip { min-width: 0; gap: var(--s-3); overflow: hidden; }
  .nodes { gap: var(--s-2); min-width: 0; }
  .node-label { display: none; }
  .conn { padding: var(--s-1); }
  .conn-label { display: none; }
  /* every grid/flex child may shrink below its content instead of forcing width */
  .main, .main-inner, .view, .card, .board-cols, .col, .rail-grid, .node-row,
  .grid-2, .grid-tiles, .stat-row, .brain-list, .brain-map-card { min-width: 0; max-width: 100%; }
  .rail { display: none; }
  .tape { display: none; }
  .tape-toggle { display: none; }
  .topstrip { position: sticky; top: 0; z-index: 20; }
  /* content clears the fixed tab bar + the phone's home-bar safe area */
  .main { padding: var(--s-4); padding-bottom: calc(56px + env(safe-area-inset-bottom) + var(--s-4)); overflow: visible; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex; align-items: stretch;
    background: var(--bg-0); border-top: 1px solid var(--line-0);
  }
  .tab-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--ink-3); font-size: 10px; letter-spacing: 0.02em;
  }
  .tab-btn.active { color: var(--green); }
  .tab-btn .icon { width: 20px; height: 20px; }
  .node-row, .grid-tiles, .stat-row, .board-cols, .set-grid, .dock-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .node-row { grid-template-columns: 1fr; }
  .netmonth { font-size: var(--fs-sm); }
  .brand-word { display: none; }
  .hero-fig { font-size: var(--fs-3xl); }
  .msg { max-width: 88%; }
}

@media (min-width: 721px) and (max-width: 900px) {
  .grid-tiles { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
}
