:root {
  --bg: #f5f6ff;
  --surface: #ffffff;
  --surface-soft: #f0f2ff;
  --ink: #263047;
  --muted: #68718a;
  --primary: #5b5bd6;
  --primary-dark: #4545b7;
  --accent: #ffb86b;
  --success: #2f9b72;
  --danger: #cc4c63;
  --warning: #d18b16;
  --line: #dfe3f2;
  --shadow: 0 18px 50px rgba(62, 67, 130, .12);
  --radius: 24px;
  --radius-sm: 16px;
  --tap: 48px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 5%, rgba(132, 125, 255, .15), transparent 28rem),
    radial-gradient(circle at 95% 18%, rgba(255, 184, 107, .15), transparent 26rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 4px solid rgba(91, 91, 214, .25);
  outline-offset: 3px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(245, 246, 255, .9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(223, 227, 242, .8);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand img { flex: 0 0 auto; }
.brand strong { display: block; font-size: 1.12rem; line-height: 1.1; }
.brand small { color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .profile-button {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(62, 67, 130, .08);
}
.icon-button { width: var(--tap); padding: 0; font-size: 1.2rem; }
.profile-button { padding: 0 16px; font-weight: 700; }

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: clamp(22px, 5vw, 54px) 0 60px;
}
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  padding: 24px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.hero {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  align-items: center;
  gap: clamp(24px, 6vw, 72px);
  margin-bottom: 42px;
}
.hero-copy h1 {
  margin: 0 0 14px;
  max-width: 14ch;
  font-size: clamp(2.25rem, 6vw, 5rem);
  line-height: .98;
  letter-spacing: -.045em;
}
.hero-copy p {
  max-width: 60ch;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}
.hero-art { max-width: 400px; justify-self: center; width: 100%; }
.hero-art img { width: 100%; display: block; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #ececff;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: .88rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.course-grid, .module-grid, .stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.course-card, .module-card, .panel, .activity-card, .stat-card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.course-card {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 4vw, 34px);
}
.course-card::after {
  content: "";
  position: absolute;
  inset: auto -36px -52px auto;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-accent, var(--primary)) 16%, transparent);
}
.course-card h2, .module-card h3 { margin: 0 0 8px; }
.course-card p, .module-card p { margin: 0 0 20px; color: var(--muted); }
.course-icon { font-size: 3rem; margin-bottom: 12px; }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: .88rem;
  font-weight: 800;
}

.primary-button, .secondary-button, .choice-button, .text-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}
.primary-button, .secondary-button {
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 14px;
}
.primary-button { background: var(--primary); color: #fff; box-shadow: 0 10px 24px rgba(91, 91, 214, .25); }
.primary-button:hover { background: var(--primary-dark); }
.secondary-button { background: var(--surface-soft); color: var(--primary-dark); }
.text-button { background: transparent; color: var(--primary-dark); padding: 6px 8px; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.section-head, .activity-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}
.section-head h1, .activity-head h1 { margin: 0; }
.section-head p, .activity-head p { margin: 6px 0 0; color: var(--muted); }
.back-link { display: inline-flex; margin-bottom: 18px; color: var(--primary-dark); font-weight: 800; text-decoration: none; }

.progress-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7e9f5;
}
.progress-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8f87ff); }
.progress-label { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 0; color: var(--muted); font-size: .9rem; }

.module-card {
  display: flex;
  flex-direction: column;
  min-height: 245px;
  padding: 24px;
}
.module-card .module-icon { font-size: 2.5rem; }
.module-card .button-row { margin-top: auto; }

