
:root {
    --bg:          #F3F2EF;
    --card-bg:     #FAF8F2;
    --text-main:   #1E4349;
    --text-muted:  #5a7b80;
    --border:      #d6e0e2;

    --cat-root:      #1E4349;
    --cat-uebergang: #6dbf96;
    --cat-analysis:  #7aaee0;
    --cat-linalg:    #d97a7a;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Geist', sans-serif; }

body {
    background: radial-gradient(circle at 50% 50%, #faece3 0%, var(--bg) 60%);
    background-attachment: fixed;
    background-color: var(--bg);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    /* NEU: Verhindert native "Pull-to-Refresh" und Zoom-Gesten auf iOS/Android */
    overscroll-behavior: none;
    touch-action: none;
}

/* ── FLOATING CONTROLS ── */
.controls {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(250, 248, 242, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 4px 20px rgba(30, 67, 73, 0.08);
}

.ctrl-back {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: color 0.15s;
}
.ctrl-back:hover { color: var(--text-main); }

.ctrl-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-main);
    user-select: none;
}
.ctrl-toggle input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--cat-uebergang);
    cursor: pointer;
    flex-shrink: 0;
}

.ctrl-reset {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.15s;
    text-align: left;
}
.ctrl-reset:hover {
    border-color: var(--cat-linalg);
    color: var(--cat-linalg);
}

.ctrl-info-fab {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--text-main);
    color: #fff;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(30, 67, 73, 0.25);
    transition: background 0.15s, transform 0.15s;
    font-family: 'Geist', sans-serif;
}
.ctrl-info-fab:hover {
    background: #132d31;
    transform: scale(1.08);
}

/* ── LEGEND ── */
.legend {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(250, 248, 242, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 4px 20px rgba(30, 67, 73, 0.06);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── TOAST ── */
/* ── ONBOARDING MODAL ── */
.st-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 67, 73, 0.45);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.st-modal {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(30, 67, 73, 0.2);
    border: 1px solid var(--border);
}
.st-modal-title {
    font-family: 'Fraunces', serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}
.st-modal-intro {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 14px;
}
.st-modal-cats {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.st-modal-cats li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.st-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.st-dot-uebergang { background: var(--cat-uebergang); }
.st-dot-analysis  { background: var(--cat-analysis); }
.st-dot-linalg    { background: var(--cat-linalg); }
.st-modal-subhead {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}
.st-modal-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
}
.st-modal-list li {
    padding-left: 18px;
    position: relative;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.st-modal-list li::before {
    content: "–";
    position: absolute;
    left: 0;
    color: var(--text-muted);
}
.st-modal-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--text-main);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    font-family: 'Geist', sans-serif;
}
.st-modal-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.st-modal-btn:not(:disabled):hover { background: #132d31; }

.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #fdf0f1;
    border: 1.5px solid var(--cat-linalg);
    color: var(--cat-linalg);
    padding: 10px 22px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    display: none;
    z-index: 300;
    white-space: nowrap;
}

/* ── VIEWPORT (full page, scrollable) ── */
.viewport {
    width: 100vw;
    height: 100vh;
    overflow: auto;
    cursor: grab;
    position: relative;
    display: flex;
    /* NEU: Überlässt JS die komplette Kontrolle über Touch-Gesten (Wischen/Pinch) */
    touch-action: none;
}
.viewport.dragging { cursor: grabbing; }

/* ── CANVAS SPACER (maintains scroll area at zoom ≠ 1) ── */
#canvas-spacer {
    position: relative;
    margin: auto !important; /* NEU: Zentriert das Canvas, wenn es kleiner als der Bildschirm ist */
    width: 3800px;
    height: 2700px;
    overflow: hidden; /* NEU: Schneidet den leeren Raum rigoros ab (Blockiert das "Geister-Draggen") */
    flex-shrink: 0; /* NEU: Verhindert, dass Flexbox das Feld staucht */
}

/* ── CANVAS (large, nodes positioned inside) ── */
.mindmap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 3800px;
    height: 2700px;
    transform-origin: top left;
    will-change: transform;
    transform: translateZ(0);
}

/* ── SVG LINES ── */
.lines-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ── NODE CIRCLES ── */
.node-circle {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    overflow: hidden;

    /* Größe über CSS-Variable — height:auto, min-height hält die Kreisform */
    min-width: var(--node-size);
    max-width: var(--node-size);
    min-height: var(--node-size);
    padding: 0;

    transition: min-width 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                max-width 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                min-height 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                border-radius 0.35s ease,
                padding 0.35s ease,
                transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                box-shadow 0.2s ease,
                background 0.25s ease,
                border-color 0.25s ease,
                opacity 0.25s ease;
}

