/* zestlystorycrates.com — Wave Fluid design system
   Palette order: page background, panel background, main text, primary accent, secondary accent, border */

/* ---------- Design tokens ---------- */
:root {
  --bg: #EAF6FB;
  --panel: #FFFFFF;
  --text: #0B2540;
  --accent: #0B6FA4;
  --accent-2: #F0703A;
  --border: #BBD9E8;

  /* derived shades for accessible states */
  --accent-dark: #084F78;
  --accent-2-text: #B23E10;
  --input-border: #4A6A82;
  --tint: #D6EDF7;

  --u: 8px;
  --shell: 1200px;
  --pad: 16px;
  --rhythm: 28px;
  --radius: 22px;
  --wave-h: clamp(24px, 4vw, 56px);
  --shadow-soft: 0 14px 34px -22px rgba(11, 37, 64, 0.45);

  --f-head: Georgia, "Times New Roman", Times, serif;
  --f-body: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --f-data: "Courier New", Courier, monospace;

  /* Decorative wave shapes (used as masks; no information is carried by them) */
  --mask-wave-divider-bottom-fill: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 80' preserveAspectRatio='none'%3E%3Cpath d='M0 40C240 80 480 0 720 40S1200 0 1440 40V80H0Z'/%3E%3C/svg%3E");
  --mask-wave-divider-top-fill: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 80' preserveAspectRatio='none'%3E%3Cpath d='M0 0H1440V40C1200 80 960 0 720 40S240 0 0 40Z'/%3E%3C/svg%3E");
  --mask-wave-tile-repeating: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 100' preserveAspectRatio='none'%3E%3Cpath d='M0 50C150 0 450 0 600 50S1050 100 1200 50V100H0Z'/%3E%3C/svg%3E");
  --mask-wave-squiggle-underline: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 12'%3E%3Cpath d='M0 6Q10 0 20 6T40 6' fill='none' stroke='black' stroke-width='3'/%3E%3C/svg%3E");
}

