/* Layout: one-column plan board - masthead with a data stamp, a hero meter with
   figure tiles, then ruled tables whose rows open into task lists. Colours and
   faces follow the owner's review site (tools/review_site/index.html): concrete
   ground, gas-pipe yellow accent, PT Sans Narrow / PT Sans / PT Mono. */
:root {
  --bg: #E6E3DA;
  --surface: #F1EFE8;
  --ink: #2B2A28;
  --ink-2: #5F5D57;
  --ink-3: #625F58;
  --line: #CFCBC0;
  --track: #D5D1C6;
  --accent: #6B5720;
  --done: #1baf7a;
  --review: #eda100;
  --prog: #2a78d6;
  --crit: #d03b3b;
  --display: "PT Sans Narrow", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "PT Sans", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "PT Mono", Consolas, "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1F1F1C; --surface: #292825; --ink: #E6E3DA; --ink-2: #B3AC9C; --ink-3: #989284;
    --line: #3D3C38; --track: #3B3A36; --accent: #C4A65A;
    --done: #199e70; --review: #c98500; --prog: #3987e5; --crit: #e66767;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1F1F1C; --surface: #292825; --ink: #E6E3DA; --ink-2: #B3AC9C; --ink-3: #989284;
  --line: #3D3C38; --track: #3B3A36; --accent: #C4A65A;
  --done: #199e70; --review: #c98500; --prog: #3987e5; --crit: #e66767;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--body);
  -webkit-text-size-adjust: 100%;
}
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
code, .mono { font-family: var(--mono); font-size: 0.87em; }
.num { font-variant-numeric: tabular-nums; }

/* Masthead */
.mast { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-end; justify-content: space-between; }
.eyebrow { font: 12px/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
h1 { font: 700 30px/1.1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; text-wrap: balance; }
.mast-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 40px;
  border: 2px solid var(--ink); border-radius: 4px; background: var(--ink); color: var(--bg);
  font: 700 15px/1.2 var(--display); letter-spacing: 0.05em; text-transform: uppercase; text-decoration: none;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.stamp { font: 12px/1.4 var(--mono); color: var(--ink-2); text-align: right; }
.stamp b { font-weight: 400; color: var(--ink); }
.stamp .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--done); margin-right: 6px; }
.stamp .dot.old { background: var(--review); }

.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin-inline: -16px; padding: 8px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; padding: 5px 10px; border-radius: 4px;
  font: 700 13px/1.2 var(--display); letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
}
.nav a:hover { background: var(--track); color: var(--ink); }

main { display: flex; flex-direction: column; gap: 36px; min-width: 0; }
.loading { color: var(--ink-2); padding-block: 40px; }

