/* DTZ B1 MEISTER - Design System (mobile-first readability) */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.14);
  --secondary: #0891b2;
  --accent: #d97706;
  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;

  --bg-main: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.92);
  --bg-card-subtle: rgba(31, 41, 55, 0.72);
  --bg-glass: rgba(17, 24, 39, 0.88);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(99, 102, 241, 0.55);

  --text-main: #f3f4f6;
  --text-muted: #a1a8b3;
  --text-dim: #7b8494;

  --artikel-der: #38bdf8;
  --artikel-die: #f87171;
  --artikel-das: #34d399;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --font-sans: 'Source Sans 3', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --header-h: 56px;
  --bnav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --text-body: 1.0625rem;      /* 17px */
  --text-reading: 1.125rem;    /* 18px exam reading */
  --text-sm: 0.9375rem;        /* 15px */
  --text-xs: 0.875rem;         /* 14px */
  --lh-body: 1.65;
  --lh-reading: 1.8;

  --transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --border-color: rgba(15, 23, 42, 0.12);
  --border-focus: rgba(79, 70, 229, 0.45);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: var(--lh-body);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image:
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(8, 145, 178, 0.07) 0px, transparent 50%);
  background-attachment: fixed;
  padding-top: var(--safe-top);
}

img, svg, video {
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 1rem;
  min-height: var(--header-h);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  min-height: 44px;
}

.logo-badge {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.logo-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-main);
  line-height: 1.2;
}

