/* antjanus.com — Spreadsheet UI (demo 074)
   The site is a workbook: every page is a sheet, every block is a merged range on a 12-column grid (A–L),
   rows are numbered in a gutter, and a formula bar reports what the focused cell "contains". */

:root {
  --cols: 12;
  --gutter: 3rem;
  --dock-h: 4.75rem;

  /* primitives */
  --slate-900: #161b22;
  --slate-700: #3d4652;
  --slate-600: #545e6b;
  --slate-300: #d5dae1;
  --slate-200: #e3e7ec;
  --slate-100: #eef1f4;
  --slate-50: #f6f8fa;
  --white: #ffffff;
  --brand: #364f6a;
  --brand-ink: #2a3f54;
  --gold-700: #8a5a06;
  --gold-100: #fff4d1;
  --blue-100: #e5eef8;
  --green-700: #1c6e52;
  --red-700: #a03227;

  /* semantic (light) */
  --ground: var(--slate-100);
  --cell: var(--white);
  --cell-alt: var(--slate-50);
  --head: #eceff3;
  --head-ink: var(--slate-600);
  --grid: var(--slate-200);
  --grid-strong: var(--slate-300);
  --ink: var(--slate-900);
  --ink-2: var(--slate-700);
  --muted: var(--slate-600);
  --sel: var(--brand);
  --sel-ink: var(--white);
  --sel-fill: rgba(54, 79, 106, 0.09);
  --link: var(--brand);
  --accent: var(--gold-700);
  --note: var(--gold-100);
  --note-edge: #d9b44a;
  --comment: var(--blue-100);
  --comment-edge: #7ea3cc;
  --ok: var(--green-700);
  --bad: var(--red-700);
  --code-bg: #f7f8fa;
  --inverse: var(--slate-900);
  --inverse-ink: #f1f4f8;
  --inverse-muted: #b9c3cf;
  --shadow: 0 1px 2px rgba(22, 27, 34, 0.08), 0 6px 18px rgba(22, 27, 34, 0.08);

  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-display: "Fraunces", Georgia, serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0b0e12;
    --cell: #14181e;
    --cell-alt: #181d24;
    --head: #1c222a;
    --head-ink: #a3aebb;
    --grid: #262d36;
    --grid-strong: #36404b;
    --ink: #e8edf3;
    --ink-2: #c7d0da;
    --muted: #9eaab8;
    --sel: #86a9d0;
    --sel-ink: #0b0e12;
    --sel-fill: rgba(134, 169, 208, 0.13);
    --link: #9dbde0;
    --accent: #e3b95c;
    --note: #2e2917;
    --note-edge: #a8872f;
    --comment: #17222f;
    --comment-edge: #4d739c;
    --ok: #57c49b;
    --bad: #f08b7f;
    --code-bg: #0f1318;
    --inverse: #e8edf3;
    --inverse-ink: #10141a;
    --inverse-muted: #3d4652;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0b0e12;
  --cell: #14181e;
  --cell-alt: #181d24;
  --head: #1c222a;
  --head-ink: #a3aebb;
  --grid: #262d36;
  --grid-strong: #36404b;
  --ink: #e8edf3;
  --ink-2: #c7d0da;
  --muted: #9eaab8;
  --sel: #86a9d0;
  --sel-ink: #0b0e12;
  --sel-fill: rgba(134, 169, 208, 0.13);
  --link: #9dbde0;
  --accent: #e3b95c;
  --note: #2e2917;
  --note-edge: #a8872f;
  --comment: #17222f;
  --comment-edge: #4d739c;
  --ok: #57c49b;
  --bad: #f08b7f;
  --code-bg: #0f1318;
  --inverse: #e8edf3;
  --inverse-ink: #10141a;
  --inverse-muted: #3d4652;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
html[data-zoom="90"] { font-size: 90%; }
html[data-zoom="115"] { font-size: 115%; }
html[data-zoom="130"] { font-size: 130%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.15; }
p { margin: 0 0 0.9em; }
p:last-child { margin-bottom: 0; }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: 3px solid var(--sel); outline-offset: 3px; border-radius: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 0.75rem; top: -4rem; z-index: 100; background: var(--sel); color: var(--sel-ink); padding: 0.6rem 1rem; font-weight: 600; }
.skip:focus { top: 0.75rem; }

