/* === Phantasmo Eleven — Gestaltung angelehnt an die Hörspielbox ===
   Dunkle Navigationsleiste, blaue Akzente, weiße Karten. Dunkelmodus über
   prefers-color-scheme oder Konto → Einstellungen (data-theme). */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #FFFFFF;
    --bg-alt: #F3F5F8;
    --surface: #FFFFFF;
    --text: #1A1A2E;
    --muted: #4B5060;
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-text: #FFFFFF;
    --nav-bg: #1A1A2E;
    --nav-text: #FFFFFF;
    --error: #B91C1C;
    --error-bg: #FEF2F2;
    --success: #047857;
    --success-bg: #ECFDF5;
    --warning-bg: #FFFBEB;
    --info-bg: #EFF6FF;
    --border: #C5CAD3;
    --focus: #F59E0B;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12131A; --bg-alt: #1B1D27; --surface: #1E2030; --text: #ECECF3; --muted: #B4B7C5;
        --primary: #7AA7FF; --primary-hover: #9CBDFF; --primary-text: #0B1530; --nav-bg: #0B0C14;
        --error: #FF8A80; --error-bg: #3A1717; --success: #7FD99A; --success-bg: #12301E;
        --warning-bg: #3A3015; --info-bg: #142340; --border: #3D4152; --shadow: none;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #12131A; --bg-alt: #1B1D27; --surface: #1E2030; --text: #ECECF3; --muted: #B4B7C5;
    --primary: #7AA7FF; --primary-hover: #9CBDFF; --primary-text: #0B1530; --nav-bg: #0B0C14;
    --error: #FF8A80; --error-bg: #3A1717; --success: #7FD99A; --success-bg: #12301E;
    --warning-bg: #3A3015; --info-bg: #142340; --border: #3D4152; --shadow: none;
    color-scheme: dark;
}

html { font-size: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}
main:focus { outline: none; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; margin-top: 0.5rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; margin-top: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
code { background: var(--bg-alt); padding: 0.05rem 0.3rem; border-radius: 3px; word-break: break-all; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* === Barrierefreiheit === */
.skip-link {
    position: absolute; left: 0; top: -100%; z-index: 1000;
    background: var(--text); color: var(--bg); padding: 0.6rem 1rem; text-decoration: underline;
}
.skip-link:focus { top: 0; }
.sr-only, .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* === Navigation === */
.site-nav { background: var(--nav-bg); color: var(--nav-text); padding: 0 1rem; }
.nav-container {
    max-width: 1100px; margin: 0 auto; display: flex; align-items: center;
    gap: 1rem 1.5rem; min-height: 56px; flex-wrap: wrap;
}
.nav-brand { color: var(--nav-text); text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.nav-brand:hover { color: var(--nav-text); }
.nav-links { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1; margin: 0; padding: 0; }
.nav-links > li > a, .nav-dropdown summary {
    color: rgba(255,255,255,0.9); text-decoration: none; padding: 0.5rem 0.75rem;
    border-radius: var(--radius); display: inline-block; cursor: pointer;
}
.nav-links > li > a:hover, .nav-links > li > a[aria-current="page"],
.nav-dropdown summary:hover, .nav-dropdown summary[data-active] {
    color: #fff; background: rgba(255,255,255,0.16);
}
.nav-links a[aria-current="page"], .nav-dropdown-menu a[aria-current="page"] { font-weight: 700; text-decoration: underline; }
.nav-dropdown { position: relative; }
.nav-dropdown summary { list-style: none; user-select: none; }
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: " ▾"; }
.nav-dropdown summary:focus-visible, .nav-links a:focus-visible, .nav-user a:focus-visible,
.nav-user button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.nav-dropdown-menu {
    position: absolute; top: calc(100% + 0.25rem); left: 0; min-width: 15rem; list-style: none;
    margin: 0; padding: 0.25rem; background: var(--nav-bg); border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius); box-shadow: 0 6px 16px rgba(0,0,0,0.3); z-index: 100;
}
.nav-dropdown-menu a {
    display: block; padding: 0.5rem 0.75rem; color: rgba(255,255,255,0.92);
    text-decoration: none; border-radius: var(--radius); white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: rgba(255,255,255,0.16); color: #fff; }
.nav-user { display: flex; align-items: center; gap: 0.75rem; color: rgba(255,255,255,0.9); }
.nav-user a, .nav-user .link { color: rgba(255,255,255,0.9); }
.nav-user form { margin: 0; }

/* === Meldungen === */
.flash-container { margin-bottom: 1.25rem; }
.flash, .notice, .alert {
    padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 0.5rem; border-left: 4px solid;
}
.flash-error, .alert-error { background: var(--error-bg); border-color: var(--error); }
.flash-success { background: var(--success-bg); border-color: var(--success); }
.flash-info, .alert-info { background: var(--info-bg); border-color: var(--primary); }
.flash-warning, .notice { background: var(--warning-bg); border-color: #D97706; }
.error, .error-text { color: var(--error); font-weight: 600; }
.ok { color: var(--success); font-weight: 600; }

/* === Karten & Bereiche === */
.card, section.card, form.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem 1.5rem; box-shadow: var(--shadow); margin: 0 0 1.25rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.tile { display: block; text-decoration: none; color: inherit; }
.tile h3 { margin: 0 0 0.25rem; color: var(--primary); }
.tile p { margin: 0; color: var(--muted); }
.feature-list { list-style: none; margin: 0; padding: 0; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.75rem; }
.feature-list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; }
.feature-list a { font-weight: 700; font-size: 1.05rem; }
.feature-list p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.95rem; }

details.fold { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 1rem; }
details.fold > summary { padding: 0.8rem 1.2rem; cursor: pointer; font-weight: 600; }
details.fold[open] > summary { border-bottom: 1px solid var(--border); }
details.fold > .fold-body { padding: 1rem 1.2rem; }

/* === Formulare === */
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 1.1rem; padding: 0.75rem 1rem 0.5rem; }
legend { font-weight: 700; padding: 0 0.3rem; }
.form-group, .field { margin: 0 0 1.1rem; }
.form-group > label, .field > label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
input[type="search"], input[type="file"], select, textarea {
    font: inherit; color: var(--text); background: var(--bg); width: 100%; max-width: 46rem;
    padding: 0.55rem 0.7rem; border: 2px solid var(--border); border-radius: var(--radius);
}
input[type="number"] { max-width: 10rem; }
input[type="file"] { padding: 0.4rem; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--primary); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); }
.help-text, .hint { font-size: 0.93rem; color: var(--muted); margin: 0.25rem 0 0; }
.form-check, .choice { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.35rem 0; }
.form-check input, .choice input { width: 1.2rem; height: 1.2rem; margin-top: 0.2rem; flex: none; }
.range-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.range-row input[type="range"] { flex: 1; min-width: 10rem; max-width: 30rem; accent-color: var(--primary); }
.range-row output { min-width: 3rem; font-variant-numeric: tabular-nums; }
.char-count { font-size: 0.9rem; color: var(--muted); }
.inline-form { display: inline; margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1.25rem; }

