:root {
  /* Helle und dunkle Werte; Umschalten nur hier (modern-web-guidance: dark-mode) */
  --text-light: #1c2430;
  --text-dark: #e6ebf0;
  --muted-light: #55606e;
  --muted-dark: #a7b2bf;
  --bg-light: #ffffff;
  --bg-dark: #11161c;
  --soft-light: #f3f6f9;
  --soft-dark: #1a222b;
  --line-light: #d9e0e7;
  --line-dark: #2c3743;
  --accent-light: #b4451f;
  --accent-dark: #f0a07a;
  --accent-strong-light: #8a3216;
  --accent-strong-dark: #f7c2a6;
  --note-light: #fff7e0;
  --note-dark: #2a2414;
  --note-line-light: #e8c55a;
  --note-line-dark: #8a7230;
  --ok-light: #1f7a3a;
  --ok-dark: #7fd69a;
  --no-light: #a32121;
  --no-dark: #f09a9a;
  --on-accent-light: #fff;
  --on-accent-dark: #1a0f0a;
  --error-light: #a32121;
  --error-dark: #f4a6a6;
  --error-bg-light: #fdecea;
  --error-bg-dark: #3a1d1d;
  --text: var(--text-light);
  --muted: var(--muted-light);
  --bg: var(--bg-light);
  --soft: var(--soft-light);
  --line: var(--line-light);
  --accent: var(--accent-light);
  --accent-strong: var(--accent-strong-light);
  --note: var(--note-light);
  --note-line: var(--note-line-light);
  --ok: var(--ok-light);
  --no: var(--no-light);
  --on-accent: var(--on-accent-light);
  --error: var(--error-light);
  --error-bg: var(--error-bg-light);
  --max: 46rem;

  @media (prefers-color-scheme: dark) {
    --text: var(--text-dark);
    --muted: var(--muted-dark);
    --bg: var(--bg-dark);
    --soft: var(--soft-dark);
    --line: var(--line-dark);
    --accent: var(--accent-dark);
    --accent-strong: var(--accent-strong-dark);
    --note: var(--note-dark);
    --note-line: var(--note-line-dark);
    --ok: var(--ok-dark);
    --no: var(--no-dark);
    --on-accent: var(--on-accent-dark);
    --error: var(--error-dark);
    --error-bg: var(--error-bg-dark);
  }

  /* Formularfelder, Scrollbalken und Seitenhintergrund passen sich dem Farbschema an */
  color-scheme: light dark;
  accent-color: var(--accent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 1.125rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-strong); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .5rem 1rem; z-index: 10; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }
header.site { border-bottom: 1px solid var(--line); background: var(--soft); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem; padding-top: .9rem; padding-bottom: .9rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
nav.main ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; font-size: 1rem; }
nav.main a { text-decoration: none; }
nav.main a[aria-current="page"] { font-weight: 700; text-decoration: underline; }
main { padding: 1.5rem 0 3rem; }
h1 { font-size: 2rem; line-height: 1.25; margin: .5rem 0 1rem; }
h2 { font-size: 1.45rem; line-height: 1.3; margin: 2.2rem 0 .7rem; }
h3 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
.lead { font-size: 1.2rem; color: var(--muted); }
.breadcrumb { font-size: .95rem; color: var(--muted); margin-top: .5rem; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; }
.breadcrumb li + li::before { content: "›"; margin: 0 .45rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .8rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.facts li { background: var(--soft); border: 1px solid var(--line); border-radius: .5rem; padding: .9rem 1rem; }
.facts strong { display: block; font-size: 1.35rem; color: var(--accent); }
.note { background: var(--note); border-left: 4px solid var(--note-line); padding: .8rem 1rem; border-radius: .25rem; margin: 1.5rem 0; }
.stand { font-size: .95rem; color: var(--muted); }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 1rem; }
th, td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
th { background: var(--soft); }
.ok { color: var(--ok); }
.no { color: var(--no); }
details { border: 1px solid var(--line); border-radius: .4rem; padding: .6rem 1rem; margin: .6rem 0; }
details[open] { background: var(--soft); }
summary { cursor: pointer; font-weight: 600; }
form.calc { background: var(--soft); border: 1px solid var(--line); border-radius: .5rem; padding: 1rem 1.2rem; }
form.calc label { display: block; font-weight: 600; margin-top: .8rem; }
form.calc input { font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: .3rem; width: 100%; max-width: 16rem; background: var(--bg); color: var(--text); }
form.calc button { font: inherit; margin-top: 1rem; padding: .5rem 1.1rem; border: 0; border-radius: .3rem; background: var(--accent); color: var(--on-accent); cursor: pointer; }
#result { margin-top: 1.2rem; }
#result:empty { display: none; }
.sources li { margin: .3rem 0; }
footer.site { border-top: 1px solid var(--line); background: var(--soft); font-size: .95rem; color: var(--muted); padding: 1.5rem 0 2rem; }
footer.site ul { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
form.calc select { font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: .3rem; width: 100%; max-width: 16rem; background: var(--bg); color: var(--text); }
form.calc fieldset { border: 1px solid var(--line); border-radius: .4rem; margin: 0 0 1rem; padding: .3rem 1rem 1rem; }
form.calc legend { font-weight: 700; padding: 0 .3rem; }
#result table { font-size: .95rem; }

/* Tabellen (modern-web-guidance: responsive-table) */
.table-wrapper { overflow: auto; max-inline-size: 100%; container-type: inline-size; margin: 1rem 0; }
.table-wrapper table { margin: 0; border-collapse: separate; border-spacing: 0; }
.table-wrapper th, .table-wrapper td { border-width: 0 1px 1px 0; }
.table-wrapper tr > :first-child { border-left-width: 1px; }
.table-wrapper thead th, .table-wrapper caption + thead th { border-top-width: 1px; }
.table-wrapper tbody th { font-weight: 600; background: var(--bg); position: sticky; inset-inline-start: 0; }
.table-wrapper:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@container (width < 30rem) {
  .table-wrapper table, .table-wrapper tbody, .table-wrapper tr, .table-wrapper th, .table-wrapper td { display: block; }
  .table-wrapper thead { display: none; }
  .table-wrapper tr { border: 1px solid var(--line); border-radius: .4rem; margin-block-end: .8rem; overflow: hidden; }
  .table-wrapper th, .table-wrapper td { border: 0; }
  .table-wrapper tbody th { position: static; background: var(--soft); }
  .table-wrapper td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; }
}