/* ---------- title bar ---------- */
.titlebar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.55rem 1rem;
  background: var(--cell);
  border-bottom: 1px solid var(--grid);
}
.brand { display: inline-flex; align-items: center; gap: 0.65rem; color: var(--ink); text-decoration: none; min-width: 0; }
.brand svg { flex: none; width: 2.25rem; height: 2.25rem; }
.brand .wordmark { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; }
.brand .sheetname { color: var(--muted); font-weight: 400; white-space: nowrap; }
.titlebar .chip { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); border: 1px solid var(--grid); padding: 0.1rem 0.5rem; border-radius: 3px; white-space: nowrap; }
.titlebar .spacer { flex: 1; }
.find { display: flex; align-items: stretch; border: 1px solid var(--grid-strong); border-radius: 4px; background: var(--cell); overflow: hidden; }
.find input { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 0.9375rem; padding: 0.45rem 0.7rem; width: 14rem; min-width: 0; }
.find input::placeholder { color: var(--muted); }
.find input:focus-visible { outline-offset: -3px; }
.find button { border: 0; border-left: 1px solid var(--grid); background: var(--head); color: var(--ink); font: inherit; font-size: 0.875rem; font-weight: 600; padding: 0 0.8rem; cursor: pointer; min-height: 2.5rem; }
.iconbtn { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 1px solid var(--grid-strong); border-radius: 4px; background: var(--cell); color: var(--ink); cursor: pointer; }
.iconbtn:hover { background: var(--head); }
.iconbtn svg { width: 1.25rem; height: 1.25rem; }
.theme-dark-icon { display: none; }
:root[data-theme="dark"] .theme-dark-icon { display: block; }
:root[data-theme="dark"] .theme-light-icon { display: none; }

/* ---------- ribbon (primary nav) ---------- */
.ribbon { background: var(--cell); border-bottom: 1px solid var(--grid); padding: 0 1rem; }
.ribbon ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.ribbon a {
  display: block; padding: 0.7rem 0.9rem 0.6rem; color: var(--ink-2); text-decoration: none;
  font-size: 0.9375rem; font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap;
}
.ribbon a:hover { color: var(--ink); background: var(--head); }
.ribbon a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--sel); font-weight: 700; }
.ribbon a .ext { font-size: 0.8125rem; color: var(--muted); }

/* ---------- dock: formula bar + column heads (sticky) ---------- */
.dock { position: sticky; top: 0; z-index: 30; background: var(--cell); box-shadow: 0 1px 0 var(--grid-strong); }
.fxbar { display: flex; align-items: stretch; border-bottom: 1px solid var(--grid); min-height: 2.75rem; }
.namebox-wrap { position: relative; flex: none; width: 11.5rem; border-right: 1px solid var(--grid); }
.namebox {
  appearance: none; -webkit-appearance: none; width: 100%; height: 100%;
  border: 0; background: var(--cell); color: var(--ink); font-family: var(--font-mono); font-size: 0.875rem;
  padding: 0 1.8rem 0 0.75rem; cursor: pointer;
}
.namebox-wrap::after { content: "▾"; position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 0.875rem; }
.namebox:focus-visible { outline-offset: -3px; }
.cellref { flex: none; display: grid; place-items: center; min-width: 4.5rem; padding: 0 0.6rem; font-family: var(--font-mono); font-size: 0.875rem; color: var(--sel); font-weight: 600; border-right: 1px solid var(--grid); background: var(--sel-fill); }
.fx { flex: none; display: grid; place-items: center; width: 2.75rem; font-family: var(--font-display); font-style: italic; font-weight: 600; color: var(--muted); border-right: 1px solid var(--grid); }
.formula { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 0.85rem; font-family: var(--font-mono); font-size: 0.9375rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.formula .fn { color: var(--sel); font-weight: 600; }
.formula .str { color: var(--accent); }
.colheads { display: grid; grid-template-columns: var(--gutter) repeat(var(--cols), minmax(0, 1fr)); background: var(--head); }
.colheads span { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--head-ink); text-align: center; padding: 0.2rem 0; border-right: 1px solid var(--grid); }
.colheads span:first-child { background: var(--head); position: relative; }
.colheads span:first-child::after { content: ""; position: absolute; right: 3px; bottom: 3px; border: 5px solid transparent; border-right-color: var(--grid-strong); border-bottom-color: var(--grid-strong); }
.colheads span.on { background: var(--sel-fill); color: var(--sel); font-weight: 600; box-shadow: inset 0 -2px 0 var(--sel); }
.progress { position: absolute; left: 0; bottom: -1px; height: 3px; width: 0; background: var(--accent); }

