:root {
  --bg: #f3f6f1;
  --surface: #ffffff;
  --ink: #17231b;
  --muted: #5b6b60;
  --line: #d6e0d4;
  --leaf: #2d6a3e;
  --leaf-ink: #ffffff;
  --leaf-soft: #e1eedf;
  --bran: #b5772a;
  --bran-soft: #f6ead8;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111813; --surface: #18221b; --ink: #e6efe6; --muted: #9db0a2; --line: #2b3a2f;
    --leaf: #7fc58f; --leaf-ink: #0d1a10; --leaf-soft: #1f3324; --bran: #e2a457; --bran-soft: #3a2b18; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111813; --surface: #18221b; --ink: #e6efe6; --muted: #9db0a2; --line: #2b3a2f;
  --leaf: #7fc58f; --leaf-ink: #0d1a10; --leaf-soft: #1f3324; --bran: #e2a457; --bran-soft: #3a2b18; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.6;
}
a { color: var(--leaf); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2rem, 5.5vw, 3rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.55rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--leaf); font-weight: 700; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

/* Site chrome */
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 20px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; flex: none; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 700; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a[aria-current="page"] { color: var(--leaf); background: var(--leaf-soft); }
@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; gap: 0; padding-top: 10px; }
  .nav { margin: 0 -16px; padding: 4px 12px 8px; width: calc(100% + 32px); }
}
.page { max-width: 792px; margin: 0 auto; padding-block: 40px 64px; display: grid; gap: 36px; }
.page.wide { max-width: 1112px; }
.intro { display: grid; gap: 12px; }
.intro p { color: var(--muted); max-width: 62ch; font-size: 1.05rem; }
.crumbs { font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.sitefoot { border-top: 1px solid var(--line); background: var(--surface); }
.sitefoot-in { max-width: 1080px; margin: 0 auto; padding-block: 32px 40px; display: grid; gap: 20px; font-size: 0.9rem; color: var(--muted); }
.footcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; }
.footcols b { display: block; color: var(--ink); margin-bottom: 6px; }
.footcols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footcols a { color: var(--muted); }

/* Prose */
.prose { display: grid; gap: 32px; }
.prose section { display: grid; gap: 12px; }
.prose p, .prose li { max-width: 66ch; }
.prose ul, .prose ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.callout { background: var(--leaf-soft); border-radius: 12px; padding: 18px 20px; display: grid; gap: 8px; }
.callout.warn { background: var(--bran-soft); }
.answer { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--leaf); border-radius: 12px; padding: 20px 22px; display: grid; gap: 8px; }
.answer .big { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 1.5rem; }
.stat span { font-size: 0.85rem; color: var(--muted); }
.cta { display: inline-flex; align-items: center; gap: 8px; background: var(--leaf); color: var(--leaf-ink); font-weight: 700; text-decoration: none; padding: 12px 18px; border-radius: 10px; border: 0; font: inherit; font-weight: 700; cursor: pointer; }
.cta:hover { filter: brightness(1.08); }
.cta.ghost { background: transparent; color: var(--leaf); border: 1px solid var(--leaf); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: grid; gap: 6px; text-decoration: none; color: var(--ink); }
a.card:hover { border-color: var(--leaf); }
.card p { color: var(--muted); font-size: 0.92rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
td.r, th.r { text-align: right; }
td a { color: var(--ink); }
th button { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; padding: 0; }
th button[aria-pressed="true"] { color: var(--leaf); }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { cursor: pointer; font-weight: 700; }
details p { margin-top: 8px; color: var(--muted); }

/* Controls */
label, .label { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
select, input[type="number"], input[type="search"] { font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; min-width: 0; }
.field { display: grid; gap: 6px; flex: 1 1 180px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: var(--bg); }
.seg button { font: inherit; font-size: 0.88rem; font-weight: 700; border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 0.85rem; font-weight: 700; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-size: 0.9rem; color: var(--leaf); text-decoration: underline; cursor: pointer; }
.iconbtn { width: 34px; height: 34px; flex: none; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 1.1rem; cursor: pointer; line-height: 1; display: inline-grid; place-items: center; padding: 0; }
.iconbtn:hover { border-color: var(--leaf); }

/* Calculator */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .calc { grid-template-columns: minmax(0, 1fr); } .calc .side { order: -1; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 18px; }
@media (max-width: 480px) { .panel { padding: 16px; } }
.main-col { display: grid; gap: 24px; min-width: 0; }
.side { display: grid; gap: 16px; position: sticky; top: 16px; }
@media (max-width: 900px) { .side { position: static; } }
.meter { display: grid; gap: 10px; }
.total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total strong { font-family: var(--font-display); font-size: 3.2rem; font-weight: 800; line-height: 1; }
.total span { color: var(--muted); }
.bar { position: relative; height: 18px; background: var(--leaf-soft); border-radius: 9px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--leaf); border-radius: 9px; transition: width .3s ease; }
.bar-target { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.status { font-weight: 700; }
.status.over { color: var(--bran); }
.status.done { color: var(--leaf); }
.suggest { background: var(--leaf-soft); border-radius: 10px; padding: 14px 16px; display: grid; gap: 8px; }
.suggest ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.suggest button { font: inherit; text-align: left; background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; }
.suggest button b { color: var(--leaf); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.example-note { font-size: 0.88rem; color: var(--bran); background: var(--bran-soft); padding: 8px 12px; border-radius: 8px; }
.list { display: grid; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-name b { display: block; font-weight: 700; line-height: 1.3; }
.item-name small { color: var(--muted); font-size: 0.85rem; }
.item-g { font-weight: 700; min-width: 5ch; text-align: right; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty output { min-width: 3.5ch; text-align: center; font-weight: 700; }
.qty input { width: 76px; padding: 6px 8px; text-align: right; }
.empty { color: var(--muted); padding: 12px 0; }
.result-add { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--leaf); background: var(--leaf-soft); color: var(--leaf); font-size: 1.2rem; font-weight: 700; cursor: pointer; padding: 0; }
.result-add:hover { background: var(--leaf); color: var(--leaf-ink); }
.results { max-height: 520px; overflow-y: auto; }
@media (max-width: 900px) { .results { max-height: 420px; } }
.share-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.share-btns .cta { padding: 9px 14px; font-size: 0.92rem; }
.toast { font-size: 0.88rem; color: var(--leaf); }
.preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); }

/* Plan */
.weeks { display: grid; gap: 14px; }
.week { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: grid; gap: 10px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.week-head b { font-family: var(--font-display); font-size: 1.3rem; }
.week ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.pill { font-size: 0.8rem; font-weight: 700; background: var(--leaf-soft); color: var(--leaf); padding: 3px 10px; border-radius: 999px; }

@media print {
  .topbar, .sitefoot, .noprint { display: none !important; }
  body { background: #fff; color: #000; }
  .week { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
