/* ------------------------------------------------------------------ base */
:root {
  --bg: #fbfbfb;
  --surface: #ffffff;
  --surface-2: #f2f2f3;
  --line: #e8e8ea;
  --line-strong: #d8d8db;
  --ink: #121214;
  --ink-2: #5b5b60;
  --ink-3: #98989e;
  /* the only hue in the app, kept for live data and real actions */
  --accent: #1963e3;
  --accent-soft: rgba(25, 99, 227, 0.10);
  --on-accent: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-1: 0 1px 2px rgba(20, 20, 26, 0.04), 0 2px 8px rgba(20, 20, 26, 0.04);
  --shadow-2: 0 2px 6px rgba(20, 20, 26, 0.06), 0 18px 44px rgba(20, 20, 26, 0.10);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/*
 * Theme follows the system until the toggle sets data-theme on <html>, after
 * which the explicit choice wins. Both paths land on the same tokens.
 */
:root[data-theme='dark'] {
  --bg: #0c0c0d;
  --surface: #151517;
  --surface-2: #1d1d20;
  --line: #26262a;
  --line-strong: #34343a;
  --ink: #f3f3f4;
  --ink-2: #a6a6ac;
  --ink-3: #6f6f77;
  --accent: #4d8dff;
  --accent-soft: rgba(77, 141, 255, 0.14);
  --on-accent: #06070a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0c0c0d;
    --surface: #151517;
    --surface-2: #1d1d20;
    --line: #26262a;
    --line-strong: #34343a;
    --ink: #f3f3f4;
    --ink-2: #a6a6ac;
    --ink-3: #6f6f77;
    --accent: #4d8dff;
    --accent-soft: rgba(77, 141, 255, 0.14);
    --on-accent: #06070a;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 460px at 50% -8%, color-mix(in srgb, var(--ink) 4%, transparent), transparent 70%),
    radial-gradient(900px 400px at 92% 104%, color-mix(in srgb, var(--ink) 3%, transparent), transparent 70%);
  transition: background 700ms var(--ease);
}

/* No header bar: the two controls float over the page and nothing else does. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.back, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  border: 1px solid transparent;
  transition: background 200ms var(--ease), color 200ms var(--ease), border-color 200ms var(--ease), opacity 300ms var(--ease), transform 200ms var(--ease);
}
.icon-btn { width: 34px; padding: 0; justify-content: center; }
.back:hover, .icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.back[hidden] { display: none; }
.back.ghost { opacity: 0; pointer-events: none; }

/* ------------------------------------------------------------------ app */
.app {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 62px 22px 220px;
  min-height: 60vh;
}

.view { animation: view-in 520ms var(--ease) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px) scale(0.994); }
  to   { opacity: 1; transform: none; }
}

.hero {
  text-align: center;
  padding: 12vh 0 34px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.44em;
  color: var(--ink-3);
  text-indent: 0.44em;
}
.hero p {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
}

/* -------------------------------------------------------- aspect tiles -- */
.aspect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
}

.aspect-tile {
  position: relative;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  animation: tile-in 560ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 65ms);
  transition: transform 320ms var(--ease), box-shadow 320ms var(--ease), border-color 320ms var(--ease);
}
@keyframes tile-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.aspect-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%);
  opacity: 0;
  transition: opacity 320ms var(--ease);
  pointer-events: none;
}
.aspect-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.aspect-tile:hover::after { opacity: 1; }
.aspect-tile:active { transform: translateY(-1px) scale(0.995); }

.aspect-tile .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.aspect-tile h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.aspect-tile .pct { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.aspect-tile .meta { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); }

.bar {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 10px;
}
.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--v, 0%);
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left;
  animation: bar-grow 900ms var(--ease) both;
  animation-delay: 120ms;
}
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bar.lg { height: 9px; }

.add-tile {
  display: grid;
  place-items: center;
  min-height: 88px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  background: transparent;
  transition: color 260ms var(--ease), border-color 260ms var(--ease), background 260ms var(--ease), transform 260ms var(--ease);
  animation: tile-in 560ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 65ms);
}
.add-tile:hover { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }

/* ------------------------------------------------------- aspect detail -- */
.aspect-band {
  position: relative;
  border-radius: 22px;
  padding: 22px 24px;
  margin-bottom: 22px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 5%, var(--surface)), var(--surface));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  animation: view-in 520ms var(--ease) both;
}
.aspect-band .head {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.aspect-band h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 620;
  letter-spacing: -0.02em;
}
.aspect-band .pct { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.aspect-band .mission { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; max-width: 68ch; }
.aspect-band .bar { max-width: 420px; }
.aspect-band .band-actions { position: absolute; top: 18px; right: 18px; display: flex; gap: 6px; }

.group {
  margin: 26px 0 8px;
  animation: view-in 520ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 4px 12px;
}
.group-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.group-head .rule { flex: 1; height: 1px; background: var(--line); }
.group-head .pct { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.group-head .desc {
  font-size: 12px;
  color: var(--ink-3);
  max-width: 48%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px 16px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  animation: tile-in 520ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
  transition: transform 320ms var(--ease), box-shadow 320ms var(--ease), border-color 320ms var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.edited {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
}
.chev { color: var(--ink-3); display: inline-flex; transition: transform 320ms var(--ease), color 200ms var(--ease); }
.card:hover .chev { color: var(--ink-2); }
.card:hover .chev { color: var(--accent); transform: translate(1px, -1px); }

.status { flex: none; display: grid; justify-items: end; gap: 4px; align-self: center; }
.via { font-size: 10px; color: var(--ink-3); white-space: nowrap; }

.meta-line { margin-top: 5px; font-size: 11px; color: var(--ink-3); }

.modal-mission { margin: 12px 0 2px; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.tags.left { justify-content: flex-start; max-width: 100%; margin-top: 2px; }
.card-grid.wide { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-top: 16px; }

/* deliberately quiet: present, but never the point of the dialog */
.quiet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  opacity: 0.35;
  transition: opacity 260ms var(--ease);
}
.quiet-actions:hover { opacity: 1; }
.quiet-actions .sep { color: var(--ink-3); font-size: 11px; }
.quiet {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.quiet:hover { color: var(--ink-2); border-color: var(--line-strong); }
.quiet.danger:hover { color: var(--ink); border-color: var(--ink); }

.today {
  flex: none;
  align-self: flex-start;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 550;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.today.on {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h4 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-head .sub { margin-top: 2px; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  max-width: 58%;
}
.tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--ink);
  color: var(--on-accent);
  border: 1px solid var(--ink);
}
/* the three kinds read as fill, outline and mute rather than as hues */
.tag[data-t="manual review"] { background: transparent; color: var(--ink); }
.tag[data-t="manual intervention"] { background: var(--surface-2); color: var(--ink-2); border-color: var(--line-strong); }

.mission {
  margin: 10px 0 0;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.panel {
  text-align: left;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 11px 10px;
  transition: background 240ms var(--ease), border-color 240ms var(--ease), transform 240ms var(--ease);
}
button.panel:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--surface-2)); }
button.panel:active { transform: scale(0.985); }

.panel .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.panel .body { margin-top: 6px; font-size: 12.5px; color: var(--ink); min-height: 34px; }
.panel .body.muted { color: var(--ink-3); }

.dots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.dot {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-2);
}

.spark { display: block; width: 100%; height: 34px; margin-top: 6px; overflow: visible; }
.spark path.line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 400);
  stroke-dashoffset: var(--len, 400);
  animation: draw 1100ms var(--ease) forwards;
  animation-delay: 200ms;
}
.spark path.area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; opacity: 0; animation: fade-in 700ms var(--ease) 500ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.seg button {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--ink-3);
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.steps-panel .count { font-size: 20px; font-weight: 620; letter-spacing: -0.02em; }
.steps-panel .count small { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 4px; letter-spacing: 0; }

.locked {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
}
.locked svg { flex: none; }