@media (min-width: 768px) { :root { --pad: 24px; --rhythm: 40px; } }
@media (min-width: 1280px) { :root { --pad: 40px; --rhythm: 64px; } }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: clamp(1rem, 0.94rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { font-family: var(--f-head); line-height: 1.2; margin: 0 0 var(--u); overflow-wrap: break-word; }
h1 { font-size: clamp(1.875rem, 1.1rem + 3.2vw, 3.5rem); line-height: 1.12; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.25rem; }

p { margin: 0 0 16px; }
ul, ol { margin: 0 0 16px; padding-left: 1.4em; }
img, svg { max-width: 100%; height: auto; }
[id] { scroll-margin-top: 24px; }
[hidden] { display: none !important; }

a { color: var(--accent-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent-2-text); outline-offset: 3px; }

.vh {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -80px; z-index: 60;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px;
}
.skip-link:focus { top: 8px; }

/* ---------- Layout ---------- */
.shell {
  width: 100%;
  max-width: calc(var(--shell) + var(--pad) * 2);
  margin-inline: auto;
  padding-inline: var(--pad);
}
.section { padding-block: var(--rhythm); }
.page-head { padding-block: 8px var(--rhythm); }
.lede { font-size: 1.125rem; max-width: 68ch; }
.reading { max-width: 68ch; }
.status-line {
  font-family: var(--f-data); font-size: 0.9375rem; color: var(--accent-2-text);
  border-bottom: 2px solid var(--accent-2); display: inline-block; padding-bottom: 4px; margin-bottom: 16px;
}
.hint { font-size: 0.9375rem; margin: 8px 0; }
.note {
  font-size: 0.9375rem; background: var(--tint); padding: 12px 18px;
  border-radius: 16px; max-width: 72ch;
}
.empty {
  background: var(--panel); border-bottom: 3px solid var(--accent-2); border-radius: 16px;
  padding: 16px 20px; font-weight: 700;
}
.scroll-cue { display: block; font-size: 0.9375rem; color: var(--accent-2-text); margin-bottom: 8px; }
@media (min-width: 768px) { .scroll-cue { display: none; } }

/* ---------- Header and navigation ---------- */
.site-header {
  position: relative;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent-dark) 55%, var(--accent) 100%);
  padding-bottom: calc(var(--wave-h) * 0.7);
  color: #fff;
}
.masthead {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 32px; padding-block: 16px 4px;
}
.brand {
  font-family: var(--f-head); font-weight: 700; font-size: 1.5rem; color: #fff;
  text-decoration: none; overflow-wrap: anywhere; min-height: 44px; display: inline-flex; align-items: center;
}
.primary-nav ul { display: flex; flex-wrap: wrap; gap: 0 24px; list-style: none; margin: 0; padding: 0; }
.primary-nav a {
  display: inline-block; padding: 10px 0 8px; min-height: 44px; color: #fff;
  text-decoration: none; border-bottom: 4px solid transparent;
}
.primary-nav a:hover { border-bottom-color: rgba(255, 255, 255, 0.5); }
.primary-nav a[aria-current="page"] { border-bottom-color: #FFB38F; font-weight: 700; }
.site-header :focus-visible { outline-color: #FFE3D3; }
@media (prefers-reduced-motion: no-preference) {
  .primary-nav a, .ledger a, .btn { transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease; }
}

.crumbs { padding-block: 8px 0; font-size: 0.9375rem; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 0 8px; list-style: none; padding: 0; margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 8px; }

/* ---------- Hero (home page) ---------- */
.hero { padding-block: 8px var(--rhythm); }
.hero-panel {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; gap: 32px; align-items: center;
  padding: clamp(24px, 5vw, 64px);
  border-radius: clamp(28px, 4vw, 48px);
  color: #fff;
  background:
    radial-gradient(circle at 88% 8%, rgba(240, 112, 58, 0.38) 0%, rgba(240, 112, 58, 0) 42%),
    radial-gradient(circle at 6% 100%, rgba(11, 111, 164, 0.75) 0%, rgba(11, 111, 164, 0) 50%),
    linear-gradient(135deg, #0B2540 0%, #084F78 62%, #0B6FA4 100%);
  box-shadow: 0 30px 60px -34px rgba(11, 37, 64, 0.7);
}
@media (min-width: 1000px) {
  .hero-panel { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 56px; }
}
.hero-text, .hero-visual { position: relative; z-index: 1; min-width: 0; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 12px; margin: 0 0 16px;
  font-family: var(--f-data); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #FFC4A6;
}
.eyebrow::before { content: ""; width: 36px; height: 3px; border-radius: 3px; background: var(--accent-2); flex: none; }

.hero h1 {
  color: #fff; font-size: clamp(2.125rem, 1.1rem + 4.2vw, 4.25rem); line-height: 1.06;
  letter-spacing: -0.01em; max-width: 16ch; margin-bottom: 20px;
}
.intro { font-size: 1.125rem; max-width: 62ch; }
.hero .intro { color: #E3F3FA; }
.hero .status-line { color: #FFD3BC; border-bottom-color: var(--accent-2); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 0; }
.btn-accent { background: var(--accent-2); border-color: var(--accent-2); color: var(--text); }
.btn-accent:hover { background: #FF8A5B; border-color: #FF8A5B; color: var(--text); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.75); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); border-color: #fff; color: #fff; }
.hero :focus-visible { outline-color: #FFE3D3; }

.month-label {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; font-family: var(--f-head); color: #fff;
  line-height: 0.95; padding: 28px 28px 32px; border-radius: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  overflow-wrap: anywhere;
}
.month-label > span { position: relative; z-index: 1; }
.month-name { font-size: clamp(2.5rem, 8vw, 5rem); font-weight: 400; }
.month-year { font-size: clamp(1.75rem, 4vw, 2.5rem); font-family: var(--f-data); color: #CDEBF7; margin-top: 8px; }
@media (min-width: 1000px) {
  .hero .month-label { text-align: right; min-height: 240px; justify-content: flex-end; }
}

.hero-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0 0;
}
.hero-stats div {
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px; padding: 14px 16px;
  display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 4px;
}
.hero-stats dt {
  font-family: var(--f-data); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: #CDEBF7;
}
.hero-stats dd {
  margin: 0; font-family: var(--f-data); font-weight: 700; font-size: clamp(1.5rem, 3vw, 1.875rem); line-height: 1.1; color: #fff;
}

.mini-search {
  margin-top: 28px; max-width: 540px; padding: 16px 20px 8px;
  background: var(--panel); color: var(--text); border-radius: 26px;
  border-bottom: 4px solid var(--accent-2);
}
.mini-search label { display: block; font-weight: 700; margin-bottom: 8px; }
.mini-search-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-search-row input { flex: 1 1 200px; }
.hero .mini-search :focus-visible { outline-color: var(--accent-2-text); }

/* ---------- Forms and buttons ---------- */
input[type="text"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 16px; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--panel); border: 1px solid var(--input-border); border-radius: 16px;
  border-bottom: 2px solid var(--text);
}
textarea { min-height: 160px; resize: vertical; }
label { display: block; font-weight: 700; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .hint { margin-top: 6px; font-weight: 400; }
.error { color: #8C2F1B; font-weight: 700; font-size: 0.9375rem; margin: 6px 0 0; }
[aria-invalid="true"] { border-color: #8C2F1B; border-bottom-width: 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 24px;
  font: inherit; font-size: 1rem; font-weight: 700; color: #fff; background: var(--accent);
  border: 2px solid var(--accent); border-radius: 999px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-quiet { background: transparent; color: var(--accent-dark); }
.btn-quiet:hover { background: var(--tint); color: var(--text); border-color: var(--accent-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }

/* ---------- Master / detail ---------- */
.md { display: grid; gap: 32px; }
@media (min-width: 1000px) {
  .md { grid-template-columns: minmax(0, 36fr) minmax(0, 64fr); gap: 40px; align-items: start; }
}
@media (min-width: 1000px) and (min-height: 700px) {
  .archive-side {
    position: sticky; top: 16px;
    max-height: calc(100vh - 32px); overflow-y: auto;
    padding: 4px 8px 4px 4px; margin: -4px -8px -4px -4px;
    overscroll-behavior: contain;
  }
  #archive-list .md-detail { position: sticky; top: 16px; }
}

/* Ledger rows: soft rounded cards */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li {
  --lpx: 16px; --lpy: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: var(--lpy) var(--lpx); margin-bottom: 10px;
}
.ledger p { margin: 0 0 2px; }
.row-date { font-family: var(--f-head); font-weight: 700; font-size: 1.125rem; }
.row-nums { font-family: var(--f-data); font-size: 1rem; }
.lbl {
  display: inline-block; min-width: 3.4em; font-family: var(--f-body); font-size: 0.8125rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2-text);
}
.row-link { margin-top: 4px !important; }
.row-link a { display: inline-block; padding: 8px 0; min-height: 44px; }
.ledger .row-link-block {
  display: block; color: var(--text); text-decoration: none;
  margin: calc(var(--lpy) * -1) calc(var(--lpx) * -1); padding: var(--lpy) var(--lpx); min-height: 44px;
  border-radius: 18px;
}
.ledger .row-link-block > span { display: block; }
.ledger .row-link-block:hover { background: var(--tint); }
.ledger .row-link-block:hover .row-date { text-decoration: underline; }

/* Detail sheets: white, rounded, folder-tab label */
.sheet {
  background: var(--panel); border: 1px solid var(--border); border-bottom: 4px solid var(--border);
  border-radius: 26px; box-shadow: var(--shadow-soft); padding: 0 16px 24px; margin-bottom: 24px;
}
@media (min-width: 768px) { .sheet { padding: 0 28px 24px; } }
.sheet-lead { border-bottom-color: var(--accent-2); }
.tab {
  display: inline-block; margin: 0 0 16px 8px; padding: 6px 16px; font-family: var(--f-data); font-size: 0.875rem;
  color: var(--panel); background: var(--accent); border-radius: 0 0 14px 14px;
}
.sheet h3, .sheet h4 { margin-bottom: 4px; }

.pools { display: grid; gap: 16px; margin-block: 16px; }
@media (min-width: 768px) { .pools { grid-template-columns: minmax(0, 1fr) auto; gap: 32px; } }
.pool-label {
  margin: 0 0 8px; font-family: var(--f-data); font-size: 0.875rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent-2-text);
}
.nums { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.nums li {
  font-family: var(--f-data); font-weight: 700; font-size: 1.75rem; line-height: 1.2; min-width: 3rem;
  padding: 4px 8px; text-align: center; border-bottom: 4px solid var(--accent);
  background: var(--tint); border-radius: 16px 16px 6px 6px;
}
.nums-euro li { border-bottom-color: var(--accent-2); }
.nums-lg li { font-size: clamp(1.75rem, 6vw, 2.5rem); min-width: 3.2rem; }

.meta { margin: 16px 0; }
.meta div { padding-block: 8px; border-bottom: 1px solid var(--border); }
.meta dt {
  font-family: var(--f-data); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent-2-text);
}
.meta dd { margin: 0; }
@media (min-width: 768px) {
  .meta div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 16px; }
  .meta dt { padding-top: 4px; }
}

/* Archive filters */
.filters { margin-bottom: 32px; }
.match-line { font-family: var(--f-data); font-size: 1.0625rem; margin: 16px 0 0; }
.archive-side h3 { border-bottom: 2px solid var(--text); padding-bottom: 4px; }

/* ---------- Tables ---------- */
.freq-grid { display: grid; gap: 32px; margin-block: 16px; }
@media (min-width: 1000px) { .freq-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
.table-wrap {
  overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow-soft); max-width: 100%; margin-bottom: 16px;
}
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
caption {
  caption-side: top; text-align: left; font-family: var(--f-head); font-weight: 700; font-size: 1.125rem;
  padding: 14px 12px; line-height: 1.3;
}
th, td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); line-height: 1.45; }
thead th { border-bottom: 2px solid var(--text); font-size: 0.875rem; background: var(--tint); }
.data-table tbody th, .data-table td, .data-table tfoot th, .data-table tfoot td { font-family: var(--f-data); font-size: 1rem; }
.data-table thead th { font-family: var(--f-body); }
.data-table { min-width: 420px; }
.text-table { min-width: 640px; }
tfoot th, tfoot td { border-top: 2px solid var(--text); font-weight: 700; border-bottom: 0; }

/* ---------- Guides, reading columns ---------- */
.guide-steps { max-width: 68ch; padding-left: 1.4em; }
.guide-steps li { margin-bottom: 12px; padding-left: 4px; }
.prose { max-width: 68ch; }
.prose h3 { margin-top: 32px; }
.article-list { list-style: none; padding: 0; margin: 0 0 24px; max-width: 68ch; }
.article-list li { margin-bottom: 8px; }
.article-list a {
  display: block; padding: 12px 20px; min-height: 48px; font-family: var(--f-head); font-weight: 700; font-size: 1.125rem;
  text-decoration: none; background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
}
.article-list a:hover { background: var(--tint); text-decoration: underline; }
.guide-article { padding-block: var(--rhythm); border-top: 1px solid var(--border); }
.worked { background: var(--panel); border-bottom: 3px solid var(--accent-2); border-radius: 22px; box-shadow: var(--shadow-soft); padding: 16px 22px; margin: 24px 0; }
.worked h3 { margin-top: 0; }
.tag {
  display: inline-block; font-family: var(--f-data); font-size: 0.8125rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent-2-text); border-bottom: 2px solid var(--accent-2); margin-right: 6px;
}
.tag-calc { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tag-edit { color: var(--text); border-bottom-style: dashed; }

/* ---------- FAQ ---------- */
.faq { max-width: 72ch; }
.faq details { border: 1px solid var(--border); border-radius: 20px; background: var(--panel); margin-bottom: 10px; overflow: hidden; }
.faq details[open] { background: var(--panel); border-color: var(--accent); box-shadow: var(--shadow-soft); }
.faq summary {
  list-style: none; cursor: pointer; padding: 16px 52px 16px 20px; min-height: 56px; position: relative;
  font-family: var(--f-head); font-weight: 700; font-size: 1.125rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 20px; top: 12px; font-family: var(--f-data); font-size: 1.5rem; color: var(--accent-2-text); }
.faq details[open] summary::after { content: "\2212"; }
.faq details p, .faq details ul { padding: 0 20px; }
.faq details > :last-child { margin-bottom: 16px; }

/* ---------- Legal and reading pages ---------- */
.legal-layout { display: grid; gap: 24px; padding-bottom: var(--rhythm); }
@media (min-width: 1000px) { .legal-layout { grid-template-columns: 260px minmax(0, 720px); gap: 56px; } }
.toc {
  background: var(--panel); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-soft);
  padding: 16px 20px; font-size: 0.9375rem; align-self: start;
}
.toc h2 { font-size: 1.0625rem; font-family: var(--f-body); text-transform: uppercase; letter-spacing: 0.05em; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc a { display: block; padding: 8px 0; min-height: 44px; border-bottom: 1px solid var(--border); text-decoration: none; }
.toc a:hover { text-decoration: underline; }
@media (min-width: 1000px) and (min-height: 700px) { .toc { position: sticky; top: 16px; } }
.legal { max-width: 720px; }
.legal section { margin-bottom: 32px; }
.legal h2 { border-bottom: 1px solid var(--border); padding-bottom: 6px; font-size: 1.5rem; }
.legal ul { padding-left: 1.3em; }
.legal li { margin-bottom: 6px; }

.tool-box { background: var(--panel); border: 1px solid var(--border); border-bottom: 4px solid var(--accent-2); border-radius: 26px; box-shadow: var(--shadow-soft); padding: 22px; margin-block: 16px; max-width: 720px; }
.tool-box .local-only { font-weight: 700; border-bottom: 2px solid var(--accent); padding-bottom: 8px; }
#fb-output { font-family: var(--f-data); min-height: 220px; }

.sitemap-list { columns: 1; list-style: none; padding: 0; }
.sitemap-list li { margin-bottom: 4px; }
.sitemap-list a { display: inline-block; padding: 6px 0; min-height: 40px; }
.sitemap-group { margin-bottom: 24px; max-width: 720px; }
.sitemap-group ul { padding-left: 1.2em; }
.sitemap-group ul ul { margin-top: 4px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: var(--rhythm); }
.index-band { position: relative; background: var(--panel); padding-block: 16px; }
.index-title { font-family: var(--f-data); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-2-text); margin-bottom: 4px; }
.index-band ul { display: flex; flex-wrap: wrap; gap: 0 24px; list-style: none; margin: 0; padding: 0; }
.index-band a { display: inline-block; padding: 10px 0; min-height: 44px; color: var(--text); font-size: 1rem; }
.colophon {
  position: relative; background: var(--text); color: var(--bg); padding-block: 32px; font-size: 0.9375rem;
}
.colophon p { max-width: 80ch; }
.colophon a { color: var(--bg); }
.colophon-name { font-family: var(--f-head); font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.colophon :focus-visible { outline-color: #FFD3BC; }
.copyright { border-top: 1px solid rgba(234, 246, 251, 0.35); padding-top: 12px; margin-top: 16px; margin-bottom: 0; }

/* ---------- Cookie notice ---------- */
.cookie-notice {
  position: fixed; z-index: 50; left: 12px; right: 12px; bottom: 12px; max-width: 520px;
  max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-bottom: 5px solid var(--accent-2);
  border-radius: 28px 28px 28px 10px; box-shadow: 0 22px 50px -18px rgba(11, 37, 64, 0.6);
  padding: 20px 22px 16px; font-size: 0.9375rem;
}
@media (min-width: 640px) { .cookie-notice { left: 24px; right: auto; bottom: 24px; } }
.cookie-title { font-family: var(--f-head); font-weight: 700; font-size: 1.25rem; margin: 0 0 6px; }
.cookie-notice p { margin: 0 0 8px; }
.cookie-notice .btn-row { margin: 12px 0 0; }

/* ---------- Wave decorations (need CSS mask support; everything works without them) ---------- */
@supports ((-webkit-mask-image: none) or (mask-image: none)) {
  .site-header::after,
  .index-band::before,
  .colophon::before {
    content: ""; position: absolute; left: 0; right: 0; height: var(--wave-h); pointer-events: none;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
    -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  }
  .site-header::after {
    bottom: -1px; background: var(--bg);
    -webkit-mask-image: var(--mask-wave-divider-bottom-fill); mask-image: var(--mask-wave-divider-bottom-fill);
  }
  .index-band { padding-top: calc(var(--wave-h) + 12px); }
  .index-band::before {
    top: -1px; background: var(--bg);
    -webkit-mask-image: var(--mask-wave-divider-top-fill); mask-image: var(--mask-wave-divider-top-fill);
  }
  .colophon { padding-top: calc(var(--wave-h) + 24px); }
  .colophon::before {
    top: -1px; background: var(--panel);
    -webkit-mask-image: var(--mask-wave-divider-top-fill); mask-image: var(--mask-wave-divider-top-fill);
  }

  .section > h2::after {
    content: ""; display: block; width: 120px; height: 12px; margin-top: 8px; background: var(--accent-2);
    -webkit-mask-image: var(--mask-wave-squiggle-underline); mask-image: var(--mask-wave-squiggle-underline);
    -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
    -webkit-mask-size: 40px 12px; mask-size: 40px 12px;
  }

  /* Hero: layered drifting waves along the bottom of the panel */
  .hero-panel::before,
  .hero-panel::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 0;
    -webkit-mask-image: var(--mask-wave-tile-repeating); mask-image: var(--mask-wave-tile-repeating);
    -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
    -webkit-mask-position: 0 100%; mask-position: 0 100%;
  }
  .hero-panel::before {
    height: 46%; background: rgba(255, 255, 255, 0.06);
    -webkit-mask-size: 1200px 100%; mask-size: 1200px 100%;
  }
  .hero-panel::after {
    height: 30%; background: rgba(240, 112, 58, 0.16);
    -webkit-mask-size: 800px 100%; mask-size: 800px 100%;
  }

  .month-label::before,
  .month-label::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none;
    -webkit-mask-image: var(--mask-wave-tile-repeating); mask-image: var(--mask-wave-tile-repeating);
    -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
    -webkit-mask-position: 0 100%; mask-position: 0 100%;
  }
  .month-label::before {
    height: 58%; background: rgba(255, 255, 255, 0.08);
    -webkit-mask-size: 720px 100%; mask-size: 720px 100%;
  }
  .month-label::after {
    height: 42%; background: rgba(255, 255, 255, 0.14);
    -webkit-mask-size: 480px 100%; mask-size: 480px 100%;
  }
}

@keyframes wave-drift-slow { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; } to { -webkit-mask-position: 720px 100%; mask-position: 720px 100%; } }
@keyframes wave-drift-fast { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; } to { -webkit-mask-position: -480px 100%; mask-position: -480px 100%; } }
@keyframes wave-drift-hero-a { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; } to { -webkit-mask-position: 1200px 100%; mask-position: 1200px 100%; } }
@keyframes wave-drift-hero-b { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; } to { -webkit-mask-position: -800px 100%; mask-position: -800px 100%; } }
@keyframes notice-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: no-preference) {
  .month-label::before { animation: wave-drift-slow 18s linear infinite; }
  .month-label::after { animation: wave-drift-fast 12s linear infinite; }
  .hero-panel::before { animation: wave-drift-hero-a 40s linear infinite; }
  .hero-panel::after { animation: wave-drift-hero-b 28s linear infinite; }
  .cookie-notice { animation: notice-rise 400ms ease-out both; }
}

