/* Story-Engine · Design-System nach /root/projects/DESIGN_TEMPLATE.md */
:root {
    --primary: #6366f1; --primary-dark: #4f46e5; --primary-light: #e0e7ff;
    --bg-page: #f8fafc; --bg-card: #ffffff; --bg-muted: #f1f5f9; --border: #e2e8f0;
    --text: #0f172a; --text-muted: #64748b; --text-body: #334155;
    --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #3b82f6;
    --success-bg: #ecfdf5; --warning-bg: #fffbeb; --danger-bg: #fef2f2; --info-bg: #eff6ff;
    --sidebar: #0f172a; --sidebar-text: #cbd5e1;
    --shadow: 0 4px 16px rgba(0,0,0,0.06);
    color-scheme: light;
}
[data-theme="dark"] {
    --primary: #818cf8; --primary-dark: #6366f1; --primary-light: rgba(129,140,248,0.15);
    --bg-page: #0f172a; --bg-card: #1e293b; --bg-muted: #334155; --border: #334155;
    --text: #e2e8f0; --text-muted: #94a3b8; --text-body: #cbd5e1;
    --success: #34d399; --warning: #fbbf24; --danger: #f87171; --info: #60a5fa;
    --success-bg: rgba(52,211,153,0.12); --warning-bg: rgba(251,191,36,0.12); --danger-bg: rgba(248,113,113,0.12); --info-bg: rgba(96,165,250,0.12);
    --sidebar: #020617; --sidebar-text: #94a3b8;
    --shadow: 0 4px 16px rgba(0,0,0,0.35);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-page); color: var(--text); line-height: 1.55; min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 2rem; font-weight: 800; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.75rem; }
