:root {
  --bg: #f5f4f0;
  --surface: #fffdf9;
  --surface-2: #efe9df;
  --ink: #1f1b16;
  --ink-2: #5d554b;
  --ink-3: #8f857a;
  --line: #e2dacd;
  --accent: #2b4a8f;
  --accent-ink: #fff;
  --accent-soft: #dfe6f4;
  --hl: #ffd86b;
  --hl-ink: #1f1b16;
  --ok: #2f7d4f;
  --warn: #b26b12;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 8px 24px rgba(40, 30, 20, .08);
  --radius: 14px;
  --zh: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --fr: "Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, var(--zh);
  --bar-h: 132px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: currentColor; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font: 600 20px/1 var(--zh);
}
.navlink { text-decoration: none; color: var(--ink-2); font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.navlink:hover { background: var(--surface-2); }

.view { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.view.with-bar { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 24px); }

h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 28px 0 10px; color: var(--ink-2); font-weight: 600; }
.sub { color: var(--ink-2); margin: 0 0 18px; }
.muted { color: var(--ink-3); }

/* ---------- Karten / Buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; }

/* ---------- Login ---------- */
.login { max-width: 360px; margin: 12vh auto 0; padding: 28px 24px; text-align: center; }
.login .big { font: 600 64px/1 var(--zh); color: var(--accent); margin-bottom: 8px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }
.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.error { color: var(--accent); font-size: 14px; min-height: 1.4em; }

