/* LearnCards 3 – Styles. Nur Systemschriften, keine externen Ressourcen.
   Farben als Variablen; dunkles Schema per Systemeinstellung oder data-theme. */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1d2127;
  --muted: #5d6570;
  --border: #e0e3e8;
  --border-strong: #cdd2d9;
  --accent: #3a62c4;
  --accent-text: #2f55b0;
  --accent-soft: rgba(58, 98, 196, 0.1);
  --on-accent: #ffffff;
  --good: #2b7a4b;
  --good-soft: #e6f3eb;
  --bad: #b3423a;
  --bad-soft: #fbeceb;
  --warn: #a8660b;
  --code-bg: #f1f3f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 8px 32px rgba(16, 24, 40, 0.16);
  --backdrop: rgba(17, 20, 24, 0.38);
  --radius: 16px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --fast: 140ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111316;
    --surface: #1a1d21;
    --surface-2: #23272c;
    --text: #e6e8eb;
    --muted: #9ba3ad;
    --border: #2b3036;
    --border-strong: #3a4048;
    --accent: #86a6ef;
    --accent-text: #9db7f3;
    --accent-soft: rgba(134, 166, 239, 0.14);
    --on-accent: #0f1625;
    --good: #72cf98;
    --good-soft: rgba(114, 207, 152, 0.13);
    --bad: #f08c82;
    --bad-soft: rgba(240, 140, 130, 0.13);
    --warn: #e5b061;
    --code-bg: #15181b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111316;
  --surface: #1a1d21;
  --surface-2: #23272c;
  --text: #e6e8eb;
  --muted: #9ba3ad;
  --border: #2b3036;
  --border-strong: #3a4048;
  --accent: #86a6ef;
  --accent-text: #9db7f3;
  --accent-soft: rgba(134, 166, 239, 0.14);
  --on-accent: #0f1625;
  --good: #72cf98;
  --good-soft: rgba(114, 207, 152, 0.13);
  --bad: #f08c82;
  --bad-soft: rgba(240, 140, 130, 0.13);
  --warn: #e5b061;
  --code-bg: #15181b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --backdrop: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

#app {
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) calc(env(safe-area-inset-right, 0px) + 16px)
           calc(env(safe-area-inset-bottom, 0px) + 32px) calc(env(safe-area-inset-left, 0px) + 16px);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  #app { padding-left: calc(env(safe-area-inset-left, 0px) + 28px); padding-right: calc(env(safe-area-inset-right, 0px) + 28px); }
}

button, input, select, textarea { font: inherit; color: inherit; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 6px; }
kbd { border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 0.3em; margin: 0 0.15em; }
[hidden] { display: none !important; }

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

/* ---------- Bildschirme und Kopfzeile ---------- */

