:root {
  --bg: #f4f4f1;
  --paper: #ffffff;
  --ink: #111111;
  --ink-2: rgba(17, 17, 17, 0.7);
  --ink-3: rgba(17, 17, 17, 0.45);
  --rule: rgba(17, 17, 17, 0.14);
  --live: #2f9e5b;
  --sans: "Geist", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --bar-h: 36px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0e; --paper: #161616; --ink: #ededea;
    --ink-2: rgba(237, 237, 234, 0.7); --ink-3: rgba(237, 237, 234, 0.45);
    --rule: rgba(237, 237, 234, 0.16); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0e; --paper: #161616; --ink: #ededea;
  --ink-2: rgba(237, 237, 234, 0.7); --ink-3: rgba(237, 237, 234, 0.45);
  --rule: rgba(237, 237, 234, 0.16); color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }

/* Top bar */
.bar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 1000;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px; border-bottom: 1px solid var(--rule); background: var(--bg);
  font-size: 13px;
}
.bar-l, .bar-r { display: flex; gap: 20px; align-items: center; }
.bar a:hover { color: var(--ink-3); }
.wordmark { font-weight: 500; }
.status { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
#clock { font-size: 13px; font-variant-numeric: tabular-nums; }

/* Desktop */
.desk { position: fixed; inset: var(--bar-h) 0 0 0; }
.desk.grid::before {
  content: ""; position: absolute; inset: 0 16px; pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(255, 0, 0, 0.06) 0 calc((100% - 11 * 16px) / 12), transparent 0 calc((100% - 11 * 16px) / 12 + 16px));
}

.icon {
  position: absolute; left: var(--x); top: var(--y);
  width: 92px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  touch-action: none; user-select: none;
}
.icon svg { width: 40px; height: 48px; overflow: visible; }
.icon svg path { fill: var(--paper); stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.icon svg text { font: 500 8px var(--mono); fill: var(--ink); text-anchor: middle; letter-spacing: 0.04em; }
.icon span { font: 11px/1.2 var(--mono); padding: 2px 4px; text-align: center; }
.icon:hover span, .icon.active span { background: var(--ink); color: var(--bg); }
.icon.trash svg path { fill: none; }

.colophon { position: absolute; left: 16px; bottom: 12px; color: var(--ink-3); }

/* Windows */
.win {
  position: absolute; width: min(var(--w), calc(100vw - 32px));
  max-height: calc(100vh - var(--bar-h) - 32px);
  display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--ink);
}
.win[hidden] { display: none; }
.win-bar {
  display: flex; justify-content: space-between; align-items: center;
  height: 28px; padding: 0 4px 0 10px; border-bottom: 1px solid var(--ink);
  font: 11px var(--mono); letter-spacing: 0.02em; cursor: grab; touch-action: none; user-select: none;
}
.win.front .win-bar { background: var(--ink); color: var(--paper); }
.win-bar:active { cursor: grabbing; }
.close { width: 22px; height: 22px; font-size: 11px; }
.close:hover { opacity: 0.5; }
.win-body { padding: 16px 18px 20px; overflow: auto; }
.win-body > * + * { margin-top: 12px; }

.lede { font-size: 22px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 500; }
.meta { color: var(--ink-3); text-transform: uppercase; }

/* Tour + next-file CTAs */
.tour { padding-top: 8px; }
.tour .meta { padding-bottom: 6px; border-bottom: 1px solid var(--ink); }
.tour a, .next, .files a {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: baseline; gap: 8px;
  padding: 9px 8px; margin: 0 -8px; border-bottom: 1px solid var(--rule);
}
.tour a .mono:first-child, .next .mono:first-child { color: var(--ink-3); }
.tour a .mono:last-child, .next .mono:last-child { color: var(--ink-2); }
.tour a:hover, .next:hover, .files a:hover { background: var(--ink); color: var(--paper); }
.tour a:hover .mono, .next:hover .mono, .files a:hover .mono { color: var(--paper); }
.tour a.primary, .next.primary { background: var(--ink); color: var(--paper); border-bottom-color: var(--ink); }
.tour a.primary .mono, .next.primary .mono { color: var(--paper); }
.tour a.primary:hover, .next.primary:hover { opacity: 0.85; }
.next { margin-top: 20px; border-top: 1px solid var(--ink); grid-template-columns: 44px 1fr auto; }
.win-foot { padding: 0 18px 16px; }
.win-foot .next { margin-top: 0; }