h3 { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; color: var(--text-body); }
small, .small { font-size: 0.85rem; }
.muted { color: var(--text-muted); }
.label, .tag { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.narrow { max-width: 760px; }
main { padding: 2rem 0 4rem; }
.topbar { background: var(--bg-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .container { display: flex; align-items: center; gap: 1.5rem; height: 60px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav a { padding: 0.45rem 0.75rem; border-radius: 8px; color: var(--text-body); font-weight: 500; }
.nav a:hover { background: var(--bg-muted); text-decoration: none; }
.nav a.active { background: var(--primary-light); color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.theme-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.theme-group button { background: transparent; border: 0; padding: 0.35rem 0.6rem; cursor: pointer; color: var(--text-muted); font-size: 0.85rem; }
.theme-group button.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.credits-pill { font-size: 0.8rem; background: var(--bg-muted); padding: 0.3rem 0.65rem; border-radius: 999px; color: var(--text-body); white-space: nowrap; }
footer { border-top: 1px solid var(--border); padding: 1.5rem 0; color: var(--text-muted); font-size: 0.85rem; }
footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }

/* Admin */
.admin-wrap { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 60px); }
.sidebar { background: var(--sidebar); padding: 1.25rem 0; }
.sidebar a { display: block; padding: 0.6rem 1.25rem; color: var(--sidebar-text); border-left: 3px solid transparent; }
.sidebar a:hover { background: rgba(255,255,255,0.05); text-decoration: none; color: #fff; }
.sidebar a.active { background: rgba(255,255,255,0.08); border-left-color: var(--primary); color: #fff; }
.sidebar .label { color: var(--text-muted); padding: 1rem 1.25rem 0.35rem; opacity: 0.8; }
.admin-content { padding: 2rem; min-width: 0; }
@media (max-width: 800px) { .admin-wrap { grid-template-columns: 1fr; } .sidebar { display: flex; flex-wrap: wrap; padding: 0.5rem; } .sidebar .label { display: none; } .sidebar a { border-left: 0; border-radius: 6px; } }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.25rem; }
.card.hover { transition: all 0.15s; }
.card.hover:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stat { padding: 1.25rem; }
.stat .num { font-size: 1.75rem; font-weight: 800; }
.stat .label { color: var(--text-muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.625rem 1.25rem; border-radius: 8px; border: 1px solid transparent; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.15s; background: var(--bg-card); color: var(--text); text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn:disabled, .btn.loading { opacity: 0.6; cursor: wait; }
.btn-block { width: 100%; justify-content: center; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.actions.right { justify-content: flex-end; }

/* Forms */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.92rem; }
.field label .req { color: var(--danger); }
.field .hint { display: block; color: var(--text-muted); font-size: 0.82rem; margin-top: 0.3rem; }
.field .err { display: block; color: var(--danger); font-size: 0.82rem; margin-top: 0.3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%; padding: 0.625rem 0.875rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text); font: inherit; font-size: 0.95rem;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg-muted); border: 1px solid var(--border); border-radius: 999px; transition: 0.15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked + span { background: var(--primary); border-color: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }

/* Badges / Tags */
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; background: var(--bg-muted); color: var(--text-body); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.herkunft { font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 4px; margin-left: 0.4rem; text-transform: none; letter-spacing: 0; vertical-align: middle; }
.herkunft-gemessen { background: var(--success-bg); color: var(--success); }
.herkunft-abgeleitet { background: var(--info-bg); color: var(--info); }
.herkunft-geschaetzt { background: var(--warning-bg); color: var(--warning); }
.herkunft-manuell { background: var(--bg-muted); color: var(--text-muted); }

/* Alerts */
.alert { border-left: 4px solid var(--info); background: var(--info-bg); padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem; color: var(--text); }
.alert-success { border-color: var(--success); background: var(--success-bg); }
.alert-warning { border-color: var(--warning); background: var(--warning-bg); }
.alert-error, .alert-danger { border-color: var(--danger); background: var(--danger-bg); }
.toast-wrap { position: fixed; top: 72px; right: 1rem; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; max-width: 380px; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 8px; padding: 0.75rem 2.25rem 0.75rem 1rem; box-shadow: var(--shadow); position: relative; }
.toast.success { border-left-color: var(--success); } .toast.error { border-left-color: var(--danger); } .toast.warning { border-left-color: var(--warning); }
.toast button { position: absolute; right: 0.4rem; top: 0.4rem; background: none; border: 0; cursor: pointer; color: var(--text-muted); font-size: 1rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
tr:hover td { background: var(--bg-muted); }
td.right, th.right { text-align: right; }
.table-wrap { overflow-x: auto; }

/* Stepper */
.stepper { display: flex; gap: 0; margin-bottom: 1.5rem; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-card); }
.stepper .step { flex: 1; padding: 0.75rem 1rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); border-right: 1px solid var(--border); display: flex; align-items: center; gap: 0.5rem; }
.stepper .step:last-child { border-right: 0; }
.stepper .step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; }
.stepper .step.done { color: var(--success); } .stepper .step.done .n { background: var(--success-bg); color: var(--success); }
.stepper .step.current { color: var(--primary); background: var(--primary-light); } .stepper .step.current .n { background: var(--primary); color: #fff; }
@media (max-width: 700px) { .stepper { flex-wrap: wrap; } .stepper .step { flex: 1 1 45%; border-bottom: 1px solid var(--border); } }

/* Flow diagram */
.flow { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.flow span { background: var(--bg-muted); padding: 0.25rem 0.6rem; border-radius: 6px; }
.flow i { font-style: normal; }

/* Beats */
.beat { border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 0.75rem; background: var(--bg-card); }
.beat-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.beat-head .nr { width: 28px; height: 28px; border-radius: 8px; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.beat-head strong { flex: 1; }
.beat-meta { font-size: 0.8rem; color: var(--text-muted); }
.beat .row { margin-top: 0.5rem; }
.beat textarea { min-height: 60px; }
.beat.warn { border-color: var(--warning); }
.beat.fail { border-color: var(--danger); }
.beat.ok { border-color: var(--success); }

/* Voiceover */
.voiceover { white-space: pre-wrap; line-height: 1.7; font-size: 1.02rem; color: var(--text); background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem 1.75rem; max-height: 70vh; overflow: auto; }
.voiceover mark { background: var(--danger-bg); color: inherit; outline: 2px solid var(--danger); border-radius: 4px; }
.vo-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }

/* Progress */
.progress { height: 8px; background: var(--bg-muted); border-radius: 999px; overflow: hidden; margin: 0.5rem 0 1rem; }
.progress div { height: 100%; background: var(--primary); width: 0; transition: width 0.3s; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty p { margin-bottom: 1.25rem; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tabs button { background: none; border: 0; padding: 0.65rem 1rem; font: inherit; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.85rem; cursor: pointer; font-size: 0.9rem; background: var(--bg-card); color: var(--text); }
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* Ideen */
.idee { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.idee input { margin-top: 0.3rem; width: 18px; height: 18px; accent-color: var(--primary); }
.idee strong { display: block; }
.idee small { color: var(--text-muted); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: none; align-items: center; justify-content: center; z-index: 60; padding: 1rem; }
.modal-bg.open { display: flex; }
.modal { background: var(--bg-card); border-radius: 12px; padding: 1.5rem; max-width: 460px; width: 100%; border: 1px solid var(--border); }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 1.5rem; font-size: 1.4rem; }

/* DNA list */
.dna { display: grid; grid-template-columns: 180px 1fr; gap: 0.35rem 1rem; font-size: 0.92rem; }
.dna dt { color: var(--text-muted); font-weight: 600; }
.dna dd { margin: 0; color: var(--text); }
@media (max-width: 600px) { .dna { grid-template-columns: 1fr; } .dna dt { margin-top: 0.5rem; } }
details summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.pruef li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); list-style: none; display: flex; gap: 0.6rem; align-items: baseline; }
.pruef ul { padding: 0; margin: 0; }
.pruef .ok::before { content: "✓"; color: var(--success); font-weight: 700; }
.pruef .fail::before { content: "✕"; color: var(--danger); font-weight: 700; }
.pruef .warn::before { content: "!"; color: var(--warning); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
