/* ==========================================================================
   Quillo — the design system.

   One stylesheet for every signed-in surface (journal, context graph) and for
   the two doors into the product (sign-in, invite). apps.css layers on top of
   these tokens, so every token name here is a public contract: add, never
   rename.

   The instincts it holds to:
     · calm, editorial, paper-like — hairlines and air do the separating
     · one type family (Inter), a real scale, one measure for body copy
     · Montserrat is the wordmark face and nothing else
     · colour means something: kind of node, overdue, live, connected
     · one obvious subject per page; support recedes rather than competing
     · every colour is a token, defined light on :root and re-tinted for dark
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — the complete light palette lives here, on bare :root.
      The dark block below re-values these names and defines nothing new.
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;   /* light only, by decision */

  /* grounds */
  --bg:        #ffffff;
  --bg-2:      #fafafa;   /* recessed columns: the rail, the graph rail */
  --surface:   #ffffff;
  --sunk:      #f5f5f5;
  --hover:     #f8f8f8;
  --scrim:     rgba(22, 22, 26, .28);

  /* ink */
  --ink:       #16161a;
  --ink-2:     #5f5f68;
  --ink-3:     #8e8e97;
  --ink-4:     #b4b4bb;
  --on-ink:    #ffffff;   /* text on an --ink fill (inverts with the theme) */
  --on-accent: #ffffff;   /* text on an --accent fill */

  /* rules */
  --line:      #ebebeb;
  --line-2:    #e0e0e0;
  --line-3:    #cccccc;

  /* meaning */
  --accent:    #2f6157;
  --accent-2:  #3d7a6d;
  --accent-bg: #ecf3f0;
  --amber:     #9a6416;
  --amber-bg:  #f9f1e3;
  --danger:    #a33a2c;
  --danger-bg: #fbeceb;
  --good:      #2f6157;
  --blue:      #4c6d8f;
  --violet:    #7c5cd6;

  /* graph — read by graph.js through getComputedStyle */
  --node-root:     #1a1917;
  --node-topic:    #b1602c;
  --node-entity:   #2f6157;
  --node-source:   #4c6d8f;
  --node-fact:     #a6a49e;
  --graph-edge:    #dcdad5;
  --graph-edge-hi: #8d8778;
  --graph-halo:    #ffffff;
  --graph-ground:  #ffffff;

  /* radii */
  --r-sm:   6px;
  --r:      9px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-full: 999px;

  /* elevation */
  --shadow:   0 1px 2px rgba(20, 20, 20, .05);
  --shadow-2: 0 1px 2px rgba(20, 20, 20, .05), 0 6px 20px rgba(20, 20, 20, .06);
  --shadow-3: 0 1px 2px rgba(20, 20, 20, .06), 0 18px 44px rgba(20, 20, 20, .12);
  /* One definition that reads in both themes: a wash of the accent, not a flat tint. */
  --ring:     0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
  --dot-hi:   rgba(255, 255, 255, .22);   /* the highlight inside the wordmark dot */

  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mark: "Montserrat", var(--font);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* type scale — eight steps, used deliberately and nowhere else improvised */
  --fs-0: 10.5px;  /* legend, provenance */
  --fs-1: 11.5px;  /* eyebrows, chips, meta */
  --fs-2: 12.5px;  /* secondary UI */
  --fs-3: 13.5px;  /* dense UI, rail body */
  --fs-4: 14.5px;  /* body copy */
  --fs-5: 16.5px;  /* entry titles, lede */
  --fs-6: 21px;    /* section titles */
  --fs-7: 27px;    /* page title */
  --fs-8: 34px;    /* the one hero line on a door page */

  --lh-tight: 1.2;
  --lh-snug:  1.4;
  --lh-body:  1.62;

  /* measure — body copy never runs wider than this */
  --measure:       68ch;
  --measure-tight: 44ch;

  /* space scale */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* frame */
  --topbar: 52px;
  --rail:   312px;
  --panel:  392px;
  --gutter: 32px;
}

/* No dark theme: this product is light only. Every colour is defined once, on :root. */
/* --------------------------------------------------------------------------
   2. Reset and base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute must win over any author `display`.
   The UA rule for [hidden] is `display: none` at the lowest specificity, so a class rule like
   `.panel { display: flex }` silently defeats it — which showed up as the graph's empty state
   painted on top of a full graph, and the node panel stuck open and blank. Every element the JS
   toggles with `el.hidden` relies on this one line. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body.today {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-4)/var(--lh-body) var(--font);
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; }

button, input, textarea, select {
  font: inherit; letter-spacing: inherit; color: inherit;
}
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-bg); color: var(--ink); }

.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;
}

/* A single scrollbar treatment, so no pane looks like a different app. */
.scrolls { overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.scrolls::-webkit-scrollbar { width: 10px; height: 10px; }
.scrolls::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: var(--r-full);
  border: 3px solid transparent; background-clip: content-box;
}
.scrolls::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: content-box; }
.scrolls::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   3. Type utilities — the only places a size is chosen
   -------------------------------------------------------------------------- */

.eyebrow {
  font-size: var(--fs-1); font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
}

.lede {
  font-size: var(--fs-5); line-height: var(--lh-body);
  color: var(--ink-2); max-width: var(--measure);
}

.prose { max-width: var(--measure); }
.nums  { font-variant-numeric: tabular-nums; }
.note  { font-size: var(--fs-3); line-height: var(--lh-snug); color: var(--ink-3); }
.note-em { color: var(--ink-2); }
.quiet { color: var(--ink-3); }