/* ---------- sheet ---------- */
.sheet { counter-reset: row; padding-left: var(--gutter); background: var(--cell); position: relative; overflow-x: clip; }
.sheet::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--gutter); background: var(--head); border-right: 1px solid var(--grid-strong); }
.r {
  counter-increment: row;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  border-bottom: 1px solid var(--grid);
  background-image: linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) 100%;
  scroll-margin-top: calc(var(--dock-h) + 0.5rem);
}
.r::before {
  content: counter(row);
  position: absolute; right: 100%; top: 0; bottom: 0; width: var(--gutter);
  font-family: var(--font-mono); font-size: 0.8125rem; color: var(--head-ink);
  text-align: center; padding-top: 0.45rem;
  border-bottom: 1px solid var(--grid); margin-bottom: -1px;
  z-index: 1;
}
.r:hover::before, .r:focus-within::before { background: var(--sel-fill); color: var(--sel); font-weight: 600; box-shadow: inset -2px 0 0 var(--sel); }
.r.gap { min-height: 2rem; }
.r.gap-lg { min-height: 3.5rem; }

/* cells */
.c { position: relative; min-width: 0; background: var(--cell); box-shadow: inset 1px 0 0 var(--grid); padding: 1.1rem 1.25rem; }
.c.pad-lg { padding: 2rem 2.25rem; }
.c.tight { padding: 0; }
.c.alt { background: var(--cell-alt); }
.c.head { background: var(--head); }
.c.fill { background: var(--inverse); color: var(--inverse-ink); }
.c.fill h2, .c.fill h3, .c.fill .big { color: var(--inverse-ink); }
.c.fill .lbl { color: var(--inverse-muted); }
.c.fill a:not(.btn) { color: var(--inverse-ink); }
.c.empty { background: transparent; box-shadow: none; }
.c.sel, .c:focus-within, .c.is-active { box-shadow: inset 0 0 0 2px var(--sel); z-index: 2; }
.c.sel::after, .c:focus-within::after, .c.is-active::after {
  content: ""; position: absolute; right: -4px; bottom: -4px; width: 8px; height: 8px;
  background: var(--sel); border: 1.5px solid var(--cell); z-index: 3;
}
.c[data-f] { cursor: cell; }

.s2 { grid-column: span 2; } .s3 { grid-column: span 3; } .s4 { grid-column: span 4; }
.s5 { grid-column: span 5; } .s6 { grid-column: span 6; } .s7 { grid-column: span 7; }
.s8 { grid-column: span 8; } .s9 { grid-column: span 9; } .s12 { grid-column: 1 / -1; }
.st2 { grid-column-start: 2; } .st3 { grid-column-start: 3; }

/* type */
.lbl { font-family: var(--font-mono); font-size: 0.8125rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); display: block; }
.lbl .ref { color: var(--sel); font-weight: 600; }
.display { font-family: var(--font-display); font-weight: 600; font-variation-settings: "opsz" 144; letter-spacing: -0.025em; font-size: clamp(2.5rem, 1.6rem + 3.4vw, 4.75rem); line-height: 1.02; margin: 0.6rem 0 1.1rem; }
.lede { font-size: 1.25rem; line-height: 1.5; color: var(--ink-2); max-width: 44rem; }
.secthead { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.35rem 1rem; }
.secthead h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.6rem, 1.3rem + 1vw, 2.2rem); letter-spacing: -0.015em; }
.secthead .sub { color: var(--muted); font-size: 1.0625rem; }
.secthead .more { margin-left: auto; font-weight: 600; white-space: nowrap; }
.big { font-family: var(--font-mono); font-weight: 600; font-size: clamp(2rem, 1.5rem + 1.6vw, 2.9rem); line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.005em; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.measure { max-width: 42rem; }
.stack > * + * { margin-top: 0.75rem; }

/* buttons */
.btns { display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; align-items: center; margin-top: 1.25rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.55rem 1.1rem;
  font: inherit; font-weight: 600; font-size: 1rem; border-radius: 3px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--sel); background: var(--sel); color: var(--sel-ink);
  transition: background-color 150ms, box-shadow 150ms, transform 150ms;
}
.btn:hover { box-shadow: 0 0 0 3px var(--sel-fill); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--cell); color: var(--ink); border-color: var(--grid-strong); }
.btn.ghost:hover { background: var(--head); }
.btn.link { background: none; border: 0; padding-inline: 0; color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 0.2em; }
.btn.link:hover { color: var(--ink); box-shadow: none; }
.btn.small { min-height: 2.25rem; padding: 0.3rem 0.75rem; font-size: 0.9375rem; }
.c.fill .btn { background: var(--inverse-ink); color: var(--inverse); border-color: var(--inverse-ink); }

