:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efeae2;
  --text: #1d1b19;
  --muted: #6b645c;
  --line: #ddd5ca;
  --accent: #c8402b;      /* Tartanbahn-Rot */
  --accent-ink: #ffffff;
  --accent-soft: #f6dcd5;
  --lane: rgba(255, 255, 255, 0.55);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 8px 24px rgba(40, 30, 20, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  /* Native UI (Scrollbars, Formulare, Canvas) folgt dem System-Theme */
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #201d1a;
    --surface-2: #2a2622;
    --text: #f1ece6;
    --muted: #a69d93;
    --line: #3a342e;
    --accent: #ec6a52;
    --accent-ink: #1b0f0c;
    --accent-soft: #3d221c;
    --lane: rgba(255, 255, 255, 0.18);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 var(--font);
  overflow-wrap: break-word;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; }
h1, h2, h3, summary { text-wrap: balance; }
p, li { text-wrap: pretty; }

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

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header .wrap { 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: 600; letter-spacing: -.02em; color: var(--text); text-decoration: none; font-size: 1.1875rem; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; overflow: hidden; flex: none; }
.logo-mark::before, .logo-mark::after { content: ""; position: absolute; left: -4px; right: -4px; height: 2px; background: var(--lane); }
.logo-mark::before { top: 9px; } .logo-mark::after { top: 17px; }
.nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9375rem; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }

/* Hero */
.hero { padding-top: 36px; padding-bottom: 8px; }
.hero h1, .page-title { font-size: clamp(1.875rem, 1.25rem + 2.5vw, 2.875rem); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 10px; }
.lead { color: var(--muted); font-size: 1.125rem; margin: 0 0 24px; max-width: 62ch; }

/* Calculator card */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.mode { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.mode button { appearance: none; border: 0; background: transparent; color: var(--muted); font: 600 .9375rem var(--font); min-block-size: 48px; padding: 10px 6px; border-radius: 7px; cursor: pointer; }
.mode button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.fields { display: grid; gap: 20px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { display: block; padding: 0; font-weight: 600; font-size: .9375rem; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: .84375rem; font-weight: 400; }
.input-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.part { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.part > label { color: var(--muted); font-size: .8125rem; }
.input-row > .unit.sep { align-self: flex-end; padding-bottom: 12px; }
input[type="text"], select {
  font: 600 1.25rem var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-block-size: 48px;
  width: 100%;
  min-width: 0;
}
select { font: 600 1rem var(--font); }
input:focus, select:focus, button:focus-visible, .table-scroll:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); outline-offset: 1px; }
input[aria-invalid="true"] { border-color: var(--accent); }
.unit { align-self: center; color: var(--muted); font-size: .9375rem; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { appearance: none; border: 1.5px solid var(--line); background: transparent; color: var(--text); font: 600 .875rem var(--font); min-block-size: 44px; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.inline-select { width: auto; flex: 0 0 auto; }

/* Results */
.result { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 20px; }
.result-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.result-main .big { font: 600 clamp(2.5rem, 1.75rem + 4vw, 3.75rem)/1 var(--mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--accent); }
.result-main .big-unit { color: var(--muted); font-weight: 600; }
.result-label { color: var(--muted); font-size: .9375rem; font-weight: 600; margin: 0 0 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat b, .stat output { display: block; font: 700 1.25rem var(--mono); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .84375rem; }
.error { color: var(--accent); font-weight: 600; margin: 0; }
.error:empty { display: none; }
.share-row { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn { appearance: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: 600 .875rem var(--font); min-block-size: 44px; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.copied { color: var(--muted); font-size: .875rem; }

details.panel { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.panel > summary { cursor: pointer; padding: 14px 18px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; font: 700 1.25rem var(--mono); color: var(--muted); }
details.panel[open] > summary::after { content: "–"; }
details.panel .panel-body { padding: 0 18px 16px; }

/* Tables: scrollbarer, fokussierbarer Bereich mit fixierten Kopfzeilen und Zeilenköpfen */
.table-scroll { overflow: auto; max-inline-size: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9375rem; }
/* Ganzzahlige Zeilenhöhe: sonst zeichnet Chromium die Linien fixierter Zellen auf Subpixeln blass */
th, td { line-height: 1.5rem; padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface-2); font-size: .8125rem; font-weight: 600; color: var(--muted); position: sticky; inset-block-start: 0; z-index: 1; }
thead th:first-child { inset-inline-start: 0; z-index: 2; }
tbody th { position: sticky; inset-inline-start: 0; background: var(--surface); font-weight: 600; }
tbody td { font-family: var(--mono); }
tbody th, tbody td { font-variant-numeric: tabular-nums; }
tbody tr:last-child > * { border-bottom: 0; }
tr.mark > * { background: var(--accent-soft); font-weight: 700; }

/* Content */
.content { padding-top: 40px; padding-bottom: 24px; }
.content h2 { font-size: 1.6875rem; letter-spacing: -.02em; line-height: 1.2; margin: 44px 0 12px; }
.content h3 { font-size: 1.25rem; margin: 28px 0 8px; }
.content p, .content li { max-width: 68ch; }
.content ul, .content ol { padding-left: 24px; }
.formula { font: 600 1rem var(--mono); background: var(--surface-2); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 0 10px 10px 0; overflow-x: auto; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.faq details p { margin-top: 0; }
.content .toc, .toc { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; padding: 0; list-style: none; }
.toc a { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: .875rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 24px 0 40px; color: var(--muted); font-size: .90625rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 520px) {
  body { font-size: 1.03125rem; }
  .calc { padding: 16px; }
  .mode button { font-size: .875rem; }
  th, td { padding: 7px 9px; }
}
