/* Blickleser – Lesepult. Tokens oben, alles andere leitet sich ab. */
:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --stage: #fbfbfc;
  --fg: #1b2230;
  --muted: #5d6676;
  --line: #d6dae2;
  --accent: #d2452f;
  --accent-soft: #f6dcd6;
  --focus: #2f6fd2;
  --ok: #2e7d4f;
  --font-read: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-ui: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --surface: #181d26; --stage: #0b0e13; --fg: #e8ebf1; --muted: #98a1b2;
    --line: #2a313d; --accent: #ff6a52; --accent-soft: #3a211d; --focus: #79a6ff; --ok: #5cc28a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
  padding-inline: 16px; padding-block: 12px;
}
a { color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; }

button, .btn, select, input[type="text"], input[type="email"], input[type="password"] {
  font: inherit; font-size: 15px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); min-height: 48px; padding: 0 16px;
}
button, .btn { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
button:hover, .btn:hover { border-color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.ghost { background: transparent; }
.danger:hover { border-color: var(--accent); color: var(--accent); }
button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 20px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.01em; }
.brand .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand a { text-decoration: none; }
.label { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.flash { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; }
.flash.ok { border-color: var(--ok); }
.flash.err { border-color: var(--accent); color: var(--accent); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; }
.login form { width: 100%; max-width: 380px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }
.login .demo { font-family: var(--font-read); font-size: 30px; font-weight: 600; text-align: center; padding: 10px 0 6px; }
.login .demo b { color: var(--accent); font-weight: 600; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); }
.field input { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }

/* Bibliothek */
.upload { display: grid; gap: 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; padding: 20px; margin-bottom: 28px; }
.upload.drag { border-color: var(--accent); background: var(--accent-soft); }
.upload-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.upload-row input[type="text"] { flex: 1 1 240px; min-width: 0; }
.upload input[type="file"] { font: inherit; max-width: 100%; }
.books { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.book { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.book .info { min-width: 0; }
.book h2 { font-size: 18px; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.book h2 a { text-decoration: none; }
.book h2 a:hover { text-decoration: underline; }
.meta { font-family: var(--font-num); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); }
@media (max-width: 560px) { .book { grid-template-columns: 1fr; } }

/* Lesen */
.reader { height: 100%; display: grid; grid-template-rows: auto 1fr auto auto; gap: 12px; }
.reader .topbar { margin-bottom: 0; }
.stage {
  position: relative; background: var(--stage); border: 1px solid var(--line); border-radius: 14px;
  display: grid; place-items: center; min-height: 240px; overflow: hidden; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.guide { position: absolute; left: 50%; width: 2px; height: 18px; background: var(--line); transform: translateX(-50%); }
.guide.top { top: calc(50% - 4.2rem); } .guide.bottom { top: calc(50% + 3rem); }
.stage.mode-sentence .guide, .stage.mode-chunk .guide { display: none; }
#display { width: 100%; }
.word { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline;
  font-family: var(--font-read); font-size: clamp(2.2rem, 7vw, 4.6rem); font-weight: 600; letter-spacing: 0.01em; line-height: 1.1; }
.word .l { text-align: right; } .word .r { text-align: left; } .word .p { color: var(--accent); }
.chunk { font-family: var(--font-read); font-size: clamp(1.8rem, 5.5vw, 3.6rem); font-weight: 600; text-align: center; padding-inline: 24px; }
.sentence { font-family: var(--font-read); font-size: clamp(1.3rem, 3vw, 2.1rem); line-height: 1.45; max-width: 32ch; margin: 0 auto; padding: 24px; text-wrap: pretty; }
.hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 13px; padding-inline: 12px; }
.paused-tag { position: absolute; top: 14px; left: 16px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.save-tag { position: absolute; top: 14px; right: 16px; font-size: 12px; color: var(--muted); }
.progress { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; font-family: var(--font-num); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wpm { font-family: var(--font-num); font-size: 22px; font-weight: 600; min-width: 4ch; text-align: center; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
#playBtn { min-width: 140px; }
.stage:fullscreen { border-radius: 0; border: 0; }
@media (max-width: 560px) {
  .guide.top { top: calc(50% - 3rem); } .guide.bottom { top: calc(50% + 2.2rem); }
  .progress { grid-template-columns: 1fr 1fr; } .progress input { grid-column: 1 / -1; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
