/* Dunkel als Standard, hell bei prefers-color-scheme: light.
   Schriften: Systemschriften, bewusst keine Webfonts von Drittanbietern
   (Datenschutz: keine Verbindung zu Google Fonts o. ä.). */
:root {
  color-scheme: dark light;
  --bg: #161514;
  --surface: #1f1d1a;
  --text: #f3eee6;
  --body: #d9d2c7;
  --muted: #a0998e;
  --faint: #756f66;
  --accent: #d9925a;
  --accent-dim: #7a5230;
  --on-accent: #161514;
  --hair: #2b2925;
  --line: #3a3733;
  --ok: #86b872;
  --bad: #d97b62;
  --serif: "Iowan Old Style", "Charter", "Source Serif Pro", "Palatino Linotype", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* iPhone: Inhalt nicht unter Statusleiste, Notch oder Home-Indikator.
     Seitlich übernimmt .wrap die Abstände (Querformat). */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf7f2;
    --surface: #f1ece3;
    --text: #1d1b18;
    --body: #35322d;
    --muted: #6b655c;
    --faint: #8f887d;
    --accent: #b5651d;
    --accent-dim: #dcb48a;
    --on-accent: #faf7f2;
    --hair: #e4ded1;
    --line: #d3ccbd;
    --ok: #3f7d2e;
    --bad: #b5422a;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem max(1.5rem, env(safe-area-inset-right)) 4rem
    max(1.5rem, env(safe-area-inset-left));
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* -- Bausteine ----------------------------------------------------------- */

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.section {
  margin: 3.25rem 0 0;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.rule {
  border: 0;
  border-top: 1px solid var(--hair);
  margin: 3rem 0 0;
}

.status {
  margin: 4rem 0;
  text-align: center;
  color: var(--muted);
}

.status button,
.retry {
  margin-top: 1rem;
  padding: 0.7rem 1.4rem;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.stale {
  margin: 1.5rem 0 0;
  padding: 0.8rem 1.1rem;
  font-size: 0.95rem;
  color: var(--body);
  background: var(--surface);
  border-radius: 1rem;
}

/* -- Kopf ---------------------------------------------------------------- */

h1 {
  margin: 1.1rem 0 0.9rem;
  font-family: var(--serif);
  font-size: clamp(2.3rem, 9vw, 3rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--text);
}

.lede {
  margin: 0;
  font-size: 1.15rem;
  color: var(--muted);
}

.note {
  margin: 2.25rem 0 0;
  padding: 1.5rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-left: 3px solid var(--accent);
  border-radius: 1.75rem;
}

.note .eyebrow {
  color: var(--accent);
}

.note p:last-child {
  margin: 0.6rem 0 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--text);
}

/* -- Audio-Player -------------------------------------------------------- */

.player {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: center;
  margin: 2.5rem 0 0;
}

.play {
  display: grid;
  place-items: center;
  width: 5.25rem;
  height: 5.25rem;
  padding: 0;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 2.5rem color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: pointer;
}

.play svg {
  width: 2.1rem;
  height: 2.1rem;
  fill: currentColor;
}

.play:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: default;
}

.player-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--text);
}

.player-meta {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.seek {
  --p: 0%;
  display: block;
  width: 100%;
  height: 1.5rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p));
}

.seek::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.seek::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

.seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

.seek:disabled {
  opacity: 0.4;
  cursor: default;
}

/* -- Items --------------------------------------------------------------- */

.item {
  margin: 2.4rem 0 0;
}

.item .eyebrow {
  margin-bottom: 0.5rem;
}

.item h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.55rem, 6vw, 1.85rem);
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
}

.summary {
  margin: 1rem 0 0;
  color: var(--body);
}

.why {
  margin: 0.8rem 0 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
}

.why strong {
  font-weight: 600;
  color: var(--body);
}

.source {
  display: inline-block;
  margin-top: 1rem;
  padding-bottom: 2px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

/* -- Quiz ---------------------------------------------------------------- */

.q {
  margin: 2.4rem 0 0;
}

.question {
  margin: 0.4rem 0 1.2rem;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 5.6vw, 1.7rem);
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
}

.opts {
  display: grid;
  gap: 0.75rem;
}

.opt {
  min-height: 3.6rem;
  padding: 1rem 1.4rem;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.opt:hover:not(:disabled) {
  background: var(--surface);
}

.opt:disabled {
  cursor: default;
  color: var(--text);
}

.opt:disabled:not(.is-correct):not(.is-wrong) {
  opacity: 0.5;
}

.opt.is-correct {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}

.opt.is-wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, transparent);
}

.explain {
  margin: 0.9rem 0 0;
  font-size: 0.97rem;
  line-height: 1.6;
  color: var(--muted);
}

/* -- Benachrichtigungen --------------------------------------------------- */

.notify {
  margin: 3rem 0 0;
  padding: 1.4rem 1.5rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 1.5rem;
}

.notify p:not(.eyebrow) {
  margin: 0.6rem 0 0;
}

.btn {
  min-height: 2.9rem;
  margin: 1.1rem 0.6rem 0 0;
  padding: 0.7rem 1.4rem;
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
}

.btn.ghost {
  font-weight: 400;
  color: var(--text);
  background: transparent;
  border-color: var(--line);
}

.code {
  display: block;
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.8rem 1rem;
  font: 0.8rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--body);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 1rem;
  resize: none;
}

/* display: block oben würde das hidden-Attribut sonst überstimmen. */
.code[hidden] {
  display: none;
}

/* -- Fuß ----------------------------------------------------------------- */

.foot {
  margin: 3.5rem 0 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--faint);
}

@media (prefers-reduced-motion: reduce) {
  .opt {
    transition: none;
  }
}