/* Häufige Fragen (modern-web-guidance: accordion) */
summary { list-style: none; display: flex; align-items: center; gap: .5ch; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; inline-size: .8em; block-size: .8em; flex-shrink: 0; background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 8l8 8 8-8' fill='none' stroke='black' stroke-width='3'/%3E%3C/svg%3E") no-repeat center / contain;
  rotate: -90deg;
}
details[open] > summary::before { rotate: 0deg; }
details::details-content { interpolate-size: allow-keywords; overflow: clip; contain: layout; }
details:not([open])::details-content { block-size: 0; opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  summary::before { transition: rotate 200ms var(--ease-out); }
  details::details-content {
    transition: block-size 200ms var(--ease-out), opacity 200ms var(--ease-out), content-visibility 200ms;
    transition-behavior: allow-discrete;
  }
}
@media (prefers-reduced-motion: reduce) {
  details::details-content { transition: opacity 150ms var(--ease-out), content-visibility 150ms; transition-behavior: allow-discrete; }
}

/* Formulare (modern-web-guidance: validate-input-after-interaction, accessible-error-announcement) */
form.calc .hint { display: block; color: var(--muted); font-size: .95rem; font-weight: 400; }
form.calc .error-msg { display: none; color: var(--error); font-size: .95rem; margin-top: .2rem; }
form.calc :is(input, select):user-invalid { border-color: var(--error); background-color: var(--error-bg); }
form.calc :is(input, select):user-invalid ~ .error-msg { display: block; }
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important; clip-path: inset(50%) !important; overflow: hidden !important;
  width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important;
  border: 0 !important; white-space: nowrap !important;
}
form.calc .user-invalid-fallback { border-color: var(--error); background-color: var(--error-bg); }
form.calc .user-invalid-fallback ~ .error-msg { display: block; }

/* ── Bewegung (Emil Kowalski: animate/choreograph; modern-web-guidance: motion, animate-element-entry-exit) ──
   Nur dort, wo sie einen Zweck hat. transform/opacity, starke ease-out-Kurve,
   bei „Bewegung reduzieren“ nur noch Einblenden ohne Weg und ohne Versatz. */
:root { --ease-out: cubic-bezier(0.23, 1, 0.32, 1); }

@keyframes enter { from { opacity: 0; translate: 0 10px; } }
@keyframes fade-in { from { opacity: 0; } }

/* 1. Seiteneinstieg: Überschrift und Einleitung als ein Takt (Lead), Kacheln folgen (Support) */
main h1, main .lead { animation: enter 500ms var(--ease-out) both; }
.facts li { animation: enter 450ms var(--ease-out) both; animation-delay: 90ms; }
.facts li:nth-child(2) { animation-delay: 140ms; }
.facts li:nth-child(3) { animation-delay: 175ms; }
.facts li:nth-child(4) { animation-delay: 200ms; }
/* Kürzer werdende Abstände (90, 145, 168, 185 ms) statt Metronom; feste Werte oben als Rückfall */
@supports (animation-delay: calc(sibling-index() * 1ms)) {
  .facts li:nth-child(n) { animation-delay: calc(90ms + 55ms * sqrt(sibling-index() - 1)); }
}
@media (prefers-reduced-motion: reduce) {
  main h1, main .lead, .facts li { animation-name: fade-in; animation-delay: 0ms; }
}

/* 2. Rechner-Ergebnis: neue Inhalte gleiten herein statt aufzuploppen */
#result > * {
  transition: opacity 300ms var(--ease-out), translate 300ms var(--ease-out);
  @starting-style { opacity: 0; translate: 0 8px; }
}
#result > :nth-child(2) { transition-delay: 40ms; }
#result > :nth-child(n+3) { transition-delay: 70ms; }
@media (prefers-reduced-motion: reduce) {
  #result > * { transition-delay: 0ms; @starting-style { translate: none; } }
}

/* 3. Rückmeldung beim Drücken */
form.calc button { transition: background-color 150ms ease; }
@media (hover: hover) and (pointer: fine) {
  form.calc button:hover { background-color: var(--accent-strong); }
}
@media (prefers-reduced-motion: no-preference) {
  form.calc button { transition: transform 160ms var(--ease-out), background-color 150ms ease; }
  form.calc button:active { transform: scale(0.97); }
}

/* Links: nur Farbe, bleibt auch bei reduzierter Bewegung */
a { transition: color 150ms ease; }
