/* Layout: header bar → H1 + calculator (inputs | live result + top-down rig drawing) → readable article column.
   Visual language: timing screen. Purple = best/primary value (fastest sector), green = checked, yellow = community. */
:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #0e1b2e;
  --muted: #56677d;
  --line: #d4dce6;
  --purple: #6d28d9;
  --purple-soft: #efe7fd;
  --green: #0f7a43;
  --green-soft: #e3f4ea;
  --yellow: #8a6200;
  --yellow-soft: #fdf3d6;
  --red: #c8102e;
  --kerb-w: #ffffff;
  --rig: #0e1b2e;
  --ray: #6d28d9;
  --shadow: 0 1px 2px rgba(14, 27, 46, .06), 0 8px 24px rgba(14, 27, 46, .06);
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --measure: 68ch;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c131e; --surface: #131d2b; --surface-2: #182435; --ink: #e8eef6; --muted: #93a4ba; --line: #263449;
    --purple: #b98cff; --purple-soft: #2a1f45; --green: #4fd08b; --green-soft: #12301f; --yellow: #f0c24b; --yellow-soft: #34290d;
    --red: #ff4d5e; --kerb-w: #e8eef6; --rig: #e8eef6; --ray: #b98cff; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c131e; --surface: #131d2b; --surface-2: #182435; --ink: #e8eef6; --muted: #93a4ba; --line: #263449;
  --purple: #b98cff; --purple-soft: #2a1f45; --green: #4fd08b; --green-soft: #12301f; --yellow: #f0c24b; --yellow-soft: #34290d;
  --red: #ff4d5e; --kerb-w: #e8eef6; --rig: #e8eef6; --ray: #b98cff; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 17px/1.6 var(--font-body);
  font-variant-numeric: tabular-nums;
}
img, svg { max-width: 100%; }
a { color: var(--purple); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 24px/1 var(--font-display); color: var(--ink); text-decoration: none; letter-spacing: .01em; }
.brand svg { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; padding: 6px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--purple); }
@media (max-width: 720px) { .nav { margin-left: 0; width: 100%; padding-bottom: 8px; overflow-x: auto; flex-wrap: nowrap; } .nav a { white-space: nowrap; } }

/* Hero */
.hero { padding-block: 28px 8px; }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.crumbs a { color: var(--muted); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.08; text-wrap: balance; letter-spacing: .005em; }
h1 { font-size: clamp(34px, 5vw, 52px); font-weight: 700; margin: 0 0 8px; }
.lede { font-size: 18px; color: var(--muted); margin: 0; max-width: 62ch; }

/* Calculator */
.calc { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; padding-block: 20px 8px; align-items: start; }
@media (max-width: 900px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.inputs { padding: 18px; display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="number"], select {
  width: 100%; font: 500 17px var(--font-body); color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 44px;
}
input[type="number"]:focus, select:focus { border-color: var(--purple); outline: none; box-shadow: 0 0 0 3px var(--purple-soft); }
.unit-input { position: relative; }
.unit-input input { padding-right: 46px; }
.unit-input span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { font: 600 15px var(--font-body); color: var(--muted); background: transparent; border: 0; border-radius: 6px; min-height: 38px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--purple); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 500 13px var(--font-body); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; cursor: pointer; }
.chip:hover { border-color: var(--purple); }
details.more summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--purple); }
details.more[open] summary { margin-bottom: 10px; }