/* ---------- Stufenwahl ---------- */
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.level {
  display: flex; flex-direction: column; gap: 2px; padding: 18px 16px; text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.level:hover { transform: translateY(-2px); border-color: var(--accent); }
.level .lv { font-size: 13px; color: var(--ink-3); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.level .num { font: 700 34px/1.1 var(--ui); color: var(--accent); }
.level .cnt { font-size: 14px; color: var(--ink-2); }
.level.empty .num { color: var(--ink-3); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 8px; }

.segmented.filter { margin: 0 0 14px; }
.segmented .count { margin-left: 6px; font-size: 12px; color: var(--ink-3); font-weight: 500; }
.len { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-right: 8px; background: var(--surface-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.len-kurz { color: var(--ok); }
.len-lang { color: var(--accent); }
.len-sehr_lang { color: #fff; background: var(--accent); }
#len-choice { width: fit-content; }
@media (max-width: 480px) {
  .segmented.filter, #len-choice { width: 100%; }
  .segmented.filter button, #len-choice button { flex: 1 1 auto; padding: 8px 4px; font-size: 13px; }
  .segmented.filter .count { margin-left: 3px; }
}

.textlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.textlist a {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none;
}
.textlist a:hover { border-color: var(--accent); }
.textlist .zh { font: 500 19px/1.3 var(--zh); }
.textlist .de { font-size: 14px; color: var(--ink-2); }
.textlist .meta { margin-left: auto; font-size: 13px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; display: flex; align-items: center; }
.empty-state { padding: 28px 20px; text-align: center; color: var(--ink-2); }

/* ---------- Player / Mitlesen ---------- */
.player-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.back { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; text-decoration: none; border: 1px solid var(--line); background: var(--surface); }
.player-head .titles { min-width: 0; }
.player-head .title-zh { font: 600 24px/1.3 var(--zh); margin: 0; }
.player-head .title-de { color: var(--ink-2); margin: 2px 0 0; font-size: 15px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; margin-right: 6px; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; cursor: pointer; user-select: none;
}
.chip input { accent-color: var(--accent); margin: 0; }

.reader {
  padding: 22px 20px; font: 400 28px/2.1 var(--zh); letter-spacing: .02em; word-break: break-all;
}
.reader.pinyin-on { line-height: 2.6; }
.reader { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.tok { cursor: pointer; border-radius: 6px; padding: 2px 1px; transition: background-color .08s linear; }
.tok rt { font: 500 12px/1 var(--ui); color: var(--ink-3); letter-spacing: 0; ruby-position: over; display: none; }
.reader.pinyin-on .tok rt { display: ruby-text; }
.tok:hover { background: var(--surface-2); }
.tok.active { background: var(--hl); color: var(--hl-ink); }
.tok.active rt { color: var(--hl-ink); }
.tok.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.punct { color: var(--ink-2); }

.translation { margin-top: 14px; padding: 18px 20px; color: var(--ink-2); font-size: 16px; line-height: 1.65; }
.translation h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

.footer-actions { margin-top: 26px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- Player-Leiste ---------- */
.playerbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(0,0,0,.06);
}
.playerbar > * { max-width: 760px; margin: 0 auto; }
.seekrow { display: flex; align-items: center; gap: 10px; }
.time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-3); width: 36px; text-align: center; }
#seek { flex: 1; accent-color: var(--accent); height: 28px; }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.transport { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.play-btn {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.play-btn svg { width: 30px; height: 30px; }


.switches { display: flex; gap: 10px; flex-wrap: wrap; }
.switch-group { display: flex; flex-direction: column; gap: 3px; }
.switch-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding-left: 4px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-2); min-height: 38px; white-space: nowrap;
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

@media (max-width: 480px) {
  .controls { justify-content: center; }
  .transport { margin: 0 auto; }
  .switches { width: 100%; flex-wrap: nowrap; }
  .switch-group { flex: 1; min-width: 0; }
  .switch-group .segmented { width: 100%; }
  .segmented button { flex: 1; padding: 8px 6px; }
  :root { --bar-h: 192px; }
  .transport { gap: 2px; }
  .transport .icon-btn { width: 40px; }
  .reader { font-size: 26px; padding: 18px 14px; }
}

/* ---------- Fokus-Modus ---------- */
.focus {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
.focus-close {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 14px; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 18px; cursor: pointer;
}
.focus-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; user-select: none; }
.focus-word { font: 600 clamp(72px, 26vw, 200px)/1.1 var(--zh); color: var(--ink); min-height: 1.1em; }
.focus-word.punct-pause { color: var(--ink-3); }
.focus-pinyin { margin-top: 18px; font-size: clamp(22px, 6vw, 36px); color: var(--accent); min-height: 1.3em; font-weight: 500; }
.focus-trans { margin-top: 8px; font-size: clamp(16px, 4.5vw, 22px); color: var(--ink-2); min-height: 1.3em; }
.focus-controls { display: flex; justify-content: center; align-items: center; gap: clamp(4px, 2.5vw, 16px); padding-top: 8px; }
.focus-skip {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: transparent; color: var(--ink); cursor: pointer;
}
.focus-skip svg { width: 34px; height: 34px; }
.focus-skip:active { transform: scale(.92); background: var(--surface-2); }
.focus-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 52px; padding: 8px 2px;
  border: 0; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer;
}
.focus-btn svg { width: 30px; height: 30px; color: var(--ink); }
.focus-play {
  display: grid; place-items: center; width: 72px; height: 72px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}
.focus-play svg { width: 38px; height: 38px; }

.focus-btn:active, .focus-play:active { transform: scale(.95); }
.hf-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.handsfree-on .hf-dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.handsfree-on .handsfree-chip { border-color: var(--accent); color: var(--accent); }
.mic-btn.listening svg { color: var(--accent); animation: pulse 1s ease-in-out infinite; }
.icon-btn.mic-btn.listening { background: var(--accent-soft); }
@keyframes pulse { 50% { transform: scale(1.18); } }
.focus-bottom { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 12px 0 16px; flex-wrap: wrap; }
.focus-hint { font-size: 13px; color: var(--ink-3); }
.focus-progress { height: 4px; background: var(--surface-2); border-radius: 4px; margin-bottom: 14px; overflow: hidden; }
#focus-progress-bar { height: 100%; width: 0; background: var(--accent); }
.focus.paused .focus-word { opacity: .55; }
.focus-end { display: none; gap: clamp(28px, 10vw, 64px); align-items: center; justify-content: center; }
.focus.ended .focus-end { display: flex; animation: fade-in .25s ease-out; }
.focus.ended .focus-word, .focus.ended .focus-pinyin, .focus.ended .focus-trans { display: none; }
.end-btn {
  display: grid; place-items: center; width: clamp(104px, 30vw, 150px); height: clamp(104px, 30vw, 150px);
  border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
}
.end-btn svg { width: 48%; height: 48%; }
.end-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.end-btn:active { transform: scale(.95); }
@keyframes fade-in { from { opacity: 0; transform: scale(.96); } }

/* ---------- Popup ---------- */
.popup {
  position: fixed; z-index: 60; min-width: 180px; max-width: min(320px, calc(100vw - 24px));
  padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0,0,0,.18);
}
.popup-word { font: 600 30px/1.2 var(--zh); }
.popup-pinyin { color: var(--accent); font-size: 18px; font-weight: 500; margin-top: 2px; }
.popup-trans { color: var(--ink-2); margin-top: 4px; font-size: 15px; }
.popup-play {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: 14px;
}
.popup-play svg { width: 18px; height: 18px; }

/* ---------- Vokabeln ---------- */
.vocab-levels { margin-bottom: 12px; display: flex; width: 100%; max-width: 520px; }
.vocab-levels button { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; }
.vocab-tools { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-bottom: 8px; }
.vocab-tools .chip { grid-column: 1 / -1; justify-self: start; }
.vocab-count { font-size: 14px; margin: 4px 0 10px; }
.vocab-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.vocab-item { padding: 10px 14px; cursor: pointer; }
.vocab-item:hover { border-color: var(--accent); }
.vocab-main { display: flex; align-items: flex-start; gap: 14px; }
.vocab-zh { font: 500 26px/1.2 var(--zh); min-width: 2.2em; }
.vocab-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.vocab-py { color: var(--accent); font-weight: 500; }
.vocab-de { color: var(--ink-2); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vocab-item.open .vocab-de { -webkit-line-clamp: unset; }
.vocab-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; padding-top: 3px; }
.vocab-meta .badge { margin: 0; }
.vocab-occ { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.vocab-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); cursor: default; }
.vocab-texts { margin-top: 12px; display: grid; gap: 6px; font-size: 15px; }
.stroke-panel { display: grid; gap: 10px; justify-items: center; }
.stroke-chars { display: flex; gap: 8px; justify-content: center; width: 100%; }
.stroke-cell { position: relative; background: var(--bg); border-radius: 6px; }
.stroke-cell .grid { position: absolute; inset: 0; width: 100%; height: 100%; }
.stroke-cell .grid rect { fill: none; stroke: #d9b9ae; stroke-width: 1; }
.stroke-cell .grid line { stroke: #e6cfc7; stroke-width: .6; stroke-dasharray: 3 3; }
.stroke-cell svg:not(.grid) { position: relative; width: 100%; height: 100%; }  /* nicht die 24-px-Icon-Regel */
.quizzing .stroke-cell { touch-action: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.stroke-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn.small svg { width: 16px; height: 16px; }
.stroke-status { font-size: 14px; min-height: 1.3em; text-align: center; }
.vocab-texts a { text-decoration: none; font-family: var(--zh); }
.vocab-texts a:hover { color: var(--accent); }
@media (max-width: 480px) {
  .vocab-tools { grid-template-columns: 1fr; }
  .vocab-levels button { font-size: 12.5px; }
  .vocab-main { gap: 10px; }
  .vocab-zh { font-size: 23px; }
  .topnav .navlink { padding: 6px 6px; font-size: 13px; }
}

/* ---------- Admin ---------- */
.form { display: grid; gap: 14px; padding: 20px; }
.form label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.status { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--accent); }
.jobs { display: grid; gap: 10px; }
.job { padding: 14px 16px; }
.job-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.job-state { font-size: 13px; }
.job-state.running, .job-state.queued { color: var(--warn); }
.job-state.done { color: var(--ok); }
.job-state.failed, .job-state.interrupted { color: var(--accent); }
.job pre { margin: 8px 0 0; font-size: 12.5px; white-space: pre-wrap; color: var(--ink-2); max-height: 180px; overflow: auto; font-family: ui-monospace, Menlo, monospace; }
.progress { height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; background: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 80; font-size: 14px;
  box-shadow: var(--shadow);
}
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0s !important; } }