/* === Knöpfe === */
.btn, button, .button {
    font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
    gap: 0.35rem; min-height: 44px; min-width: 44px; padding: 0.55rem 1.1rem; border-radius: var(--radius);
    border: 2px solid var(--primary); background: var(--surface); color: var(--primary);
    cursor: pointer; text-decoration: none;
}
.btn:hover, button:hover, .button:hover { background: var(--bg-alt); }
.btn-primary, button.primary {
    background: var(--primary); color: var(--primary-text); border-color: var(--primary);
}
.btn-primary:hover, button.primary:hover { background: var(--primary-hover); color: var(--primary-text); }
.btn-danger, button.danger { border-color: var(--error); color: var(--error); background: var(--surface); }
.btn-danger:hover, button.danger:hover { background: var(--error-bg); }
.btn-sm { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.93rem; }
.link, button.link { border: none; background: none; padding: 0; min-height: 0; min-width: 0; color: var(--primary);
    text-decoration: underline; font-weight: 400; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.actions, .btn-group { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; align-items: center; }

/* === Tabellen & Listen === */
table { border-collapse: collapse; width: 100%; margin: 0 0 1.25rem; }
caption { text-align: left; font-weight: 700; padding-bottom: 0.4rem; }
th, td { padding: 0.55rem 0.6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: var(--bg-alt); font-weight: 700; }
.table-wrap { overflow-x: auto; }
ul.plain, ol.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li, ol.plain > li { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.voice-list > li { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; }
.voice-list .meta { color: var(--muted); font-size: 0.93rem; flex-basis: 100%; }
.badge { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
    background: var(--bg-alt); border: 1px solid var(--border); }
.status-done { color: var(--success); font-weight: 700; }
.status-failed { color: var(--error); font-weight: 700; }
.status-running, .status-pending { color: var(--primary); font-weight: 700; }

/* === Ergebnisse & Wiedergabe === */
.result-box { border-left: 4px solid var(--primary); padding: 0.75rem 1rem; background: var(--bg-alt);
    border-radius: var(--radius); margin: 1rem 0; }
.result-box:empty { display: none; }
.result-box h2, .result-box h3 { margin-top: 0; }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.file-list audio, .file-list video, audio.full { width: 100%; max-width: 46rem; display: block; margin: 0.35rem 0; }
.file-list img { max-width: 100%; height: auto; display: block; margin: 0.35rem 0; border-radius: var(--radius); }
.transcript { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); padding: 0.75rem;
    border-radius: var(--radius); max-height: 30rem; overflow: auto; }
progress { width: 100%; max-width: 40rem; height: 1.1rem; }
.spinner { display: inline-block; width: 1.1rem; height: 1.1rem; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.2rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Song-Plan-Editor === */
.plan-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0 0 1rem;
    background: var(--surface); }
.plan-section h3 { margin-top: 0; }

/* === Aufnahme-Widget === */
.recorder { border: 1px dashed var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0.5rem 0 1rem; }

/* === ProVC-Kompatibilität === */
.status-box { border-left: 4px solid var(--primary); padding: 0.5rem 0.75rem; }
.chat { list-style: none; padding: 0; margin: 0 0 1rem; max-height: 28rem; overflow-y: auto; }
.chat li { padding: 0.5rem 0.75rem; margin: 0.4rem 0; border-radius: var(--radius); border: 1px solid var(--border); white-space: pre-wrap; }
.chat li.user { background: var(--bg-alt); }
.chat li.system { color: var(--muted); font-style: italic; }
.chat li.question { border-color: var(--primary); border-width: 2px; }
.consent { background: var(--warning-bg); border: 2px solid var(--border); }
.consent label { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0.5rem 0; }
.consent input { flex: none; margin-top: 0.3rem; }
.player { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.5rem 1rem; margin-top: 1rem; }
.player audio { width: 100%; }
.sender-row { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; margin: 0.35rem 0; }
td.num { white-space: nowrap; }
form.inline { display: inline; margin: 0; }

/* === Fußzeile === */
footer { text-align: center; padding: 1.25rem; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--border); }

@media (max-width: 760px) {
    .nav-container { padding: 0.5rem 0; }
    .card, section.card, form.card { padding: 0.9rem; }
    th, td { padding: 0.4rem; }
    .nav-dropdown-menu { position: static; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
    .btn-primary, button.primary { border: 2px solid ButtonText; }
    :focus-visible { outline: 3px solid Highlight; }
}