/* Editing controls stay out of the way until you are actually on the thing. */
.aspect-band .band-actions,
.group-head .mini {
  opacity: 0;
  transition: opacity 220ms var(--ease), color 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease);
}
.aspect-band:hover .band-actions,
.aspect-band:focus-within .band-actions,
.group:hover .group-head .mini,
.group-head:focus-within .mini,
.mini:focus-visible { opacity: 1; }
.mini {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: color 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease);
}
.mini:hover { color: var(--ink); border-color: var(--line-strong); }
.mini.danger:hover { color: var(--ink); border-color: var(--ink); }
.mini:active { transform: scale(0.9); }

/* dashed "add" affordances: a card at the end of a process grid, a row under a view */
.add-card, .add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-3);
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  transition: color 260ms var(--ease), border-color 260ms var(--ease), background 260ms var(--ease), transform 260ms var(--ease);
}
.add-card {
  min-height: 132px;
  flex-direction: column;
  gap: 6px;
  animation: tile-in 520ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.add-row {
  width: 100%;
  height: 52px;
  margin-top: 22px;
  border-radius: var(--radius-sm);
}
.add-card:hover, .add-row:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}
.add-card:active, .add-row:active { transform: translateY(0) scale(0.99); }

.gen-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
}
.gen-note svg { color: var(--accent); flex: none; margin-top: 2px; }

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.empty strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; font-weight: 600; }

/* ---------------------------------------------------------------- modal */
.modal-root { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.modal-root[hidden] { display: none; }
.modal-scrim {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 34%, transparent);
  backdrop-filter: blur(3px);
  animation: fade-in 260ms var(--ease) both;
}
.modal-root.closing .modal-scrim { animation: fade-out 200ms var(--ease) both; }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

.modal {
  position: relative;
  width: min(860px, 100%);
  max-height: min(84vh, 860px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-2);
  padding: 22px;
  animation: modal-in 380ms var(--ease) both;
}
.modal-root.closing .modal { animation: modal-out 200ms var(--ease) both; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes modal-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(8px) scale(0.985); }
}

/* ------------------------------------------------- one-field dialogs -- */
.modal.compact {
  width: min(430px, 100%);
  padding: 22px 24px 20px;
  border-radius: 20px;
}
.modal .close.floating { position: absolute; top: 14px; right: 14px; }

