:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #1d2320;
  --muted: #5b6560;
  --line: #dfe2dc;
  --brand: #1f6f5c;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ec;
  --accent: #b85c1e;
  --error: #b3261e;
  --logo-ink: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 4px 16px rgba(20, 30, 25, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a201d;
    --ink: #e6ebe8;
    --muted: #9aa6a0;
    --line: #2c3531;
    --brand: #5cc2a4;
    --brand-ink: #0f1a16;
    --brand-soft: #1d2f29;
    --accent: #e39a62;
    --error: #ff8a80;
    --logo-ink: #0f1a16;
    --shadow: none;
    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: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: 0.4em 0 0.3em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 0.5em; }
h3 { font-size: 1.05rem; margin: 1.3em 0 0.3em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { margin: 0.3em 0; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.logo-mark { width: 30px; height: 30px; color: var(--brand); }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.site-header nav a:hover { color: var(--brand); }

main { padding-bottom: 48px; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-top: 20px; }
.crumbs a { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 70ch; margin-top: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tool { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 20px; align-items: start; margin: 24px 0; }
@media (max-width: 760px) { .tool { grid-template-columns: 1fr; } }
.calc-form { padding: 20px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.control { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); overflow: hidden; }
.control:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
.control input, .control select {
  font: inherit; color: var(--ink); background: transparent; border: 0; padding: 10px 12px; min-width: 0;
}
.control input { flex: 1; }
.control input:focus, .control select:focus { outline: none; }
.control select { cursor: pointer; }
.control input + select { border-left: 1px solid var(--line); max-width: 45%; }
.control > select:only-child { width: 100%; }
.prefix, .suffix { display: flex; align-items: center; padding: 0 12px; color: var(--muted); background: var(--surface); }
.prefix { border-right: 1px solid var(--line); }
.suffix { border-left: 1px solid var(--line); }
.control:has(input[aria-invalid="true"]) { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.help { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn { font: inherit; font-size: 0.9rem; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); }

.results-card { padding: 20px; position: sticky; top: 16px; }
@media (max-width: 760px) { .results-card { position: static; } }
.results-h { margin: 0 0 12px; font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.results { display: grid; gap: 10px; }
.result { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.result-primary { background: var(--brand-soft); border-color: transparent; }
.result-label { font-size: 0.875rem; color: var(--muted); }
.result-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-primary .result-value { font-size: 1.7rem; color: var(--brand); }
.result-secondary { font-size: 0.875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-note { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.result-error { color: var(--error); margin: 0; }

.shop { padding: 16px 20px; margin: 0 0 24px; }
.shop h2 { margin: 0 0 8px; font-size: 1.05rem; }
.shop-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 8px; }
.shop-list a { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); text-decoration: none; font-size: 0.9rem; }

.content { max-width: 75ch; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: 0.35em 0; }
.content code, .formula { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.formula { display: block; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 6px; overflow-x: auto; margin: 0.8em 0; white-space: pre-wrap; }
.example { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 640px) { .example { grid-template-columns: 1fr; } }
.example-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.example-table th, .example-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.example-table th { font-weight: 500; color: var(--muted); }
.example-results .result-primary .result-value { font-size: 1.35rem; }

.hero { padding: 28px 0 8px; }
.search input { width: 100%; max-width: 520px; font: inherit; font-size: 1.05rem; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.search input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.cat-section h2 a { color: var(--ink); text-decoration: none; }
.cat-section h2 a:hover { color: var(--brand); }
.card-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.calc-card a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.calc-card a:hover { border-color: var(--brand); }
.calc-card strong { color: var(--brand); }
.calc-card span { font-size: 0.9rem; color: var(--muted); }
.related { margin-top: 40px; }

.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 32px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-h { font-size: 0.95rem; margin: 0 0 8px; }
.footer-legal { margin-top: 20px; }

@media print {
  .site-header, .site-footer, .actions, .related, .shop, .crumbs { display: none; }
  .card { box-shadow: none; }
}

/* Project planners */
.tool-planner { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
@media (max-width: 760px) {
  .tool-planner { grid-template-columns: 1fr; }
  .calc-form, .results-card { padding: 16px; }
  .shopping th, .shopping td { padding: 7px 4px; }
}
.input-group { border-top: 1px solid var(--line); margin: 8px 0 12px; padding-top: 10px; }
.input-group summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 12px; }
.result-list { background: var(--surface); padding: 0; border: 0; }
.tool > * { min-width: 0; }
.shopping { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; table-layout: fixed; }
.shopping thead th:nth-child(2) { width: 28%; }
.shopping thead th:nth-child(3) { width: 24%; text-align: right; }
.shopping th, .shopping td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.shopping thead th { font-size: 0.8rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.shopping tbody th { font-weight: 600; }
.shopping .item-detail { display: block; font-weight: 400; font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.shopping .item-qty { white-space: nowrap; font-weight: 600; }
.shopping .item-cost { text-align: right; white-space: nowrap; }
.shopping tfoot th, .shopping tfoot td { border-bottom: 0; font-weight: 700; font-size: 1.05rem; color: var(--brand); padding-top: 12px; }
.result-list .result-label { margin-bottom: 4px; }
.work-order li { margin: 0.6em 0; }

@media print {
  .calc-form, .print-hide, .lead { display: none; }
  .tool, .tool-planner { grid-template-columns: 1fr; margin: 0; }
  .results-card { position: static; border: 0; padding: 0; }
  body { background: #fff; color: #000; }
}