/* ---------- Responsive refinements ---------- */
@media (max-width: 1279px) and (min-width: 1000px) { .shell { padding-inline: 24px; } }
@media (max-width: 767px) {
  .masthead { padding-block: 8px 0; }
  .primary-nav ul { gap: 0 16px; }
  .ledger li { --lpx: 12px; }
  .caption-small { font-size: 1rem; }
  th, td { padding: 8px; }
}
@media (max-width: 480px) {
  .btn { width: 100%; }
  .btn-row { flex-direction: column; }
  .hero-actions { flex-direction: column; }
  .mini-search-row .btn { width: 100%; }
  .nums li { min-width: 2.6rem; font-size: 1.5rem; }
  .month-label { padding: 22px 20px 26px; border-radius: 28px; }
  .hero-panel { padding: 22px 18px; }
  .mini-search { padding: 14px 14px 6px; }
}

/* ---------- Layout refinements ---------- */

/* Page heads: a clear, calm title block with a soft rule below */
.page-head { position: relative; }
.page-head > h1 { max-width: 22ch; }
.page-head h1:only-child { max-width: none; }
@media (min-width: 1000px) {
  .page-head > h1 { max-width: 26ch; }
}

/* Ledger rows: date on its own line, both number pools aligned beneath */
.ledger li { transition: none; }
.ledger .row-date, .ledger .row-link-block .row-date { display: block; margin-bottom: 4px; }
.ledger li:last-child { margin-bottom: 0; }
@media (min-width: 1000px) {
  #home-ledger, #archive-ledger { padding-right: 2px; }
}