.logo-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  display: block;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Nav Tabs */
.nav-scroll-wrap {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-scroll-wrap::-webkit-scrollbar {
  display: none;
}

.nav-tabs {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  padding: 0.5rem 0.75rem;
  gap: 0.4rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

/* Main */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(var(--bnav-h) + var(--safe-bottom) + 1.5rem);
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}
.badge-b1 { background: rgba(79, 70, 229, 0.18); color: #a5b4fc; border: 1px solid rgba(79, 70, 229, 0.35); }
.badge-a2 { background: rgba(217, 119, 6, 0.18); color: #fbbf24; border: 1px solid rgba(217, 119, 6, 0.35); }
.badge-success { background: rgba(5, 150, 105, 0.18); color: #34d399; border: 1px solid rgba(5, 150, 105, 0.35); }

[data-theme="light"] .badge-b1 { color: #4338ca; }
[data-theme="light"] .badge-a2 { color: #b45309; }
[data-theme="light"] .badge-success { color: #047857; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-align: center;
  max-width: 100%;
  white-space: normal;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-sm {
  padding: 0.55rem 0.9rem;
  font-size: var(--text-xs);
  min-height: 40px;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

/* Toolbar rows that wrap cleanly */
.toolbar-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.toolbar-row .form-input,
.toolbar-row select.form-input {
  flex: 1 1 160px;
  min-width: 0;
}

.toolbar-row .btn {
  flex: 0 1 auto;
}

/* Audio Player */
.audio-player-box {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(8, 145, 178, 0.12));
  border: 1px solid rgba(79, 70, 229, 0.28);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 180px;
  min-width: 0;
}

.audio-play-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.audio-play-btn:hover {
  background: var(--primary-hover);
}

.audio-info {
  flex: 1;
  min-width: 0;
}

.audio-title {
  font-weight: 700;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.audio-status {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Questions */
.question-item {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
}

.q-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  line-height: 1.45;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.options-list.row .option-btn {
  flex: 1 1 140px;
  min-width: 0;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  min-height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-align: left;
  font-size: var(--text-body);
  line-height: 1.45;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  overflow-wrap: anywhere;
}

.option-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.option-btn.correct {
  background: rgba(5, 150, 105, 0.2) !important;
  border-color: #10b981 !important;
  color: #34d399 !important;
  font-weight: 700;
}

.option-btn.wrong {
  background: rgba(220, 38, 38, 0.18) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
}

.opt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.opt-badge.choice {
  width: 42px;
  height: 42px;
  min-width: 42px;
  cursor: pointer;
  transition: var(--transition);
}
.opt-badge.choice:hover,
.opt-badge.choice.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--text-main);
}

.choice-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.explanation-box {
  margin-top: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(79, 70, 229, 0.08);
  border-left: 4px solid var(--primary);
  font-size: var(--text-sm);
  line-height: 1.65;
  display: none;
  overflow-wrap: anywhere;
}

.explanation-box.show {
  display: block;
}

.transcript-toggle {
  background: none;
  border: none;
  color: var(--secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.65rem;
  min-height: 44px;
  padding: 0.35rem 0;
}

.transcript-content {
  margin-top: 0.65rem;
  padding: 1rem;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  line-height: var(--lh-reading);
  color: var(--text-muted);
  display: none;
  overflow-wrap: anywhere;
}
.transcript-content.show {
  display: block;
}

/* Reading text surfaces */
.reading-text,
.ad-text {
  font-family: var(--font-serif);
  font-size: var(--text-reading);
  line-height: var(--lh-reading);
  color: var(--text-main);
  overflow-wrap: anywhere;
}

.instruction-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.section-heading {
  color: var(--primary);
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

/* Lesen */
.lesen-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1.25rem;
  align-items: start;
}

.lesen-ads-scroll {
  max-height: min(70vh, 640px);
  overflow-y: auto;
  padding-right: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 960px) {
  .lesen-split {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
  .lesen-ads {
    order: -1;
  }
  .lesen-ads-scroll {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (min-width: 961px) {
  .lesen-ads-scroll {
    position: sticky;
    top: calc(var(--header-h) + 12px);
  }
}

.ad-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  margin-bottom: 0.85rem;
  line-height: var(--lh-reading);
  overflow-wrap: anywhere;
}
.ad-title {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--secondary);
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

/* Schreiben */
.schreiben-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .schreiben-layout {
    grid-template-columns: 1fr;
  }
}

.leitpunkte-card {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  border: 1px solid var(--border-color);
}

.leitpunkt-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.leitpunkt-item:last-child {
  border-bottom: none;
}

.letter-textarea {
  width: 100%;
  min-height: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  font-family: var(--font-serif);
  font-size: var(--text-reading);
  color: var(--text-main);
  line-height: var(--lh-reading);
  resize: vertical;
  outline: none;
  transition: var(--transition);
}
.letter-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.editor-toolbar .btn {
  flex: 1 1 auto;
}

.word-count {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.model-letters-grid,
.stack-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 700px) {
  .model-letters-grid,
  .stack-2 {
    grid-template-columns: 1fr;
  }
}

.redemittel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 0.85rem;
}

/* AI Feedback */
.ai-feedback-box {
  margin-top: 1.25rem;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(8, 145, 178, 0.1));
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  display: none;
  overflow-wrap: anywhere;
}
.ai-feedback-box.show {
  display: block;
  animation: fadeIn 0.35s ease;
}

/* Score banner (replaces alert) */
.score-banner {
  margin: 1rem 0 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  font-size: var(--text-body);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.score-banner.good {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.12);
}
.score-banner.warn {
  border-color: rgba(217, 119, 6, 0.5);
  background: rgba(217, 119, 6, 0.12);
}
.score-banner.bad {
  border-color: rgba(220, 38, 38, 0.45);
  background: rgba(220, 38, 38, 0.1);
}

.sticky-check-bar {
  position: sticky;
  bottom: calc(var(--bnav-h) + var(--safe-bottom) + 0.5rem);
  z-index: 40;
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: stretch;
  gap: 0.75rem;
}
.sticky-check-bar .btn {
  width: 100%;
}

@media (min-width: 769px) {
  .sticky-check-bar {
    bottom: 0.75rem;
  }
}

/* Flashcards */
.flashcard-wrapper {
  max-width: 540px;
  margin: 1.5rem auto;
  perspective: 1000px;
}

.flashcard {
  width: 100%;
  min-height: 280px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.75rem 1.25rem;
  text-align: center;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 1.25rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-wrap: anywhere;
}

.card-back {
  transform: rotateY(180deg);
  background: var(--bg-card-subtle);
  border-radius: var(--radius-xl);
}

.word-artikel {
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: lowercase;
  margin-bottom: 0.4rem;
}
.word-artikel.der { color: var(--artikel-der); }
.word-artikel.die { color: var(--artikel-die); }
.word-artikel.das { color: var(--artikel-das); }

.word-german {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 800;
  margin-bottom: 0.4rem;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.word-plural {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.word-turkish {
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.85rem;
  line-height: 1.25;
}

.word-example-de {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  line-height: 1.45;
}
.word-example-tr {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.45;
}

.flash-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.flash-actions .btn {
  flex: 1 1 140px;
  max-width: 260px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-width: 580px;
  width: 100%;
  max-height: min(92vh, 900px);
  overflow-y: auto;
  padding: 1.35rem 1.25rem calc(1.35rem + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform 0.2s ease;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.open .modal-content {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .modal-content {
    border-radius: var(--radius-xl);
    padding: 1.75rem;
  }
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}
.modal-header-row h3 {
  font-size: 1.15rem;
  line-height: 1.35;
}

.settings-block {
  margin-bottom: 1.25rem;
}
.settings-label {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--secondary);
  display: block;
  margin-bottom: 0.35rem;
}
.settings-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 0.55rem;
  line-height: 1.55;
}
.info-callout {
  margin-top: 0.75rem;
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding: 0.75rem 0.9rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  line-height: 1.55;
}
.info-callout ol {
  margin: 0.35rem 0 0 1.15rem;
}
.info-callout a {
  color: var(--primary);
  font-weight: 700;
}
.privacy-note {
  background: var(--bg-main);
  font-size: var(--text-sm);
}
.privacy-note p {
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.modal-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* Inputs */
.form-input,
select.form-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 16px; /* iOS zoom önleme */
  outline: none;
}

input.form-input {
  text-overflow: ellipsis;
}

select.form-input {
  white-space: normal;
  overflow: visible;
}

select.form-input option {
  background: var(--bg-card);
  color: var(--text-main);
  white-space: normal;
  padding: 0.5rem;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Bottom Navigation */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  z-index: 90;
  justify-content: space-around;
  align-items: stretch;
  padding: 0.35rem 0.2rem calc(0.35rem + var(--safe-bottom));
  min-height: calc(var(--bnav-h) + var(--safe-bottom));
}

.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex: 1;
  min-width: 0;
  min-height: 52px;
}
.bnav-item .bnav-icon {
  font-size: 1.25rem;
  line-height: 1;
}
.bnav-item span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bnav-item.active {
  color: var(--primary);
}

/* More sheet */
.more-sheet {
  position: fixed;
  inset: 0;
  z-index: 95;
}
.more-sheet[hidden] {
  display: none !important;
}
.more-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.more-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 0.75rem 1rem calc(1rem + var(--bnav-h) + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
}
.more-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-color);
  margin: 0 auto 0.75rem;
}
.more-sheet-title {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.more-sheet-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 0.85rem;
  min-height: 52px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: var(--text-body);
  cursor: pointer;
  margin-bottom: 0.5rem;
  text-align: left;
}
.more-sheet-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Sprechen helpers */
.teil-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.teil-tabs .btn {
  flex: 1 1 auto;
}

.chat-composer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.chat-composer-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.chat-composer .form-input {
  flex: 1 1 100%;
  min-width: 0;
}
.chat-composer .btn {
  flex: 1 1 auto;
}

.exam-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  background: var(--bg-card-subtle);
  padding: 1rem 1.15rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}
.exam-stats-row > div {
  flex: 1 1 90px;
  text-align: center;
  min-width: 0;
}

.exam-timer-bar {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  z-index: 50;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.module-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.word-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 0.75rem;
}

.word-list-scroll {
  margin-top: 1rem;
  max-height: none;
}

/* Mobile refinements */
@media (max-width: 768px) {
  .nav-scroll-wrap {
    display: none;
  }
  .bottom-nav {
    display: flex;
  }
  .card {
    padding: 1rem;
  }
  .card-title {
    font-size: 1.12rem;
  }
  .card-header {
    flex-direction: column;
    align-items: stretch;
  }
  .options-list.row {
    flex-direction: column;
  }
  .options-list.row .option-btn {
    flex: none;
    width: 100%;
  }
  .audio-player-box {
    flex-direction: column;
    align-items: stretch;
  }
  .audio-player-box > .btn {
    width: 100%;
  }
  .main-content {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}

@media (min-width: 769px) {
  .main-content {
    padding-bottom: 2rem;
  }
}

/* Tablet: keep tabs readable */
@media (min-width: 769px) and (max-width: 1024px) {
  .tab-btn {
    font-size: 0.88rem;
    padding: 0.55rem 0.85rem;
  }
  .main-content {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}