/* --------------------------------------------------------------------------
   4. Top bar — the one piece of chrome every signed-in page shares
   -------------------------------------------------------------------------- */

.bar {
  position: relative; z-index: 30;
  height: var(--topbar);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-3) 0 var(--sp-4);
  border-bottom: 1px solid var(--line);
  /* Deliberately opaque and unfiltered: a `backdrop-filter` here would become the containing block
     for the account menu's fixed click-outside sheet and trap it inside the bar. */
  background: color-mix(in srgb, var(--bg) 78%, var(--surface));
}

.mark {
  font: 600 14px/1 var(--mark);
  letter-spacing: -.022em;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 5px 7px 5px 5px; border-radius: var(--r-sm);
  flex: 0 0 auto;
}
.mark:hover { background: var(--sunk); }

.mark-dot {
  width: 17px; height: 17px; border-radius: 6px; flex: 0 0 auto;
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  box-shadow: inset 0 0 0 1px var(--dot-hi);
}

.bar-spacer { flex: 1 1 auto; }

/* --- sections ------------------------------------------------------------- */

.nav {
  display: flex; align-items: center; gap: 2px;
  margin-left: var(--sp-3);
  min-width: 0;
}

.nav-link {
  position: relative;
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 11px;
  border-radius: var(--r-sm);
  font-size: var(--fs-3); font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color .12s, background .12s;
}
.nav-link:hover { color: var(--ink); background: var(--sunk); }

/* The active tab is unmistakable: full-strength ink and a rule that sits on
   the bar's own bottom border, so the section reads as continuous with it. */
.nav-link.is-active { color: var(--ink); font-weight: 600; }
.nav-link.is-active::after {
  content: "";
  position: absolute; left: 11px; right: 11px;
  /* sit exactly on the bar's bottom border, whatever height the bar is */
  bottom: calc((var(--topbar) - 30px) / -2 - 1px);
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.nav-link.is-secondary { color: var(--ink-4); font-weight: 400; }
.nav-link.is-secondary:hover { color: var(--ink-2); }

.bar-link {
  font-size: var(--fs-2); color: var(--ink-2);
  padding: 6px 9px; border-radius: var(--r-sm);
}
.bar-link:hover { background: var(--sunk); color: var(--ink); }

/* --- account menu (a bare <details>, no JavaScript) ---------------------- */

.usermenu { position: relative; flex: 0 0 auto; }

.usermenu > summary {
  list-style: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary::marker { content: ""; }

.avatar {
  width: 27px; height: 27px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font: 600 11.5px/1 var(--font);
  letter-spacing: 0;
  margin-left: 2px;
  box-shadow: 0 0 0 0 var(--accent-bg);
  transition: box-shadow .12s;
  user-select: none;
}
.usermenu > summary.avatar:hover { box-shadow: var(--ring); }
.usermenu[open] > summary.avatar { box-shadow: var(--ring); }

/* Clicking anywhere else lands on this invisible sheet — and because it is part
   of the summary, that click closes the menu. It is what makes the menu look,
   and behave, dismissible without a line of script. */
.usermenu[open] > summary::before {
  content: "";
  position: fixed; inset: 0; z-index: 40;
  cursor: default;
}

.usermenu-pop {
  position: absolute; top: calc(100% + 9px); right: 0; z-index: 50;
  width: 236px; padding: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: pop-in .12s ease-out;
}

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.usermenu-who {
  display: grid; gap: 2px;
  padding: 9px 10px 10px;
  margin-bottom: var(--sp-1);
  border-bottom: 1px solid var(--line);
}
.usermenu-who b {
  font-size: var(--fs-3); font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.usermenu-who span {
  font-size: var(--fs-1); color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.usermenu-item {
  display: flex; align-items: center; width: 100%;
  padding: 7px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-3); color: var(--ink-2);
  text-align: left;
}
.usermenu-item:hover { background: var(--sunk); color: var(--ink); }
.usermenu-item.is-danger { color: var(--ink-3); }
.usermenu-item.is-danger:hover { background: var(--danger-bg); color: var(--danger); }
.usermenu-pop form { margin: 0; }

/* --------------------------------------------------------------------------
   5. Page frame — a subject column and a support rail
   -------------------------------------------------------------------------- */

.shell {
  height: calc(100dvh - var(--topbar));
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail);
  /* An implicit `auto` row refuses to shrink below its content, so the panes would grow past the
     viewport and scroll the whole document — taking the top bar with them. */
  grid-template-rows: minmax(0, 1fr);
}

.stream {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;   /* head · subject · footer */
  min-width: 0; min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

/* The subject column keeps a fixed measure and centres it: the journal is a
   page, not a fluid table. */
.column { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }

/* --------------------------------------------------------------------------
   6. Page head
   -------------------------------------------------------------------------- */

.pagehead { padding: var(--sp-6) 0 var(--sp-4); }

.pagehead h1 {
  font-size: var(--fs-7); font-weight: 600;
  letter-spacing: -.028em; line-height: var(--lh-tight);
}

.pagehead .eyebrow { margin-bottom: 7px; }

.pagehead p {
  margin-top: 6px;
  font-size: var(--fs-3); color: var(--ink-3);
  max-width: var(--measure);
}

/* legacy day header (today.js) — kept working, quieter */
.dayhead { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--gutter) var(--sp-3); }
.dayhead h1 { font-size: var(--fs-6); font-weight: 600; letter-spacing: -.024em; }
.daysub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: var(--fs-2); color: var(--ink-3); }
.daynav { margin-left: auto; display: flex; gap: 2px; }
.daynav button {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--ink-3); font-size: var(--fs-3);
  border: 1px solid transparent;
}
.daynav button:hover:not(:disabled) { background: var(--sunk); border-color: var(--line); color: var(--ink); }
.daynav button:disabled { color: var(--ink-4); cursor: default; }