/* Hover: Kreis wächst auf 1/12 Bildschirmbreite */
.node-circle:not(.node-root):not(.state-locked):hover {
    min-width: var(--hover-size, 160px);
    max-width: var(--hover-size, 160px);
    min-height: var(--hover-size, 160px);
    border-radius: 50%;
    padding: 0 calc(var(--hover-size, 160px) * 0.12);
    transform: translate(-50%, -50%);
    z-index: 20;
    overflow: visible;
}

/* Gesperrte Nodes: Kreis wächst auf 1/16 Bildschirmbreite */
.node-circle.state-locked:hover {
    min-width: var(--hover-size-locked, 120px);
    max-width: var(--hover-size-locked, 120px);
    min-height: var(--hover-size-locked, 120px);
    border-radius: 50%;
    padding: 0 calc(var(--hover-size-locked, 120px) * 0.12);
    transform: translate(-50%, -50%);
    opacity: 0.65;
    z-index: 20;
    overflow: visible;
    cursor: not-allowed;
}

/* State: locked */
.node-circle.state-locked {
    background: #eeede9;
    border: 2px solid #d4d0c8;
    opacity: 0.42;
    cursor: not-allowed;
    box-shadow: none;
}

/* State: unlocked */
.node-circle.state-unlocked {
    background: var(--card-bg);
    border: 2.5px solid var(--cc);
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

/* State: completed */
.node-circle.state-completed {
    background: var(--cc);
    border: 2.5px solid var(--cc);
    box-shadow: 0 4px 14px rgba(0,0,0,0.14);
}

/* Empfohlene Node: Orange Glow mit Atmungseffekt (Glow + sanftes Skalieren) */
.node-circle.state-recommended {
    box-shadow:
        0 0 18px 6px rgba(249, 160, 119, 0.55),
        0 0 36px 12px rgba(249, 160, 119, 0.25);
    animation: recommended-breathe 3.4s ease-in-out infinite;
    will-change: transform, box-shadow;
}

/* Atmung: langsames Ein-/Ausatmen — translate bleibt für die Positionierung erhalten */
@keyframes recommended-breathe {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow:
            0 0 16px 5px rgba(249, 160, 119, 0.45),
            0 0 32px 10px rgba(249, 160, 119, 0.20);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.09);
        box-shadow:
            0 0 30px 12px rgba(249, 160, 119, 0.80),
            0 0 58px 22px rgba(249, 160, 119, 0.38);
    }
}

/* Beim Hover übernimmt die Hover-Größe — Atmung pausiert, damit nichts springt */
.node-circle.state-recommended:hover {
    animation: none;
}

/* ── GLOW-WANDERUNG (Learning Path) ── */
/* Oranger Punkt, der wie durch ein Kabel über die Linien wandert */
.glow-dot {
    fill: #f9a077;
    pointer-events: none;
    filter: drop-shadow(0 0 5px rgba(249, 160, 119, 0.95))
            drop-shadow(0 0 14px rgba(249, 160, 119, 0.55));
}
/* Ankunft: kurz aufweiten und ausblenden */
.glow-dot-arrive {
    transition: opacity 0.45s ease, r 0.45s ease;
    opacity: 0;
    r: 30px;
}

/* Kanten wechseln ihren Zustand weich */
.edge-line {
    transition: stroke 0.3s ease, opacity 0.3s ease, stroke-width 0.3s ease;
}
/* Kante, über die der Punkt gerade wandert */
.edge-line.edge-glow {
    stroke: #f9a077;
    stroke-width: 3;
    opacity: 0.95;
}

/* Knoten blitzt kurz auf, wenn der Punkt ihn passiert
   (!important: übertrumpft auch die Hub-Regeln weiter unten) */
.node-circle.node-flash {
    box-shadow:
        0 0 16px 6px rgba(249, 160, 119, 0.6),
        0 0 34px 12px rgba(249, 160, 119, 0.28) !important;
}

/* Root node */
.node-circle.node-root {
    cursor: default;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
    overflow: visible;
}
.node-circle.node-root:hover {
    transform: translate(-50%, -50%);
    min-width: var(--node-size);
    max-width: var(--node-size);
    min-height: var(--node-size);
    padding: 0;
    border-radius: 50%;
}