/* team/ folder, Finder icon view */
.finder-bar {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center;
  height: 34px; padding: 0 12px; border-bottom: 1px solid var(--rule);
  font-size: 13px; font-weight: 500;
}
.finder-bar .mono { color: var(--ink-3); font-weight: 400; }
.finder { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 20px 8px; padding: 12px 0 20px; }
.finder-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.finder-item svg { width: 48px; height: 58px; overflow: visible; }
.finder-item svg path { fill: var(--paper); stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.finder-item svg text { font: 500 8px var(--mono); fill: var(--ink); text-anchor: middle; }
.finder-item .thumb { width: 48px; height: 58px; border: 1px solid var(--ink); overflow: hidden; display: block; }
.finder-item .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; filter: grayscale(1) contrast(1.08); display: block; }
.finder-item > span:last-child { font: 11px/1.2 var(--mono); padding: 2px 4px; }
.finder-item:hover > span:last-child, .finder-item:focus-visible > span:last-child { background: var(--ink); color: var(--paper); }

.files { list-style: none; border-top: 1px solid var(--ink); }
.files a { grid-template-columns: 130px 1fr auto; }
.files a .mono:last-child { color: var(--ink-3); text-transform: uppercase; }
.redact { background: var(--ink); color: transparent; user-select: none; line-height: 1; }
.files a:hover .redact { background: var(--paper); }
.withheld {
  width: 160px; height: 200px; display: flex; align-items: flex-end; padding: 10px;
  color: var(--ink-3); text-transform: uppercase; line-height: 1.4;
  background: repeating-linear-gradient(135deg, var(--rule) 0 1px, transparent 1px 7px);
  border: 1px solid var(--rule);
}