/* --------------------------------------------------------------------------
   7. Chips and small parts
   -------------------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  max-width: 100%;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--sunk); color: var(--ink-2);
  font-size: var(--fs-1); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chip.is-warn   { background: var(--amber-bg); color: var(--amber); }
.chip.is-accent { background: var(--accent-bg); color: var(--accent); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* graph neighbour chips are buttons and carry a type swatch */
button.chip { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 400; padding: 4px 10px; }
button.chip:hover { background: var(--hover); border-color: var(--line-3); }
.chip-root   i { color: var(--node-root); }
.chip-topic  i { color: var(--node-topic); }
.chip-entity i { color: var(--node-entity); }
.chip-source i { color: var(--node-source); }
.chip-fact   i { color: var(--node-fact); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); flex: 0 0 auto; }

.linky {
  font-size: var(--fs-2); color: var(--ink-3);
  border-bottom: 1px solid transparent;
  transition: color .12s, border-color .12s;
}
.linky:hover { color: var(--accent); border-bottom-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: var(--r-sm);
  font-size: var(--fs-3); font-weight: 500;
  border: 1px solid transparent;
  transition: opacity .12s, background .12s, border-color .12s;
}
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { opacity: .86; }
.btn-primary:disabled { opacity: .38; cursor: default; }
.btn-quiet { background: var(--surface); border-color: var(--line-2); color: var(--ink-2); }
.btn-quiet:hover { border-color: var(--line-3); color: var(--ink); }
.btn-block { width: 100%; }
.btn-lg { height: 40px; font-size: var(--fs-4); border-radius: var(--r); }

.code { display: inline-block; margin-top: 6px; font: 400 var(--fs-1)/1.4 var(--mono); color: var(--ink-4); }

code {
  font: 400 .92em/1.4 var(--mono);
  background: var(--sunk); padding: 1px 5px; border-radius: 4px;
}

/* --------------------------------------------------------------------------
   8. The journal — a diary page, not a transcript
   -------------------------------------------------------------------------- */

.feed { padding-bottom: var(--sp-5); }
.stream-foot { padding: 0 0 var(--sp-6); }

.entry { padding: var(--sp-5) 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; padding-top: var(--sp-2); }

.entry-head { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }

.entry-head h2 {
  font-size: var(--fs-5); font-weight: 600; letter-spacing: -.02em;
}
.entry.is-today .entry-head h2 { color: var(--accent); }
.entry.is-today .entry-head h2::before {
  content: ""; display: inline-block; vertical-align: middle;
  width: 5px; height: 5px; border-radius: 50%;
  margin: -2px 8px 0 0; background: var(--accent);
}

.entry-chips { display: flex; gap: 5px; flex-wrap: wrap; }

.entry-body { max-width: var(--measure); }

.entry-sub {
  margin: var(--sp-4) 0 var(--sp-2);
  font-size: var(--fs-1); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3);
}
.entry-sub:first-child { margin-top: 0; }

.learned, .given { list-style: none; margin: 0; padding: 0; }

.learned li {
  display: flex; align-items: baseline; gap: var(--sp-2);
  padding: 5px 0 5px 15px; position: relative;
  font-size: var(--fs-4); line-height: var(--lh-body); color: var(--ink);
}
/* A hanging mark reads as a diary bullet without the browser's default indent. */
.learned li::before {
  content: ""; position: absolute; left: 0; top: 12px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--line-3);
}
.learned-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.learned-topic {
  flex: 0 0 auto; font-size: var(--fs-0); color: var(--ink-3);
  padding: 2px 7px; border-radius: var(--r-full); background: var(--sunk);
}
.learned-more::before { display: none; }
.learned-more { padding-left: 15px; }

.given li {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  padding: 5px 0; font-size: var(--fs-3); color: var(--ink-2);
}
.given-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.given-note { flex: 0 0 auto; font-size: var(--fs-1); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.entry-note {
  margin-top: var(--sp-3); padding: 10px 13px;
  border-left: 2px solid var(--accent); background: var(--accent-bg);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: var(--fs-3); line-height: var(--lh-body); color: var(--ink-2);
  white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   9. Skeletons, blank slates, failures — the states that decide whether the
      product feels finished
   -------------------------------------------------------------------------- */

.sk { padding: var(--sp-5) 0; border-top: 1px solid var(--line); }
.sk:first-child { border-top: 0; padding-top: var(--sp-2); }

.sk-bar {
  display: block; height: 9px; border-radius: var(--r-full);
  background: var(--sunk);
  position: relative; overflow: hidden;
}
.sk-bar + .sk-bar { margin-top: 10px; }
.sk-bar::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  transform: translateX(-100%);
  animation: sk-sweep 1.35s ease-in-out infinite;
}
.sk-head { height: 13px; width: 34%; margin-bottom: var(--sp-4); }
.sk-w90 { width: 90%; } .sk-w75 { width: 75%; } .sk-w60 { width: 60%; } .sk-w45 { width: 45%; }

@keyframes sk-sweep { to { transform: translateX(100%); } }

/* The first screen a new account sees. One sentence saying what to do next,
   then the two ways to do it — nothing else. */
.blank {
  padding: var(--sp-6) 0 var(--sp-7);
  max-width: var(--measure);
}
.blank h2 {
  font-size: var(--fs-6); font-weight: 600; letter-spacing: -.024em; line-height: var(--lh-tight);
  margin-bottom: 8px;
}
.blank p { font-size: var(--fs-4); line-height: var(--lh-body); color: var(--ink-2); max-width: var(--measure-tight); }
.blank-steps {
  list-style: none; margin: var(--sp-5) 0 0; padding: 0;
  counter-reset: step;
  border-top: 1px solid var(--line);
}
.blank-steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-3); color: var(--ink-2);
}
.blank-steps li::before {
  content: counter(step);
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sunk); color: var(--ink-3);
  font-size: var(--fs-0); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.blank-steps b { color: var(--ink); font-weight: 600; }