/* ---------- Wiedergabe-Zustand ---------- */
.play-btn, .focus-play { position: relative; }
.play-btn .i-pause, .play-btn .i-replay, .focus-play .i-pause, .focus-play .i-replay { display: none; }
.playing .play-btn .i-play, .playing .focus-play .i-play { display: none; }
.playing .play-btn .i-pause, .playing .focus-play .i-pause { display: block; }
.ended .play-btn .i-play, .ended .focus-play .i-play { display: none; }
.ended .play-btn .i-replay, .ended .focus-play .i-replay { display: block; }
.ring { position: absolute; inset: -5px; border-radius: 50%; border: 3px solid transparent; pointer-events: none; }
.loading .ring { border-color: color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.needs-tap .play-btn, .needs-tap .focus-play { animation: tap-pulse 1.1s ease-in-out infinite; }
@keyframes tap-pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 22%, transparent); } }

.mode-btn { position: relative; }
.mode-btn svg .one { display: none; }
.mode-btn[data-mode="one"] svg .one { display: inline; }
.mode-btn[data-mode="off"] svg { color: var(--ink-3); }
.mode-btn[data-mode="one"] svg, .mode-btn[data-mode="auto"] svg { color: var(--accent); }
.mode-dot { position: absolute; bottom: 5px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); display: none; }
.mode-btn[data-mode="one"] .mode-dot, .mode-btn[data-mode="auto"] .mode-dot { display: block; }
.focus-btn.mode-btn[data-mode="one"] .mode-label, .focus-btn.mode-btn[data-mode="auto"] .mode-label { color: var(--accent); }