/* Figures */
figure + figure { margin-top: 28px; }
.fig { width: 100%; height: auto; display: block; overflow: visible; }
.fig rect, .fig path { fill: none; stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.fig .dash { stroke-dasharray: 3 3; stroke: var(--ink-3); }
.fig .fill { fill: var(--ink); }
.fig .faint { stroke: var(--ink-3); }
.fig .rule { stroke: var(--rule); }
.fig text.f { fill: var(--ink-3); }
.fig .head { fill: none; }
.fig text { font: 13px var(--sans); fill: var(--ink); }
.fig text.m { font: 9.5px var(--mono); letter-spacing: 0.06em; fill: var(--ink-3); }
.fig text.c { text-anchor: middle; }
.fig text.r { text-anchor: end; }
.fig text.inv { fill: var(--paper); }
figcaption { margin-top: 10px; font-size: 12px; color: var(--ink-2); }
figcaption .mono { margin-right: 6px; color: var(--ink); }

/* Ledger */
.ledger { width: 100%; border-collapse: collapse; font-size: 11.5px; line-height: 1.45; }
.ledger th { text-align: left; font-weight: 400; color: var(--ink-3); text-transform: uppercase; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--ink); }
.ledger td { vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--rule); }
.ledger td:first-child, .ledger td.ping { white-space: nowrap; color: var(--ink-2); }
.ledger td.ping { text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.ledger th:nth-child(3) { text-align: center; }
.ledger td.ready { width: 190px; color: var(--ink-2); }
.ledger td.ready b { font-weight: 500; color: var(--ink); display: block; }
.ledger td.ready em { font-style: normal; color: var(--ink-3); }
.ledger tr.warn td.ready b { text-decoration: line-through; color: var(--ink-3); }
.ask { display: block; }
.ask-2 { display: block; margin-top: 2px; color: var(--ink-3); }
.depth { margin-top: 6px; padding: 1px 6px; border: 1px solid var(--ink); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.depth::after { content: " +"; }
.depth[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
.depth[aria-expanded="true"]::after { content: " −"; }
.steps { margin: 8px 0 2px; padding: 0; list-style: none; counter-reset: s; border-left: 1px solid var(--ink); }
.steps li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; padding: 3px 0 3px 10px; font-size: 12.5px; color: var(--ink-2); }
.steps li::before { content: counter(s, decimal-leading-zero); font: 10.5px/1.7 var(--mono); color: var(--ink-3); }
.steps li:last-child { color: var(--ink); }
.ledger td:nth-child(2) { font-family: var(--sans); font-size: 13px; letter-spacing: 0; }
.ledger tr.open td { color: var(--ink-3); }
.ledger tbody tr { opacity: 0; }
.ledger tbody tr.in { opacity: 1; transition: opacity 0.25s; }
blockquote { font-size: 17px; line-height: 1.3; letter-spacing: -0.01em; }
blockquote.testimonial { border-left: 2px solid var(--ink); padding: 2px 0 2px 14px; margin: 4px 0 14px; }
blockquote .tag { display: block; margin-bottom: 8px; text-transform: uppercase; color: var(--ink-3); }
blockquote p { font-size: 19px; font-weight: 500; letter-spacing: -0.015em; }
blockquote cite { display: block; margin-top: 6px; line-height: 1.3; font-style: normal; color: var(--ink-3); }
blockquote cite .improve { display: block; margin-top: 7px; color: color-mix(in srgb, var(--ink) 90%, transparent); }

/* Rules */
.rules { padding-left: 0; list-style: none; counter-reset: r; }
.rules li { counter-increment: r; display: grid; grid-template-columns: 28px 1fr; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.rules li::before { content: counter(r, decimal-leading-zero); font: 11px/1.9 var(--mono); color: var(--ink-3); }
.rules.plain li::before { content: "—"; }

/* CV */
.cv { display: grid; grid-template-columns: 160px 1fr; gap: 18px; align-items: start; }
.cv > * + * { margin-top: 0; }
.cv > div > * + * { margin-top: 10px; }
.cv img { width: 160px; height: 200px; object-fit: cover; object-position: 50% 40%; filter: grayscale(1) contrast(1.08); display: block; }
.cv dl { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; padding-top: 8px; border-top: 1px solid var(--rule); }
.cv dt { color: var(--ink-3); text-transform: uppercase; }
.cv dd { font: 13px/1.4 var(--sans); letter-spacing: 0; }

/* Terms */
.terms { display: grid; grid-template-columns: 80px 1fr; }
.terms dt, .terms dd { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.terms dt { color: var(--ink-3); text-transform: uppercase; line-height: 1.9; }
.terms dd:first-of-type { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }

/* Form */
form label { display: block; }
form label + label { margin-top: 12px; }
form label span { display: block; color: var(--ink-3); text-transform: uppercase; margin-bottom: 4px; }
input, textarea {
  width: 100%; font: 15px var(--sans); color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--ink); padding: 4px 0; border-radius: 0; resize: vertical;
}
input:focus, textarea:focus { outline: none; border-bottom-width: 2px; }
.submit { margin-top: 18px; width: 100%; padding: 10px; background: var(--ink); color: var(--paper); text-align: left; }
.submit:hover { opacity: 0.85; }
form .meta { margin-top: 10px; }

/* Trash */
.trashlist { list-style: none; }
.trashlist li { padding: 6px 0; border-bottom: 1px solid var(--rule); text-decoration: line-through; text-decoration-thickness: 1px; color: var(--ink-2); }

:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

/* Phone: desktop becomes a file list, windows become sheets */
@media (max-width: 720px) {
  body { overflow: auto; }
  .desk { position: static; padding: calc(var(--bar-h) + 16px) 16px 48px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 8px; align-content: start; min-height: 100vh; }
  .icon { position: static; width: auto; }
  .icon span { font-size: 10px; word-break: break-all; }
  .bar-l a:not(.wordmark):not(:last-child) { display: none; }
  .status { display: none; }
  .win { position: fixed; left: 0 !important; top: var(--bar-h) !important; width: 100%; max-height: none; height: calc(100% - var(--bar-h)); border: 0; border-top: 1px solid var(--ink); z-index: 900 !important; }
  .win-bar { height: 40px; font-size: 12px; }
  .close { width: 40px; height: 40px; }
  .cv { grid-template-columns: 1fr; }
  .cv img, .withheld { width: 100%; height: 260px; }
  .files a { grid-template-columns: 1fr auto; }
  .files a span:nth-child(2) { grid-row: 2; grid-column: 1 / -1; }
  .ledger thead { display: none; }
  .ledger tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
  .ledger td { border: 0; padding: 0; }
  .ledger td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .colophon { position: static; grid-column: 1 / -1; margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; }
  .ledger tbody tr { opacity: 1; }
}

/* Draft EA files: hidden unless ?preview */
.win.draft, .finder-item.draft { display: none; }
.preview .finder-item.draft { display: flex; }
.preview .win.draft:not([hidden]) { display: flex; }
.draft-stamp { color: #b3261e; text-transform: uppercase; }

/* Header tooltips */
.ledger th { position: relative; white-space: nowrap; }
.tip {
  display: inline-grid; place-items: center; width: 14px; height: 14px; margin-left: 3px;
  border: 1px solid var(--ink-3); border-radius: 50%; font-size: 9px; line-height: 1; color: var(--ink-2);
  cursor: help; position: relative; vertical-align: 1px;
}
.tip-text {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 5;
  width: 210px; padding: 8px 10px; background: var(--ink); color: var(--paper);
  font: 12px/1.4 var(--sans); letter-spacing: 0; text-transform: none; text-align: left; white-space: normal;
  opacity: 0; pointer-events: none; transition: opacity 0.12s;
}
.tip-r .tip-text { left: auto; right: -4px; transform: none; }
.tip:hover .tip-text, .tip:focus .tip-text { opacity: 1; }
.tip:hover, .tip:focus { border-color: var(--ink); color: var(--ink); outline: none; }

/* Fig. 3 benchmark */
.bench { margin-top: 28px; }
.bench-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; border: 1px solid var(--ink); }
.bench-grid > div:not(.bench-vs) { padding: 12px 14px; }
.bench-grid > div:first-child { border-right: 1px solid var(--ink); }
.bench-grid > div:last-child { border-left: 1px solid var(--ink); }
.bench-vs { display: grid; place-items: center; padding: 0 12px; color: var(--ink-3); text-transform: uppercase; }
.bench-q { margin-top: 6px; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.bench-rule { margin-top: 12px; font-size: 15px; }

/* Superpower row */
.cv dt.power { color: var(--ink); }
.cv dd.power { font-weight: 500; }

.status.off .dot { background: var(--ink-3); animation: none; }

/* Next / Start rows: label and arrow closer to the file name's size */
.next .mono:first-child, .next .mono:last-child { font-size: 13px; }
.next { align-items: center; }

/* Readme story */
.story { margin: -4px 0 4px; }
.story canvas { display: block; width: 100%; height: 150px; cursor: pointer; touch-action: none; }
.story-cap { display: flex; justify-content: space-between; margin-top: 6px; text-transform: uppercase; color: var(--ink-3); }
#story-step { color: var(--ink); }

/* CTAs: only the arrow is filled, and it blinks */
.next, .next.primary { background: none; color: var(--ink); border-bottom-color: var(--rule); }
.next .mono:first-child, .next.primary .mono:first-child { color: var(--ink-3); }
.next .mono:last-child, .next.primary .mono:last-child {
  justify-self: end; padding: 1px 7px; background: var(--ink); color: var(--paper);
}
.next.blink .mono:last-child { animation: cta-blink 0.8s steps(1, end) 5; } /* ~4s, then stays solid */
.next:hover, .next.primary:hover { background: none; color: var(--ink); opacity: 1; }
.next:hover .mono:first-child { color: var(--ink-3); }
.next:hover .mono:last-child { animation: none; background: var(--ink); color: var(--paper); }
.next:hover span:nth-child(2) { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
@keyframes cta-blink { 50% { background: transparent; color: var(--ink); } }
@media (prefers-reduced-motion: reduce) { .next .mono:last-child, .next.blink .mono:last-child { animation: none; } }

/* Ledger hint: first "steps" button blinks for 3s */
.depth.blink { animation: depth-blink 0.6s steps(1, end) 5; }
@keyframes depth-blink { 0% { background: var(--ink); color: var(--paper); } 50% { background: none; color: var(--ink); } }
@media (prefers-reduced-motion: reduce) { .depth.blink { animation: none; } }

.cv.no-photo { grid-template-columns: 1fr; }