/* tags / badges */
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; padding: 0; margin: 0; }
.tag { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink-2); background: var(--cell-alt); border: 1px solid var(--grid-strong); padding: 0.05rem 0.45rem; border-radius: 2px; text-decoration: none; overflow-wrap: anywhere; }
a.tag:hover { border-color: var(--sel); color: var(--sel); }
.badge { display: inline-block; font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600; padding: 0.05rem 0.45rem; border-radius: 2px; border: 1px solid currentColor; white-space: nowrap; }
.badge.new { color: var(--ok); }
.badge.upd { color: var(--accent); }
.badge.draft { color: var(--muted); border-style: dashed; }
.badge.type { color: var(--sel); }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 1px; margin-right: 0.4rem; vertical-align: 0.05em; }

/* picture object (image "inserted" over cells, shown selected) */
.pic { position: relative; height: 100%; min-height: 16rem; background: repeating-linear-gradient(45deg, var(--cell-alt) 0 10px, var(--head) 10px 20px); }
.pic img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.pic .h { position: absolute; width: 9px; height: 9px; background: var(--cell); border: 1.5px solid var(--sel); z-index: 2; }
.pic .h.tl { left: 6px; top: 6px; } .pic .h.tr { right: 6px; top: 6px; } .pic .h.bl { left: 6px; bottom: 6px; } .pic .h.br { right: 6px; bottom: 6px; }
.pic .h.tm { left: calc(50% - 4px); top: 6px; } .pic .h.bm { left: calc(50% - 4px); bottom: 6px; }
.pic .frame { position: absolute; inset: 10px; border: 1.5px solid var(--sel); pointer-events: none; z-index: 1; }
.pic .cap { position: absolute; left: 10px; bottom: 10px; z-index: 2; font-family: var(--font-mono); font-size: 0.8125rem; background: var(--cell); color: var(--ink); padding: 0.1rem 0.45rem; border: 1px solid var(--grid-strong); }

/* ---------- data tables ---------- */
.tablewrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 1rem; }
table.grid caption { text-align: left; padding: 0.75rem 1rem; font-size: 0.9375rem; color: var(--muted); caption-side: top; }
table.grid th, table.grid td { border: 1px solid var(--grid); padding: 0.6rem 0.8rem; text-align: left; vertical-align: top; }
table.grid thead th { background: var(--head); color: var(--ink); font-size: 0.875rem; font-weight: 600; white-space: nowrap; position: sticky; top: var(--dock-h); z-index: 5; }
table.grid tr > :first-child { border-left: 0; }
table.grid tr > :last-child { border-right: 0; }
table.grid th.rn, table.grid td.rn { width: 3rem; text-align: center; background: var(--head); font-family: var(--font-mono); font-size: 0.8125rem; color: var(--head-ink); font-weight: 400; }
table.grid tbody tr:hover, table.grid tbody tr:focus-within { background: var(--sel-fill); }
table.grid tbody tr:hover td.rn, table.grid tbody tr:focus-within td.rn { color: var(--sel); font-weight: 600; box-shadow: inset -2px 0 0 var(--sel); }
table.grid td.n, table.grid th.n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.d { font-family: var(--font-mono); font-size: 0.9375rem; white-space: nowrap; color: var(--ink-2); }
table.grid .t { font-weight: 600; color: var(--ink); text-decoration: none; }
table.grid a.t:hover { text-decoration: underline; color: var(--link); }
table.grid .desc { display: block; color: var(--muted); margin-top: 0.2rem; line-height: 1.5; max-width: 60rem; }
table.grid.nowrap .desc { display: none; }
table.grid td.thumbcell { width: 7rem; padding: 0.4rem; }
.thumb { width: 6.25rem; aspect-ratio: 16 / 10; object-fit: cover; border: 1px solid var(--grid); background: var(--head); }
.term { width: 6.25rem; aspect-ratio: 16 / 10; display: grid; place-items: center; background: #0f1318; color: #9fe0b8; font-family: var(--font-mono); font-size: 0.8125rem; border: 1px solid var(--grid); }
tr.dim td:not(.rn) { color: var(--muted); }
tr.dim .t { color: var(--muted); }
tr.empty-row td { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); background: var(--cell-alt); }