/* Hero */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.hero-main { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.hero-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 20px; }
.hero-num { font: 700 76px/0.9 var(--display); letter-spacing: -0.01em; }
.hero-num span { font-size: 0.45em; font-weight: 500; margin-left: 2px; color: var(--ink-2); }
.hero-sub { color: var(--ink-2); max-width: 46ch; padding-bottom: 4px; }
.hero-sub b { color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.tile { background: var(--surface); padding: 12px 20px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .k { font-size: 12.5px; color: var(--ink-2); }
.tile .v { font: 700 26px/1.15 var(--display); }
.tile .n { font-size: 12.5px; color: var(--ink-3); }
.tiles.plain { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }

/* Progress bar: segments separated by a 2px surface gap */
.bar { display: flex; gap: 2px; height: 10px; min-width: 72px; }
.bar i { display: block; height: 100%; min-width: 3px; }
.bar i:first-child { border-radius: 3px 0 0 3px; }
.bar i:last-child { border-radius: 0 3px 3px 0; }
.bar i:only-child { border-radius: 3px; }
.bar.big { height: 16px; }
.s-done { background: var(--done); }
.s-review { background: var(--review); }
.s-prog { background: var(--prog); }
.s-rest { background: var(--track); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }

/* Sections */
section { display: flex; flex-direction: column; gap: 12px; min-width: 0; scroll-margin-top: 72px; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
h2 { font: 700 19px/1.2 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.head p { color: var(--ink-2); font-size: 13.5px; }
h3 { font: 700 14px/1.3 var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.note { color: var(--ink-2); font-size: 13.5px; max-width: 75ch; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.cols > * { min-width: 0; display: flex; flex-direction: column; gap: 10px; }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th {
  text-align: left; font: 400 11.5px/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-3); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:last-child, td:last-child { padding-right: 0; }
th.r, td.r { text-align: right; }
td.pc { font: 700 17px/1 var(--display); width: 3.4em; white-space: nowrap; }
td.barcell { width: 34%; min-width: 96px; }
td.muted, .muted { color: var(--ink-3); }
tr.sum td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; }
tr.open > td { border-bottom-color: transparent; }
tr.detail > td { padding: 0 0 14px; }
.name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.name .id { font: 700 15px/1.2 var(--display); letter-spacing: 0.04em; white-space: nowrap; }
.name .ttl { color: var(--ink-2); min-width: 0; }
button.tog {
  all: unset; cursor: pointer; display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 28px;
}
button.tog::before {
  content: ""; flex: none; width: 6px; height: 6px; margin-right: 2px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: translateY(-2px) rotate(-45deg); transition: transform 0.15s;
}
button.tog[aria-expanded="true"]::before { transform: translateY(-4px) rotate(45deg); }
button.tog:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
tr.row:hover > td { background: color-mix(in srgb, var(--track) 45%, transparent); }

/* Chips and task lists */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--track); box-shadow: inset 0 0 0 1px var(--ink-3); }
.chip.done::before { background: var(--done); box-shadow: none; }
.chip.review::before { background: var(--review); box-shadow: none; }
.chip.in_progress::before { background: var(--prog); box-shadow: none; }
.chip.blocked::before, .chip.waiting::before, .chip.decision::before { background: var(--ink-3); box-shadow: none; }
.tag { font: 11px/1.2 var(--mono); letter-spacing: 0.03em; color: var(--ink-2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; white-space: nowrap; }
.tag.now { border-color: var(--accent); color: var(--accent); }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.tasks { display: flex; flex-direction: column; }
.tasks li {
  display: grid; grid-template-columns: 7.2em minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline;
  padding: 6px 0; border-top: 1px solid var(--line); font-size: 13.5px;
}
.tasks li:first-child { border-top: 0; }
.tasks .what { min-width: 0; overflow-wrap: anywhere; }
.tasks .what code { margin-right: 6px; color: var(--ink); }
.tasks .when { font: 12px/1.3 var(--mono); color: var(--ink-3); white-space: nowrap; }
.tasks .why { grid-column: 2 / -1; font-size: 12.5px; color: var(--ink-3); }
details > summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; padding: 4px 0; }
details > summary b { color: var(--ink); }
details[open] > summary { margin-bottom: 6px; }
.plain-list li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13.5px; overflow-wrap: anywhere; }
.plain-list li:first-child { border-top: 0; }
.plain-list .src { font: 11px/1.2 var(--mono); color: var(--ink-3); margin-right: 6px; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 11px var(--mono); fill: var(--ink-3); }
.chart .lbl { fill: var(--ink); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .col { fill: var(--prog); }
.chart .ln { fill: none; stroke: var(--done); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--done); opacity: 0.12; }
.chart .scope { stroke: var(--ink-3); stroke-width: 1; }
.chart .enddot { fill: var(--done); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .hit:hover, .chart .hit.on { fill: color-mix(in srgb, var(--ink) 7%, transparent); }
.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 240px;
  background: var(--ink); color: var(--bg); border-radius: 4px; padding: 6px 9px;
  font: 12px/1.45 var(--mono); white-space: pre-line;
}

.foot { color: var(--ink-3); font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 14px; }
.foot summary { font-size: 12.5px; }
.foot li { padding: 2px 0; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .wide { display: none; }
  h1 { font-size: 25px; }
  .hero-num { font-size: 60px; }
  .hero-main { padding: 16px; }
  .tile { padding: 10px 16px 12px; }
  .stamp { text-align: left; }
  .mast-side { align-items: flex-start; }
  td.barcell { width: 26%; min-width: 52px; }
  .bar { min-width: 48px; }
  th { font-size: 10.5px; letter-spacing: 0; padding-right: 6px; }
  td { padding-right: 6px; }
  td.pc { width: 2.9em; font-size: 16px; }
  td.r { white-space: nowrap; }
  .tasks li { grid-template-columns: minmax(0, 1fr) auto; }
  .tasks .st { grid-column: 1 / -1; }
  .tasks .why { grid-column: 1 / -1; }
  .name { flex-direction: column; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { button.tog::before { transition: none; } }
