:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --ink: #1b1d22;
  --ink-2: #4a4f5a;
  --muted: #6f7480;
  --line: #e2dfd7;
  --accent: #0b6e66;
  --accent-ink: #ffffff;
  --accent-soft: #dff0ec;
  --hl: #fff1c7;
  --hl-ink: #6b4a00;
  --bad: #c13a2f;
  --shadow: 0 1px 2px rgba(20, 22, 27, .04), 0 8px 24px rgba(20, 22, 27, .06);
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1c1f26;
    --surface-2: #252932;
    --ink: #eceae4;
    --ink-2: #c3c5cc;
    --muted: #9095a1;
    --line: #2f333d;
    --accent: #5fd3c2;
    --accent-ink: #0d1f1c;
    --accent-soft: #19332f;
    --hl: #4a3b12;
    --hl-ink: #ffe08a;
    --bad: #ff7b6e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
p { margin: 0 0 1rem; }
sup { line-height: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 1.05rem; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; flex: none; color: var(--accent); }
.site-nav { min-width: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-size: .92rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current=page] { background: var(--surface-2); color: var(--ink); }
@media (max-width: 760px) { .site-nav .opt { display: none; } }
@media (max-width: 480px) { .site-nav .opt2 { display: none; } }

/* Hero */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 750; max-width: 20ch; }
.hero p { color: var(--ink-2); font-size: 1.125rem; max-width: 62ch; margin: 14px 0 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }

/* Cards and tools */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; margin: 24px 0 48px; }
@media (max-width: 860px) { .tool { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
@media (max-width: 480px) { .card { padding: 18px; } }
.card h2 { font-size: 1rem; font-weight: 650; margin-bottom: 16px; }

.today-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.big { font-family: var(--mono); font-size: clamp(3rem, 9vw, 4.5rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin: 8px 0 6px; color: var(--accent); font-variant-numeric: tabular-nums; }
.today-date { font-weight: 600; color: var(--ink); margin: 0 0 18px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0; }
.stats.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 480px) { .stats.three { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); padding: 11px 14px; min-width: 0; }
.stat dt { font-size: .76rem; color: var(--muted); font-weight: 600; }
.stat dd { margin: 2px 0 0; font-weight: 700; font-size: 1.08rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat dd.mono { font-size: 1rem; }
.copy { font: 600 .72rem var(--font); color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; cursor: pointer; vertical-align: 2px; }
.copy:hover { color: var(--accent); border-color: var(--accent); }

.tabs { display: flex; width: 100%; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { flex: 1; font: 650 .88rem var(--font); height: 36px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

label, .label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }
.field-row { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 480px) { .field-row.wrapmob { grid-template-columns: 1fr 1fr; } }
input[type=number], input[type=text], input[type=date], input[type=time], select {
  width: 100%; height: 46px; padding: 0 12px;
  font: 600 1.05rem var(--font); font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input.code { font-family: var(--mono); font-size: 1.2rem; letter-spacing: .02em; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); font-weight: 500; }
input[aria-invalid=true] { border-color: var(--bad); }
.out { margin-top: 18px; }
.out .result-line { font-size: 1.25rem; font-weight: 700; margin: 0 0 4px; }
.out .note { font-size: .86rem; color: var(--muted); margin: 0 0 14px; }
.err { color: var(--bad); font-weight: 600; font-size: .92rem; }
.btn { font: 650 .92rem var(--font); height: 46px; padding: 0 16px; border-radius: 10px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; }
.btn-link { display: inline-block; text-decoration: none; background: var(--ink); color: var(--bg); font-weight: 650; padding: 12px 20px; border-radius: 10px; }
.btn-link:hover { background: color-mix(in srgb, var(--ink) 85%, var(--bg)); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { font: 600 .8rem var(--font); color: var(--ink-2); background: var(--surface-2); border: 1px solid transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; text-decoration: none; }
.chip:hover { color: var(--ink); }

/* Julian date chart */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-head h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 700; }
.chart-nav { display: flex; gap: 6px; align-items: center; }
.chart-nav a, .chart-nav button { text-decoration: none; }
.chart-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.jchart { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; min-width: 720px; }
.jchart th, .jchart td { text-align: center; padding: 4px 2px; border: 1px solid var(--line); }
.jchart thead th { background: var(--surface-2); color: var(--ink-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; padding: 8px 2px; border-top: 0; }
.jchart tbody th { background: var(--surface-2); color: var(--ink-2); font-weight: 650; width: 44px; }
.jchart tr > :first-child { border-left: 0; }
.jchart tr > :last-child { border-right: 0; }
.jchart tbody tr:last-child > * { border-bottom: 0; }
.jchart td { font-family: var(--mono); color: var(--ink); }
.jchart td.x { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--surface-2) 5px 6px); }
.jchart td.we { color: var(--muted); }
.jchart td.today { background: var(--hl); color: var(--hl-ink); font-weight: 700; outline: 2px solid var(--hl-ink); outline-offset: -2px; }
.jchart tbody tr:hover td:not(.x) { background: var(--accent-soft); }
.jchart tbody tr:hover td.today { background: var(--hl); }
.chart-legend { font-size: .84rem; color: var(--muted); margin: 10px 0 0; display: flex; gap: 18px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.chart-section { margin: 0 0 56px; }

.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 0 0 1rem; }
.year-grid a { display: block; text-align: center; padding: 10px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.year-grid a:hover { border-color: var(--accent); color: var(--accent); }
.year-grid a small { display: block; font-size: .7rem; font-weight: 600; color: var(--muted); }
.year-grid a.cur { border-color: var(--accent); background: var(--accent-soft); }

/* Article */
.article { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; padding-bottom: 64px; }
@media (max-width: 860px) { .article { grid-template-columns: minmax(0, 1fr); gap: 0; } .toc { display: none; } }
.toc { position: sticky; top: 84px; align-self: start; font-size: .88rem; }
.toc p { font-weight: 650; color: var(--ink); margin-bottom: 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 4px 0 4px 14px; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 1px solid transparent; }
.toc a:hover { color: var(--ink); border-left-color: var(--ink); }
.prose { max-width: 70ch; color: var(--ink-2); }
.prose section { margin-bottom: 56px; }
.prose h2 { font-size: clamp(1.5rem, 3vw, 1.85rem); color: var(--ink); margin-bottom: 16px; font-weight: 700; }
.prose h3 { font-size: 1.15rem; color: var(--ink); margin: 28px 0 10px; font-weight: 650; }
.prose strong { color: var(--ink); font-weight: 650; }
.prose ul, .prose ol { padding-left: 1.25rem; margin: 0 0 1rem; }
.prose li { margin-bottom: .4rem; }
.prose code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; color: var(--ink); }
.eq { font-family: var(--mono); font-size: .95rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 14px 16px; margin: 0 0 1rem; overflow-x: auto; }
.table-wrap { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table-wrap th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface-2); }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:first-child { color: var(--ink); font-weight: 600; }
.steps { counter-reset: s; list-style: none; padding: 0 !important; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; margin-bottom: 14px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; display: grid; place-items: center; }
.callout { background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; color: var(--ink); margin: 0 0 1rem; }
.callout.warn { background: var(--hl); color: var(--hl-ink); }
details { border-bottom: 1px solid var(--line); padding: 14px 0; }
details:first-of-type { border-top: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 650; color: var(--ink); list-style: none; display: flex; justify-content: space-between; gap: 16px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--muted); font-weight: 500; font-size: 1.2rem; line-height: 1; }
details[open] summary::after { content: "–"; }
details p { margin: 10px 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 0 0 56px; }
.cards a { display: block; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink-2); font-size: .92rem; }
.cards a strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 4px; }
.cards a:hover { border-color: var(--accent); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 40px 0 28px; font-size: .9rem; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }
.site-footer h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin-bottom: 10px; font-weight: 650; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); font-size: .84rem; }