.blank-cta { margin-top: var(--sp-5); display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.failed {
  display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap;
  margin: var(--sp-5) 0;
  padding: 12px 14px;
  border: 1px solid var(--line-2); border-left: 2px solid var(--danger);
  border-radius: 0 var(--r) var(--r) 0;
  background: var(--surface);
  font-size: var(--fs-3); color: var(--ink-2);
}
.failed button { color: var(--danger); }
.failed button:hover { border-bottom-color: var(--danger); }

.feed-empty { padding: var(--sp-7) 0; text-align: center; color: var(--ink-3); font-size: var(--fs-3); }
.rail-empty { font-size: var(--fs-2); color: var(--ink-4); padding: var(--sp-1) 0; }

/* --------------------------------------------------------------------------
   10. Composer (today.js) — kept for the older surface
   -------------------------------------------------------------------------- */

.ask {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  margin: 0 var(--gutter) var(--sp-5);
  padding: 7px 7px 7px 13px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: border-color .12s, box-shadow .12s;
}
.ask:focus-within { border-color: var(--accent); box-shadow: var(--shadow-2); }
.ask textarea {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: 0; resize: none; background: none;
  padding: 5px 0; max-height: 168px;
  font-size: var(--fs-4); line-height: var(--lh-snug);
}
.ask textarea::placeholder { color: var(--ink-4); }
.ask-send {
  flex: 0 0 auto;
  height: 30px; padding: 0 13px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--on-ink);
  font-size: var(--fs-2); font-weight: 500;
}
.ask-send:hover { opacity: .86; }
.ask-send:disabled { opacity: .4; cursor: default; }
.ask-hint { flex: 0 0 auto; align-self: center; font-size: var(--fs-1); color: var(--ink-4); padding-right: 2px; }

