/* ============== Basis ============== */
:root {
  --bg: #0f1216;
  --surface: #1a1f26;
  --surface-2: #232934;
  --text: #e8eaed;
  --text-dim: #9aa3ad;
  --accent: #8ab4f8;
  --accent-2: #b39ddb;
  --border: #2d3440;
  --danger: #e57373;
  --success: #6fcf97;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ============== Header ============== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + var(--safe-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.3px;
  line-height: 1.3;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.streak-badge {
  font-size: 0.8rem;
  color: var(--accent-2);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px calc(48px + var(--safe-bottom));
}

/* ============== Views ============== */
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }

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

@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
  .module-card, .breath-pacer, .halo-motion-wrap { transition: none !important; }
  .halo-motion-wrap .silhouette-svg { animation: none !important; }
}

.brand-line {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--accent-2);
}
.brand-line a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.brand-line a:hover { text-decoration: underline; }

.notice {
  background: var(--surface);
  border-left: 3px solid var(--accent-2);
  padding: 12px 16px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.intro {
  margin: 18px 2px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.section-title {
  font-weight: 500;
  font-size: 1.1rem;
  margin: 28px 0 12px;
  color: var(--text-dim);
}

h2 {
  font-weight: 500;
  margin: 6px 0 18px;
  font-size: clamp(1.2rem, 4vw, 1.4rem);
}

h3 {
  font-weight: 500;
  margin: 4px 0 8px;
  font-size: 1.05rem;
}

/* ============== Lernpfad ============== */
.path-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 18px;
  margin: 22px 0;
}
.path-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.path-card h2 { margin: 0; font-size: 1.2rem; }
.path-progress-label {
  font-size: 0.85rem;
  color: var(--accent);
}
.path-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  margin: 14px 0;
  overflow: hidden;
}
.path-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 4px;
  width: 0%;
  transition: width .4s ease;
}
.path-today-desc {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0 0 16px;
}
.path-all-btn { margin-top: 10px; display: block; }

.path-day-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.path-day-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.path-day-item.locked { opacity: 0.45; }
.path-day-item.done { border-color: rgba(111, 207, 151, 0.4); }
.path-day-item.current { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(138, 180, 248, 0.2); }
.path-day-num {
  font-weight: 600;
  color: var(--accent);
  min-width: 3rem;
}
.path-day-meta { flex: 1; min-width: 160px; }
.path-day-meta strong { display: block; font-weight: 500; }
.path-day-meta span { font-size: 0.85rem; color: var(--text-dim); }
.path-day-item .primary-btn,
.path-day-item .link-btn {
  padding: 8px 14px;
  font-size: 0.88rem;
  min-height: 44px;
}

/* ============== Module-Cards ============== */
.module-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-top: 8px;
}
@media (min-width: 520px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 800px) {
  .module-grid:not(.small) { grid-template-columns: repeat(2, 1fr); }
}
.module-grid.small { gap: 12px; }

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  font-family: inherit;
  width: 100%;
  min-height: 44px;
}
.module-card:hover,
.module-card:focus-visible {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-2px);
  outline: none;
}
.module-card h2, .module-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}
.module-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.module-icon {
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 8px;
  line-height: 1;
}

/* ============== Settings ============== */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 16px 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 480px) {
  .settings-panel {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 720px) {
  .settings-panel {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
.settings-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--text-dim);
  gap: 6px;
}
.settings-panel label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  grid-column: 1 / -1;
}
.settings-panel select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  min-height: 44px;
  width: 100%;
}
.settings-panel input[type=checkbox],
.settings-panel input[type=radio] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.instructions {
  background: var(--surface);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 14px 0;
}
.instructions em { color: var(--text); font-style: normal; font-weight: 500; }
.intensity-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ============== Tutorial & Offline ============== */
.tutorial-blocks { display: flex; flex-direction: column; gap: 16px; }
.tutorial-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.tutorial-block ul {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  color: var(--text-dim);
}
.tutorial-block li { margin-bottom: 8px; }

.offline-scenario {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  background: var(--surface);
}
.offline-scenario legend {
  padding: 0 6px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  min-height: 44px;
}
.offline-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}
.offline-checklist li { margin-bottom: 8px; }
.offline-checklist label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}
.offline-checklist input:checked + span { text-decoration: line-through; color: var(--text-dim); }
.offline-complete-msg {
  color: var(--success);
  margin: 16px 0;
  font-weight: 500;
}

/* ============== Buttons ============== */
.primary-btn {
  background: var(--accent);
  color: #102030;
  border: 0;
  padding: 14px 24px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: filter .15s;
  min-height: 48px;
  width: 100%;
  max-width: 320px;
}
@media (min-width: 480px) {
  .primary-btn { width: auto; }
}
.primary-btn:hover { filter: brightness(1.1); }

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 10px 4px;
  font-family: inherit;
  min-height: 44px;
}
.link-btn:hover { text-decoration: underline; }

.back-ex { margin-bottom: 10px; }

.stage-tool-btn {
  background: rgba(26, 31, 38, 0.72);
  color: #e8eaed;
  border: 1px solid rgba(0, 0, 0, 0.35);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  backdrop-filter: blur(6px);
  font-family: inherit;
  min-height: 44px;
  min-width: 44px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.stage-tool-btn:hover { background: rgba(26, 31, 38, 0.9); }

/* Beenden: auf hellem Übungshintergrund gut sichtbar */
#stage .stop-btn {
  background: #1a1f26;
  color: #f0f3f6;
  border: 2px solid #3d4d63;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  min-height: 48px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
#stage .stop-btn:hover {
  background: #252d38;
  border-color: var(--accent);
}
#stage.dark .stop-btn {
  background: #f0f3f6;
  color: #1a1f26;
  border-color: #c5cdd8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