/* sort buttons */
th .sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.2rem; margin: -0.15rem -0.2rem; border-radius: 2px; }
th .sort:focus-visible { outline: 3px solid var(--sel); outline-offset: 2px; }
th .sort:hover { color: var(--sel); }
th .sort .ind { font-size: 0.75rem; color: var(--muted); width: 0.8rem; display: inline-block; text-align: center; }
th .sort .ind::before { content: "♢"; }
th[aria-sort="ascending"] .ind::before { content: "▲"; color: var(--sel); }
th[aria-sort="descending"] .ind::before { content: "▼"; color: var(--sel); }
th.n .sort { flex-direction: row-reverse; }

/* data bar (conditional formatting) */
.databar { position: relative; display: block; height: 1.6rem; background: var(--cell-alt); border: 1px solid var(--grid); }
.databar > span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--sel), color-mix(in srgb, var(--sel) 55%, transparent)); opacity: 0.85; }
.databar > b { position: relative; z-index: 1; font-family: var(--font-mono); font-size: 0.875rem; padding: 0 0.5rem; line-height: 1.6rem; color: var(--ink); }

/* toolbar / autofilter */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; }
.filter-input { display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--grid-strong); background: var(--cell); padding: 0 0.7rem; border-radius: 3px; flex: 1 1 18rem; max-width: 32rem; min-height: 2.75rem; }
.filter-input .ico { font-family: var(--font-mono); color: var(--muted); font-size: 0.875rem; }
.filter-input input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1rem; padding: 0.5rem 0; }
.filter-input input:focus-visible { outline: none; }
.filter-input:focus-within { box-shadow: 0 0 0 2px var(--sel); border-color: var(--sel); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-btn { font: inherit; font-size: 0.9375rem; min-height: 2.5rem; padding: 0.3rem 0.8rem; border: 1px solid var(--grid-strong); background: var(--cell); color: var(--ink-2); border-radius: 3px; cursor: pointer; display: inline-flex; gap: 0.45rem; align-items: center; }
.chip-btn .num { color: var(--muted); font-size: 0.875rem; }
.chip-btn:hover { border-color: var(--sel); }
.chip-btn[aria-pressed="true"] { background: var(--sel); border-color: var(--sel); color: var(--sel-ink); font-weight: 600; }
.chip-btn[aria-pressed="true"] .num { color: var(--sel-ink); }
.chip-btn[aria-pressed="true"]::before { content: "✓"; font-size: 0.8125rem; }
.count { font-family: var(--font-mono); font-size: 0.9375rem; color: var(--ink-2); margin-left: auto; }

/* notes and comments (callouts) */
.note { position: relative; background: var(--note); border: 1px solid var(--note-edge); padding: 1rem 1.25rem 1rem 1.25rem; margin: 1.5rem 0; color: var(--ink); }
.note::after { content: ""; position: absolute; top: -1px; right: -1px; border: 7px solid transparent; border-top-color: var(--bad); border-right-color: var(--bad); }
.note .who { display: block; font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); margin-bottom: 0.3rem; }
.note.q { background: var(--comment); border-color: var(--comment-edge); }
.note.q::after { border-top-color: var(--sel); border-right-color: var(--sel); }
.note.q .who { color: var(--sel); }
.note p { margin: 0; }