/* Content pages */
.page { padding-top: 48px; padding-bottom: 72px; }
.page .hero { padding: 0 0 32px; }
.page .prose section { margin-bottom: 40px; }
.page .prose h2 { font-size: 1.35rem; }
.meta-line { font-size: .88rem; color: var(--muted); margin-top: 12px; }

/* Print: just the chart, on one landscape page */
.print-only { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f1f1f1; --ink: #000; --ink-2: #222; --muted: #555; --line: #bbb; --hl: #fff; --hl-ink: #000; --accent: #000; }
  body { font-size: 10pt; background: #fff; }
  .site-header, .site-footer, .no-print, .tool, .article, .cards, .chart-nav, .hero p, .crumbs { display: none !important; }
  .print-only { display: block; }
  .hero { padding: 0 0 4mm; }
  .hero h1 { font-size: 16pt; max-width: none; }
  .chart-section { margin: 0; }
  .chart-head { margin-bottom: 2mm; }
  .chart-head h2 { font-size: 12pt; }
  .chart-wrap { border: 0; box-shadow: none; overflow: visible; }
  table.jchart { min-width: 0; font-size: 7.5pt; }
  .jchart th, .jchart td { padding: 0 1px; line-height: 1.35; }
  .jchart thead th { padding: 1mm 0; font-size: 7pt; }
  .jchart td.today { outline: 0; font-weight: 400; }
  .chart-legend { font-size: 7pt; margin-top: 2mm; }
  .chart-legend .no-print { display: none; }
}

@media (max-width: 420px) { .tabs button { font-size: .8rem; padding: 0 8px; } }
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 4px 0 18px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.table-wrap tr.today-row td { background: var(--hl); color: var(--hl-ink); }
pre.code { font: .85rem/1.55 var(--mono); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 14px 16px; margin: 0 0 1rem; overflow-x: auto; white-space: pre; }