.overline {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.name-input {
  width: 100%;
  margin-top: 10px;
  padding: 6px 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  font-size: 23px;
  font-weight: 560;
  letter-spacing: -0.015em;
  outline: none;
  transition: border-color 260ms var(--ease);
}
.name-input::placeholder { color: var(--ink-3); font-weight: 420; }
.name-input:focus { border-color: var(--accent); }

.confirm-line { margin: 12px 0 0; font-size: 13.5px; color: var(--ink-2); }

.form-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.form-foot .note { flex: 1; font-size: 11px; color: var(--ink-3); }
.form-foot .btn { height: 34px; padding: 0 18px; }
/* destructive confirm is never the accent: the accent means go, not undo */
.modal .btn.danger-fill { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.modal .btn.danger-fill:hover { filter: none; opacity: 0.86; }

.modal h3 { margin: 0; font-size: 17px; font-weight: 620; letter-spacing: -0.01em; }
.modal .modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.modal .modal-head.bare { margin-bottom: 18px; }
.modal .modal-sub { color: var(--ink-3); font-size: 12.5px; margin: 2px 0 16px; }
.modal .close { width: 30px; height: 30px; border-radius: 10px; color: var(--ink-3); }
.modal .close:hover { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------------------ step rows */
.step-card {
  padding: 15px 0 16px;
  border-top: 1px solid var(--line);
  animation: row-in 420ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.step-card:first-child { border-top: 0; padding-top: 6px; }
@keyframes row-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.step-head { display: flex; align-items: flex-start; gap: 12px; }
.step-idx {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.step-title { flex: 1; min-width: 0; }
.step-name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.step-desc { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }

/* the four facts, aligned in columns so the eye can scan down one of them */
.step-facts {
  display: grid;
  grid-template-columns: 1.3fr 1.4fr 1fr 1fr;
  gap: 6px 18px;
  margin: 11px 0 0 34px;
}
.fact { display: grid; gap: 2px; min-width: 0; }
.fact-label {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fact-value {
  font-size: 12.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.fact-value .dim { color: var(--ink-3); }

.blocker-line { margin: 10px 0 0 34px; font-size: 11.5px; color: var(--ink-2); }

@media (max-width: 620px) {
  .step-facts { grid-template-columns: 1fr 1fr; }
}

/* history grid */
.hist-wrap { overflow-x: auto; padding-bottom: 4px; }
.hist {
  border-collapse: separate;
  border-spacing: 3px;
  font-size: 11px;
  min-width: 100%;
}
.hist th { font-weight: 550; color: var(--ink-3); text-align: center; font-size: 9.5px; letter-spacing: 0.02em; padding-bottom: 2px; }
.hist th.step-col { text-align: left; min-width: 170px; position: sticky; left: 0; background: var(--surface); z-index: 2; }
.hist td.step-col {
  text-align: left;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
  padding-right: 10px;
}
.hist td.step-col small { color: var(--ink-3); font-size: 10.5px; margin-left: 6px; }
.cell {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: block;
  animation: cell-in 420ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 8ms);
  transition: transform 180ms var(--ease);
}
.cell:hover { transform: scale(1.16); }
@keyframes cell-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.hist tfoot td { color: var(--ink-3); font-size: 10px; text-align: center; }

.chartbox {
  margin: 16px 0 6px;
  padding: 14px 14px 6px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.chart { display: block; width: 100%; height: 130px; overflow: visible; }
.chart .grid-line { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis { fill: var(--ink-3); font-size: 9px; }
.chart .bar-col { fill: color-mix(in srgb, var(--accent) 26%, transparent); transition: fill 200ms var(--ease); }
.chart .bar-col:hover { fill: var(--accent); }

/* forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; font-weight: 620; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }
.field input[type="text"], .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  outline: none;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease), background 200ms var(--ease);
}
.field textarea { min-height: 74px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 580;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  transition: transform 180ms var(--ease), background 200ms var(--ease), border-color 200ms var(--ease), opacity 200ms var(--ease);
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

pre.code {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--ink);
}
.token-row { display: flex; gap: 8px; align-items: center; }
.token-row code {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--ink-3); display: inline-block; margin-right: 6px; }
.status-dot.on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ------------------------------------------------------------ ask dock */
.ask-dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 0);
  transition: transform 720ms var(--ease);
  width: min(620px, calc(100% - 32px));
  z-index: 30;
  padding-bottom: 22px;
  text-align: center;
}
/*
 * The fade behind the dock spans the whole viewport, not the dock's own box, so
 * it cannot leave vertical seams at its edges. The stops are eased rather than
 * linear so there is no visible band where the gradient meets the background.
 */
.dock-veil {
  transition: opacity 520ms var(--ease);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 240px;
  z-index: 25;
  pointer-events: none;
  background: linear-gradient(
    to top,
    var(--bg) 0%,
    color-mix(in srgb, var(--bg) 99%, transparent) 26%,
    color-mix(in srgb, var(--bg) 92%, transparent) 44%,
    color-mix(in srgb, var(--bg) 72%, transparent) 60%,
    color-mix(in srgb, var(--bg) 40%, transparent) 76%,
    color-mix(in srgb, var(--bg) 14%, transparent) 88%,
    transparent 100%
  );
}
.ask-label { font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; font-weight: 550; }
.ask-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 5px 5px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
  transition: box-shadow 300ms var(--ease), border-color 300ms var(--ease), transform 300ms var(--ease);
}
.ask-form:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.ask-form input { flex: 1; border: 0; background: transparent; outline: none; height: 36px; font-size: 13.5px; }
.ask-form input::placeholder { color: var(--ink-3); }
#ask-send {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  transition: transform 200ms var(--ease), opacity 200ms var(--ease);
}
#ask-send:active { transform: scale(0.92); }
#ask-send.busy { opacity: 0.6; pointer-events: none; }
#ask-send.busy svg { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ask-hints-wrap {
  position: relative;
  margin-top: 9px;
  padding: 0 22px;
  animation: hints-in 460ms var(--ease) both;
}
.ask-hints-wrap[hidden] { display: none; }
.ask-hints-wrap.leaving { animation: hints-out 400ms var(--ease) both; }
@keyframes hints-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes hints-out { to { opacity: 0; transform: translateY(6px); filter: blur(2px); } }

.hints-dismiss {
  position: absolute;
  top: -2px;
  right: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease), color 200ms var(--ease);
}
.ask-hints-wrap:hover .hints-dismiss, .hints-dismiss:focus-visible { opacity: 1; transform: none; }
.hints-dismiss:hover { color: var(--ink); border-color: var(--line-strong); }

.ask-hints { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ask-hints .hint { animation: hints-in 460ms var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
.hint {
  font-size: 11px;
  color: var(--ink-3);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  transition: color 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease);
}
.hint:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }

.ask-answer {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-2);
  max-height: 46vh;
  overflow: auto;
  animation: answer-in 420ms var(--ease) both;
}
@keyframes answer-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.ask-answer .meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.ask-answer p { margin: 0; font-size: 13.5px; line-height: 1.6; }
.ask-answer ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 12.5px; }
.ask-answer .dismiss { position: absolute; }