/* Hinweise nie über den Bedienknöpfen: über der Player-Leiste bzw. im Fokus-Modus oben */
body:has(#playerbar:not([hidden])) .toast { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 14px); }
body:has(#focus:not([hidden])) .toast { top: calc(env(safe-area-inset-top) + 20px); bottom: auto; }
.toast { max-width: calc(100vw - 32px); text-align: center; }

/* ---------- Französisch: Lesetext, Grammatik-Markierung ---------- */
.reader { font: 400 22px/1.75 var(--fr); letter-spacing: 0; word-break: normal; hyphens: manual; }
.reader .tok { padding: 1px 0; border-radius: 4px; }
.reader .punct { color: var(--ink); }
.title-zh, .textlist .zh { font-family: var(--fr); }
.focus-word { font: 600 clamp(40px, 13vw, 112px)/1.15 var(--fr); word-break: break-word; }
.focus-pinyin { font-size: clamp(16px, 4.2vw, 24px); }
.popup-word { font-family: var(--fr); font-size: 26px; }
.popup-pinyin { font-size: 15px; }
@media (max-width: 480px) { .reader { font-size: 20px; padding: 18px 16px; } }

/* sechs gut unterscheidbare Markierungsfarben (Unterstreichung + leichter Hintergrund) */
.g0 { --gc: #c2410c; } .g1 { --gc: #15803d; } .g2 { --gc: #7c3aed; } .g3 { --gc: #b45309; } .g4 { --gc: #0e7490; } .g5 { --gc: #be185d; }
.grammar-on .tok.gram { box-shadow: inset 0 -3px 0 var(--gc); background: color-mix(in srgb, var(--gc) 9%, transparent); }
.tok.active, .grammar-on .tok.gram.active { background: var(--hl); color: var(--hl-ink); }
.gram-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 0 12px; font-size: 13px; color: var(--ink-2); }
.gram-key { display: inline-flex; align-items: center; gap: 6px; }
.gram-key::before { content: ""; width: 16px; height: 4px; border-radius: 2px; background: var(--gc); }
.gram-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.gram-tag { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Erzeugen: Grammatik-Auswahl */
.gram-choose { display: grid; gap: 8px; }
.gram-head { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.gram-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.gram-opt { display: flex !important; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); cursor: pointer; font-weight: 500 !important; color: var(--ink) !important; font-size: 14px !important; }
.gram-opt input { accent-color: var(--accent); margin: 0; }
.gram-opt small { margin-left: auto; color: var(--ink-3); font-weight: 600; font-size: 11px; }
.gram-opt.on { border-color: var(--accent); background: var(--accent-soft); }

/* Vokabeln */
.vocab-zh { font: 500 21px/1.25 var(--fr); min-width: 0; }
.vocab-py { color: var(--ink-3); font-weight: 500; font-size: 13.5px; }
.vocab-de-inline { color: var(--ink-2); }
.brand-mark { font-family: var(--fr); }

.job-cancel { margin-top: 10px; color: var(--accent); }
.job-note { font-size: 13px; margin: 8px 0 0; }
.job-state.cancelling, .job-state.cancelled { color: var(--ink-3); }
