/* The progression plan: the paper look the board wears (warm off-white ground, ink type, hairline
   borders, mono micro-labels, a film grain), with the matrix as the one dense thing on the page.
   Tokens first, then layout. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --fg: #16161a;
  --muted: #6a6a72;
  --line: rgba(22, 22, 26, 0.13);
  --line-strong: rgba(22, 22, 26, 0.34);
  --surface: rgba(22, 22, 26, 0.035);
  --surface-2: rgba(22, 22, 26, 0.07);
  --card-bg: #fbfaf8;
  --nav-bg: rgba(244, 242, 238, 0.86);
  --accent: #16161a;
  --accent-ink: #fbfaf8;
  --danger: #b3261e;
  /* The three marks. Shape-coded as well as coloured, so a column of skips reads in greyscale. */
  --key: #2b5fb3;
  --alt: #2e7d4f;
  --skip: #c96a1b;
  --font-body: "Inter Tight", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --r-card: 10px;
  --r-btn: 8px;
  --nav-h: 58px;
  --cell: 34px;
  --gatecol: 250px;
  --wrap: 1240px;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(rgba(22, 22, 26, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 22, 26, 0.045) 1px, transparent 1px);
  background-size: 100% 46px, 46px 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--font-mono); font-size: 0.9em; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── the bar ─────────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 30;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.nav-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.status { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.status.bad { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-btn);
  background: none; color: var(--fg); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { opacity: 0.88; background: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ── sign in ─────────────────────────────────────────────────────────────── */
.login { display: flex; justify-content: center; padding: 14vh 20px 20px; }
.login-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--card-bg); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 26px;
}
.login-card h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.015em; }
.login-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.login-card input {
  font-family: var(--font-body); font-size: 15px; text-transform: none; letter-spacing: 0;
  color: var(--fg); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: var(--r-btn); padding: 9px 11px;
}
.login-error { color: var(--danger); font-size: 13px; }

/* ── page ────────────────────────────────────────────────────────────────── */
.plan { max-width: var(--wrap); margin: 0 auto; padding: 0 20px 64px; }
.block { padding-block: 30px; border-top: 1px solid var(--line); }
.block:first-child { border-top: 0; }
.shead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 8px; }
.shead h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; }
.lede { max-width: 72ch; color: var(--muted); margin-bottom: 16px; }
.lede strong { color: var(--fg); font-weight: 600; }
.lede em { font-style: normal; font-family: var(--font-mono); font-size: 0.92em; color: var(--fg); }

.kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.kind { background: var(--card-bg); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 15px; }
.kind b {
  display: block; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 5px;
}
.kind.cap b { color: var(--skip); }
.kind.item b { color: var(--alt); }
.kind.money b { color: var(--key); }
.kind span { font-size: 13.5px; color: var(--muted); }
.kind strong { color: var(--fg); font-weight: 600; }

/* ── the marks ───────────────────────────────────────────────────────────── */
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; margin-bottom: 14px; }
.legend .li { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--muted); }
.legend .li b { color: var(--fg); font-weight: 600; }
.mk { width: 17px; height: 17px; flex: 0 0 17px; display: block; }
.mk-key { background: var(--key); border-radius: 3px; }
.mk-alt { border: 2.5px solid var(--alt); border-radius: 50%; }
.mk-skip { background: var(--skip); clip-path: polygon(50% 4%, 100% 96%, 0 96%); }
.mk-early { border-radius: 3px; box-shadow: inset 0 0 0 2px var(--danger); }

.tools { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 12px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); cursor: pointer;
}

