:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --text: #2b2622;
  --muted: #6b625a;
  --border: #e4ddd3;
  --accent: #1f6f6b;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ee;
  --seam: #c4623a;
  --fabric: #e8f1ef;
  --ring-0: #f3e2d3;
  --ring-1: #dbe8e6;
  --ring-2: #ece3f1;
  --notice: #fff4e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 38, 34, .06), 0 4px 16px rgba(43, 38, 34, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916;
    --surface: #24211d;
    --text: #efe9e1;
    --muted: #a99f94;
    --border: #3a352f;
    --accent: #5fb3ad;
    --accent-ink: #10201f;
    --accent-soft: #23302e;
    --seam: #e08a62;
    --fabric: #26332f;
    --ring-0: #3b2f26;
    --ring-1: #263533;
    --ring-2: #332a38;
    --notice: #3a2f1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 26px; height: 26px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

main { padding: 24px 0 48px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.35rem; margin: 40px 0 8px; }
h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.lead { font-size: 1.08rem; color: var(--muted); margin: 0 0 20px; max-width: 70ch; }
.breadcrumb { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

.calc-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .calc-grid { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

form.calc fieldset { border: 0; padding: 0; margin: 0 0 14px; }
form.calc legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: .95rem; }
.field small { color: var(--muted); font-size: .85rem; line-height: 1.4; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.input-unit { position: relative; }
.input-unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
input[type="number"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 36px 8px 10px; min-height: 44px;
}
select { padding-right: 10px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { padding: 6px 14px; cursor: pointer; font-size: .95rem; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
button, .button {
  font: inherit; font-size: .9rem; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 36px;
}
button:hover { border-color: var(--accent); color: var(--accent); }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 8px; }

.results .answer { font-size: 1.08rem; margin: 0 0 12px; }
.results .answer.big { font-size: 1.2rem; }
.result { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 12px; }
.result:first-of-type { border-top: 0; }
.results h3 { margin-top: 12px; }
.badge { display: inline-block; font-size: .75rem; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.muted { color: var(--muted); }
.notice { background: var(--notice); border-radius: 8px; padding: 10px 12px; margin: 0; }
.tools { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .85rem; }

.diagram { width: 100%; max-height: 340px; margin: 6px 0 4px; }
.diagram .fabric { fill: var(--fabric); stroke: var(--accent); stroke-width: 1.5; }
.diagram .seam { stroke: var(--seam); stroke-width: 2.5; stroke-dasharray: 6 4; }
.diagram .top { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 3 3; }
.diagram .ring { stroke: var(--muted); stroke-width: 1; }
.diagram .ring-0 { fill: var(--ring-0); }
.diagram .ring-1 { fill: var(--ring-1); }
.diagram .ring-2 { fill: var(--ring-2); }
.diagram .center { fill: var(--surface); stroke: var(--muted); stroke-width: 1; }
.diagram text { fill: var(--muted); font-family: inherit; }

article { max-width: 72ch; }
article p, article li { margin: 0 0 12px; }
.formula { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; font-variant-numeric: tabular-nums; }
.faq details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }

.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.related a { display: block; text-decoration: none; color: var(--text); }
.related a:hover { border-color: var(--accent); }
.related strong { color: var(--accent); display: block; }
.related span { color: var(--muted); font-size: .9rem; }

.byline { color: var(--muted); font-size: .9rem; margin-top: 32px; }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0 32px; color: var(--muted); font-size: .9rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }

.print-only { display: none; }
@media print {
  .site-header, .site-footer, form.calc, .tools, article, .more-tools, .breadcrumb, .lead, .byline, .faq { display: none !important; }
  .print-only { display: block; font-size: 10pt; color: #444; }
  .calc-grid { display: block; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body { background: #fff; color: #000; font-size: 12pt; }
}
