[hidden] { display: none !important; }

:root {
  --teal: #7c3aed;        /* Primärfarbe LearnIt (Violett), zugleich theme-color */
  --teal-dark: #6d28d9;
  --teal-light: #ede9fe;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f5f3ff;
  --card: #ffffff;
  --line: #e5e7eb;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
}
button, a, select, input { -webkit-tap-highlight-color: transparent; font: inherit; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
.view {
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(96px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.hello { color: var(--teal-dark); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--red); font-size: 0.9rem; }
.banner { background: var(--teal-light); border-radius: var(--radius); padding: 12px; }
.version { text-align: center; font-size: 0.8rem; }
.loading { text-align: center; color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row:first-child { border-top: 0; }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.avatar { font-size: 1.6rem; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

label { display: block; font-size: 0.9rem; color: var(--muted); margin: 12px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); }
input:not([type="checkbox"]), select {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
select.small { width: auto; padding: 6px 8px; margin: 0; }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { background: transparent; color: var(--teal-dark); }
.btn.danger { background: #fee2e2; color: var(--red); }
.btn.small { display: inline-block; width: auto; padding: 6px 10px; margin: 0; font-size: 0.85rem; }
.subtle-link { color: var(--muted); font-size: 0.9rem; }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  border: 0;
  background: none;
  padding: 8px 0 10px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.75rem;
  cursor: pointer;
}
.tab.active { color: var(--teal); font-weight: 600; }
.tab-icon { font-size: 1.4rem; }

.login-page {
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.12);
}
.login-card h1 { text-align: center; margin: 0; color: var(--teal-dark); }
.logo { font-size: 3rem; text-align: center; }
.subtitle { text-align: center; color: var(--muted); margin: 4px 0 8px; }

@media (min-width: 640px) { #app, .login-card { zoom: 1.3; } }
@media (min-width: 900px) { #app, .login-card { zoom: 1.5; } }

/* ---------- Segmente und Editor (0.2.0) ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.topbar h1 { margin: 0; font-size: 1.25rem; min-width: 0; overflow-wrap: anywhere; }
.chev { color: var(--muted); font-size: 1.4rem; }
.kid-row, .seg-row, .asg-row { cursor: pointer; }
.btn[disabled] { opacity: 0.45; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--teal-dark);
  cursor: pointer;
}
.chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.page-img { display: block; width: 100%; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; }

.words { list-style: none; margin: 0; padding: 0; }
.word {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.word:first-child { border-top: 0; }
.word .de { color: var(--muted); text-align: right; }
.word.in { background: var(--teal-light); }
.word.start, .word.end { background: var(--teal); color: #fff; border-radius: 8px; }
.word.start .de, .word.end .de { color: #fff; }
.word.excluded { background: var(--teal-light); text-decoration: line-through; opacity: 0.5; }

.ed-bar {
  position: sticky;
  bottom: calc(64px + env(safe-area-inset-bottom));
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  padding: 12px;
}
.ed-bar input { margin-top: 0; }
.ed-bar .error { margin: 0 0 8px; }
.ed-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

.zoom { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.9); overflow: auto; cursor: zoom-out; }
.zoom img { display: block; width: 200%; max-width: none; }

/* ---------- Tests (0.3.0) ---------- */
.stars-mini { color: #f59e0b; letter-spacing: 1px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mode-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 600;
  color: var(--teal-dark);
  cursor: pointer;
}
.mode-tile.off { opacity: 0.45; cursor: default; }
.mode-icon { font-size: 1.6rem; }
.size-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  color: var(--teal-dark);
  cursor: pointer;
}
.size-btn.on { background: var(--teal); border-color: var(--teal); color: #fff; }

.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.q-bar { flex: 1; height: 10px; background: var(--teal-light); border-radius: 999px; overflow: hidden; }
.q-fill { height: 100%; background: var(--teal); transition: width 0.3s; }
.q-card { text-align: center; }
.q-label { color: var(--muted); margin: 0 0 6px; }
.q-prompt { font-size: 1.6rem; font-weight: 700; margin: 8px 0 16px; word-break: break-word; }
.q-back { font-size: 1.4rem; margin: 12px 0; }
.q-row { display: flex; gap: 8px; }
.q-row .btn { flex: 1; }
.q-opt {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 1.05rem;
  cursor: pointer;
}
.q-speak { font-size: 1.2rem; }
.q-retry { color: var(--amber); font-weight: 600; }
.q-hintword { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; letter-spacing: 1px; }
.q-feedback { text-align: center; border: 2px solid var(--line); }
.q-feedback.ok { border-color: var(--green); background: #f0fdf4; }
.q-feedback.almost { border-color: var(--amber); background: #fffbeb; }
.q-feedback.wrong { border-color: var(--teal-light); background: #faf5ff; }
.q-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 8px; }
.q-solution { font-size: 1.15rem; }
#q-input { text-align: center; font-size: 1.2rem; }

.result { text-align: center; }
.stars { font-size: 2.6rem; letter-spacing: 4px; margin: 8px 0; }
.star { color: var(--line); display: inline-block; transform: scale(0.6); animation: star-in 0.4s forwards; }
.star.on { color: #f59e0b; }
.star:nth-child(2) { animation-delay: 0.15s; }
.star:nth-child(3) { animation-delay: 0.3s; }
.star:nth-child(4) { animation-delay: 0.45s; }
.star:nth-child(5) { animation-delay: 0.6s; }
@keyframes star-in { to { transform: scale(1); } }
.praise { font-size: 1.15rem; font-weight: 600; color: var(--teal-dark); }

/* ---------- Belohnung (0.4.0) ---------- */
.level-card .level-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.level-bar, .badge-bar { height: 10px; background: var(--teal-light); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; align-self: stretch; width: 100%; }
.level-fill, .badge-fill { height: 100%; background: var(--teal); }
.streak { font-weight: 700; color: var(--amber); margin: 6px 0 0; }
.badge-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.badge-tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 12px 8px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); overflow-wrap: anywhere; }
.badge-medal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%; font-size: 1.8rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.bronze .badge-medal { background: radial-gradient(circle at 35% 30%, #f1c08b, #cd7f32); }
.silver .badge-medal { background: radial-gradient(circle at 35% 30%, #ffffff, #b8bcc4); }
.gold .badge-medal { background: radial-gradient(circle at 35% 30%, #fff3b0, #f5b400); }
.badge-tile.locked { opacity: 0.55; }
.badge-tile.locked .badge-medal { filter: grayscale(1); }
.w-status.learned { color: var(--green); font-weight: 700; }
.w-status.hard { color: var(--amber); }
.r-praise { font-size: 1.1rem; font-weight: 600; color: var(--teal-dark); margin: 6px 0; }
.r-total { font-size: 1.4rem; font-weight: 800; color: var(--teal); margin: 0 0 4px; text-align: center; }
.r-badge, .r-levelup { text-align: center; }
.r-badge .badge-medal { margin: 6px auto; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti span {
  position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px;
  animation: confetti-fall 2.4s ease-in forwards;
}
.confetti span:nth-child(3n) { background: #f59e0b; }
.confetti span:nth-child(3n + 1) { background: var(--teal); }
.confetti span:nth-child(3n + 2) { background: #10b981; }
.confetti span:nth-child(1) { left: 5%; animation-delay: 0s; }
.confetti span:nth-child(2) { left: 12%; animation-delay: 0.2s; }
.confetti span:nth-child(3) { left: 19%; animation-delay: 0.4s; }
.confetti span:nth-child(4) { left: 27%; animation-delay: 0.1s; }
.confetti span:nth-child(5) { left: 34%; animation-delay: 0.5s; }
.confetti span:nth-child(6) { left: 41%; animation-delay: 0.3s; }
.confetti span:nth-child(7) { left: 49%; animation-delay: 0.6s; }
.confetti span:nth-child(8) { left: 56%; animation-delay: 0.15s; }
.confetti span:nth-child(9) { left: 63%; animation-delay: 0.45s; }
.confetti span:nth-child(10) { left: 70%; animation-delay: 0.25s; }
.confetti span:nth-child(11) { left: 77%; animation-delay: 0.55s; }
.confetti span:nth-child(12) { left: 84%; animation-delay: 0.05s; }
.confetti span:nth-child(13) { left: 90%; animation-delay: 0.35s; }
.confetti span:nth-child(14) { left: 96%; animation-delay: 0.65s; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(540deg); opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .star { animation: none; transform: none; }
}

.cert-page {
  background: #fff;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.cert {
  max-width: 900px; margin: 0 auto; padding: 40px 32px; text-align: center;
  border: 10px double #f5b400; border-radius: 12px; background: #fffdf5;
}
.cert-top { letter-spacing: 6px; text-transform: uppercase; color: var(--muted); }
.cert-medal { font-size: 4rem; }
.cert-name { font-size: 2.4rem; color: var(--teal-dark); margin: 8px 0; }
.cert-title { font-size: 1.8rem; margin: 8px 0; }
.cert-date, .cert-sign { color: var(--muted); }
.cert-actions { max-width: 900px; margin: 16px auto; display: flex; gap: 8px; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  .cert-actions { display: none; }
  .cert { border-color: #d4a200; }
}

/* ---------- Zusatzübungen (0.5.0) ---------- */
.q-sentence { font-size: 1.2rem; line-height: 1.5; margin: 8px 0 12px; }
.q-gap { display: inline-block; min-width: 3.5em; border-bottom: 3px solid var(--teal); color: transparent; }
.scr-slots, .scr-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 12px; max-width: 100%; }
.scr-slots { column-gap: 16px; row-gap: 8px; }
/* F1: ein einzelnes langes Wort (z. B. 20 Buchstaben ohne Leerzeichen) darf in sich umbrechen,
   statt die Karte zu sprengen — min-width: 0 verhindert, dass der Flex-Container sich am
   Inhalt "min-content" aufbläht und dadurch horizontal scrollt. */
.scr-word { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 3px; row-gap: 6px; max-width: 100%; min-width: 0; }
.scr-slot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 38px; border-bottom: 3px solid var(--line);
  font-size: 1.3rem; font-weight: 700; color: var(--teal-dark);
}
.scr-slot.filled { border-color: var(--green); }
.scr-slot.fixed { width: auto; min-width: 8px; border-color: transparent; }
/* F2: Platz für den Fehltipp-Hinweis fest reservieren — die Zeile ist immer im DOM, wird aber
   nur bei einem Fehltipp sichtbar, damit "Lösung zeigen" darunter nicht springt. */
.scr-oops { min-height: 1.4em; }
.scr-oops.invisible { visibility: hidden; }
.scr-tile, .pair-tile {
  min-width: 48px; min-height: 48px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 1.3rem; font-weight: 700; color: var(--teal-dark); cursor: pointer;
  touch-action: manipulation;
}
.scr-tile.used { visibility: hidden; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.pair-col { display: flex; flex-direction: column; gap: 8px; }
/* F3: lange deutsche Beschriftungen ("Klassenkamerad, Klassenkameradin") sauber trennen statt
   mitten im Wort umzubrechen — lang="de" bzw. lang="en" am Element steuert die Trennregeln. */
.pair-tile { font-size: 1rem; font-weight: 600; overflow-wrap: break-word; hyphens: auto; }
.pair-tile.sel { border-color: var(--teal); background: var(--teal-light); }
.pair-tile.done { opacity: 0.55; border-color: var(--green); cursor: default; }
.shake { animation: shake 0.35s; border-color: var(--amber); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.pair-list .row { justify-content: space-between; }
@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
}
/* F6: #q-quit optisch klein, aber mit voller Tippfläche ≥ 44×44 px */
#q-quit { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Eltern-Ansicht und Aufträge (0.6.0) ---------- */
.kid-line { display: block; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.asg-status { display: block; color: var(--muted); margin-top: 2px; }
.asg-status.overdue { color: var(--amber); }
.asg-item.done strong { color: var(--muted); }
.asg-item strong { overflow-wrap: anywhere; }
.asg-del, #kid-tests-all { min-height: 44px; }
.asg-form { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.asg-form h3 { font-size: 1rem; margin: 0 0 8px; }

/* ---------- Admin: Vokabeln und Konto bearbeiten (0.6.0) ---------- */
textarea {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}
.voc-row { cursor: pointer; min-height: 44px; }
.voc-tag { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--teal-light); color: var(--teal-dark); }
.voc-tag.hidden-tag { background: #fee2e2; color: var(--red); }
.voc-orig { display: block; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.user-row .actions .btn.small, .user-edit .btn.small, .chip { min-height: 44px; }
.user-edit { flex-basis: 100%; border-top: 1px dashed var(--line); padding-top: 8px; }
.user-edit form { margin-bottom: 8px; }
.seg-few { color: var(--amber); }
.asg-form label.check { min-height: 44px; margin: 0; }

/* ---------- PWA-Feinschliff (1.0.0) ---------- */
.offline-bar {
  position: sticky; top: 0; z-index: 10; margin: 0;
  padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
  background: #fef3c7; color: #92400e; font-size: 0.9rem; text-align: center;
}
.offline-bar:not([hidden]) + .view { padding-top: 16px; }
.install h2 { margin-bottom: 4px; }
