/* ==========================================================================
   Grammatik-Trainer A2 – Stylesheet
   ========================================================================== */

:root {
  --bg:        #f4f5fb;
  --bg-soft:   #eceef8;
  --surface:   #ffffff;
  --surface-2: #f8f9fd;
  --border:    #e0e3f0;
  --text:      #1b1c2b;
  --text-dim:  #61637a;
  --primary:   #4f46e5;
  --primary-d: #4338ca;
  --primary-l: #eef0ff;
  --accent:    #f59e0b;
  --ok:        #12805c;
  --ok-bg:     #e4f7ef;
  --bad:       #c62828;
  --bad-bg:    #fdeaea;
  --shadow:    0 1px 2px rgba(20,20,50,.06), 0 8px 24px rgba(20,20,50,.06);
  --radius:    16px;
  --maxw:      880px;
}

html[data-theme="dark"] {
  --bg:        #0f1117;
  --bg-soft:   #151823;
  --surface:   #191c27;
  --surface-2: #1f2331;
  --border:    #2b3042;
  --text:      #e9eaf2;
  --text-dim:  #9ca0b8;
  --primary:   #8b87ff;
  --primary-d: #a5a1ff;
  --primary-l: #24263c;
  --accent:    #fbbf24;
  --ok:        #4ade80;
  --ok-bg:     #14301f;
  --bad:       #fca5a5;
  --bad-bg:    #34191b;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

/* Auf breiten Bildschirmen darf die App mehr Platz nehmen. Im Vollbild und
   in einer Seite über die ganze Breite wirkt eine schmale Spalte verloren. */
@media (min-width: 1180px) {
  :root { --maxw: 1120px; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .8em; }
b, strong { color: var(--text); font-weight: 600; }
s { color: var(--bad); }

/* ------------------------------- Kopfzeile ------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: .6rem 1rem;
  display: flex; align-items: center; gap: .6rem;
  /* Mit vier Niveaus passt die Zeile auf dem Telefon nicht mehr nebeneinander.
     Die Bedienelemente rutschen dann gemeinsam in eine zweite Zeile. */
  flex-wrap: wrap; row-gap: .5rem;
}
.brand {
  display: flex; align-items: center; gap: .55rem; min-width: 0;
  font-weight: 700; letter-spacing: -.02em; cursor: pointer;
  background: none; border: 0; color: var(--text); font-size: 1rem; padding: 0;
  text-align: left;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 800;
}
.brand small { display: block; font-size: .68rem; color: var(--text-dim); font-weight: 500; }
.spacer { flex: 1; }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  font-size: 1rem; display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

@media (max-width: 480px) {
  .topbar-inner { padding: .55rem .75rem; gap: .45rem; }
  .brand { font-size: .92rem; }
  .lang-select { max-width: 7.5rem; }
}

/* --------------------------------- Layout -------------------------------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 1.1rem 1rem 5.5rem; }
.view { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.hero {
  background: linear-gradient(135deg, var(--primary), #7c3aed 60%, #a855f7);
  color: #fff; border: 0;
}
.hero h1 { color: #fff; margin-bottom: .2rem; }
.hero p { color: rgba(255,255,255,.86); margin-bottom: .9rem; }
.hero .bar { background: rgba(255,255,255,.25); }
.hero .bar span { background: #fff; }
.hero-stats { display: flex; gap: 1.4rem; margin-top: .9rem; flex-wrap: wrap; }
.hero-stats div { font-size: .78rem; color: rgba(255,255,255,.8); }
.hero-stats b { display: block; font-size: 1.35rem; color: #fff; line-height: 1.2; }

/* Fortschrittsbalken */
.bar { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .68rem 1.15rem; border-radius: 12px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; transition: .15s; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--primary-d); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn.light { background: #fff; color: #4f46e5; }
.btn.light:hover { background: #f2f2ff; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }

/* -------------------------------- Kapitel -------------------------------- */
.chapter-title {
  display: flex; align-items: center; gap: .5rem;
  margin: 1.6rem .2rem .7rem; font-size: .78rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--text-dim);
}
.chapter-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.topic-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.topic {
  text-align: left; width: 100%; font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: .85rem .95rem; transition: .16s; display: block;
}
.topic:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.topic-head { display: flex; align-items: center; gap: .6rem; }
.topic-icon { font-size: 1.2rem; width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  background: var(--primary-l); border-radius: 10px; }
.topic-name { font-weight: 650; }
.topic-sub { font-size: .76rem; color: var(--text-dim); }
.topic .bar { margin-top: .7rem; height: 6px; }
.topic-meta { display: flex; justify-content: space-between; font-size: .7rem; color: var(--text-dim); margin-top: .35rem; }
.badge {
  font-size: .66rem; font-weight: 700; padding: .1rem .45rem; border-radius: 99px;
  background: var(--primary-l); color: var(--primary);
}
.badge.done { background: var(--ok-bg); color: var(--ok); }

/* -------------------------------- Theorie -------------------------------- */
.theory > * { max-width: 100%; }
/* Fließtext bleibt lesbar, auch wenn die Seite breiter wird. Tabellen und
   Beispielkästen dürfen die Breite dagegen ausnutzen. */
.theory p, .rule, .warn, .topic-summary { max-width: 74ch; }
.rule {
  background: var(--primary-l); border-left: 4px solid var(--primary);
  padding: .75rem .9rem; border-radius: 0 12px 12px 0; margin: 0 0 .9rem; font-weight: 500;
}
.warn {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-left: 4px solid var(--accent);
  padding: .75rem .9rem; border-radius: 0 12px 12px 0; margin: 0 0 .9rem;
}
.examples { list-style: none; padding: 0; margin: 0 0 .9rem; }
.examples li {
  padding: .4rem .7rem .4rem 1.6rem; position: relative;
  background: var(--surface-2); border-radius: 10px; margin-bottom: .35rem;
}
.examples li::before { content: "\2192"; position: absolute; left: .65rem; color: var(--primary); font-weight: 700; }

.table-wrap { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
tr:last-child td { border-bottom: 0; }

/* --------------------------------- Quiz ---------------------------------- */
.quiz-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem; }
.quiz-head .bar { flex: 1; }
.counter { font-size: .8rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pill {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--primary); background: var(--primary-l);
  padding: .18rem .55rem; border-radius: 99px; margin-bottom: .6rem;
}
.question { font-size: 1.18rem; font-weight: 600; line-height: 1.5; margin-bottom: 1rem; }
.question .gap { color: var(--primary); font-weight: 800; letter-spacing: .05em; }

.options { display: grid; gap: .55rem; }
.option {
  display: flex; align-items: center; gap: .7rem; text-align: left; width: 100%;
  padding: .75rem .9rem; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: .13s;
}
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-l); }
.option .key {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .78rem; font-weight: 700; color: var(--text-dim);
}
.option.selected { border-color: var(--primary); background: var(--primary-l); }
.option.selected .key { background: var(--primary); color: #fff; border-color: var(--primary); }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.correct .key { background: var(--ok); color: #fff; border-color: var(--ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.option:disabled { cursor: default; }

.answer-input {
  width: 100%; padding: .8rem .95rem; font: inherit; font-size: 1.05rem;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
}
.answer-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }
.answer-input.correct { border-color: var(--ok); background: var(--ok-bg); }
.answer-input.wrong { border-color: var(--bad); background: var(--bad-bg); }
.hint { font-size: .78rem; color: var(--text-dim); margin-top: .45rem; }

