/* ==========================================================================
   Story-Pfad | Design System & Theme Engine - cmschule.de
   ========================================================================== */
/* System fonts used for GDPR compliance */

/* --------------------------------------------------------------------------
   THEME 1: HELL (Standard / Daylight cmschule.de)
   -------------------------------------------------------------------------- */
:root, [data-theme="light"] {
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #ffffff;
    --bg-column: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-focus: #6366f1;
    
    --brand-primary: #7c3aed;
    --brand-indigo: #6366f1;
    --brand-teal: #0f766e;
    
    /* Block-Typen */
    --color-narrator: #2563eb;
    --color-narrator-bg: #eff6ff;
    --color-narrator-text: #1d4ed8;
    --color-dialog: #059669;
    --color-dialog-bg: #ecfdf5;
    --color-dialog-text: #047857;
    --color-choice: #7c3aed;
    --color-choice-bg: #faf5ff;
    --color-choice-text: #6d28d9;
    
    /* Spalten-Farben */
    --col-main: #4f46e5;
    --col-path1: #0d9488;
    --col-path2: #d97706;
    --col-path3: #e11d48;

    --input-bg: #f8fafc;
    --input-border: #cbd5e1;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 4px 14px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 32px -8px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.05);
}

/* --------------------------------------------------------------------------
   THEME 2: MITTERNACHT (Dark Mode - augenschonend)
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
    --bg-page: #0b0f19;
    --bg-surface: #131b2e;
    --bg-surface-elevated: #1a243b;
    --bg-column: #0e1526;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #1e293b;
    --border-strong: #334155;
    --border-focus: #818cf8;
    
    --brand-primary: #a78bfa;
    --brand-indigo: #818cf8;
    --brand-teal: #2dd4bf;
    
    --color-narrator: #60a5fa;
    --color-narrator-bg: rgba(37, 99, 235, 0.18);
    --color-narrator-text: #93c5fd;
    --color-dialog: #34d399;
    --color-dialog-bg: rgba(5, 150, 105, 0.18);
    --color-dialog-text: #6ee7b7;
    --color-choice: #c084fc;
    --color-choice-bg: rgba(124, 58, 237, 0.18);
    --color-choice-text: #d8b4fe;
    
    --col-main: #818cf8;
    --col-path1: #34d399;
    --col-path2: #fbbf24;
    --col-path3: #fb7185;

    --input-bg: #0b0f19;
    --input-border: #334155;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, 0.7);
}

/* --------------------------------------------------------------------------
   THEME 3: PERGAMENT (Fantasy-Buch / Abenteuerroman)
   -------------------------------------------------------------------------- */
[data-theme="sepia"] {
    --bg-page: #f4ede4;
    --bg-surface: #fdfbf7;
    --bg-surface-elevated: #ffffff;
    --bg-column: #eae0d0;
    
    --text-primary: #2e241c;
    --text-secondary: #6e5b4c;
    --text-muted: #9e8d7f;
    
    --border-color: #dfd2c0;
    --border-strong: #cabaa7;
    --border-focus: #8c5a2b;
    
    --brand-primary: #9a481c;
    --brand-indigo: #785233;
    --brand-teal: #2e6b52;
    
    --color-narrator: #2b5c8f;
    --color-narrator-bg: #eaf1f8;
    --color-narrator-text: #1d4ed8;
    --color-dialog: #2e7d32;
    --color-dialog-bg: #eaf4eb;
    --color-dialog-text: #1b5e20;
    --color-choice: #8e24aa;
    --color-choice-bg: #f5e9f8;
    --color-choice-text: #6a1b9a;
    
    --col-main: #6d4c41;
    --col-path1: #2e7d32;
    --col-path2: #b26a00;
    --col-path3: #c2185b;

    --input-bg: #f8f4ed;
    --input-border: #d4c4b0;
    
    --shadow-sm: 0 1px 3px rgba(46, 36, 28, 0.06);
    --shadow-md: 0 4px 14px -2px rgba(46, 36, 28, 0.08);
    --shadow-lg: 0 16px 32px -8px rgba(46, 36, 28, 0.12);
}