#stage.dark .stop-btn:hover {
  background: #fff;
  border-color: var(--accent);
}

.exercise { animation: fade .25s ease; }
.hidden { display: none !important; }

/* ============== Dialogs ============== */
.app-dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px;
  background: var(--surface);
  color: var(--text);
  max-width: min(420px, calc(100vw - 32px));
  width: calc(100% - 32px);
  margin: auto;
}
.app-dialog::backdrop {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}
.app-dialog h3 { margin-top: 0; }
.dialog-check { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-dim); font-size: 0.9rem; }
.dialog-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.dialog-actions .primary-btn { max-width: none; flex: 1; min-width: 140px; }
.summary-dialog #summary-body { color: var(--text-dim); font-size: 0.95rem; }
.summary-dialog #summary-body p { margin: 8px 0; }

/* ============== Stage ============== */
#stage {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ececec;
  transition: background-color .6s ease;
  padding: var(--safe-top) 0 var(--safe-bottom);
  overflow: visible;
}

#stage-canvas {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  padding: 60px 16px 100px;
  overflow: visible;
}

.silhouette-wrap {
  position: relative;
  display: inline-block;
  overflow: visible;
}

.silhouette-wrap.has-halo-glow {
  padding: 48px;
  margin: -48px;
}
.silhouette-wrap.has-halo-glow[data-intensity="subtle"] {
  padding: 36px;
  margin: -36px;
}
.silhouette-wrap.has-halo-glow[data-intensity="subtle"] .halo-glow {
  width: 120%;
  height: 115%;
}

.halo-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140%;
  height: 130%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
}
.halo-glow-inner { width: 95%; height: 95%; }
.halo-glow-outer { width: 155%; height: 145%; }

.silhouette-svg {
  display: block;
  max-width: min(220px, 55vw);
  width: auto;
  height: auto;
  color: #222;
  filter: none;
}
#stage.dark .silhouette-svg { color: #111; }

@media (min-width: 600px) {
  .silhouette-svg { max-width: 260px; }
}

.fixation-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(0,0,0,0.65);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
}
#stage.dark .fixation-dot { background: rgba(255,255,255,0.75); }

.timer-overlay {
  position: fixed;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1rem, 4vw, 1.15rem);
  color: rgba(0,0,0,0.4);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 1px;
  user-select: none;
  z-index: 1005;
}
#stage.dark .timer-overlay { color: rgba(255,255,255,0.5); }

.hint-overlay {
  position: fixed;
  bottom: calc(88px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(0,0,0,0.45);
  font-size: clamp(0.75rem, 3.2vw, 0.88rem);
  text-align: center;
  max-width: min(92%, 360px);
  pointer-events: none;
  letter-spacing: 0.2px;
  z-index: 1005;
  line-height: 1.45;
}
#stage.dark .hint-overlay { color: rgba(255,255,255,0.55); }

.stage-controls {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 1010;
}

.afterimage-square {
  width: min(360px, 85vw);
  height: min(360px, 85vw);
  max-width: 85vmin;
  max-height: 85vmin;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.afterimage-square .fixation-dot {
  position: relative;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  width: 12px;
  height: 12px;
}

.breath-pacer {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.25);
  opacity: 0.55;
  transition: transform 4s ease-in-out, background-color 4s ease-in-out;
  z-index: 1004;
}
#stage.dark .breath-pacer { border-color: rgba(255,255,255,0.3); }
.breath-pacer.inhale { transform: translateX(-50%) scale(1.55); background: rgba(138,180,248,0.18); }
.breath-pacer.exhale { transform: translateX(-50%) scale(0.88); background: rgba(138,180,248,0.05); }

.halo-motion-wrap .halo-glow {
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.stage-break {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.break-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 24px 20px;
  max-width: 400px;
  border: 1px solid var(--border);
  text-align: center;
}
.break-card .primary-btn { width: 100%; max-width: none; margin-bottom: 8px; }
.break-card p { color: var(--text-dim); font-size: 0.92rem; }

#stage-question {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  padding: 16px;
  overflow-y: auto;
}
.question-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 22px 18px;
  max-width: 520px;
  width: 100%;
  border: 1px solid var(--border);
  max-height: 90vh;
  overflow-y: auto;
}
.question-card h3 {
  margin: 0 0 14px;
  font-weight: 500;
  font-size: 1.05rem;
}
.color-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
@media (min-width: 400px) {
  .color-choices { grid-template-columns: repeat(4, 1fr); }
}
.color-choice,
.density-choice {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 14px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, transform .15s;
  min-height: 48px;
}
.color-choice:hover:not(:disabled),
.density-choice:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
}
.color-choice.correct { border-color: var(--success); box-shadow: 0 0 0 2px rgba(111,207,151,0.25); }
.color-choice.wrong { border-color: var(--danger); opacity: 0.65; }
.color-choice:disabled { cursor: default; }

.reflection-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.reflection-btn {
  width: 100%;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 48px;
}
.reflection-btn:hover { border-color: var(--accent); }

.question-result {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.92rem;
}
.question-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.question-actions .primary-btn,
.question-actions .link-btn {
  width: auto;
  min-width: 100px;
}

.question-skip {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.skip-question-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid #4a5568;
  background: #2a323d;
  color: #e8eaed;
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 48px;
  line-height: 1.35;
}
.skip-question-btn:hover {
  background: #353f4d;
  border-color: var(--accent-2);
}

.pdf-link-wrap {
  margin: 20px 0 8px;
}
.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 10px 0;
  min-height: 44px;
}
.pdf-link:hover { text-decoration: underline; }

.note-input {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 72px;
}

.multilayer-prompt { font-size: 0.9rem; color: var(--text-dim); margin: 12px 0 8px; }