/* cards inside cells */
.card-img { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; border: 1px solid var(--grid); background: var(--head); margin-bottom: 0.9rem; }
.cardlink { color: var(--ink); text-decoration: none; }
.cardlink:hover { color: var(--link); text-decoration: underline; }
.meta { font-family: var(--font-mono); font-size: 0.875rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 1rem; margin: 0; }
.kv dt { font-family: var(--font-mono); font-size: 0.875rem; color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }
.plainlist { list-style: none; padding: 0; margin: 0; }
.plainlist li { padding: 0.4rem 0; border-bottom: 1px dashed var(--grid); }
.plainlist li:last-child { border-bottom: 0; }

/* chart object */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font-mono); font-size: 13px; fill: var(--muted); }
.chart .bar { fill: var(--sel); }
.chart .bar.hi { fill: var(--accent); }
.chart .axis { stroke: var(--grid-strong); }
.chart .val { fill: var(--ink); font-weight: 600; }

/* gantt */
.gantt { display: grid; grid-template-columns: 11rem repeat(16, minmax(0, 1fr)); font-size: 0.9375rem; }
.gantt .yr { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--head-ink); background: var(--head); text-align: center; padding: 0.35rem 0; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid-strong); }
.gantt .yr.lab { text-align: left; padding-left: 0.8rem; }
.gantt .co { padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--grid); color: var(--ink); font-weight: 600; grid-column: 1; }
.gantt .co small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 0.8125rem; color: var(--muted); }
.gantt .lane { grid-column: 2 / -1; border-bottom: 1px solid var(--grid); position: relative; background-image: linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: calc(100% / 16) 100%; display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); align-items: center; }
.gantt .bar { height: 1.5rem; background: var(--sel); border-radius: 1px; }
.gantt .bar.now { background: repeating-linear-gradient(90deg, var(--sel) 0 70%, var(--accent) 70% 100%); }

/* prose */
.prose { font-size: 1.125rem; line-height: 1.72; color: var(--ink-2); max-width: 44rem; }
.prose h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.95rem; letter-spacing: -0.015em; margin: 2.75rem 0 0.9rem; scroll-margin-top: calc(var(--dock-h) + 1rem); display: flex; gap: 0.75rem; align-items: baseline; }
.prose h2 .ref { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 600; color: var(--sel); border: 1px solid var(--grid-strong); padding: 0 0.4rem; flex: none; }
.prose p { margin: 0 0 1.15em; }
.prose ol, .prose ul { padding-left: 1.4rem; margin: 0 0 1.2em; }
.prose li { margin: 0.25rem 0; }
.prose li::marker { font-family: var(--font-mono); color: var(--sel); }
.prose code { background: var(--code-bg); border: 1px solid var(--grid); padding: 0.05em 0.3em; border-radius: 2px; }
.prose strong { color: var(--ink); }

/* code as a range of cells with row numbers */
.code { margin: 1.5rem 0; border: 1px solid var(--grid-strong); background: var(--code-bg); max-width: 100%; }
.code .bar { display: flex; align-items: center; gap: 0.75rem; background: var(--head); border-bottom: 1px solid var(--grid-strong); padding: 0.25rem 0.35rem 0.25rem 0.8rem; }
.code .bar .lbl { flex: 1; }
.code pre { margin: 0; overflow-x: auto; font-size: 0.9375rem; line-height: 1.6; counter-reset: line; padding: 0.5rem 0; }
.code code { display: block; font-size: inherit; background: none; border: 0; padding: 0; min-width: max-content; }
.code code > span { display: block; padding-right: 1rem; white-space: pre; }
.code code > span::before { counter-increment: line; content: counter(line); display: inline-block; width: 2.75rem; margin-right: 1rem; text-align: right; padding-right: 0.6rem; color: var(--head-ink); border-right: 1px solid var(--grid); font-size: 0.8125rem; user-select: none; }
.code code > span:hover { background: var(--sel-fill); }
.code .cm { color: var(--muted); font-style: italic; }