/* legacy feed items (today.js) */
.fi { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: var(--sp-3); padding: 9px 10px; margin: 0 -10px; border-top: 1px solid var(--line); border-radius: var(--r-sm); }
.fi:first-child { border-top: 0; }
.fi:hover { background: var(--hover); }
.fi-meta { display: flex; align-items: center; gap: 6px; padding-top: 1px; font-size: var(--fs-1); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.fi-meta::before { content: ""; width: 5px; height: 5px; border-radius: 50%; flex: 0 0 auto; background: var(--ink-4); }
.fi-chat .fi-meta::before     { background: var(--accent); }
.fi-drop .fi-meta::before     { background: var(--blue); }
.fi-reminder .fi-meta::before { background: var(--amber); }
.fi-nudge .fi-meta::before    { background: var(--violet); }
.fi-kind { display: none; }
.fi-body { min-width: 0; max-width: var(--measure); }
.fi-you { font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.fi-agent { margin-top: 3px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.fi-title { font-weight: 500; overflow-wrap: anywhere; }
.fi-note, .fi-wait { display: inline-block; margin-top: 3px; font-size: var(--fs-1); color: var(--ink-3); }
.fi-wait { color: var(--accent); }
.fi-wait.is-error { color: var(--danger); }
.fi.is-live .fi-wait::after {
  content: ""; display: inline-block;
  width: 4px; height: 4px; margin-left: 5px; border-radius: 50%;
  background: currentColor; vertical-align: middle;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* --------------------------------------------------------------------------
   11. The rail — support, and it should look like it
   -------------------------------------------------------------------------- */

.rail {
  padding: var(--sp-5) var(--sp-4) var(--sp-7);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  min-width: 0;
}

/* Sections are separated by air and a hairline, not by a box each. The only
   boxed thing in the rail is the one you can click. */
.rail-sec { padding: var(--sp-4) 0; border-top: 1px solid var(--line); }
.rail-sec:first-child { padding-top: 0; border-top: 0; }
.rail-sec > .card { margin-top: 2px; }

.rail-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.rail-head h2 {
  font-size: var(--fs-1); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3);
}
.rail-count {
  margin-left: auto;
  font-size: var(--fs-1); font-weight: 600; color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* the card, kept for apps.css and for the rail's one clickable summary */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 13px 13px;
}

.card-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.card-head h2 { font-size: var(--fs-3); font-weight: 600; letter-spacing: -.01em; }
.card-count { margin-left: auto; font-size: var(--fs-1); font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.card-link { display: block; transition: border-color .12s, box-shadow .12s, background .12s; }
.card-link:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.card-link .card-count { color: var(--ink-4); font-size: var(--fs-4); }

/* A sentence beats a row of tiles: it says the same thing and reads once. */
.card-prose { font-size: var(--fs-3); line-height: var(--lh-snug); color: var(--ink-2); }
.card-prose b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.stat-row { display: flex; gap: var(--sp-4); }
.stat { font-size: var(--fs-1); color: var(--ink-3); }
.stat b { display: block; font-size: var(--fs-5); font-weight: 600; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* --- tasks --------------------------------------------------------------- */

.task-add input {
  width: 100%; margin-bottom: var(--sp-2);
  padding: 7px 9px; border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-3);
  transition: border-color .12s, box-shadow .12s;
}
.task-add input:focus { outline: 0; border-color: var(--accent); box-shadow: var(--ring); }
.task-add input::placeholder { color: var(--ink-4); }

.task {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: 6px 4px 6px 2px; margin: 0 -4px 0 -2px;
  border-radius: var(--r-sm);
}
.task:hover { background: var(--hover); }

.task-check {
  flex: 0 0 auto; width: 15px; height: 15px; margin-top: 3px;
  border: 1.5px solid var(--line-3); border-radius: 50%;
  transition: border-color .12s, background .12s;
}
.task-check:hover { border-color: var(--accent); background: var(--accent-bg); }
.task-check.is-clock { border: 0; display: grid; place-items: center; color: var(--ink-4); font-size: var(--fs-1); }

.task-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.task-title { font-size: var(--fs-3); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.task-due { font-size: var(--fs-1); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.task.is-overdue .task-check { border-color: var(--danger); }
.task.is-overdue .task-due { color: var(--danger); }
.task.is-done { opacity: .38; }
.task.is-done .task-title { text-decoration: line-through; }
.task.is-scheduled .task-title { color: var(--ink-2); }

/* --- drop space ---------------------------------------------------------- */

.dropzone {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 11px; border-radius: var(--r-sm);
  border: 1px dashed var(--line-3);
  background: var(--surface);
  color: var(--ink-2); font-size: var(--fs-3);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.dropzone::before {
  content: "+"; flex: 0 0 auto;
  width: 20px; height: 20px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--sunk); border: 1px solid var(--line);
  font-size: var(--fs-4); line-height: 1; color: var(--ink-3);
}
.dropzone:hover, .dropzone.is-over {
  border-color: var(--accent); background: var(--accent-bg); color: var(--accent);
  border-style: solid;
}
.dropzone.is-busy { opacity: .6; }
.dropzone.is-error { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.dropzone-title { font-weight: 500; }
.dropzone-sub { color: var(--ink-3); font-size: var(--fs-1); }
.dropzone input[type="file"] { display: none; }

/* journal.js drop rows */
.drop-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2);
  padding: 6px 0; font-size: var(--fs-2);
}
.drop-row + .drop-row { border-top: 1px solid var(--line); }
.drop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.drop-status { flex: 0 0 auto; font-size: var(--fs-1); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.drop-status.is-live { color: var(--accent); }

/* graph.js drop rows */
.drops { list-style: none; margin: 0; padding: 0; }
.drops li {
  display: grid; grid-template-columns: 6px minmax(0, 1fr) auto;
  align-items: baseline; gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.drops li:last-child { border-bottom: 0; }
.drops .dot { align-self: center; }
.drops .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-3); color: var(--ink); }
.drops .meta { font-size: var(--fs-1); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.drops .s-done .dot   { background: var(--good); }
.drops .s-error .dot  { background: var(--danger); }
.drops .s-error .meta { color: var(--danger); }
.drops .s-active .dot { background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.drops .gain { color: var(--accent); }

/* --- connected apps ------------------------------------------------------ */

.app-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  padding: 6px 0; font-size: var(--fs-3);
}
.app-row + .app-row { border-top: 1px solid var(--line); }
.app-name { color: var(--ink); }
.app-state { font-size: var(--fs-1); color: var(--ink-3); }
.app-state.is-on { color: var(--accent); }

/* --- channel nudges ------------------------------------------------------ */

.nudge p { margin: 0 0 var(--sp-3); font-size: var(--fs-3); line-height: var(--lh-snug); color: var(--ink-2); }
.nudge-done { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-3); color: var(--ink-2); }
.nudge-done .dot { background: var(--good); }

.wa-steps { margin: 0 0 var(--sp-3); padding-left: var(--sp-4); font-size: var(--fs-2); line-height: 1.7; color: var(--ink-2); }
.wa-form { display: grid; gap: 6px; }
.wa-form input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-size: var(--fs-3);
}
.wa-form input:focus { outline: 0; border-color: var(--accent); box-shadow: var(--ring); }
.wa-form input::placeholder { color: var(--ink-4); }
.wa-form .btn { width: 100%; }

#wa-status { margin-top: var(--sp-2); }
#wa-status.is-error { color: var(--danger); }
#wa-status a { color: var(--accent); border-bottom: 1px solid var(--accent); }

/* ==========================================================================
   12. The context graph — same bar, same tokens, same frame as the journal
   ========================================================================== */

/* Its own shell: a head strip, then the canvas and a support rail. */
.gshell {
  height: calc(100dvh - var(--topbar));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.ghead {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}

.ghead-title { min-width: 0; }
.ghead-title h1 {
  font-size: var(--fs-6); font-weight: 600; letter-spacing: -.024em; line-height: var(--lh-tight);
}

/* Facts / topics / people / sources as one meta sentence, not a tile grid. */
.gstats {
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
  margin-top: 4px;
  font-size: var(--fs-2); color: var(--ink-3);
}
.gstats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.gstats .sep { color: var(--ink-4); }

.gtools { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

.search { position: relative; display: flex; align-items: center; }
.search svg {
  position: absolute; left: 9px; width: 14px; height: 14px;
  color: var(--ink-4); pointer-events: none;
}
.search input {
  width: 190px; height: 32px;
  padding: 0 10px 0 28px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); font-size: var(--fs-3);
  transition: border-color .12s, box-shadow .12s, width .16s;
}
.search input:focus { outline: 0; border-color: var(--accent); box-shadow: var(--ring); width: 230px; }
.search input::placeholder { color: var(--ink-4); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.toggle {
  position: relative;   /* keeps the visually hidden checkbox anchored here */
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-2); color: var(--ink-2); cursor: pointer;
  user-select: none;
}
.toggle input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.toggle .track {
  width: 30px; height: 18px; border-radius: var(--r-full);
  background: var(--line-2); position: relative;
  transition: background .14s;
  flex: 0 0 auto;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .14s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(12px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.who { font-size: var(--fs-2); color: var(--ink-3); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gbody {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

.stage {
  position: relative; min-width: 0; min-height: 0;
  background: radial-gradient(120% 90% at 50% 38%, var(--surface) 0%, var(--graph-ground) 70%);
  overflow: hidden;
  border-right: 1px solid var(--line);
}
.stage canvas {
  display: block; width: 100%; height: 100%;
  cursor: grab; touch-action: none;
  transition: opacity .2s;
}
.stage canvas.grabbing { cursor: grabbing; }
.stage canvas.pointing { cursor: pointer; }
.stage canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.stage-legend {
  position: absolute; left: var(--sp-5); bottom: var(--sp-4);
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: var(--fs-0); color: var(--ink-3);
  pointer-events: none;
}
.stage-legend span { display: inline-flex; align-items: center; gap: 6px; }
.stage-legend i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.stage-hint {
  position: absolute; right: var(--sp-5); bottom: var(--sp-4);
  font: 400 var(--fs-0)/1.4 var(--mono);
  color: var(--ink-4); pointer-events: none;
  max-width: 45%; text-align: right;
}

.stage-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); text-align: center; padding: var(--sp-6);
  pointer-events: none;
}
.stage-empty h2 {
  font-size: var(--fs-6); font-weight: 600; letter-spacing: -.024em; color: var(--ink);
}
.stage-empty p { max-width: var(--measure-tight); color: var(--ink-3); font-size: var(--fs-4); line-height: var(--lh-body); }
/* the one thing in the empty state you can actually press */
.stage-empty .btn, .stage-empty label { pointer-events: auto; cursor: pointer; margin-top: var(--sp-2); }

/* --- node detail: a side sheet on wide screens, a bottom sheet on small --- */

.panel {
  position: fixed; top: var(--topbar); right: 0; bottom: 0; z-index: 25;
  width: var(--panel); max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  animation: sheet-in .18s ease;
}
@keyframes sheet-in { from { transform: translateX(18px); opacity: 0; } to { transform: none; opacity: 1; } }

.panel-head {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: var(--sp-3);
}
.panel-head h2 {
  font-size: var(--fs-6); font-weight: 600; letter-spacing: -.024em; line-height: var(--lh-tight);
  overflow-wrap: anywhere;
}
.panel-kind {
  display: inline-block; margin-bottom: 5px;
  font-size: var(--fs-0); font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
}
.panel-close {
  flex: 0 0 auto; width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 50%;
  color: var(--ink-3);
}
.panel-close:hover { background: var(--sunk); color: var(--ink); }

.panel-body { overflow-y: auto; min-height: 0; padding: var(--sp-4) var(--sp-4) var(--sp-6); }
.panel-body h3 {
  margin: var(--sp-5) 0 var(--sp-2);
  font-size: var(--fs-1); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3);
}
.panel-body h3:first-child { margin-top: 0; }
.panel-meta { font-size: var(--fs-2); color: var(--ink-3); overflow-wrap: anywhere; }

.facts { list-style: none; margin: 0; padding: 0; }
.facts li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.facts li:last-child { border-bottom: 0; }
.facts .statement { margin-bottom: 6px; font-size: var(--fs-4); line-height: var(--lh-body); }
.facts .prov {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 9px;
  font-size: var(--fs-0); color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.facts .conf-high { color: var(--good); }
.facts .conf-low  { color: var(--amber); }
.src {
  padding: 1px 6px; border-radius: 4px;
  background: var(--sunk); color: var(--ink-2);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ==========================================================================
   13. The doors — sign-in and invite
   ========================================================================== */

body.gate {
  overflow: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100dvh;
  background: var(--bg);
}

.gate-bar { padding: var(--sp-5) var(--sp-5) 0; }
.gate-bar .mark { font-size: 15px; padding-left: 0; }
.gate-bar .mark:hover { background: none; }

.gate-main { display: flex; align-items: flex-start; justify-content: center; padding: var(--sp-6) var(--sp-5) var(--sp-7); }

.gate-card { width: 100%; max-width: 440px; }

.gate-card h1 {
  font-size: var(--fs-8); font-weight: 600;
  letter-spacing: -.032em; line-height: 1.12;
  margin-bottom: var(--sp-3);
  text-wrap: balance;
}

.gate-lede {
  font-size: var(--fs-5); line-height: var(--lh-body); color: var(--ink-2);
  max-width: 38ch;
  margin-bottom: var(--sp-6);
}

.gate-block {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--sp-5);
}

.gate-step-head { margin-bottom: var(--sp-4); }
.gate-step-head h2 {
  font-size: var(--fs-4); font-weight: 600; letter-spacing: -.014em;
  margin-bottom: 3px;
}
.gate-step-head p { font-size: var(--fs-2); line-height: var(--lh-snug); color: var(--ink-3); }
.gate-step-head p b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

.gate-form { display: grid; gap: var(--sp-3); }

.field {
  width: 100%; height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--bg);
  font-size: var(--fs-4);
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.field:focus { outline: 0; border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); }
.field::placeholder { color: var(--ink-4); }
.field[aria-invalid="true"] { border-color: var(--danger); }

/* --- phone: a country <select> and the national number, as one control ------
   Both children are borderless; the wrapper carries the border and the focus ring, so it reads as a
   single field however the browser chooses to draw a select. `focus-within` is what makes the ring
   appear for either child. */

.phone {
  display: flex; align-items: stretch;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--bg);
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.phone:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}

.phone-cc {
  flex: 0 0 auto;
  height: 42px;
  /* Every option is "<flag> +<dial>", so letting the select size itself gives exactly the right
     width on every platform — including ones that render a flag as two letters, or not at all.
     A fixed width guessed at the flag glyph's advance and clipped the dial code. */
  width: auto; min-width: 5.2em; max-width: 9em;
  /* Ask for a font that actually has flag glyphs before falling back to the UI stack. */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--font);
  padding: 0 26px 0 13px;
  border: 0; border-radius: var(--r) 0 0 var(--r);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-4);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  /* Draw our own chevron: the platform one sits badly inside a borderless select. */
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 14px center, right 9px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.phone-cc:focus { outline: 0; }
/* The open list inherits the page font but not the transparent ground, so give it a real one —
   Windows in particular renders options against the select's own background. */
.phone-cc option { background: var(--surface); color: var(--ink); }

/* A hairline between the two halves, so the boundary is legible without a second border. */
.phone-num {
  flex: 1 1 auto; min-width: 0;
  height: 42px;
  padding: 0 13px;
  border: 0; border-left: 1px solid var(--line-2); border-radius: 0 var(--r) var(--r) 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-4);
}
.phone-num:focus { outline: 0; }
.phone-num::placeholder { color: var(--ink-4); }
.phone[aria-invalid="true"] { border-color: var(--danger); }

@media (max-width: 420px) {
  .phone-cc { max-width: 7em; padding-right: 24px; }
}

.field-label {
  display: block; margin-bottom: 6px;
  font-size: var(--fs-2); font-weight: 500; color: var(--ink-2);
}
.field-label span { font-weight: 400; color: var(--ink-4); }
.field-help { margin-top: 5px; font-size: var(--fs-1); color: var(--ink-3); }

/* the code field: one input, but it reads as a code */
.field-code {
  font: 500 22px/1 var(--mono);
  letter-spacing: .34em;
  text-align: center;
  height: 52px; padding-left: 13px; padding-right: 0;
  text-indent: .34em;
}

.gate-err {
  display: flex; gap: 7px;
  padding: 9px 11px; border-radius: var(--r-sm);
  background: var(--danger-bg); color: var(--danger);
  font-size: var(--fs-2); line-height: var(--lh-snug);
}
.gate-err::before { content: "!"; font-weight: 700; flex: 0 0 auto; }
.gate-err[hidden] { display: none; }

.gate-ok {
  padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--accent-bg); color: var(--accent);
  font-size: var(--fs-3); line-height: var(--lh-snug);
}

.gate-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-1);
  font-size: var(--fs-2); color: var(--ink-3);
}
.gate-row .nums { font-variant-numeric: tabular-nums; }