/* ---------------------------------------------------------------- toast */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; }
.toast {
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  box-shadow: var(--shadow-2);
  animation: toast-in 320ms var(--ease) both;
}
.toast.out { animation: toast-out 260ms var(--ease) both; }
.toast.warn { background: var(--ink); color: var(--bg); border: 1px solid var(--line-strong); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(0.96); } }

@media (max-width: 620px) {
  .app { padding: 6px 14px 240px; }
  .process-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .hero { padding: 8vh 0 26px; }
  .modal { padding: 18px; border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

.dock-veil.hidden { opacity: 0; }

/* ------------------------------------------------------------ characters */
/*
 * Line art on transparent PNGs, deliberately still. In dark mode the whole
 * image is inverted, which turns black strokes white and white fills black,
 * so one asset serves both themes.
 */
.chr {
  display: block;
  height: auto;
  max-width: 100%;
  user-select: none;
  pointer-events: none;
}
:root[data-theme='dark'] .chr { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .chr { filter: invert(1); }
}

/* placements */
.hero .chr { margin: 0 auto 14px; }
.empty .chr { margin: 0 auto 14px; }
.empty { display: block; }

.modal-head .titled { display: flex; align-items: center; gap: 10px; }
.modal-head .titled .chr { flex: none; }

.thinking-row { display: flex; align-items: center; gap: 12px; }
.thinking-row .chr { flex: none; }

.topbar-right { display: flex; align-items: center; gap: 6px; }

/* ----------------------------------------------------- occurrence states */
.today.s-met     { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.today.s-open    { color: var(--ink); background: var(--surface-2); border-color: var(--line-strong); }
.today.s-missed  { color: var(--ink-2); background: transparent; border-style: dashed; }
.today.s-skipped,
.today.s-not_due { color: var(--ink-3); background: transparent; border-color: var(--line); }

.cell.c-met      { background: var(--accent); border-color: transparent; }
.cell.c-open     { background: var(--surface-2); border-color: var(--line-strong); }
.cell.c-missed   { background: transparent; border-style: dashed; border-color: var(--line-strong); }
.cell.c-skipped  { background: var(--surface-2); border-color: var(--line); opacity: 0.6; }
.cell.c-not_due  { background: transparent; border-color: transparent; }

.lock-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  white-space: nowrap;
}
.blocker-line { margin-top: 5px; font-size: 11px; color: var(--ink-2); }
.spark-empty { font-size: 11px; color: var(--ink-3); padding: 8px 0 2px; }
.chart .bar-none { fill: var(--line-strong); }

/* ------------------------------------------------------------- the guide */
.doc {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  max-width: 980px;
  margin: 0 auto;
}

.doc-nav {
  position: sticky;
  top: 74px;
  display: grid;
  gap: 14px;
  padding-bottom: 40px;
}
.doc-nav-title {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.doc-nav-group { display: grid; gap: 2px; }
.doc-nav a {
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 3px 0;
  border-left: 2px solid transparent;
  padding-left: 10px;
  margin-left: -12px;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.doc-nav a.sub { font-size: 12px; color: var(--ink-3); padding-left: 22px; }
.doc-nav a:hover { color: var(--ink); }
.doc-nav a.on { color: var(--accent); border-left-color: var(--accent); }

.doc-body { min-width: 0; padding-bottom: 60px; }
.doc-section { scroll-margin-top: 84px; padding: 26px 0 6px; border-top: 1px solid var(--line); }
.doc-section:first-child { border-top: 0; padding-top: 6px; }
.doc-section h2 {
  margin: 0 0 12px;
  font-size: 21px;
  font-weight: 620;
  letter-spacing: -0.02em;
}
.doc-section h3 {
  margin: 22px 0 8px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.doc-section p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); max-width: 74ch; }
.doc-section p.lede { font-size: 14.5px; color: var(--ink); }
.doc-section code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
.doc-section code.wrap { white-space: normal; }

.doc-code { margin: 0 0 14px; max-height: 420px; overflow: auto; }

.doc-facts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.doc-facts > div {
  display: grid;
  gap: 3px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.doc-facts span { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

.doc-urls { display: grid; gap: 8px; }
.doc-url {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.doc-url > span { font-size: 11px; color: var(--ink-3); min-width: 74px; }
.doc-url code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-url .btn { height: 28px; padding: 0 12px; font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; }

.doc-table-wrap { overflow-x: auto; margin: 0 0 14px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.doc-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 650;
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.doc-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.doc-table td:first-child { color: var(--ink); white-space: nowrap; }
.doc-table td.ty { color: var(--accent); font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px; }
.doc-table .muted { color: var(--ink-3); }

.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.doc-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease);
}
.doc-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.doc-card code { font-size: 13px; color: var(--ink); font-weight: 600; }
.doc-card span { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }

.doc-list { margin: 0 0 14px; padding-left: 18px; display: grid; gap: 7px; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.doc-list code { color: var(--ink); }
.doc-list.rules li { color: var(--ink); }

.doc-eg { font-weight: 550; color: var(--ink) !important; margin-bottom: 6px !important; }
.doc-step { display: flex; gap: 10px; align-items: baseline; color: var(--ink) !important; }
.doc-step > span {
  flex: none;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.doc-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-3);
  transition: border-color 200ms var(--ease), background 200ms var(--ease), color 200ms var(--ease);
}
.doc-link-row:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.doc-link-row strong { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.doc-link-row em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }

@media (max-width: 760px) {
  .doc { grid-template-columns: 1fr; gap: 18px; }
  .doc-nav { position: static; grid-auto-flow: row; }
}

body.reading .ask-dock,
body.reading .dock-veil {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms var(--ease);
}

/* -------------------------------------------------------- busy feedback */
.spinner {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  opacity: 0.85;
  animation: spin 720ms linear infinite;
}
.btn[disabled] .spinner { opacity: 1; }
.btn .spinner + span { margin-left: 2px; }
.btn:has(.spinner) { display: inline-flex; align-items: center; gap: 7px; justify-content: center; }

/* while a write is in flight, nothing else in the dialog is clickable */
.modal.busy [data-close],
.modal.busy .quiet,
.modal.busy .name-input { pointer-events: none; opacity: 0.45; }
.modal-root.busy .modal-scrim { cursor: progress; }

/* a label row that can carry its own action */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.field-head label { margin-bottom: 0; }
.btn.tiny { height: 26px; padding: 0 11px; font-size: 11.5px; }

/* ------------------------------------------------------------- sign in -- */

/* Nothing but the card until there is a session. */
body.signed-out .topbar,
body.signed-out .ask-dock,
body.signed-out .dock-veil { display: none; }

.signin {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.signin-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
}

.signin-mark {
  color: var(--accent);
  margin-bottom: 14px;
}

.signin-card h1 {
  margin: 0 0 26px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}

.signin-field { display: block; margin-bottom: 14px; }
.signin-field span {
  display: block;
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.signin-field input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.signin-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.signin-go { width: 100%; margin-top: 8px; }

.signin-error {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: #d6455a;
}