/* ── the matrix ──────────────────────────────────────────────────────────── */
.scroller {
  overflow-x: auto; overflow-y: visible;
  border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card-bg);
}
table.mx { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.mx th, table.mx td { padding: 0; margin: 0; }
table.mx .corner {
  position: sticky; left: 0; z-index: 4; background: var(--surface-2);
  width: var(--gatecol); min-width: var(--gatecol);
  border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
  vertical-align: bottom; padding: 8px 10px; text-align: left;
}
table.mx thead th.ab {
  height: 150px; width: var(--cell); min-width: var(--cell);
  border-bottom: 1px solid var(--line-strong); border-left: 1px solid var(--line);
  vertical-align: bottom; background: var(--surface-2);
}
table.mx thead th.ab .gtag { display: block; height: 4px; }
table.mx thead th.ab.g-weapon .gtag { background: var(--key); }
table.mx thead th.ab.g-utility .gtag { background: var(--alt); }
table.mx thead th.ab.g-topping .gtag { background: var(--skip); }
table.mx thead th.ab .rot {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  white-space: nowrap; padding: 6px 0; margin: 0 auto;
  max-height: 138px; overflow: hidden;
}
table.mx td.gate {
  position: sticky; left: 0; z-index: 3; background: var(--card-bg);
  width: var(--gatecol); min-width: var(--gatecol); max-width: var(--gatecol);
  border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line);
  padding: 5px 10px; text-align: left; vertical-align: middle;
}
table.mx tbody tr:nth-child(even) td.gate { background: var(--surface); }
table.mx td.gate .gname { display: block; font-weight: 500; line-height: 1.25; }
table.mx td.gate .gmeta {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted); letter-spacing: 0.03em;
}
table.mx td.cl {
  width: var(--cell); min-width: var(--cell); height: 30px;
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  text-align: center; vertical-align: middle; cursor: pointer;
}
table.mx td.cl:hover { background: var(--surface-2); }
table.mx td.cl .mk { margin: 0 auto; }
table.mx td.cl.early { box-shadow: inset 0 0 0 2px var(--danger); }

/* ── findings ────────────────────────────────────────────────────────────── */
.findings { display: grid; gap: 9px; }
.f {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  background: var(--card-bg); border: 1px solid var(--line);
  border-left: 3px solid var(--muted); border-radius: 8px; padding: 11px 14px;
}
.f.sev-bad { border-left-color: var(--danger); }
.f.sev-skip { border-left-color: var(--skip); }
.f.sev-note { border-left-color: var(--alt); }
.f .tag {
  grid-row: 1 / span 2; align-self: start; margin-top: 2px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 2px 6px; white-space: nowrap;
}
.f .ft { font-weight: 600; }
.f .fd { color: var(--muted); font-size: 13.5px; }
.clean { color: var(--muted); font-style: italic; }

/* ── tables ──────────────────────────────────────────────────────────────── */
.tscroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card-bg); }
table.rows { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 13.5px; }
table.rows th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  padding: 9px 10px; border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2); white-space: nowrap;
}
table.rows td { padding: 2px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.rows tr:last-child td { border-bottom: 0; }
table.rows td.n {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--muted); text-align: right; padding-right: 10px; width: 3rem;
}
table.rows td.calc { font-family: var(--font-mono); font-variant-numeric: tabular-nums; padding-left: 10px; }
table.rows td.calc.warn { color: var(--skip); font-weight: 500; }
table.rows td.calc.bad { color: var(--danger); font-weight: 500; }
table.rows td.dim { color: var(--muted); }

input.cellin, select.cellin {
  width: 100%; min-width: 0; background: none; border: 1px solid transparent;
  border-radius: 5px; color: inherit; font: inherit; padding: 5px 6px;
}
input.cellin:hover, select.cellin:hover { border-color: var(--line); }
input.cellin:focus, select.cellin:focus { border-color: var(--accent); outline: none; background: var(--bg); }
input.cellin::placeholder { color: var(--muted); opacity: 0.6; }
select.cellin { font-family: var(--font-mono); font-size: 11.5px; }
td.money input.cellin { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.rowtools { display: flex; gap: 10px; padding-top: 12px; }
button.del {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 4px 7px; border-radius: 5px;
}
button.del:hover { color: var(--danger); background: rgba(179, 38, 30, 0.1); }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--fg); font-weight: 600; margin-bottom: 4px; }
.foot { padding-top: 26px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; max-width: 80ch; }

/* ── grain ───────────────────────────────────────────────────────────────── */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 100; contain: strict; }
.fx-grain {
  position: absolute; inset: 0; opacity: 0.17; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

@media (max-width: 760px) {
  :root { --gatecol: 170px; }
  .nav { padding: 0 14px; }
  .plan { padding: 0 14px 48px; }
  .nav-title { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