/* the secondary way in, folded away under a rule */
.gate-alt { margin-top: 0; }
.gate-or {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-5) 0 var(--sp-3);
  font-size: var(--fs-1); font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-4);
}
.gate-or::before, .gate-or::after { content: ""; height: 1px; flex: 1 1 auto; background: var(--line); }

.gate-alt > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-3); color: var(--ink-2);
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 1px;
}
.gate-alt > summary::-webkit-details-marker { display: none; }
.gate-alt > summary::marker { content: ""; }
.gate-alt > summary:hover { color: var(--ink); border-bottom-color: var(--ink-3); }
.gate-alt > summary::after { content: "▾"; font-size: 9px; color: var(--ink-4); }
.gate-alt[open] > summary::after { content: "▴"; }
.gate-alt-body { padding-top: var(--sp-4); }

.gate-note { margin-top: var(--sp-4); font-size: var(--fs-2); line-height: var(--lh-body); color: var(--ink-3); max-width: 46ch; }
.gate-note strong { color: var(--ink-2); font-weight: 600; }

.gate-promise {
  display: flex; gap: var(--sp-2); align-items: flex-start;
  margin-top: var(--sp-5); padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  font-size: var(--fs-2); line-height: var(--lh-body); color: var(--ink-3);
  max-width: 48ch;
}
.gate-promise .dot { margin-top: 7px; background: var(--accent); }
.gate-promise b { color: var(--ink-2); font-weight: 600; }

