  :root {
    --purple-dark:  #3a3558;
    --purple-mid:   #7a78a8;
    --purple-light: #c8cadb;
    --text-muted:   #5a5790;
    --lavender:     #f4e2e7;
    --lavender-soft:#fdf5f7;
    --mint:         #b9dcd2;
    --teal:         #ddf0eb;
    --teal-mid:     #6aada0;
    --white:        #ffffff;
    --gray-text:    #4a4a5e;
    --gray-light:   #f2f3f6;
    --radius:       14px;
    --shadow:       0 4px 20px rgba(58,53,88,0.10);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--lavender);
    min-height: 100vh; color: var(--gray-text); padding: 16px;
  }
  .app-header {
    text-align: center; padding: 32px 24px 24px; margin-bottom: 20px;
    background: var(--lavender);
    border-radius: 20px;
    max-width: 680px; margin-left: auto; margin-right: auto;
    box-shadow: 0 4px 20px rgba(185,120,140,0.13);
  }
  .app-header .brand-title {
    font-family: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
    /* min(): bei sehr großer Schrift deckelt 11vw den Namen, damit er auf
       schmalen Handys nicht über den Rand läuft. */
    font-size: min(2.6rem, 11vw); font-weight: 700; letter-spacing: 0.5px;
    line-height: 1.1; margin-bottom: 6px;
  }
  .app-header .brand-title .migra { color: var(--purple-mid); }
  .app-header .brand-title .motion { color: var(--teal-mid); }
  .app-header .brand-sub { margin-top: 8px; font-size: 0.9rem; color: var(--purple-mid); opacity: 0.85; }

  .nav { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
  .nav-btn {
    padding: 9px 16px; border: none; border-radius: 50px; font-size: 0.85rem;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
    background: var(--white); color: var(--purple-mid);
    box-shadow: 0 2px 8px rgba(74,45,107,0.1);
    text-decoration: none; display: inline-block;
  }
  .nav-btn.active { background: var(--purple-mid); color: var(--white); }
  .nav-btn:hover:not(.active) { background: var(--lavender); }

  .card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
    max-width: 680px; margin-left: auto; margin-right: auto;
  }

  /* user-select und touch-action: damit iOS beim mehrfachen Antippen des Titels
     weder den Text markiert noch auf Doppeltipp-zum-Zoomen wartet. Beides würde
     den Tipp-Zähler für den Testmodus unbrauchbar machen (siehe handleTitleTap). */
  h1.journey-h1 { font-family: 'Fredoka', sans-serif; color: var(--purple-dark); font-size: 1.4rem; margin-bottom: 10px;
    -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .tap-hinweis { font-size: 0.72rem; color: var(--text-muted); margin: -6px 0 10px; }
  .journey-intro { font-size: 0.9rem; line-height: 1.6; color: var(--gray-text); }

  /* MODULE LIST */
  .module-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 12px; margin-bottom: 10px;
    background: var(--gray-light); transition: background 0.2s;
  }
  .module-card.active, .module-card.completed { cursor: pointer; }
  .module-card.active:hover, .module-card.completed:hover { background: var(--lavender); }
  .module-card.locked { opacity: 0.55; }
  .module-num {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--purple-light); color: var(--purple-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem;
  }
  .module-card.completed .module-num { background: var(--teal-mid); color: var(--white); }
  .module-title { font-weight: 700; color: var(--purple-dark); font-size: 0.95rem; }
  .module-status { font-size: 0.78rem; margin-top: 2px; color: var(--text-muted); }
  .module-status.completed { color: var(--teal-mid); font-weight: 600; }
  .module-status.active { color: var(--purple-mid); font-weight: 600; }

  /* MODULE DETAIL */
  #module-detail { display: none; }
  .module-back { background: none; border: none; color: var(--purple-mid); font-size: 0.85rem; font-weight: 600; cursor: pointer; margin-bottom: 14px; padding: 0; }
  .module-back:hover { text-decoration: underline; }
  #module-detail-title { font-family: 'Fredoka', sans-serif; color: var(--purple-dark); font-size: 1.2rem; margin-bottom: 16px; }

  .start-box, .wait-box { text-align: center; padding: 20px 10px; }
  .start-box p, .wait-box p { font-size: 0.88rem; color: var(--gray-text); margin-bottom: 16px; line-height: 1.6; }
  .btn-primary {
    background: var(--purple-mid); color: var(--white); border: none;
    padding: 12px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 700;
    cursor: pointer; transition: background 0.2s;
  }
  .btn-primary:hover { background: var(--purple-dark); }
  .wait-box .wait-count { font-size: 2rem; font-weight: 800; color: var(--purple-mid); margin: 8px 0; }

  .module-progress-bar { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; font-weight: 600; }
  .module-complete-msg {
    display: none; background: var(--teal); color: var(--purple-dark); border-radius: 10px;
    padding: 12px 14px; font-size: 0.85rem; font-weight: 600; margin-top: 16px;
  }

  .question-block { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--gray-light); }
  .question-block:last-child { border-bottom: none; }
  .q-text { font-weight: 700; color: var(--purple-dark); font-size: 0.92rem; margin-bottom: 8px; display: block; line-height: 1.4; }
  .q-note { font-size: 0.76rem; color: var(--text-muted); font-style: italic; margin-bottom: 8px; }
  .q-freitext {
    width: 100%; min-height: 70px; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--purple-light); font-family: inherit; font-size: 0.88rem;
    color: var(--gray-text); resize: vertical;
  }
  .q-freitext:focus { outline: none; border-color: var(--purple-mid); }

  /* Textfeld zur offenen Auswahloption ("Sonstiges" / "andere"), geht mit dem
     Haken auf und zu. Etwas eingerückt, damit klar ist, dass es zur Option gehört. */
  .q-freitext-wrap { margin: 8px 0 0 26px; }
  .q-freitext-label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 5px; }
  .q-freitext-inline {
    width: 100%; font-family: inherit; font-size: 0.9rem; color: var(--gray-text);
    padding: 9px 11px; border: 1.5px solid var(--purple-light); border-radius: 8px; background: var(--white);
    min-height: 56px; resize: vertical;
  }
  .q-freitext-inline:focus { outline: none; border-color: var(--purple-mid); }
  .q-options { display: flex; flex-direction: column; gap: 8px; }
  .q-radio, .q-checkbox {
    display: flex; align-items: center; gap: 8px; font-size: 0.86rem;
    color: var(--gray-text); cursor: pointer; padding: 6px 4px;
  }
  .q-radio input, .q-checkbox input { accent-color: var(--purple-mid); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }

  .skool-hint {
    background: var(--lavender-soft); border-radius: 10px; padding: 12px 14px;
    font-size: 0.8rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5;
  }

  /* ÜBUNGS-CHECK (innerhalb eines Moduls) */
  .uebungs-check-title { font-family: 'Fredoka', sans-serif; color: var(--purple-dark); font-size: 1rem; margin: 24px 0 14px; padding-top: 20px; border-top: 2px solid var(--lavender); }
  .exercise-card-list { display: flex; flex-direction: column; gap: 18px; }
  .exercise-card { display: flex; gap: 14px; background: var(--gray-light); border-radius: 12px; padding: 14px; }
  .exercise-img { width: 96px; height: 96px; object-fit: contain; flex-shrink: 0; background: var(--white); border-radius: 8px; }
  .exercise-info { flex: 1; min-width: 0; }
  .exercise-name { font-weight: 700; color: var(--purple-dark); font-size: 0.9rem; margin-bottom: 3px; }
  .exercise-wdh { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
  .exercise-check-q { margin-bottom: 10px; }
  .exercise-check-q:last-child { margin-bottom: 0; }
  .q-text-sm { font-size: 0.8rem; font-weight: 600; color: var(--gray-text); margin-bottom: 6px; }
  .exercise-check-q .q-options { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; }
  .exercise-check-q .q-radio { padding: 2px 0; font-size: 0.8rem; }

  /* PLAN VIEW */
  .plan-section-title { font-family: 'Fredoka', sans-serif; color: var(--purple-dark); font-size: 1.05rem; margin-bottom: 6px; }
  .plan-section-sub { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
  .plan-note {
    background: var(--lavender-soft); border-radius: 10px; padding: 10px 12px;
    font-size: 0.78rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5;
  }
  .plan-empty { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }

  .vn-compare { display: flex; align-items: center; gap: 14px; margin: 14px 0 26px; }
  .vn-col { flex: 1; background: var(--gray-light); border-radius: 12px; padding: 16px; text-align: center; }
  .vn-label { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
  .vn-val { font-size: 1.8rem; font-weight: 800; color: var(--purple-dark); line-height: 1; }
  .vn-unit { font-size: 0.76rem; color: var(--text-muted); margin-top: 4px; }
  .vn-arrow { font-size: 1.3rem; color: var(--purple-mid); flex-shrink: 0; }

  .erkenntnis-card { margin-bottom: 26px; }
  .erkenntnis-field {
    background: var(--lavender-soft); border-left: 4px solid var(--purple-mid);
    border-radius: 0 12px 12px 0; padding: 14px 16px; margin-bottom: 12px;
  }
  .erkenntnis-label { font-size: 0.8rem; font-weight: 700; color: var(--purple-mid); margin-bottom: 6px; }
  .erkenntnis-text { font-size: 0.95rem; color: var(--purple-dark); line-height: 1.6; }

  .plan-block { margin-bottom: 22px; }
  .plan-block-title { font-weight: 700; color: var(--purple-dark); font-size: 0.92rem; margin-bottom: 8px; }
  .exercise-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
  .exercise-result-card { text-align: center; }
  .exercise-result-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--gray-light); border-radius: 10px; margin-bottom: 6px; }
  .exercise-result-name { font-size: 0.76rem; font-weight: 700; color: var(--purple-dark); line-height: 1.3; }
  .exercise-result-wdh { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

  .btn-print {
    display: block; width: 100%; background: none; border: 2px solid var(--purple-mid);
    color: var(--purple-mid); padding: 12px; border-radius: 10px; font-size: 0.88rem;
    font-weight: 700; cursor: pointer; margin: 22px 0 28px; transition: all 0.2s;
  }
  .btn-print:hover { background: var(--purple-mid); color: var(--white); }

  .plan-module { margin-bottom: 22px; }
  .plan-module h3 { font-family: 'Fredoka', sans-serif; color: var(--purple-dark); font-size: 1rem; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--lavender); }
  .plan-qa { margin-bottom: 12px; }
  .plan-q { font-size: 0.82rem; font-weight: 700; color: var(--purple-mid); margin-bottom: 3px; }
  .plan-a { font-size: 0.88rem; color: var(--gray-text); line-height: 1.5; }

  /* ATTACKENPLAN-EINSTIEG (innerhalb der normalen Card) */
  .attackenplan-entry {
    display: flex; align-items: center; gap: 14px; cursor: pointer;
    background: var(--purple-dark); color: var(--white);
    border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
  }
  .attackenplan-entry:hover { background: #2a2640; }
  .attackenplan-entry-icon { font-size: 1.6rem; flex-shrink: 0; }
  .attackenplan-entry-title { font-weight: 700; font-size: 0.98rem; }
  .attackenplan-entry-sub { font-size: 0.78rem; opacity: 0.8; margin-top: 1px; }

  /* ATTACKENPLAN-ANSICHT: eigenständig, dunkel, große Schrift - für die Nutzung im
     abgedunkelten Zimmer während einer Attacke, bewusst außerhalb der sonstigen
     hellen Optik der App. */
  /* Die Textfarbe hier fest und nicht über --lavender: diese Ansicht ist
     IMMER dunkel, die Variable kippt im dunklen Modus aber auf einen dunklen
     Wert und der Text wäre dann unsichtbar. */
  .attackenplan-view {
    display: none; position: fixed; inset: 0; z-index: 100; overflow-y: auto;
    background: #14101f; color: #f4e2e7; padding: 24px 20px 60px;
  }
  .attackenplan-back {
    background: none; border: 1px solid rgba(244,226,231,0.35); color: #f4e2e7;
    padding: 8px 16px; border-radius: 8px; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; margin-bottom: 18px;
  }
  .attackenplan-h1 {
    font-family: 'Fredoka', sans-serif; font-size: 1.5rem; margin-bottom: 24px;
    max-width: 560px; margin-left: auto; margin-right: auto;
  }
  #attackenplan-content { max-width: 560px; margin: 0 auto; }

  /* Die Bausteine darin heißen weiter akut-...: Sie beschreiben die akute
     Situation, nicht den Namen des Plans. Der Plan selbst hieß bis
     2026-10-30 „Akutplan“ und heißt jetzt „Attackenplan“, so wie in allen
     PDFs; die akut-Klassen teilt er sich mit atmen.css. */
  .akut-field {
    background: rgba(244,226,231,0.08); border-left: 4px solid #c8a8d8;
    border-radius: 0 12px 12px 0; padding: 16px 18px; margin-bottom: 16px;
  }
  .akut-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #c8a8d8; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
  /* Nummer als eigene Marke statt "1 · " im Fließtext: das Auge findet den
     Block schneller wieder, wenn man den Plan während einer Attacke nur
     überfliegt. */
  .akut-num {
    flex-shrink: 0; width: 1.5em; height: 1.5em; border-radius: 50%;
    background: rgba(200,168,216,0.18); color: #d8bce4;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.78rem; letter-spacing: 0;
  }

  /* ── Der Kasten ganz oben: wo das Medikament liegt ──────────────────
     Deutlich abgesetzt, aber nicht grell. Diese Ansicht wird bei
     Lichtempfindlichkeit geöffnet, ein leuchtender Kasten wäre genau
     falsch. Die Absetzung kommt über Rahmen und Schriftgröße, nicht über
     Helligkeit. */
  .akut-sos {
    background: rgba(200,168,216,0.10);
    border: 1.5px solid rgba(200,168,216,0.45);
    border-radius: 14px;
    padding: 18px 20px 16px;
    margin-bottom: 22px;
  }
  .akut-sos-label {
    font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: #c8a8d8; margin-bottom: 10px;
  }
  .akut-sos-ort { font-size: 1.32rem; line-height: 1.4; font-weight: 600; }
  .akut-sos-leer { font-size: 1rem; font-weight: 400; opacity: 0.75; }
  .akut-sos-med {
    font-size: 0.92rem; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid rgba(244,226,231,0.15); opacity: 0.85;
  }
  .akut-text { font-size: 1.1rem; line-height: 1.6; }

  /* Übungen im Attackenplan: nur Name und Wiederholungen, keine Bilder. Die
     Übungsbilder haben weißen Hintergrund und würden in der dunklen Ansicht
     grell leuchten, genau falsch bei Lichtempfindlichkeit. */
  /* flex-wrap statt nowrap: lange Angaben wie "3x pro Seite mit 3x tief ein- und
     ausatmen" liefen sonst über den rechten Rand hinaus. Passt es nicht neben den
     Namen, rutscht die Angabe in die nächste Zeile. */
  .akut-uebung { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid rgba(244,226,231,0.15); }
  .akut-uebung:last-child { border-bottom: none; }
  .akut-uebung-name { font-size: 1.02rem; flex: 1 1 60%; min-width: 0; }
  .akut-uebung-wdh { font-size: 0.86rem; color: #c8a8d8; flex: 0 1 auto; }
  .akut-print {
    display: block; width: 100%; max-width: 560px; margin: 22px auto 0;
    background: none; border: 1px solid rgba(244,226,231,0.35); color: #f4e2e7;
    padding: 12px 16px; border-radius: 10px; font-family: inherit; font-size: 0.9rem;
    font-weight: 600; cursor: pointer;
  }
  .akut-print:hover { background: rgba(244,226,231,0.08); }

  /* Die Einnahme-Notiz im Attackenplan. Feste Werte wie im ganzen Attackenplan, weil
     diese Ansicht immer dunkel ist und die Farbvariablen im dunklen Modus
     zu Flächenfarben werden. */
  .attackenplan-view .an-leer,
  .attackenplan-view .an-abschluss-text { color: rgba(244,226,231,0.72); }
  .attackenplan-view .an-abschluss-hinweis { color: rgba(244,226,231,0.55); }
  .attackenplan-view .an-eintrag { border-bottom-color: rgba(244,226,231,0.15); }
  .attackenplan-view .an-eintrag .an-mittel { color: #f4e2e7; }
  .attackenplan-view .an-meta,
  .attackenplan-view .an-weg,
  .attackenplan-view .an-zeit-zeile label { color: rgba(244,226,231,0.6); }
  .attackenplan-view .an-btn,
  .attackenplan-view .an-chip,
  .attackenplan-view .an-zeit,
  .attackenplan-view .an-frei,
  .attackenplan-view .an-tag-btn {
    background: rgba(244,226,231,0.06);
    border-color: rgba(200,168,216,0.45);
    color: #f4e2e7;
  }
  .attackenplan-view .an-btn-haupt,
  .attackenplan-view .an-chip,
  .attackenplan-view .an-tag-btn { color: #d8bce4; }
  .attackenplan-view .an-eingabe,
  .attackenplan-view .an-abschluss { border-top-color: rgba(244,226,231,0.15); }

  /* Wege zwischen Plan und Modulen, erst nach Modul 12 sichtbar. */
  .btn-zu-modulen, .btn-zurueck-plan {
    display: block; width: 100%; background: var(--gray-light); border: 1px solid var(--purple-light);
    color: var(--purple-dark); padding: 11px 16px; border-radius: 10px; font-family: inherit;
    font-size: 0.88rem; font-weight: 600; cursor: pointer; margin-bottom: 18px; text-align: left;
  }
  .btn-zu-modulen:hover, .btn-zurueck-plan:hover { background: var(--lavender-soft); }

  /* ── Testmodus-Balken ──────────────────────────────────────────────
     Bewusst in einer Farbe, die sonst nirgends in der App vorkommt, damit
     sofort auffällt, dass hier nicht der Echtbetrieb läuft. */
  .testmodus-banner {
    background: #fff4d6;
    border: 2px solid #e0b84a;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
  }
  .testmodus-banner .tm-title {
    font-family: 'Fredoka', sans-serif;
    color: #8a6410;
    font-size: 1rem;
    margin-bottom: 6px;
  }
  .testmodus-banner .tm-text {
    font-size: 0.85rem;
    color: #6d5312;
    line-height: 1.45;
    margin-bottom: 12px;
  }
  .testmodus-banner .tm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .testmodus-banner .tm-btn {
    font-family: inherit;
    font-size: 0.82rem;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d4a933;
    /* Fest, nicht über --white: der Balken bleibt in beiden Modi hell, die
       Variable würde im dunklen Modus fast schwarz und der Text unlesbar. */
    background: #ffffff;
    color: #6d5312;
    cursor: pointer;
  }
  .testmodus-banner .tm-btn:hover { background: #fdf2d4; }
  .testmodus-banner .tm-btn-off {
    background: #6d5312;
    border-color: #6d5312;
    color: #ffffff;
  }
  .testmodus-banner .tm-btn-off:hover { background: #533f0d; }
  .testmodus-banner .tm-hint {
    font-size: 0.76rem;
    color: #8a7333;
    line-height: 1.4;
    margin-top: 10px;
  }

  /* Das Gesprächsblatt steht neben dem Attackenplan, soll aber nicht nach Notfall
     aussehen: ruhiges Grün statt des dunklen Rot-Kontexts. */
  .arztblatt-entry { background: var(--teal-mid); }
  .arztblatt-entry:hover { background: #5c9a8e; }