.screen { display: none; flex: 1; flex-direction: column; min-width: 0; }
.screen.active { display: flex; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 60px;
  margin-bottom: 8px;
}
.brand { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.topbar > .muted { margin: 0; text-align: right; }
.topbar-actions { display: flex; gap: 4px; align-items: center; min-width: 0; }

.page-title { font-size: 1.6rem; line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 6px; overflow-wrap: anywhere; }
.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted { color: var(--muted); margin: 0 0 12px; line-height: 1.55; }
.small { font-size: 0.875rem; }
.fineprint { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 20px 0 0; }
.status-note { color: var(--muted); font-size: 0.85rem; margin: 18px 0 0; line-height: 1.45; }
.status-note:empty { display: none; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.section-head .page-title { margin: 0; }

.icon {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Knoepfe (mind. 44 px hoch) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--fast), border-color var(--fast), opacity var(--fast);
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { opacity: 0.92; }
.btn.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.secondary:hover { border-color: var(--border-strong); }
.btn.ghost { color: var(--text); padding: 0 12px; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.subtle { background: var(--accent-soft); color: var(--accent-text); }
.btn.danger-soft { background: var(--surface); border-color: var(--border); color: var(--bad); }
.btn.danger-soft:hover { background: var(--bad-soft); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { font-size: 0.9rem; padding: 0 14px; }
.btn.back { padding-left: 6px; color: var(--accent-text); max-width: 60vw; }
.btn.back span { overflow: hidden; text-overflow: ellipsis; }
.btn:active { opacity: 0.75; }

@media (max-width: 639px) {
  .icon-label span { display: none; }
  .icon-label { padding: 0 11px; }
}
@media (min-width: 640px) {
  #home-account-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }
}

.link {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--accent-text); font-weight: 600; cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
  /* Tippziel 44 px hoch, ohne die Zeilenhoehe des Absatzes zu veraendern */
  display: inline-block; min-height: 44px; padding: 10px 2px; margin: -10px 0; line-height: 24px;
  vertical-align: baseline;
}

.button-row { display: flex; gap: 10px; margin-top: 14px; }
.button-row > .btn { flex: 1; }
.button-wrap { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Eingabefelder ---------- */

.field-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.field-note { font-weight: 400; }
.input {
  display: block;
  width: 100%;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;            /* 16px verhindert das automatische Zoomen in iOS-Safari */
  transition: border-color var(--fast);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.input.tall { min-height: 180px; font-family: var(--mono); font-size: 14px; }
@supports (-webkit-touch-callout: none) { textarea.input.tall { font-size: 16px; } }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }

.message { display: none; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.92rem; line-height: 1.45; }
.message.visible { display: block; }
.message.error { background: var(--bad-soft); color: var(--bad); }

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

/* ---------- Fortschrittsbalken ---------- */

.progress { height: 6px; width: 100%; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin: 10px 0 8px; flex-shrink: 0; }
.progress.thin { height: 4px; margin: 0 0 12px; }
span.progress, span.progress-fill { display: block; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width 240ms ease; }

/* ---------- Listen (Ordner, Decks) ---------- */

.list { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .list { grid-template-columns: 1fr 1fr; } }

.row-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px 16px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--fast);
}
.row-card:hover { border-color: var(--border-strong); }
.row-card.no-icon { grid-template-columns: 1fr auto; }
.row-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text);
}
.row-main { min-width: 0; }
.row-title { display: block; font-weight: 650; font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; }
.row-sub { display: block; color: var(--muted); font-size: 0.875rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2; }
.row-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 0.82rem; }
.row-meta .progress { margin: 0; flex: 1; max-width: 160px; height: 4px; }
.row-chev { color: var(--muted); }
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; margin-left: 6px;
  vertical-align: 2px; white-space: nowrap;
}
.tag.public { color: var(--accent-text); background: var(--accent-soft); }
.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state p { margin: 0 0 12px; }

.manage { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--border); }
.manage-title { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 0 0 12px; letter-spacing: 0.02em; }
.manage .muted { margin-top: 12px; }
.visibility-box { margin-top: 22px; }
.visibility-box .muted { margin: 10px 0 0; }