/* Results */
.results { display: grid; gap: 16px; min-width: 0; }
.answer { padding: 0; overflow: hidden; }
.kerb { height: 6px; background: repeating-linear-gradient(90deg, var(--red) 0 18px, var(--kerb-w) 18px 36px); border-bottom: 1px solid var(--line); }
.answer-body { padding: 18px 20px 20px; display: grid; gap: 12px; }
.answer-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.answer-game { font-weight: 600; font-size: 15px; }
.answer-game select { width: auto; min-height: 36px; padding: 4px 8px; font-size: 15px; }
.big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.big-num { font: 700 clamp(64px, 10vw, 96px)/.9 var(--font-display); color: var(--purple); letter-spacing: -.01em; }
.big-unit { font: 600 22px var(--font-display); color: var(--muted); }
.where { font-size: 15px; }
.where b { font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 0; }
.fields div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.fields dt { font-size: 13px; color: var(--muted); }
.fields dd { margin: 0; font: 700 22px var(--font-display); }
.note { font-size: 14px; color: var(--muted); margin: 0; }
.warn { font-size: 14px; color: var(--ink); background: var(--yellow-soft); border-radius: 8px; padding: 8px 10px; margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; font: 600 12px var(--font-body); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.checked { color: var(--green); background: var(--green-soft); }
.badge.community { color: var(--yellow); background: var(--yellow-soft); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: 600 15px var(--font-body); border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; min-height: 40px; cursor: pointer; }
.btn:hover { border-color: var(--purple); }
.btn.primary { background: var(--purple); border-color: var(--purple); color: var(--surface); }
.toast { font-size: 14px; color: var(--green); min-height: 1.2em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; }
.stat { padding: 14px 16px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat dt { font-size: 13px; color: var(--muted); }
.stat dd { margin: 0; font: 700 30px/1.1 var(--font-display); }
.stat dd small { font-size: 16px; color: var(--muted); font-weight: 600; }
@media (max-width: 560px) { .stat { border-right: 0; border-bottom: 1px solid var(--line); } }

.drawing { padding: 12px; margin: 0; }
.drawing svg { display: block; width: 100%; height: auto; }
.drawing figcaption { font-size: 13px; color: var(--muted); padding: 4px 6px 0; }

.games-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table-wrap { overflow-x: auto; }
.games-table th, .games-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.games-table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.games-table td.num { font: 700 22px var(--font-display); white-space: nowrap; }
.games-table tr:last-child td { border-bottom: 0; }

/* Saved setups */
.saved { padding: 12px 16px; }
.saved h3 { margin: 0 0 8px; font-size: 20px; }
.saved ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.saved li { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 15px; }

/* Article */
.article { padding-block: 32px 48px; }
.article-inner { max-width: var(--measure); }
.article h2 { font-size: 34px; margin: 44px 0 10px; }
.article h3 { font-size: 24px; margin: 28px 0 6px; }
.article p, .article li { max-width: var(--measure); }
.article ol, .article ul { padding-left: 1.3em; }
.article li + li { margin-top: 4px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.toc a { font-size: 14px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.callout { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--purple); border-radius: 8px; padding: 12px 16px; margin: 18px 0; }
.formula { font: 600 18px var(--font-display); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; overflow-x: auto; white-space: nowrap; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 8px 0; max-width: var(--measure); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); display: grid; gap: 4px; }
.card:hover { border-color: var(--purple); }
.card b { font: 700 22px var(--font-display); }
.card span { font-size: 14px; color: var(--muted); }
.sources { font-size: 14px; color: var(--muted); }
.updated { font-size: 14px; color: var(--muted); }

/* Reverse planner */
.planner { padding: 16px 18px; display: grid; gap: 12px; }
.planner h2 { margin: 0; font-size: 26px; }
.planner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.planner-out { font-size: 16px; }
.planner-out b { font: 700 26px var(--font-display); color: var(--purple); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: 28px; font-size: 15px; color: var(--muted); }
.site-footer .wrap { display: grid; gap: 16px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.foot-links a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.skip:focus { left: 16px !important; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
code { font-size: .9em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; word-break: break-word; }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-block: 8px 0; }
.stack h2 { font-size: 30px; margin: 12px 0 10px; }

/* Mobile: live result bar while editing inputs */
.mini {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(14,27,46,.12);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font: inherit; color: var(--ink); border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; cursor: pointer;
}
.mini b { font: 700 30px/1 var(--font-display); color: var(--purple); }
.mini span { font-size: 14px; color: var(--muted); }
@media (min-width: 901px) { .mini { display: none !important; } }