/* ── LABEL INNERHALB DES KNOTENS ── */
.node-label-inner {
    opacity: 0;
    font-size: 0;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: 0.01em;
    pointer-events: none;
    transition: opacity 0.2s ease 0.08s, font-size 0.2s ease;
}

/* Root: Label immer sichtbar */
.node-circle.node-root .node-label-inner {
    opacity: 1;
    font-size: 0.72rem;
    font-weight: 700;
    color: white;
}

/* Hover: Font proportional zum Kreisdurchmesser (~11 %) */
.node-circle:not(.node-root):not(.state-locked):hover .node-label-inner {
    opacity: 1;
    font-size: calc(var(--hover-size, 160px) * 0.11);
    line-height: 1.35;
}

/* Hover: gesperrte Nodes */
.node-circle.state-locked:hover .node-label-inner {
    opacity: 1;
    font-size: calc(var(--hover-size-locked, 120px) * 0.11);
    line-height: 1.35;
    color: var(--text-muted);
}

/* Labelfarbe je nach Zustand */
.node-circle.state-unlocked:hover .node-label-inner {
    color: var(--cc);
}
.node-circle.state-completed:hover .node-label-inner {
    color: white;
}
.node-circle.no-tasks.state-unlocked:hover .node-label-inner {
    color: white;
}

/* Check-Häkchen (abgeschlossen) */
.check {
    color: #fff;
    font-size: 1.1em;
    font-weight: 700;
    line-height: 1;
    transition: opacity 0.15s ease, font-size 0.15s ease;
}
/* Beim Hover: Häkchen verschwindet, Label erscheint */
.node-circle.state-completed:hover .check {
    opacity: 0;
    font-size: 0;
}

/* ── HUB NODES (noTasks) ── */
.node-circle.no-tasks {
    cursor: default;
}
/* Hub: gefüllt mit Kategoriefarbe wenn freigeschaltet */
.node-circle.no-tasks.state-unlocked {
    background: var(--cc);
    border: 2.5px solid var(--cc);
    box-shadow: 0 4px 16px rgba(0,0,0,0.16);
}
.node-circle.no-tasks.state-locked {
    border-style: solid;
}

/* ── EXTERNES LABEL (unterhalb des Kreises, immer sichtbar) ── */
.node-label-el {
    position: absolute;
    transform: translateX(-50%);
    z-index: 5;
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--text-main);
    text-align: center;
    line-height: 1.3;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.node-label-el.label-locked {
    opacity: 0.38;
}
.node-label-el.label-completed {
    font-weight: 600;
    color: var(--cc-label);
}
.node-label-el.hub-label {
    font-weight: 700;
    font-size: 0.67rem;
}

/* ── ZOOM CONTROLS ── */
.ctrl-zoom-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ctrl-zoom-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    padding: 0;
}
.ctrl-zoom-btn:hover {
    background: var(--border);
}
.ctrl-zoom-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
}

/* ── GLOBALER FORTSCHRITTSBALKEN ── */
.global-progress {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    width: min(560px, 88vw);
    background: rgba(250, 248, 242, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px 14px 12px;
    box-shadow: 0 4px 20px rgba(30, 67, 73, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gp-labels {
    display: flex;
    width: 100%;
}
.gp-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    transition: opacity 0.3s;
}
.gp-uebergang { flex: 5;  color: var(--cat-uebergang); }
.gp-analysis  { flex: 11; color: var(--cat-analysis); }
.gp-linalg    { flex: 16; color: var(--cat-linalg); }

.gp-bar {
    display: flex;
    height: 10px;
    border-radius: 50px;
    overflow: hidden;
    gap: 3px;
}
.gp-seg {
    position: relative;
    height: 100%;
    border-radius: 50px;
    overflow: hidden;
}
.gp-seg-uebergang { flex: 5;  background: #c5edd8; }
.gp-seg-analysis  { flex: 11; background: #c2d8f2; }
.gp-seg-linalg    { flex: 16; background: #f2c5c5; }

.gp-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0%;
    border-radius: 50px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.gp-seg-uebergang .gp-fill { background: var(--cat-uebergang); }
.gp-seg-analysis  .gp-fill { background: var(--cat-analysis); }
.gp-seg-linalg    .gp-fill { background: var(--cat-linalg); }

/* ── SCROLLBAR STYLING ── */
.viewport::-webkit-scrollbar { width: 6px; height: 6px; }
.viewport::-webkit-scrollbar-track { background: transparent; }
.viewport::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