/* ---------- Modus-Auswahl ---------- */

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
@media (min-width: 900px) { .mode-grid { grid-template-columns: repeat(4, 1fr); } }
.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 112px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--fast);
}
.mode-btn:hover { border-color: var(--accent); }
.mode-icon {
  width: 26px; height: 26px; margin-bottom: 10px;
  fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.mode-btn strong { font-size: 1rem; }
.mode-btn .sub { color: var(--muted); font-size: 0.84rem; line-height: 1.35; }

/* ---------- Formatierter Karteninhalt ---------- */

.rich { line-height: 1.62; overflow-wrap: anywhere; }
.rich p { margin: 0 0 0.75em; }
.rich ul { margin: 0 0 0.75em; padding-left: 1.25em; }
.rich li { margin: 0.2em 0; }
.rich > :last-child { margin-bottom: 0; }
.rich pre {
  margin: 0 0 0.85em;
  padding: 12px 14px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.82em;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;          /* breite Diagramme scrollen nur im Kasten, nie die Seite */
  overflow-wrap: normal;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}
.rich .empty { color: var(--muted); font-style: italic; }
.rich strong { font-weight: 650; }

/* ---------- Karteikarte ----------
   Kein 3D-Flip: die Karte hat eine feste, an den Bildschirm angepasste Hoehe,
   es ist immer nur eine Seite sichtbar, lange Antworten scrollen in der Karte. */

.flashcard {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  height: calc(100vh - 250px);
  height: calc(100dvh - 250px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  min-height: 280px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline-offset: 4px;
}
.face {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 20px;
  padding: 18px 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.face.back { display: none; }
.flashcard.flipped .front { display: none; }
.flashcard.flipped .back { display: flex; animation: fade-in var(--fast) ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.face-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; flex-shrink: 0; }
.face-label {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.face-label.answer { color: var(--accent-text); }
.face-section { font-size: 0.8rem; color: var(--muted); }
.face-section:not(:empty)::before { content: "· "; }

.face-content { margin: auto 0; width: 100%; }
.question-text { font-size: clamp(1.15rem, 0.9rem + 1.2vw, 1.55rem); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.front .question-text { text-align: center; max-width: 40ch; margin-left: auto; margin-right: auto; }
.question-text.left { text-align: left; font-size: 1.15rem; }
.face-q-mini {
  font-size: 0.9rem; color: var(--muted); line-height: 1.4;
  padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere; flex-shrink: 0;
}
.back .face-content { margin: 0 auto; max-width: 68ch; font-size: 1.05rem; }
/* Fragen mit Absaetzen, Listen oder Optionen: linksbuendig, normale Listen-Einrueckung */
.front .question-text.left { text-align: left; max-width: 68ch; }
.question-text.rich ul { font-weight: 500; }
.face-q-mini.rich p, .face-q-mini.rich ul { margin-bottom: 0.4em; }

/* Antwortmoeglichkeiten auf der Karteikarte (A, B, C …) */
.option-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px;
  font-size: 1rem; font-weight: 400; line-height: 1.45; text-align: left; }
.back .option-list { margin-top: 0; }
.option-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px;
  overflow-wrap: anywhere;
}
.option-letter {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 700;
}
.option-text { flex: 1; min-width: 0; }
.option-item.is-correct { background: var(--good-soft); border-color: var(--good); }
.option-item.is-correct .option-letter { background: var(--good); color: var(--surface); }
.option-item.is-other { color: var(--muted); }
.option-badge {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 3px;
  color: var(--good); font-size: 0.78rem; font-weight: 700;
}
.option-badge .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.explain-label {
  margin: 18px 0 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}

.hint { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 10px 0 4px; }

.answer-row { display: flex; gap: 12px; justify-content: center; padding: 8px 0 0; }
.answer-btn {
  flex: 1;
  max-width: 300px;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--fast);
}
.answer-btn.dont { background: var(--bad-soft); color: var(--bad); }
.answer-btn.know { background: var(--good-soft); color: var(--good); }
.answer-btn:active { opacity: 0.75; }

/* ---------- Test ---------- */

.question-panel { margin-bottom: 18px; }
.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice {
  width: 100%;
  min-height: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--fast), background-color var(--fast);
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice.correct { background: var(--good-soft); border-color: var(--good); }
.choice.wrong { background: var(--bad-soft); border-color: var(--bad); }
.choice-result { font-weight: 700; display: block; font-size: 0.8rem; margin-bottom: 4px; }
.choice-result:empty { display: none; }
.choice.correct .choice-result { color: var(--good); }
.choice.wrong .choice-result { color: var(--bad); }
/* "Weiter" nach Multiple Choice: bleibt am unteren Rand erreichbar, auch bei langen Antworten */
.mc-next {
  position: sticky;
  bottom: 0;
  margin-top: 4px;
  padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.mc-next .btn { min-height: 52px; }

/* Auswahlfragen im Test: Optionen antippen (Mehrfachauswahl mit Kaestchen, Wahr/Falsch mit Kreis) */
.option-choice { display: flex; align-items: flex-start; gap: 12px; }
.choice-mark {
  flex-shrink: 0;
  width: 22px; height: 22px; margin-top: 1px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--surface);
  transition: background-color var(--fast), border-color var(--fast);
}
.multi .choice-mark { border-radius: 6px; }
.choice-mark .icon { width: 16px; height: 16px; stroke-width: 3; }
.choice-body { flex: 1; min-width: 0; }
.choice-text { display: block; overflow-wrap: anywhere; line-height: 1.45; }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.selected .choice-mark { background: var(--accent); border-color: var(--accent); }
.choice.selected .choice-mark::after {
  content: ""; width: 6px; height: 11px; margin-top: -3px;
  border: solid var(--on-accent); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.choice.correct .choice-mark { background: var(--good); border-color: var(--good); color: var(--surface); }
.choice.wrong .choice-mark { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.choice.missed { border: 2px dashed var(--good); padding: 13px 15px; }
.choice.missed .choice-mark { border-color: var(--good); color: var(--good); }
.choice.missed .choice-result { color: var(--good); }
.choice.neutral { color: var(--muted); }
.choice.correct .choice-mark::after, .choice.wrong .choice-mark::after, .choice.missed .choice-mark::after { display: none; }
.choice-feedback { margin-top: 14px; }
.choice-verdict { margin: 0 0 6px; font-weight: 700; }
.choice-verdict.good { color: var(--good); }
.choice-verdict.bad { color: var(--bad); }
.choice-feedback .rich { max-width: 72ch; }
.choice-feedback .rich:empty { display: none; }

.written-area { display: none; }
.written-area .field-label { margin-top: 0; }
.written-area .btn.primary { margin-top: 12px; }
.reveal { display: none; margin-top: 14px; }
.reveal .rich { margin: 4px 0 8px; max-width: 72ch; }

/* ---------- Match ---------- */

.timer { text-align: center; font-size: 1.6rem; font-weight: 650; margin: 0 0 14px; font-variant-numeric: tabular-nums; }
.match-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .match-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .match-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.match-tile {
  min-width: 0;
  min-height: 104px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--fast), background-color var(--fast), opacity 200ms;
}
.tile-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.match-tile.answer-tile .tile-label { color: var(--accent-text); }
.tile-text {
  font-size: 0.875rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}
.match-tile.question-tile .tile-text { font-weight: 600; }
.match-tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.match-tile.matched { opacity: 0; pointer-events: none; }
.match-tile.wrong-flash { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- Ergebnis ---------- */

.result { text-align: center; padding: 56px 10px; max-width: 520px; margin: 0 auto; }
.result-title { font-size: 1.8rem; letter-spacing: -0.02em; margin: 0 0 10px; }
.result .btn { min-width: 200px; margin-top: 18px; }

/* ---------- Anmelden ---------- */

.login-wrap { flex: 1; display: grid; place-items: center; padding: 24px 0; }
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.login-logo { display: block; border-radius: 14px; margin-bottom: 14px; }
.login-title { font-size: 1.5rem; margin: 0 0 8px; letter-spacing: -0.015em; }
.login-card .btn.primary { margin-top: 18px; }
.login-card .login-cancel { margin-top: 8px; }
.login-step-title { margin: 4px 0 6px; color: var(--accent-text); }
#login-step-note { margin: 0 0 4px; }

/* ---------- Import ---------- */

.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 84px;
  margin: 18px 0 4px;
  padding: 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--fast);
}
.file-drop:hover { border-color: var(--accent); }
.file-drop input, .file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-drop .muted { margin: 0; }
.file-drop-title { color: var(--accent-text); font-weight: 650; }
.file-btn { position: relative; }
#screen-import textarea { margin-bottom: 12px; }

.preview { display: none; margin-top: 18px; }
.preview.visible { display: block; }
.preview .field-label { margin-top: 4px; }
.preview #import-summary { margin: 10px 0 8px; }
.sample-list { margin: 0; padding-left: 1.4em; font-size: 0.92rem; line-height: 1.45; }
.sample-list li { margin-bottom: 10px; overflow-wrap: anywhere; }
.sample-list .sample-q { font-weight: 600; }
.sample-list .sample-a { color: var(--muted); display: block; font-size: 0.86rem; }

/* ---------- Anleitung ---------- */

.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.toc a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.9rem; font-weight: 550;
}
.toc a:hover { border-color: var(--accent); }
.guide { max-width: 760px; }
.guide section { padding: 4px 0 22px; border-bottom: 1px solid var(--border); margin-bottom: 18px; scroll-margin-top: 16px; }
.guide section:last-child { border-bottom: none; }
.guide h3 { font-size: 1.15rem; margin: 6px 0 10px; }
.guide p, .guide li { line-height: 1.6; }
.guide ul, .guide ol { padding-left: 1.25em; margin: 0 0 12px; }
.guide li { margin: 4px 0; }
.example { margin: 8px 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.example pre {
  margin: 0; padding: 12px 14px;
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.5;
  white-space: pre; overflow-x: auto; tab-size: 8; -moz-tab-size: 8;
  background: var(--code-bg);
}
.example-bar { display: flex; gap: 6px; justify-content: flex-end; padding: 4px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.example-bar .btn { min-height: 44px; font-size: 0.875rem; }

/* ---------- Konto ---------- */

.settings { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 10px; }
@media (min-width: 820px) { .settings { grid-template-columns: 1fr 1fr; } }
.setting-group h3 { font-size: 1rem; margin: 0 0 10px; }
.setting-group .muted { margin-bottom: 12px; }
#legacy-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button {
  min-height: 44px; min-width: 76px; padding: 0 14px; border: none; border-radius: 9px;
  background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented button:disabled { opacity: 0.6; cursor: default; }

/* ---------- Dialog ---------- */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: var(--backdrop);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade-in var(--fast) ease-out;
}
.dialog {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-lg);
}
.dialog h3 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.35; overflow-wrap: anywhere; }
.dialog p { margin: 0 0 10px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.dialog .field-label { margin-top: 10px; }
.dialog-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.dialog-buttons .btn { flex: 1 1 auto; }
@media (max-width: 420px) { .dialog-buttons { flex-direction: column-reverse; } .dialog-buttons .btn { width: 100%; } }

/* ---------- Statuszeile (Synchronisierung) und Hinweis ---------- */

.sync-pill, .toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 56px); color: var(--text); }

/* ---------- Bewegung reduzieren ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