/* --------------------------------------------------------------------------
   THEME 4: WALD & SALBEI (Nordic Nature / Sanftes Grün)
   -------------------------------------------------------------------------- */
[data-theme="forest"] {
    --bg-page: #edf2ee;
    --bg-surface: #f7faf8;
    --bg-surface-elevated: #ffffff;
    --bg-column: #e0e9e3;
    
    --text-primary: #14281d;
    --text-secondary: #3e5647;
    --text-muted: #728c7b;
    
    --border-color: #cbdad0;
    --border-strong: #b3c7b9;
    --border-focus: #2d6a4f;
    
    --brand-primary: #2d6a4f;
    --brand-indigo: #1b4332;
    --brand-teal: #0f766e;
    
    --color-narrator: #1d4ed8;
    --color-narrator-bg: #ebf3fb;
    --color-narrator-text: #1e40af;
    --color-dialog: #15803d;
    --color-dialog-bg: #ecfdf5;
    --color-dialog-text: #166534;
    --color-choice: #6b21a8;
    --color-choice-bg: #faf5ff;
    --color-choice-text: #581c87;
    
    --col-main: #1b4332;
    --col-path1: #0f766e;
    --col-path2: #b45309;
    --col-path3: #be123c;

    --input-bg: #f2f7f4;
    --input-border: #bdcfc3;
    
    --shadow-sm: 0 1px 3px rgba(20, 40, 29, 0.05);
    --shadow-md: 0 4px 14px -2px rgba(20, 40, 29, 0.07);
    --shadow-lg: 0 16px 32px -8px rgba(20, 40, 29, 0.11);
}

/* --------------------------------------------------------------------------
   THEME 5: CYBERPUNK (Neon / Sci-Fi Weltraum)
   -------------------------------------------------------------------------- */
[data-theme="cyber"] {
    --bg-page: #060710;
    --bg-surface: #0d1021;
    --bg-surface-elevated: #141933;
    --bg-column: #090c1a;
    
    --text-primary: #e0f2fe;
    --text-secondary: #7dd3fc;
    --text-muted: #475569;
    
    --border-color: #1e293b;
    --border-strong: #2a3852;
    --border-focus: #00f0ff;
    
    --brand-primary: #f43f5e;
    --brand-indigo: #00f0ff;
    --brand-teal: #10b981;
    
    --color-narrator: #38bdf8;
    --color-narrator-bg: rgba(56, 189, 248, 0.16);
    --color-narrator-text: #7dd3fc;
    --color-dialog: #34d399;
    --color-dialog-bg: rgba(52, 211, 153, 0.16);
    --color-dialog-text: #a7f3d0;
    --color-choice: #f472b6;
    --color-choice-bg: rgba(244, 114, 182, 0.16);
    --color-choice-text: #fbcfe8;
    
    --col-main: #38bdf8;
    --col-path1: #34d399;
    --col-path2: #facc15;
    --col-path3: #f43f5e;

    --input-bg: #070914;
    --input-border: #1e293b;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 4px 14px -2px rgba(0, 240, 255, 0.12);
    --shadow-lg: 0 16px 32px -8px rgba(0, 240, 255, 0.2);
}

/* ==========================================================================
   GLOBAL RESET & BASIS
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px 24px 90px;
    line-height: 1.5;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* ==========================================================================
   HEADER & BRANDING
   ========================================================================== */
.app-header {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 22px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.header-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.header-brand-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.brand-logo-link:hover {
    transform: scale(1.02);
}

.brand-logo {
    height: 48px;
    width: auto;
    display: block;
    transition: filter 0.3s ease;
}

[data-theme="dark"] .brand-logo,
[data-theme="cyber"] .brand-logo {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.45));
}

.brand-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-badges-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-brand {
    background: var(--color-choice-bg);
    color: var(--color-choice-text);
    border: 1px solid var(--border-color);
}

.badge-license {
    background: var(--color-narrator-bg);
    color: var(--color-narrator-text);
    border: 1px solid var(--border-color);
}

.badge-privacy {
    background: var(--color-dialog-bg);
    color: var(--color-dialog-text);
    border: 1px solid var(--border-color);
}

.brand-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}

/* Header Actions & Toolbar Groups */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-column);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Theme Switcher */
.theme-switch-group {
    padding: 4px 8px;
    gap: 6px;
}