.gate-foot {
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
  text-align: center;
  font-size: var(--fs-1); color: var(--ink-4);
}

.gate-sent { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: var(--sp-4); }
.gate-sent p { font-size: var(--fs-3); line-height: var(--lh-body); color: var(--ink-2); }
.gate-sent strong { color: var(--ink); }
.gate-error {
  margin-bottom: var(--sp-4); padding: 10px 12px;
  border: 1px solid var(--danger); border-radius: var(--r);
  background: var(--danger-bg); color: var(--danger); font-size: var(--fs-3);
}

.wordmark { font: 600 var(--fs-6)/1 var(--mark); letter-spacing: -.024em; }

/* invite landing */
.join-steps { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.join-steps h2 { font-size: var(--fs-2); font-weight: 600; margin-bottom: var(--sp-2); }
.join-steps ol { padding-left: var(--sp-4); color: var(--ink-2); font-size: var(--fs-2); line-height: 1.75; }

/* ==========================================================================
   14. Narrow — down to 375px
   ========================================================================== */

@media (max-width: 1080px) {
  :root { --rail: 272px; --gutter: 24px; }
}

@media (max-width: 900px) {
  :root { --gutter: 16px; --topbar: 50px; }

  body.today { overflow: auto; }

  /* the rail stacks under the subject */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; height: auto; }
  .stream { border-right: 0; grid-template-rows: auto auto auto; }
  .rail { border-top: 1px solid var(--line); }
  .feed { overflow: visible; }
  .column { max-width: none; }
  .pagehead { padding-top: var(--sp-5); }

  .ask { position: sticky; bottom: 0; z-index: 2; margin: 0 var(--gutter) var(--sp-3); }
  .fi { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }

  /* the graph keeps a real canvas area and its rail goes below */
  .gshell { height: auto; }
  .gbody { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
  .stage { height: 58dvh; min-height: 320px; border-right: 0; }
  .ghead { padding: var(--sp-3) var(--gutter); }
  .gtools { margin-left: 0; width: 100%; }
  .search input, .search input:focus { width: 100%; }
  .search { flex: 1 1 160px; }
  .who { display: none; }

  /* the node detail becomes a bottom sheet */
  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-width: none; max-height: 78dvh;
    border-left: 0; border-top: 1px solid var(--line-2);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: sheet-up .2s ease;
  }
  @keyframes sheet-up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
}