/* toc */
.toc { position: sticky; top: calc(var(--dock-h) + 1rem); }
.toc ol { list-style: none; margin: 0.6rem 0 0; padding: 0; counter-reset: toc; }
.toc li a { display: flex; gap: 0.6rem; padding: 0.45rem 0.5rem; text-decoration: none; color: var(--ink-2); border-left: 2px solid transparent; font-size: 0.9375rem; line-height: 1.35; }
.toc li a .ref { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); flex: none; width: 2.1rem; }
.toc li a:hover { background: var(--head); color: var(--ink); }
.toc li a[aria-current="true"] { border-left-color: var(--sel); background: var(--sel-fill); color: var(--ink); font-weight: 600; }
details.toc-m { display: none; }

/* forms */
.field { display: flex; gap: 0; border: 1px solid var(--grid-strong); background: var(--cell); max-width: 30rem; }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 0.6rem 0.8rem; }
.field input:focus-visible { outline-offset: -3px; }
.field button { border-radius: 0; }
.c.fill .field { background: transparent; border-color: var(--inverse-muted); }
.c.fill .field input { color: var(--inverse-ink); }
.formmsg { margin-top: 0.6rem; font-size: 1rem; min-height: 1.5em; }
.formmsg.ok { color: var(--ok); font-weight: 600; }
.formmsg.err { color: var(--bad); font-weight: 600; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; margin-top: 0.6rem; font-size: 0.9375rem; }
.check input { width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; accent-color: var(--sel); }

/* footer rows */
.foot h3 { font-size: 0.8125rem; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; margin-bottom: 0.6rem; }
.foot ul { list-style: none; padding: 0; margin: 0; }
.foot li a { display: inline-block; padding: 0.2rem 0; color: var(--ink-2); text-decoration: none; }
.foot li a:hover { color: var(--link); text-decoration: underline; }

/* ---------- bottom dock: sheet tabs + status ---------- */
.bottom { position: sticky; bottom: 0; z-index: 30; display: flex; align-items: stretch; background: var(--head); border-top: 1px solid var(--grid-strong); }
.tabs { display: flex; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding-left: var(--gutter); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: flex; align-items: center; padding: 0 1.1rem; min-height: 2.75rem; color: var(--ink-2); text-decoration: none; font-size: 0.9375rem; border-right: 1px solid var(--grid-strong); white-space: nowrap; }
.tabs a:hover { background: var(--cell); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--cell); color: var(--sel); font-weight: 700; box-shadow: inset 0 3px 0 var(--sel); margin-top: -1px; }
.status { display: flex; align-items: center; gap: 1rem; padding: 0 0.75rem; font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink-2); border-left: 1px solid var(--grid-strong); white-space: nowrap; }
.status .ready { color: var(--ok); font-weight: 600; }
.zoom { display: flex; align-items: center; gap: 0.25rem; }
.zoom button { width: 2.25rem; height: 2.25rem; border: 1px solid var(--grid-strong); background: var(--cell); color: var(--ink); cursor: pointer; font-family: var(--font-mono); font-size: 1rem; border-radius: 2px; }
.zoom output { min-width: 3rem; text-align: center; }

/* pattern detail panes */
.panes-bar { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: space-between; background: var(--head); border-bottom: 1px solid var(--grid-strong); }
.panes-tabs { display: flex; overflow-x: auto; }
.panes-tabs button { font: inherit; font-size: 0.9375rem; border: 0; border-right: 1px solid var(--grid-strong); background: transparent; color: var(--ink-2); padding: 0 1.1rem; min-height: 2.75rem; cursor: pointer; white-space: nowrap; }
.panes-tabs button[aria-selected="true"] { background: var(--cell); color: var(--sel); font-weight: 700; box-shadow: inset 0 3px 0 var(--sel); }
.panes-actions { display: flex; gap: 0.4rem; align-items: center; padding: 0.3rem 0.5rem; }
.pane { padding: 1.5rem; }
.pane[hidden] { display: none; }
.pane pre { margin: 0; }
.prompt-text { font-size: 1.0625rem; line-height: 1.7; max-width: 46rem; }