.theme-icon {
    font-size: 15px;
    user-select: none;
    line-height: 1;
}

.theme-select {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.theme-select:focus,
.theme-select:hover {
    border-color: var(--border-focus);
}

/* Buttons */
.btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-play-main {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-play-main:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}

.btn-tool {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-tool:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

.btn-export-game {
    background: var(--color-dialog-bg);
    color: var(--color-dialog-text);
    border: 1px solid var(--border-color);
}

.btn-export-game:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--color-dialog);
    transform: translateY(-1px);
}

.btn-tool-danger {
    background: var(--bg-surface);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.btn-tool-danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #ef4444;
    border-color: #dc2626;
}

.btn-primary { 
    background: var(--brand-indigo); 
    color: white; 
    border-color: var(--brand-indigo);
}
.btn-primary:hover { 
    filter: brightness(1.1);
}

.btn-secondary { 
    background: var(--bg-surface); 
    color: var(--text-primary); 
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { 
    background: var(--bg-column); 
    border-color: var(--border-strong);
}

.btn-danger { 
    background: #dc2626; 
    color: white; 
    border-color: #b91c1c;
}
.btn-danger:hover { 
    background: #b91c1c; 
}

.btn-small { 
    padding: 5px 10px; 
    font-size: 12px; 
    border-radius: 6px;
}

/* ==========================================================================
   MATRIX GRID & SPALTEN
   ========================================================================== */
.matrix-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    .matrix-grid {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 680px) {
    .matrix-grid {
        grid-template-columns: 1fr;
    }
}

.column {
    background: var(--bg-column);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border-color);
    padding: 16px;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.column-header {
    font-size: 14px;
    font-weight: 700;
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.col-icon {
    font-size: 16px;
}

.col-title {
    flex-grow: 1;
}

.col-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Spalten Farbschemata - Light / Sepia / Forest */
.h-main { 
    background: #eef2ff; 
    color: #3730a3; 
    border-color: #c7d2fe;
}
.h-main .col-badge { background: #c7d2fe; color: #312e81; }

.h-path1 { 
    background: #f0fdfa; 
    color: #115e59; 
    border-color: #99f6e4;
}
.h-path1 .col-badge { background: #99f6e4; color: #134e4a; }

.h-path2 { 
    background: #fffbeb; 
    color: #92400e; 
    border-color: #fde68a;
}
.h-path2 .col-badge { background: #fde68a; color: #78350f; }

.h-path3 { 
    background: #fff1f2; 
    color: #9f1239; 
    border-color: #fecdd3;
}
.h-path3 .col-badge { background: #fecdd3; color: #881337; }

/* Spalten Farbschemata - Dark Mode */
[data-theme="dark"] .h-main { background: rgba(99, 102, 241, 0.15); color: #c7d2fe; border-color: rgba(99, 102, 241, 0.35); }
[data-theme="dark"] .h-main .col-badge { background: rgba(99, 102, 241, 0.35); color: #e0e7ff; }

[data-theme="dark"] .h-path1 { background: rgba(16, 185, 129, 0.15); color: #a7f3d0; border-color: rgba(16, 185, 129, 0.35); }
[data-theme="dark"] .h-path1 .col-badge { background: rgba(16, 185, 129, 0.35); color: #d1fae5; }

[data-theme="dark"] .h-path2 { background: rgba(245, 158, 11, 0.15); color: #fde68a; border-color: rgba(245, 158, 11, 0.35); }
[data-theme="dark"] .h-path2 .col-badge { background: rgba(245, 158, 11, 0.35); color: #fef3c7; }

[data-theme="dark"] .h-path3 { background: rgba(244, 63, 94, 0.15); color: #fecdd3; border-color: rgba(244, 63, 94, 0.35); }
[data-theme="dark"] .h-path3 .col-badge { background: rgba(244, 63, 94, 0.35); color: #ffe4e6; }

/* Spalten Farbschemata - Cyberpunk */
[data-theme="cyber"] .h-main { background: rgba(56, 189, 248, 0.12); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.35); }
[data-theme="cyber"] .h-main .col-badge { background: rgba(56, 189, 248, 0.3); color: #e0f2fe; }

[data-theme="cyber"] .h-path1 { background: rgba(52, 211, 153, 0.12); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); }
[data-theme="cyber"] .h-path1 .col-badge { background: rgba(52, 211, 153, 0.3); color: #d1fae5; }

[data-theme="cyber"] .h-path2 { background: rgba(250, 204, 21, 0.12); color: #fef08a; border-color: rgba(250, 204, 21, 0.35); }
[data-theme="cyber"] .h-path2 .col-badge { background: rgba(250, 204, 21, 0.3); color: #fef9c3; }

[data-theme="cyber"] .h-path3 { background: rgba(244, 63, 94, 0.12); color: #fda4af; border-color: rgba(244, 63, 94, 0.35); }
[data-theme="cyber"] .h-path3 .col-badge { background: rgba(244, 63, 94, 0.3); color: #ffe4e6; }

/* Spalten Farbschemata - Sepia */
[data-theme="sepia"] .h-main { background: #efebe9; color: #4e342e; border-color: #d7ccc8; }
[data-theme="sepia"] .h-main .col-badge { background: #d7ccc8; color: #3e2723; }

[data-theme="sepia"] .h-path1 { background: #e8f5e9; color: #1b5e20; border-color: #c8e6c9; }
[data-theme="sepia"] .h-path1 .col-badge { background: #c8e6c9; color: #1b5e20; }

[data-theme="sepia"] .h-path2 { background: #fff8e1; color: #f57f17; border-color: #ffecb3; }
[data-theme="sepia"] .h-path2 .col-badge { background: #ffecb3; color: #e65100; }

[data-theme="sepia"] .h-path3 { background: #fce4ec; color: #880e4f; border-color: #f8bbd0; }
[data-theme="sepia"] .h-path3 .col-badge { background: #f8bbd0; color: #4a148c; }

.blocks-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-grow: 1;
    margin-bottom: 16px;
}

.btn-add-block {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-add-block:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--border-focus);
    color: var(--brand-indigo);
    transform: translateY(-1px);
}

/* ==========================================================================
   STORY BLÖCKE
   ========================================================================== */
.story-block {
    position: relative;
    background: var(--bg-surface);
    border-left: 5px solid transparent;
    border-radius: var(--radius-md);
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background-color 0.25s ease;
}

.story-block:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-focus);
}

.block-narrator { border-left-color: var(--color-narrator); }
.block-dialog   { border-left-color: var(--color-dialog); }
.block-choice   { border-left-color: var(--color-choice); }

.block-tag {
    font-size: 10.5px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    display: inline-block;
    margin-bottom: 8px;
    max-width: calc(100% - 130px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.block-narrator .block-tag { background: var(--color-narrator-bg); color: var(--color-narrator-text); }
.block-dialog .block-tag   { background: var(--color-dialog-bg); color: var(--color-dialog-text); }
.block-choice .block-tag   { background: var(--color-choice-bg); color: var(--color-choice-text); }

.block-emoji {
    font-size: 20px;
    margin-right: 6px;
    vertical-align: middle;
}

.speaker-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.block-text {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 10px;
    white-space: pre-line;
    word-break: break-word;
}

/* Edit Trigger wird nun im .block-card-actions Flexbox-Container gesteuert */
.edit-trigger {
    position: static;
}

/* Badges für Items & Attribute */
.block-item-badge {
    background: var(--color-dialog-bg);
    color: var(--color-dialog-text);
    border: 1px solid var(--border-color);
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.block-stat-badge {
    background: var(--color-choice-bg);
    color: var(--color-choice-text);
    border: 1px solid var(--border-color);
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Sprung- & Entscheidungs-Buttons */
.choice-buttons-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.jump-btn {
    width: 100%;
    text-align: left;
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.jump-btn:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
}

.jump-target {
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background: var(--color-choice-bg);
    color: var(--color-choice-text);
    white-space: nowrap;
}

/* Sprung-Highlight Animation */
@keyframes pulseHighlight {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7); }
    50% { transform: scale(1.03); box-shadow: 0 0 0 12px rgba(99, 102, 241, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.jump-highlight {
    animation: pulseHighlight 1.4s ease-out;
    border-color: var(--border-focus) !important;
}

/* ==========================================================================
   MODALS (DIALOGE)
   ========================================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

@keyframes modalEnter {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.modal-header h2 {
    font-size: 1.15rem;
    color: var(--text-primary);
    font-weight: 700;
}

.close-btn {
    background: var(--bg-column);
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--border-strong);
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   INTERAKTIVER STORY-PLAYER
   ========================================================================== */
.player-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.player-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 640px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: playerCardEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

@keyframes playerCardEnter {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.player-progress {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-column);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.player-header-actions {
    display: flex;
    gap: 8px;
}

/* Player Status- & Inventar-Leisten */
.player-stats-bar,
.player-inventory-bar {
    width: 100%;
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.stats-value-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.stat-val-item {
    background: var(--bg-surface);
    padding: 3px 9px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.inventory-emoji-list {
    display: flex;
    gap: 8px;
    font-size: 18px;
}

.player-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.player-emoji {
    font-size: 76px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: floatingEmoji 3s ease-in-out infinite;
    user-select: none;
}

@keyframes floatingEmoji {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.player-bubble-container {
    width: 100%;
    padding: 18px;
    border-radius: 14px;
    transition: all 0.3s ease;
}

.player-bubble-narrator {
    background: var(--color-narrator-bg);
    border: 1.5px dashed var(--color-narrator);
    color: var(--text-primary);
}
.player-bubble-narrator .player-speaker { display: none; }
.player-bubble-narrator .player-text {
    font-style: italic;
    font-size: 16px;
    line-height: 1.6;
}

.player-bubble-dialog {
    background: var(--color-dialog-bg);
    border-left: 5px solid var(--color-dialog);
    text-align: left;
}
.player-bubble-dialog .player-speaker {
    display: block;
    font-weight: 800;
    color: var(--color-dialog-text);
    font-size: 13.5px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.player-bubble-dialog .player-text {
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
}

.player-bubble-choice {
    background: var(--color-choice-bg);
    border-left: 5px solid var(--color-choice);
    text-align: center;
}
.player-bubble-choice .player-speaker { display: none; }
.player-bubble-choice .player-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.player-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-btn-choice {
    width: 100%;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.player-btn-choice:hover:not(:disabled) {
    background: var(--color-choice-bg);
    border-color: var(--color-choice);
    color: var(--color-choice-text);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.player-btn-choice:disabled {
    background: var(--bg-column) !important;
    border-color: var(--border-color) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.player-btn-next {
    width: 100%;
    background: linear-gradient(135deg, var(--brand-indigo) 0%, var(--brand-primary) 100%);
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.player-btn-next:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.player-btn-restart-large {
    width: 100%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.player-btn-restart-large:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
}

/* In-Game Notification Overlay */
.player-notification-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.player-notification-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.player-notification-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    max-width: 85%;
    width: 340px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-notification-overlay.active .player-notification-content {
    transform: scale(1);
}

.player-notification-emoji {
    font-size: 52px;
    margin-bottom: 10px;
}

/* ==========================================================================
   CHARAKTER- & ITEM-LISTEN IN MODALS
   ========================================================================== */
.char-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.char-item.editing {
    border-color: var(--brand-indigo);
    background: var(--color-narrator-bg);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.char-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.char-item-color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.char-item-emoji {
    font-size: 22px;
}

.char-item-name {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-primary);
}

.char-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.char-item-actions {
    display: flex;
    gap: 6px;
}

.char-item-btn {
    padding: 4px 8px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
}

.char-item-btn-edit:hover {
    background: var(--color-narrator-bg);
    border-color: var(--color-narrator);
    color: var(--color-narrator-text);
}

.char-item-btn-delete:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: #dc2626;
    color: #dc2626;
}

/* Choice Rows im Block-Editor */
.choice-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    background: var(--bg-column);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* ==========================================================================
   NATIVE EMOJI PICKER POPOVER
   ========================================================================== */
.emoji-picker-popover {
    position: absolute;
    z-index: 2000;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    width: 320px;
    max-width: calc(100vw - 32px);
    animation: popoverFade 0.2s ease;
}

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

.emoji-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.emoji-picker-cat-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin: 8px 0 6px;
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.emoji-picker-btn {
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 20px;
    padding: 6px;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-picker-btn:hover {
    background: var(--color-narrator-bg);
    border-color: var(--color-narrator);
    transform: scale(1.15);
}

.emoji-input-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-emoji-trigger {
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    color: var(--text-primary);
}

.btn-emoji-trigger:hover {
    background: var(--border-strong);
}

.btn-icon-only {
    padding: 8px 10px;
    font-size: 14px;
    min-width: 36px;
}

.btn:disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* Block Card Actions (Bearbeiten & Duplizieren) */
.block-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    z-index: 5;
}

.block-action-btn {
    position: static;
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    white-space: nowrap;
    line-height: 1.3;
}

.block-action-btn:hover {
    background: var(--brand-indigo);
    color: white;
    border-color: var(--brand-indigo);
    transform: translateY(-1px);
}

.btn-clone-block {
    padding: 3px 7px;
    font-size: 12px;
}

.btn-clone-block:hover {
    background: var(--color-choice-bg);
    border-color: var(--color-choice);
    color: var(--color-choice-text);
}

/* ==========================================================================
   DIDAKTISCHE VORLAGEN (TEMPLATE-SELECTOR MODAL)
   ========================================================================== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.template-card {
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background-color 0.25s ease;
}

.template-card:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.template-icon {
    font-size: 32px;
    line-height: 1;
}

.template-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--color-narrator-bg);
    color: var(--color-narrator-text);
    border: 1px solid var(--border-color);
}

.template-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 6px 0 2px;
}

.template-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.template-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.template-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.template-btn-load {
    width: 100%;
    font-weight: 700;
}

/* ==========================================================================
   STORY-CHECKER (LOGIK-PRÜFUNG)
   ========================================================================== */
.checker-summary-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    margin-bottom: 16px;
}

.checker-summary-card.status-perfect {
    background: var(--color-dialog-bg);
    border-color: var(--color-dialog);
    color: var(--color-dialog-text);
}

.checker-summary-card.status-warning {
    background: var(--color-choice-bg);
    border-color: var(--color-choice);
    color: var(--color-choice-text);
}

.checker-summary-card.status-error {
    background: rgba(220, 38, 38, 0.12);
    border-color: #dc2626;
    color: #dc2626;
}

.checker-status-icon {
    font-size: 36px;
    line-height: 1;
}

.checker-status-info h3 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 4px;
}

.checker-status-info p {
    font-size: 13px;
    opacity: 0.92;
    margin: 0;
}

.checker-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.checker-stat-pill {
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.checker-stat-pill .stat-num {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.checker-stat-pill .stat-lbl {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.checker-issues-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.checker-issue-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-column);
    font-size: 13px;
}

.checker-issue-item.issue-error {
    border-left: 4px solid #dc2626;
}

.checker-issue-item.issue-warning {
    border-left: 4px solid var(--color-choice);
}

.checker-issue-item.issue-tip {
    border-left: 4px solid var(--color-narrator);
}

.checker-issue-item .issue-icon {
    font-size: 18px;
    line-height: 1.2;
}

.checker-issue-item .issue-text strong {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.checker-issue-item .issue-text p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.4;
}

.checker-perfect-banner {
    padding: 16px;
    border-radius: 8px;
    background: var(--color-dialog-bg);
    color: var(--color-dialog-text);
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--color-dialog);
}

.hidden { display: none !important; }
.hidden-field { display: none !important; }

/* ==========================================================================
   MODERNE TOAST-BENACHRICHTIGUNGEN
   ========================================================================== */
.storypfad-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-24px) scale(0.95);
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 9999px;
    padding: 10px 22px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.22), 0 4px 12px rgba(15, 23, 42, 0.08);
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    user-select: none;
    max-width: calc(100vw - 32px);
}

.storypfad-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
}

.storypfad-toast-icon {
    font-size: 17px;
    line-height: 1;
    display: inline-flex;
}

.storypfad-toast-text {
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.storypfad-toast-success {
    border-color: #86efac;
}

.storypfad-toast-warning {
    border-color: #fde047;
}

.storypfad-toast-error {
    border-color: #fca5a5;
}