@media (max-width: 620px) {
  :root { --fs-7: 24px; --fs-8: 29px; }

  .bar { gap: var(--sp-1); padding: 0 var(--sp-2) 0 var(--sp-3); }
  .mark { font-size: 13px; gap: 6px; padding: 5px; }
  .nav { margin-left: 2px; gap: 0; }
  .nav-link { padding: 0 9px; font-size: var(--fs-2); }
  .nav-link.is-active::after { left: 9px; right: 9px; }
  .nav-link.is-secondary { display: none; }
  .bar-link.is-secondary { display: none; }
  .usermenu-pop { width: min(268px, calc(100vw - 24px)); }

  .gate-main { padding: var(--sp-5) var(--sp-4) var(--sp-6); }
  .gate-bar { padding: var(--sp-4) var(--sp-4) 0; }
  .gate-block { padding: var(--sp-4); }
  .gate-lede { font-size: var(--fs-4); margin-bottom: var(--sp-5); }
  .field-code { font-size: 19px; letter-spacing: .26em; text-indent: .26em; }

  .rail { padding: var(--sp-4) var(--gutter) var(--sp-6); }
  .stage-legend { position: static; padding: var(--sp-2) var(--gutter); }
  .stage-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   Life areas — the first ring of the context graph, and its checklist in the rail.
   -------------------------------------------------------------------------- */

:root {
  --node-area:      #2f6157;   /* a filled area shares the accent: it is the agent's own knowledge */
  --node-ghost:     #ececef;   /* an empty one is barely there */
  --node-ghost-ink: #9a9aa3;
}

.stage-legend i.is-ghost { background: transparent; border: 1px dashed var(--node-ghost-ink); }

.areas { display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; }
.area-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--r-sm); border: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: var(--fs-3); text-align: left; cursor: pointer;
  transition: background .12s;
}
.area-row:hover { background: var(--hover); }
.area-row.is-active { background: var(--accent-bg); }
.area-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.area-ic {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
}
.area-row.is-ghost .area-ic { background: transparent; color: var(--node-ghost-ink);
                              border: 1px dashed var(--node-ghost-ink); }
.area-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-row.is-ghost .area-label { color: var(--ink-3); }
.area-count { font-size: var(--fs-1); color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.area-row.is-ghost .area-count { color: var(--ink-4); font-style: italic; }

.panel-why { font-size: var(--fs-3); color: var(--ink-2); line-height: var(--lh-body); margin-top: var(--sp-2); }
.panel-invite {
  margin-top: var(--sp-4); padding: var(--sp-4);
  border: 1px dashed var(--line-3); border-radius: var(--r-lg);
  background: var(--bg-2);
}
.panel-invite h3 { font-size: var(--fs-4); font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px; }
.panel-invite p { font-size: var(--fs-3); color: var(--ink-2); line-height: var(--lh-body); margin: 0; }
.panel-opener { margin-top: 10px !important; color: var(--ink-3) !important; font-style: italic; }
.panel-invite .btn { margin-top: var(--sp-3); }
.panel-invite .btn.is-done { background: var(--accent); }


/* --------------------------------------------------------------------------
   Icons — the shared monoline set from _icons.html. An icon sits beside a
   word at 15–16px, takes the text's colour, and never carries meaning alone.
   -------------------------------------------------------------------------- */
.ic { flex: 0 0 auto; display: inline-block; vertical-align: -3px; }
.nav-link { gap: 7px; }
.nav-link .ic { color: var(--ink-4); transition: color .12s; }
.nav-link:hover .ic { color: var(--ink-2); }
.nav-link.is-active .ic { color: var(--accent); }
/* section headings and card titles that lead with a glyph */
.h-ic { display: inline-flex; align-items: center; gap: 8px; }
.h-ic .ic { color: var(--ink-3); }
/* a small framed tile for a brand or a glyph, used in lists */
.tile {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--sunk); color: var(--ink-2);
  border: 1px solid color-mix(in srgb, var(--ink) 6%, transparent);
  overflow: hidden;
}
.tile img { width: 22px; height: 22px; object-fit: contain; display: block; }
.tile.is-img { background: var(--surface); }
