/* Speed-Reader — eigenständiges minimalistisches Design
   Fast Schwarz/Weiss + ein einziger Akzent: elektrisches Blau #2563eb */

:root {
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-strong: #1d4ed8;

  --bg: #ffffff;
  --bg-elev: #f6f7f9;
  --bg-stage: #fbfbfc;
  --border: #e4e6ea;
  --border-strong: #d2d6dd;
  --text: #0a0a0b;
  --text-muted: #5d626b;
  --text-faint: #9aa0a8;
  --word: #0a0a0b;
  --word-dim: #b9bdc4;
  --shadow: 0 1px 2px rgba(10, 10, 11, 0.05), 0 8px 24px rgba(10, 10, 11, 0.06);
  --focus: #2563eb;

  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 720px;
}

[data-theme="dark"] {
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --accent-strong: #60a5fa;

  --bg: #0a0b0d;
  --bg-elev: #15171b;
  --bg-stage: #101216;
  --border: #24272e;
  --border-strong: #343842;
  --text: #f4f5f7;
  --text-muted: #a3a9b3;
  --text-faint: #6b717b;
  --word: #f4f5f7;
  --word-dim: #4a4f58;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
  --focus: #60a5fa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 18px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}
.brand-name {
  font-weight: 700;
  font-size: 1.06rem;
  letter-spacing: -0.01em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.icon-btn:hover { border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.95); }

.theme-icon { width: 18px; height: 18px; position: relative; display: inline-block; }
/* Sonne (Light-Modus aktiv -> Symbol zeigt Mond zum Wechseln) */
.theme-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--text);
}
[data-theme="light"] .theme-icon::before {
  /* Mond-Sichel */
  box-shadow: inset -5px -1px 0 0 var(--text);
  background: transparent;
  border: 2px solid var(--text);
  width: 18px; height: 18px;
  clip-path: polygon(0 0, 60% 0, 60% 100%, 0 100%);
}
[data-theme="dark"] .theme-icon::before {
  /* Sonne */
  width: 11px; height: 11px;
  inset: auto;
  top: 3.5px; left: 3.5px;
  box-shadow:
    0 -7px 0 -3px var(--text), 0 7px 0 -3px var(--text),
    -7px 0 0 -3px var(--text), 7px 0 0 -3px var(--text),
    -5px -5px 0 -3px var(--text), 5px 5px 0 -3px var(--text),
    -5px 5px 0 -3px var(--text), 5px -5px 0 -3px var(--text);
}

/* Layout */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* RSVP-Bühne */
.stage {
  background: var(--bg-stage);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
}

.reader {
  position: relative;
  height: clamp(150px, 30vh, 240px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.reader-guides { position: absolute; inset: 0; pointer-events: none; }
.guide {
  position: absolute;
  left: 50%;
  width: 2px;
  height: 14px;
  background: var(--accent);
  opacity: 0.5;
  transform: translateX(-50%);
}
.guide-top { top: calc(50% - clamp(28px, 8vh, 52px)); }
.guide-bottom { bottom: calc(50% - clamp(28px, 8vh, 52px)); }

.word {
  font-variant-ligatures: none;
  font-weight: 600;
  font-size: var(--reader-size, 3.4rem);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--word);
  white-space: nowrap;
  /* ORP-Ausrichtung: das Wort wird per JS horizontal verschoben */
  position: relative;
  will-change: transform;
}
.word .w-orp { color: var(--accent); }
.word.no-orp .w-orp { color: var(--word); }
.word.is-idle { color: var(--word-dim); font-size: clamp(1.1rem, 4vw, 1.5rem); font-weight: 500; }
.word.is-idle .w-orp { color: var(--word-dim); }

/* Fortschritt */
.progress-wrap { margin-top: 14px; }
.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 99px;
  transition: width .12s linear;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Steuerung */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}
.ctrl {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.ctrl:hover { border-color: var(--accent); }
.ctrl:active { transform: scale(0.92); }
.ctrl-primary {
  width: 66px;
  height: 66px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-soft);
}
.ctrl-primary:hover { filter: brightness(1.05); border: none; }
.ctrl-icon { display: grid; place-items: center; }

/* Panels */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}
.field label strong { color: var(--text); font-weight: 700; }

.ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: -2px;
}

/* Range-Slider eigenes Aussehen */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  cursor: pointer;
}

.field-row { display: flex; flex-direction: column; gap: 8px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  font-family: inherit;
}
textarea::placeholder { color: var(--text-faint); }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.84rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.text-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  flex: 1 1 auto;
  min-width: 90px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); }

.privacy-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-faint);
  margin: 4px 0 0;
}

/* Fokus-States */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
input[type="range"]:focus-visible { outline-offset: 6px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .progress-fill { transition: none !important; }
}

/* Schmale Geräte */
@media (max-width: 400px) {
  .topbar { padding: 14px 14px 6px; }
  .layout { padding: 6px 14px 36px; }
  .ctrl { width: 46px; height: 46px; }
  .ctrl-primary { width: 60px; height: 60px; }
  .btn { min-width: 0; }
}