.activity-card { padding: clamp(18px, 4vw, 34px); }
.activity-stage {
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 20px 0;
  text-align: center;
}
.activity-stage.narrow { max-width: 760px; margin: 0 auto; }
.prompt-word { font-size: clamp(2.25rem, 8vw, 5.5rem); font-weight: 900; letter-spacing: .02em; }
.prompt-sentence { max-width: 28ch; font-size: clamp(1.5rem, 4vw, 2.6rem); font-weight: 800; }
.emoji-picture { font-size: clamp(5rem, 14vw, 9rem); line-height: 1; }
.speak-button { min-width: 120px; margin: 14px 0; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: min(720px, 100%); margin-top: 20px; }
.choice-button {
  min-height: 74px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-size: clamp(1.05rem, 3vw, 1.35rem);
}
.choice-button:hover { border-color: var(--primary); transform: translateY(-1px); }
.choice-button.correct { border-color: var(--success); background: #eaf8f2; color: #17684b; }
.choice-button.wrong { border-color: var(--danger); background: #fff0f3; color: #963448; }

.answer-input {
  width: min(520px, 100%);
  min-height: 64px;
  padding: 12px 18px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-size: clamp(1.2rem, 4vw, 2rem);
  text-align: center;
  font-weight: 800;
}
.feedback {
  min-height: 58px;
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 16px;
  color: var(--muted);
  font-weight: 700;
}
.feedback.success { background: #eaf8f2; color: #17684b; }
.feedback.error { background: #fff0f3; color: #963448; }
.feedback.info { background: #eef0ff; color: var(--primary-dark); }

.trace-wrap { width: min(820px, 100%); }
.trace-canvas {
  width: 100%;
  aspect-ratio: 16 / 8;
  display: block;
  border: 3px dashed #b9bee2;
  border-radius: 24px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.trace-toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }

.crossword-wrap { overflow-x: auto; width: 100%; padding: 4px; }
.crossword-grid {
  display: grid;
  gap: 4px;
  width: max-content;
  margin: 0 auto;
}
.crossword-cell {
  position: relative;
  width: clamp(42px, 8vw, 62px);
  height: clamp(42px, 8vw, 62px);
}
.crossword-cell.block { background: transparent; }
.crossword-cell input {
  width: 100%;
  height: 100%;
  border: 2px solid #aeb5db;
  border-radius: 8px;
  text-align: center;
  text-transform: uppercase;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 900;
  color: var(--ink);
  background: #fff;
}
.crossword-cell input.good { background: #eaf8f2; border-color: var(--success); }
.crossword-cell input.bad { background: #fff0f3; border-color: var(--danger); }
.crossword-number { position: absolute; top: 2px; left: 4px; z-index: 2; font-size: .68rem; font-weight: 900; color: var(--muted); pointer-events: none; }
.clue-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 22px; margin-top: 24px; text-align: left; }
.clue-list p { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-soft); }

.stat-card { padding: 20px; }
.stat-card strong { display: block; font-size: 2rem; }
.stat-card span { color: var(--muted); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 34, 58, .55);
}
.modal {
  width: min(480px, 100%);
  padding: 26px;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}
.modal h2 { margin-top: 0; }
.form-row { display: grid; gap: 8px; margin-bottom: 18px; }
.form-row label { font-weight: 800; }
.form-row input, .form-row select {
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}
.form-row small { color: var(--muted); line-height: 1.45; }
.speech-settings {
  margin: 20px 0;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}
.speech-settings h3 { margin: 0 0 16px; }
.speech-settings .secondary-button { width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  transform: translate(-50%, 140%);
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 999px;
  background: #273043;
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .25s ease;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.noscript { padding: 20px; background: #fff0f3; color: #963448; text-align: center; font-weight: 800; }
.empty-state { padding: 34px; text-align: center; color: var(--muted); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { order: -1; max-width: 240px; }
  .course-grid, .module-grid, .stats-grid { grid-template-columns: 1fr; }
  .choice-grid, .clue-list { grid-template-columns: 1fr; }
  .section-head, .activity-head { align-items: stretch; flex-direction: column; }
  .profile-button span { display: none; }
  .brand small { display: none; }
}

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

.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.choice-button:disabled, .primary-button:disabled, .secondary-button:disabled {
  cursor: default;
  opacity: .78;
}
.profile-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.profile-choice {
  min-height: 76px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.profile-choice > span { grid-row: 1 / 3; font-size: 1.6rem; }
.profile-choice strong { align-self: end; }
.profile-choice small { color: var(--muted); }
.profile-choice.active { border-color: var(--primary); background: var(--surface-soft); }

@media (max-width: 520px) {
  .profile-list { grid-template-columns: 1fr; }
}

/* Lerninsel v4: Bilder, Bildtexte und Mathematik */
.single-course { grid-template-columns: minmax(0, 760px); }
.learning-image {
  display: block;
  width: min(260px, 72vw);
  max-height: 210px;
  object-fit: contain;
  margin: 0 auto 16px;
  border-radius: 24px;
  box-shadow: 0 12px 30px rgba(38, 48, 71, .10);
}
.prompt-word.compact { font-size: clamp(2rem, 7vw, 4rem); }
.choice-grid.wide { grid-template-columns: 1fr; width: min(900px, 100%); }
.choice-grid.wide .choice-button { min-height: 64px; text-align: left; }
.family-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px 24px;
  border-radius: 20px;
  background: #eef9e8;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
}
.counter-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 420px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface-soft);
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  line-height: 1;
}
.counter-group.dots { max-width: 220px; color: var(--primary); }
.compare-visual, .math-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: min(900px, 100%);
  margin-bottom: 16px;
}
.compare-visual > strong, .math-visual > strong { font-size: clamp(1.8rem, 6vw, 3rem); }
.sequence-visual {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
.sequence-visual span {
  display: grid;
  place-items: center;
  min-width: 66px;
  min-height: 66px;
  padding: 8px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  font-weight: 900;
}
.shape-visual { font-size: clamp(6rem, 18vw, 10rem); line-height: 1; }
.picture-text-stage { gap: 12px; }
.picture-passage {
  width: min(980px, 100%);
  padding: clamp(18px, 4vw, 30px);
  border: 3px solid var(--line);
  border-radius: 24px;
  background: #fff;
  font-size: clamp(1.25rem, 3.2vw, 2rem);
  font-weight: 750;
  line-height: 2.2;
  text-align: left;
}
.picture-blank {
  display: inline-grid;
  grid-template-columns: minmax(92px, 126px);
  justify-items: center;
  vertical-align: middle;
  margin: 8px 10px;
  padding: 8px;
  border-radius: 18px;
  background: var(--surface-soft);
}
.picture-blank .learning-image {
  width: 112px;
  height: 82px;
  margin: 0 0 6px;
  border-radius: 14px;
  box-shadow: none;
}
.picture-word-input {
  width: 100%;
  min-height: 48px;
  padding: 7px 8px;
  border: 2px solid #aeb5db;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
  text-align: center;
}
.picture-word-input.good { border-color: var(--success); background: #eaf8f2; }
.picture-word-input.bad { border-color: var(--danger); background: #fff0f3; }
.letter-hunt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 86px));
  gap: 12px;
  margin: 16px 0 24px;
}
.letter-tile {
  aspect-ratio: 1;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-size: clamp(1.5rem, 5vw, 2.4rem);
  font-weight: 900;
  cursor: pointer;
}
.letter-tile.selected { border-color: var(--primary); background: #ececff; }
.letter-tile.correct { border-color: var(--success); background: #eaf8f2; }
.letter-tile.wrong { border-color: var(--danger); background: #fff0f3; }
.server-voice-note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
}
@media (max-width: 640px) {
  .compare-visual, .math-visual { flex-direction: column; }
  .picture-passage { line-height: 1.65; }
  .picture-blank { display: grid; margin: 12px auto; }
  .letter-hunt-grid { grid-template-columns: repeat(3, minmax(58px, 86px)); }
}

/* Lerninsel v5: Profilstart, Profilverwaltung und Vorlesemarkierung */
body.modal-open { overflow: hidden; }

.profile-landing {
  padding: clamp(24px, 5vw, 46px);
}
.profile-landing-copy {
  max-width: 760px;
  margin: 0 auto 28px;
  text-align: center;
}
.profile-landing-copy h1 {
  margin: 0 0 10px;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
  line-height: 1;
}
.profile-landing-copy p { color: var(--muted); font-size: 1.08rem; }
.profile-start-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(900px, 100%);
  margin: 0 auto;
}
.profile-start-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto auto;
  column-gap: 16px;
  min-height: 180px;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(62, 67, 130, .08);
}
.profile-start-card:hover,
.profile-start-card:focus-visible {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.profile-avatar {
  grid-row: 1 / 5;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: var(--surface-soft);
  font-size: 2.3rem;
}
.profile-start-card strong { font-size: 1.35rem; }
.profile-start-card > span:not(.profile-avatar),
.profile-start-card small { color: var(--muted); }
.profile-start-card em {
  width: fit-content;
  margin-top: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #ececff;
  color: var(--primary-dark);
  font-size: .82rem;
  font-style: normal;
  font-weight: 800;
}
.profile-landing-actions { justify-content: center; margin-top: 24px; }

.course-assignment { padding: clamp(24px, 5vw, 42px); }
.course-assignment > h1 { margin: 0 0 8px; }
.course-assignment > p { max-width: 760px; color: var(--muted); }
.course-picker-grid { margin-top: 26px; }

.choice-button.selected {
  border-color: var(--primary);
  background: #ececff;
  color: var(--primary-dark);
  box-shadow: 0 0 0 4px rgba(91, 91, 214, .14);
}
.choice-button.is-speaking,
.prompt-sentence.is-speaking {
  border-color: var(--accent);
  background: #fff5df;
  color: #754909;
  box-shadow: 0 0 0 6px rgba(255, 184, 107, .24);
  transform: scale(1.025);
}
.prompt-sentence.is-speaking {
  padding: 10px 16px;
  border-radius: 16px;
}
.check-choice-button { margin-top: 18px; }

.modal-backdrop {
  align-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal.profile-modal {
  width: min(760px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.modal-sticky-head {
  position: sticky;
  top: -26px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin: -26px -26px 22px;
  padding: 24px 26px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px);
}
.modal-sticky-head h2 { margin: 0; }
.modal-sticky-head p { margin: 5px 0 0; color: var(--muted); }
.modal-close-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}
.profile-modal .profile-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.profile-modal .profile-choice {
  grid-template-rows: auto auto auto;
  min-height: 104px;
}
.profile-choice > span { grid-row: 1 / 4; }
.profile-choice em {
  overflow: hidden;
  color: var(--primary-dark);
  font-size: .76rem;
  font-style: normal;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-edit-form {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 2px solid var(--line);
}
.profile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}
.form-help {
  display: block;
  margin: -4px 0 14px;
  color: var(--muted);
}
.danger-button {
  min-height: var(--tap);
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  background: #fff0f3;
  color: #963448;
  cursor: pointer;
  font-weight: 800;
}
.danger-button:hover { background: #ffe2e8; }
.danger-button:disabled { cursor: default; opacity: .55; }
.profile-save-actions { padding-bottom: 4px; }

@media (max-width: 700px) {
  .profile-start-grid,
  .profile-modal .profile-list,
  .profile-form-grid { grid-template-columns: 1fr; }
  .profile-start-card { min-height: 150px; }
  .modal-backdrop { padding: 8px; align-items: stretch; }
  .modal.profile-modal {
    max-height: calc(100dvh - 16px);
    margin: auto 0;
    padding: 20px;
    border-radius: 20px;
  }
  .modal-sticky-head {
    top: -20px;
    margin: -20px -20px 18px;
    padding: 18px 20px 14px;
  }
}