/* ---------- responsive ---------- */
@media (max-width: 1099px) {
  :root { --cols: 6; }
  .s6, .s7, .s8, .s9 { grid-column: 1 / -1; }
  .s3, .s4, .s5 { grid-column: span 3; }
  .t6 { grid-column: 1 / -1; }
  .colheads span:nth-child(n + 8) { display: none; }
  .titlebar .chip { display: none; }
  .gantt { grid-template-columns: 8.5rem repeat(16, minmax(0, 1fr)); }
}
@media (max-width: 959px) {
  .toc-col { display: none; }
  details.toc-m { display: block; border: 1px solid var(--grid-strong); background: var(--head); margin-bottom: 1.5rem; }
  details.toc-m summary { cursor: pointer; padding: 0.7rem 1rem; font-family: var(--font-mono); font-size: 0.875rem; font-weight: 600; color: var(--ink); min-height: 2.75rem; }
  details.toc-m .toc { position: static; padding: 0 0.5rem 0.5rem; }
  .prose-col { grid-column: 1 / -1; }
}
@media (max-width: 719px) {
  :root { --cols: 4; --gutter: 2.25rem; --dock-h: 4.6rem; }
  .s2, .m2 { grid-column: span 2; }
  .s3, .s4, .s5, .s6, .s7, .s8, .s9 { grid-column: 1 / -1; }
  .s3.m2, .s4.m2 { grid-column: span 2; }
  .colheads span:nth-child(n + 6) { display: none; }
  .c { padding: 1rem 0.95rem; }
  .c.pad-lg { padding: 1.4rem 1.1rem; }
  .titlebar { padding: 0.5rem 0.75rem; gap: 0.6rem; }
  .brand .sheetname { display: none; }
  .find { display: none; }
  .ribbon { display: none; }
  .namebox-wrap { width: 7.5rem; }
  .cellref { min-width: 3.5rem; }
  .fx { width: 2.25rem; }
  .formula { font-size: 0.875rem; padding: 0 0.6rem; }
  .status { display: none; }
  .tabs { padding-left: 0; }
  .tabs a { padding: 0 0.85rem; }
  .pic { min-height: 14rem; }
  .gantt { grid-template-columns: 1fr; }
  .gantt .yr.lab { display: none; }
  .gantt .yr { display: none; }
  .gantt .co { border-bottom: 0; padding-bottom: 0.2rem; }
  .gantt .lane { grid-column: 1; min-height: 1.9rem; padding-bottom: 0.4rem; }
  .gantt .axis-m { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); padding: 0.4rem 0; border-bottom: 1px solid var(--grid-strong); }
  .code pre { font-size: 0.875rem; }
  .prose { font-size: 1.0625rem; }
  .prose h2 { font-size: 1.6rem; flex-wrap: wrap; }

  /* tables become record views */
  table.grid:has(> thead) thead { display: block; }
  table.grid:has(> thead) thead tr { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.6rem 0.75rem; background: var(--head); border-bottom: 1px solid var(--grid-strong); }
  table.grid:has(> thead) thead th { position: static; border: 1px solid var(--grid-strong); background: var(--cell); padding: 0.35rem 0.6rem; min-height: 2.5rem; display: flex; align-items: center; }
  table.grid:has(> thead) thead th.nosort, table.grid:has(> thead) thead th.rn { display: none; }
  table.grid:has(> thead) thead th.n .sort { flex-direction: row; }
  table.grid:has(> thead) tbody, table.grid:has(> thead) tr, table.grid:has(> thead) td { display: block; }
  table.grid:has(> thead) tbody tr { position: relative; padding: 0.85rem 0.9rem 0.85rem 3rem; border-bottom: 1px solid var(--grid); }
  table.grid:has(> thead) td { border: 0; padding: 0.1rem 0; }
  table.grid:has(> thead) td.rn { position: absolute; left: 0; top: 0; bottom: 0; width: 2.25rem; padding-top: 0.9rem; border-right: 1px solid var(--grid); }
  table.grid:has(> thead) td.n { text-align: left; }
  table.grid:has(> thead) td[data-label]::before { content: attr(data-label) " "; font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 0.35rem; }
  table.grid:has(> thead) td.thumbcell { width: auto; padding: 0 0 0.5rem; }
  table.grid:has(> thead) td .tags { margin-top: 0.25rem; }
  tr.empty-row { padding-left: 0.9rem !important; }
  .count { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.prose-fig { margin: 1.5em 0; border: 1px solid var(--grid, currentColor); }
.prose-fig img { display: block; width: 100%; height: auto; }
.prose blockquote.note { margin-inline: 0; }
.prose .note p + p { margin-top: .7em; }
.prose code { overflow-wrap: anywhere; }