/* Detail sheets: make the lead sheet stand out on the home page */
.sheet-lead { padding-bottom: 28px; }
.sheet-lead .pools { padding: 16px 0; border-block: 1px dashed var(--border); }
.sheet .note { max-width: none; }

/* Field guide: steps as a grid of cards on wider screens */
@media (min-width: 768px) {
  #field-guide .reading { max-width: none; }
  #field-guide .guide-steps {
    max-width: none; list-style: none; padding: 0; margin: 0 0 24px;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; counter-reset: step;
  }
  #field-guide .guide-steps li {
    counter-increment: step; position: relative; margin: 0; padding: 20px 20px 20px 64px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-soft);
  }
  #field-guide .guide-steps li::before {
    content: counter(step); position: absolute; left: 18px; top: 16px; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--f-data); font-weight: 700; color: #fff; background: var(--accent); border-radius: 50%;
  }
  #field-guide .reading > p { max-width: 68ch; }
}
@media (min-width: 1200px) {
  #field-guide .guide-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #field-guide .guide-steps li { padding: 64px 20px 20px; }
  #field-guide .guide-steps li::before { left: 20px; top: 18px; }
}

/* Frequency tables: contained height, sticky header and total row */
.freq-grid .table-wrap { max-height: min(72vh, 640px); overflow: auto; margin-bottom: 0; }
.freq-grid thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 2px 0 var(--text); border-bottom: 0; }
.freq-grid tfoot th, .freq-grid tfoot td {
  position: sticky; bottom: 0; z-index: 2; background: var(--tint);
  box-shadow: 0 -2px 0 var(--text); border-top: 0;
}
.freq-grid + .note { margin-top: 24px; }
.freq-grid .data-table tbody tr:nth-child(even) th,
.freq-grid .data-table tbody tr:nth-child(even) td { background: rgba(214, 237, 247, 0.35); }
#frequency .reading .note { margin-bottom: 16px; }
#frequency .reading { max-width: 72ch; }