/* Satzbau */
.build-area {
  min-height: 60px; padding: .6rem; border: 1.5px dashed var(--border); border-radius: 12px;
  display: flex; flex-wrap: wrap; gap: .4rem; align-content: flex-start; background: var(--surface-2);
}
.build-area:empty::before { content: "Tippe die W\00F6rter in der richtigen Reihenfolge an \2026"; color: var(--text-dim); font-size: .85rem; }
.word-bank { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.word {
  padding: .4rem .7rem; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: .12s;
}
.word:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.word.used { opacity: .3; pointer-events: none; }
.word.placed { background: var(--primary-l); border-color: var(--primary); }

.feedback { border-radius: 12px; padding: .8rem .95rem; margin-top: 1rem; animation: fade .2s ease; }
.feedback.ok  { background: var(--ok-bg);  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.feedback.bad { background: var(--bad-bg); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.feedback .verdict { font-weight: 700; display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.feedback .solution { font-weight: 600; margin-bottom: .3rem; }
.feedback .why { font-size: .9rem; color: var(--text-dim); }

/* Ergebnis */
.result-score { text-align: center; padding: .6rem 0 1rem; }
.result-score .big { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--primary); }
.result-score .sub { color: var(--text-dim); }
.review-item { border-top: 1px solid var(--border); padding: .7rem 0; font-size: .92rem; }
.review-item .q { font-weight: 600; }
.review-item .a { color: var(--ok); }
.review-item .m { color: var(--bad); text-decoration: line-through; }

/* Statistik */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: .8rem; text-align: center;
}
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; color: var(--primary); }
.stat span { font-size: .74rem; color: var(--text-dim); }
.stat-row { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: 0; }
.stat-row .name { flex: 1; font-size: .9rem; }
.stat-row .bar { width: 90px; flex: none; }
.stat-row .pct { width: 46px; text-align: right; font-size: .82rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Untere Navigation */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { max-width: var(--maxw); margin: 0 auto; display: flex; }
.tab {
  flex: 1; background: none; border: 0; padding: .5rem .2rem .6rem; cursor: pointer;
  color: var(--text-dim); font: inherit; font-size: .68rem; display: grid; gap: .1rem; justify-items: center;
}
.tab .ic { font-size: 1.15rem; line-height: 1.3; }
.tab.active { color: var(--primary); font-weight: 650; }

.empty { text-align: center; color: var(--text-dim); padding: 2rem 1rem; }
.empty .ic { font-size: 2.4rem; display: block; margin-bottom: .5rem; }
.back {
  background: none; border: 0; color: var(--text-dim); font: inherit; font-size: .85rem;
  cursor: pointer; padding: .2rem 0 .6rem; display: inline-flex; align-items: center; gap: .3rem;
}
.back:hover { color: var(--primary); }
.muted { color: var(--text-dim); font-size: .85rem; }
.center { text-align: center; }

@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  .question { font-size: 1.05rem; }
  .card { padding: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* -------------------------------- Kursplan -------------------------------- */
.lesson-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.lesson-nr {
  width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 1.05rem;
}
.lesson-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: .6rem .1rem; font: inherit; color: var(--text); cursor: pointer;
}
.lesson-item:hover { color: var(--primary); }
.lesson-item:first-of-type { border-top: 1px solid var(--border); margin-top: .8rem; }
.lesson-item .code {
  flex: none; font-size: .72rem; font-weight: 700; color: var(--primary);
  background: var(--primary-l); border-radius: 6px; padding: .1rem .35rem;
}
.lesson-item .name { flex: 1; font-size: .92rem; }
.lesson-item .bar { width: 64px; flex: none; }
.lesson-item .pct { width: 40px; text-align: right; font-size: .78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
@media (max-width: 420px) {
  .lesson-item .bar { display: none; }
}

/* ------------------------------ Sprachleiste ------------------------------ */
.lang-select {
  font: inherit; font-size: .85rem; padding: .35rem 1.6rem .35rem .6rem;
  border: 1px solid var(--border); border-radius: 11px; height: 38px;
  background: var(--surface) no-repeat right .5rem center; color: var(--text);
  cursor: pointer; max-width: 9.5rem; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: right .85rem center, right .6rem center;
  background-size: 5px 5px, 5px 5px;
}
.lang-select:hover, .lang-select:focus { border-color: var(--primary); outline: none; }
[dir="rtl"] .lang-select { padding: .35rem .6rem .35rem 1.6rem; background-position: left .6rem center, left .85rem center; }

/* ------------------------------ Niveauschalter ---------------------------- */
.level-switch {
  display: flex; gap: 2px; padding: 2px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.level-btn {
  font: inherit; font-size: .78rem; font-weight: 700; letter-spacing: .03em;
  padding: .3rem .6rem; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--text-dim); transition: .15s;
}
.level-btn:hover { color: var(--primary); }
.level-btn.active { background: var(--primary); color: #fff; }

/* --------------------- Erklärung in der Zielsprache ---------------------- */
.explain { border-left: 4px solid var(--primary); }
.explain h2 { color: var(--primary); }
.explain .pts { margin: 0 0 1rem; padding-left: 1.1rem; }
[dir="rtl"] .explain .pts { padding-left: 0; padding-right: 1.1rem; }
.explain .pts li { margin-bottom: .35rem; }
.ex-pairs { display: grid; gap: .45rem; }
.ex-pair { background: var(--surface-2); border-radius: 10px; padding: .5rem .75rem; }
.ex-pair .de { font-weight: 600; }
.ex-pair .tr { font-size: .9rem; color: var(--text-dim); }
[dir="rtl"] .ex-pair .de { direction: ltr; text-align: left; }
.note-card { border-left: 4px solid var(--accent); }
.field-label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: .3rem; }

/* -------------------------------- Lernlisten ------------------------------ */
.list-card { padding: 0; }
.list-card > summary {
  cursor: pointer; padding: .9rem 1.1rem; font-weight: 650; list-style: none;
  display: flex; align-items: center; gap: .55rem;
}
.list-card > summary::-webkit-details-marker { display: none; }
.list-card > summary::after { content: "▾"; margin-left: auto; color: var(--text-dim); }
[dir="rtl"] .list-card > summary::after { margin-left: 0; margin-right: auto; }
.list-card[open] > summary::after { content: "▴"; }
.list-card > summary:hover { color: var(--primary); }
.list-icon { font-size: 1rem; }
.list-count {
  font-size: .68rem; font-weight: 700; color: var(--primary);
  background: var(--primary-l); border-radius: 99px; padding: .1rem .45rem;
}
.list-card > p, .list-card > .table-wrap { margin-left: 1.1rem; margin-right: 1.1rem; }
.list-card > .table-wrap { margin-bottom: 1.1rem; }
/* Bedeutungsspalte in der Zielsprache */
.list-card th.gloss, .list-card td.gloss { color: var(--text-dim); }
/* Übersetzte Teile folgen der Schreibrichtung der Zielsprache, der deutsche
   Tabelleninhalt bleibt linksläufig (siehe Block „Deutsche Inhalte"). */
[dir="rtl"] .list-card > p.xl,
[dir="rtl"] .list-card table.xl th,
[dir="rtl"] .list-card table.xl td.gloss { direction: rtl; text-align: right; }

/* ---------------------------- Gemini-Weiterlernen -------------------------- */
.ai-card { border-left: 4px solid var(--accent); }
.ai-card h2 { font-size: 1rem; }
.ai-card .btn-row { margin-top: .8rem; }
.ai-prompt { margin-top: .9rem; }
.ai-prompt > summary {
  cursor: pointer; font-size: .82rem; color: var(--text-dim); list-style: none;
}
.ai-prompt > summary::-webkit-details-marker { display: none; }
.ai-prompt > summary::before { content: "▸ "; }
.ai-prompt[open] > summary::before { content: "▾ "; }
.ai-prompt > summary:hover { color: var(--primary); }
.ai-prompt p {
  margin: .5rem 0 0; padding: .7rem .85rem; border-radius: 10px;
  background: var(--surface-2); font-size: .85rem; color: var(--text-dim);
}
.btn.small { padding: .4rem .8rem; font-size: .82rem; margin-top: .6rem; }

/* --------------------------------- Test ---------------------------------- */
.pill.test { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.test-card { border-color: var(--accent); }
.test-btn { background: var(--accent); color: #23180a; }
.test-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 85%, #000); }
.lock-note { font-size: .78rem; margin: .6rem 0 0; }
.lesson-nr.passed { background: var(--accent); color: #23180a; }
.result-score .stamp { font-size: 2.6rem; line-height: 1; margin-bottom: .3rem; }
.result-score.pass .big { color: var(--ok); }
.result-score.fail .big { color: var(--text-dim); }
.verdict-big { font-size: 1.1rem; font-weight: 700; margin-top: .3rem; }
.result-score.pass .verdict-big { color: var(--ok); }
.result-score.fail .verdict-big { color: var(--bad); }

/* ------------------------------- Lernbericht ------------------------------ */
.report {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.report-head { display: flex; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--primary); padding-bottom: .9rem; }
.report-head h1 { margin: .1rem 0 .1rem; }
.report-brand { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); font-weight: 700; }
.report-sub { font-size: .85rem; color: var(--text-dim); }
.report-logo {
  margin-left: auto; width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
[dir="rtl"] .report-logo { margin-left: 0; margin-right: auto; }
.report-meta { display: flex; gap: 2rem; flex-wrap: wrap; margin: .9rem 0 1.2rem; }
.report-meta span { display: block; font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.report h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin: 1.3rem 0 .6rem; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; }
.report-note { font-size: .8rem; color: var(--text-dim); margin-top: 1.2rem; }
.report-sign { margin-top: 2rem; }
.sign-line { width: 210px; border-top: 1px solid var(--text); margin-bottom: .35rem; }
.sign-name { font-weight: 700; }
.sign-role { font-size: .85rem; color: var(--text-dim); }

/* ----------------------------- Arbeitsblätter ----------------------------- */
.sheet-tools { display: grid; gap: .8rem; }
.seg {
  display: flex; gap: .4rem; padding: .25rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.seg-btn {
  flex: 1; padding: .5rem .7rem; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-dim); font: inherit; font-weight: 600; cursor: pointer;
}
.seg-btn.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.sheet-opt { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.sheet-opt .field-label { margin: 0; }
.sheet-opt .lang-select { max-width: 6rem; }
.sheet-opt .btn.small { margin-top: 0; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }

.sheet {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--primary); padding-bottom: 1rem; }
.sheet-head h1 { margin: .15rem 0 .25rem; font-size: 1.6rem; letter-spacing: -.01em; }
.sheet-brand { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); font-weight: 700; }
.sheet-sub { font-size: .85rem; color: var(--text-dim); }
.sheet-topics { margin-top: .3rem; font-size: .78rem; color: var(--text-dim); }
.sheet-logo {
  margin-left: auto; width: 52px; height: 52px; border-radius: 13px; flex: none;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
[dir="rtl"] .sheet-logo { margin-left: 0; margin-right: auto; }
.sheet-meta { display: flex; gap: 1.4rem; flex-wrap: wrap; margin: 1rem 0 .4rem; }
.sheet-meta .line {
  display: flex; align-items: flex-end; gap: .5rem; flex: 1 1 210px;
  padding: .4rem .6rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.sheet-meta .line.short { flex: 0 0 185px; }
.sheet-meta .line b { white-space: nowrap; }
.sheet-meta .lab { font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.sheet-meta .fill { flex: 1; min-width: 60px; height: 1.1rem; border-bottom: 1px solid var(--text-dim); }
.sheet-note { margin: .2rem 0 0; font-size: .82rem; color: var(--text-dim); }

.sheet-tasks { counter-reset: task; margin-top: 1.2rem; }
.sheet-inst {
  display: flex; align-items: center; gap: .5rem;
  margin: 1.3rem 0 .7rem; padding-bottom: .3rem;
  font-weight: 600; font-size: .9rem; border-bottom: 1px solid var(--border);
}
.sec {
  width: 1.35rem; height: 1.35rem; flex: none; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: .76rem; font-weight: 800;
}
.sheet-task { counter-increment: task; position: relative; padding-left: 2.3rem; margin-bottom: 1.05rem; }
.sheet-task::before {
  content: counter(task) "."; position: absolute; left: 0; top: 0;
  font-weight: 800; font-size: .95rem; color: var(--primary);
}
.task-q { margin: 0; line-height: 2; }
.blank { display: inline-block; min-width: 6.5em; border-bottom: 1px solid var(--text-dim); }
.blank.mini { min-width: 3.2em; }
.task-options {
  list-style: none; counter-reset: opt; margin: .45rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .3rem .9rem;
}
.task-options li { display: flex; align-items: center; gap: .45rem; font-size: .95rem; }
.task-options li::before { counter-increment: opt; content: counter(opt, lower-alpha) ")"; color: var(--text-dim); font-size: .85rem; }
.box { width: .95rem; height: .95rem; flex: none; border: 1px solid var(--text-dim); border-radius: 3px; }
.task-words { margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.task-words span {
  padding: .12rem .45rem; font-size: .92rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.write-line { margin: 0; height: 1.5rem; border-bottom: 1px solid var(--text-dim); }

.sheet-answers { margin-top: 1.6rem; padding-top: .8rem; border-top: 2px solid var(--primary); }
.sheet-answers h2 { margin: 0 0 .6rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.sheet-answers ol { margin: 0; padding-left: 1.5rem; }
.sheet-answers li { margin-bottom: .45rem; font-size: .9rem; }
.sheet-why { display: block; font-size: .84rem; line-height: 1.5; color: var(--text-dim); }
.sheet-sign { margin-top: 2.4rem; padding-top: .6rem; break-inside: avoid; }
.sheet-sign .sign-line { width: 210px; border-top: 1px solid var(--text); margin-bottom: .35rem; }
.sheet-foot { margin-top: 1.4rem; padding-top: .5rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--text-dim); }

/* --------------------------------- Druck ---------------------------------- */
@media print {
  .topbar, .tabbar, .no-print, .back { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .report { border: 0; box-shadow: none; padding: 0; background: #fff; color: #000; }
  .report h2 { color: #444; }
  .report-logo { background: #4f46e5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .stat { border: 1px solid #ccc; }
  .stat b { color: #000; }
  table { font-size: .8rem; }
  th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrap { overflow: visible; border-color: #ccc; page-break-inside: auto; }
  tr { page-break-inside: avoid; }
  .report-sign { page-break-inside: avoid; }
  .sheet { border: 0; box-shadow: none; padding: 0; background: #fff; color: #000; }
  .sheet-logo { background: #4f46e5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-sub, .sheet-note, .sheet-why, .sheet-foot, .sheet-meta .lab, .sheet-topics { color: #333; }
  .sheet-meta .line { background: transparent !important; border-color: #999; }
  .sec { background: #4f46e5 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-sign { break-inside: avoid; page-break-inside: avoid; }
  .sheet-sign .sign-line { border-top-color: #000; }
  .task-options li::before { color: #333; }
  .sheet-inst { color: #000; }
  .sheet-task::before { color: #4f46e5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-inst { border-bottom-color: #999; break-after: avoid; page-break-after: avoid; }
  .sheet-task { break-inside: avoid; page-break-inside: avoid; }
  .blank, .write-line, .sheet-meta .fill { border-bottom-color: #000; }
  .box { border-color: #000; }
  .task-words span { border-color: #999; background: transparent; }
  .sheet-answers { break-before: page; page-break-before: always; }
}

/* Deutsche Inhalte bleiben auch in Sprachen mit rechtsläufiger Schrift
   linksläufig – sonst wandern Satzzeichen an die falsche Seite. */
[dir="rtl"] .theory,
[dir="rtl"] .list-card > p,
[dir="rtl"] .list-card table,
[dir="rtl"] .question,
[dir="rtl"] .options,
[dir="rtl"] .build-area,
[dir="rtl"] .word-bank,
[dir="rtl"] .feedback,
[dir="rtl"] .review-item,
[dir="rtl"] .topic-name,
[dir="rtl"] .topic-sub,
[dir="rtl"] .topic-summary,
[dir="rtl"] .lesson-item .name,
[dir="rtl"] .stat-row .name,
[dir="rtl"] .report table,
[dir="rtl"] .sheet-task,
[dir="rtl"] .sheet-answers ol {
  direction: ltr;
  text-align: left;
}
[dir="rtl"] .sheet-why { direction: rtl; text-align: right; }
[dir="rtl"] .sheet-sign .sign-line { margin-right: 0; margin-left: auto; }
[dir="rtl"] .topic-head, [dir="rtl"] .lesson-item, [dir="rtl"] .stat-row { direction: rtl; }
[dir="rtl"] .topic-head > div:last-child { text-align: right; }
[dir="rtl"] .topic-name, [dir="rtl"] .topic-sub { text-align: right; }

/* -------------------------------- Stoppuhr -------------------------------- */
.timer {
  flex: none; font-variant-numeric: tabular-nums; font-weight: 700; font-size: .85rem;
  padding: .2rem .55rem; border-radius: 99px;
  background: var(--primary-l); color: var(--primary);
  border: 1px solid transparent; transition: background .3s, color .3s;
}
.timer.warn {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
}
.timer.critical {
  background: var(--bad-bg); color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }
.result-score .expired {
  margin-top: .6rem; font-size: .9rem; font-weight: 600; color: var(--bad);
}

/* Eigene display-Regeln schlagen das voreingestellte [hidden] des Browsers.
   Diese Zeile stellt sicher, dass „hidden" überall wirklich versteckt. */
[hidden] { display: none !important; }

/* --------------------------- Konto und Adminbereich ---------------------- */
.auth-card { max-width: 440px; margin: 0 auto; }
.auth-card h1 { margin-top: 0; }
.auth-card .answer-input { width: 100%; margin-bottom: .2rem; }
.auth-msg {
  margin: .6rem 0 0; padding: .55rem .7rem; border-radius: 10px;
  background: var(--bad-bg, #fdeaea); color: var(--bad);
  font-size: .9rem; line-height: 1.4;
}
.linkish {
  font: inherit; background: none; border: 0; padding: 0;
  color: var(--primary); cursor: pointer; text-decoration: underline;
}
.linkish:hover { color: var(--primary-d); }
.auth-card .linkish { display: block; margin: .9rem auto 0; }