/* Provenance and FAQ blocks: use the width on large screens */
@media (min-width: 1000px) {
  #provenance .reading { max-width: 860px; }
}
#faq .faq { max-width: 820px; }

/* Text tables on reading pages */
.text-table tbody th { width: 22%; }
.text-table { min-width: 600px; }

/* Guides: article list as a wrapping pill row; articles in a readable column */
@media (min-width: 768px) {
  .page-head .article-list { display: flex; flex-wrap: wrap; gap: 10px; max-width: none; }
  .page-head .article-list li { margin: 0; }
}
.guide-article { max-width: 68ch; margin-inline: auto 0; }
@media (min-width: 1000px) {
  .guide-article {
    max-width: none; display: grid; grid-template-columns: 200px minmax(0, 68ch); gap: 0 56px; align-items: start;
  }
  .guide-article > .tab { grid-column: 1; margin: 0; justify-self: start; position: sticky; top: 16px; }
  .guide-article > h2 { grid-column: 2; }
  .guide-article > .prose { grid-column: 2; }
}

/* Sitemap: groups flow into columns */
.shell.section[aria-label="Site pages"] {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 40px; align-items: start;
}
.shell.section[aria-label="Site pages"] .sitemap-group {
  margin-bottom: 0; max-width: none; background: var(--panel); border: 1px solid var(--border);
  border-radius: 22px; padding: 18px 22px 12px; box-shadow: var(--shadow-soft);
}
.shell.section[aria-label="Site pages"] .sitemap-group h2 { font-size: 1.25rem; }
.shell.section[aria-label="Site pages"] .sitemap-group a { display: inline-block; padding: 4px 0; }

/* Legal pages: compact two-column contents list on small and medium screens */
@media (min-width: 560px) and (max-width: 999px) {
  .toc ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
}
@media (min-width: 1000px) {
  .legal-layout { grid-template-columns: 260px minmax(0, 760px); }
  .legal { max-width: 760px; }
}
.legal section { scroll-margin-top: 24px; }
.legal h2 { margin-bottom: 12px; }

/* Contact tool: align boxes with the reading column */
#feedback-form.tool-box { max-width: 760px; }
@media (min-width: 768px) {
  #feedback-form .field:nth-of-type(2), #feedback-form .field:nth-of-type(3) { display: block; }
}

/* Footer: index as a tidy grid, colophon in two columns */
.index-band ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
@media (min-width: 640px) { .index-band ul { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .index-band ul { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .index-band ul { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.index-band li { border-bottom: 1px solid var(--border); }
.index-band a { display: flex; align-items: center; width: 100%; }
@media (min-width: 900px) {
  .colophon .shell { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 48px; align-items: start; }
  .colophon .colophon-name, .colophon .copyright { grid-column: 1 / -1; }
}

/* Keep long strings (URLs in tables) from breaking the layout */
.text-table a, .meta a { overflow-wrap: anywhere; }

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