:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --surface-2: #f0efeb;
    --border: #e2e0da;
    --text: #1c1c1e;
    --text-muted: #6b6a66;
    --accent: #c8102e;
    --accent-hover: #a50d26;
    --accent-soft: #fbe9ec;
    --accent-text: #ffffff;
    --ok: #1f7a4d;
    --warn-bg: #fff4d6;
    --warn-text: #7a5300;
    --error-bg: #fde8e8;
    --error-text: #9b1c1c;
    --tag-pa: #e7f0ff;  --tag-pa-text: #1d4ea8;
    --tag-dl: #fff0e0;  --tag-dl-text: #9a4a00;
    --tag-vs: #efe9fb;  --tag-vs-text: #5b3aa8;
    --tag-x:  #eceae5;  --tag-x-text:  #4a4945;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
    --radius: 16px;
    --radius-sm: 10px;
    --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #16171a;
        --surface: #1f2024;
        --surface-2: #2a2b30;
        --border: #34353b;
        --text: #f1f0ee;
        --text-muted: #a3a29e;
        --accent: #ff4d5e;
        --accent-hover: #ff6b79;
        --accent-soft: #3a1d22;
        --accent-text: #16171a;
        --ok: #5cc98e;
        --warn-bg: #3a3017;
        --warn-text: #f3cf74;
        --error-bg: #3d1c1c;
        --error-text: #ff9b9b;
        --tag-pa: #1d2b47;  --tag-pa-text: #9cc0ff;
        --tag-dl: #3b2a18;  --tag-dl-text: #ffbf80;
        --tag-vs: #2d2445;  --tag-vs-text: #c8b5ff;
        --tag-x:  #2f3035;  --tag-x-text:  #c9c8c4;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #16171a;
    --surface: #1f2024;
    --surface-2: #2a2b30;
    --border: #34353b;
    --text: #f1f0ee;
    --text-muted: #a3a29e;
    --accent: #ff4d5e;
    --accent-hover: #ff6b79;
    --accent-soft: #3a1d22;
    --accent-text: #16171a;
    --ok: #5cc98e;
    --warn-bg: #3a3017;
    --warn-text: #f3cf74;
    --error-bg: #3d1c1c;
    --error-text: #ff9b9b;
    --tag-pa: #1d2b47;  --tag-pa-text: #9cc0ff;
    --tag-dl: #3b2a18;  --tag-dl-text: #ffbf80;
    --tag-vs: #2d2445;  --tag-vs-text: #c8b5ff;
    --tag-x:  #2f3035;  --tag-x-text:  #c9c8c4;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.muted { color: var(--text-muted); }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    padding-top: max(12px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; min-width: 0; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; }
.brand-icon svg { width: 20px; height: 20px; stroke-width: 2.2; }
.theme-toggle {
    display: flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    font-size: 15px; font-weight: 500;
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .i-moon { display: none; }
.theme-toggle.is-dark .i-sun { display: none; }
.theme-toggle.is-dark .i-moon { display: block; }
@media (max-width: 380px) { .theme-label { display: none; } .brand .muted { display: none; } }

/* ---------- Layout ---------- */
main {
    max-width: 1080px; margin: 0 auto;
    padding: 20px 16px 140px;
    display: flex; flex-direction: column; gap: 16px;
}
.step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
#afterUpload { display: flex; flex-direction: column; gap: 16px; }
.step-head { display: flex; align-items: center; gap: 12px; }
.step h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.step-num {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: var(--accent-text);
    font-weight: 700; font-size: 16px;
}
.step-hint { margin: 6px 0 16px 44px; color: var(--text-muted); font-size: 15px; }
@media (max-width: 560px) { .step-hint { margin-left: 0; } }

/* ---------- Upload ---------- */
.dropzone {
    margin-top: 16px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 200px; padding: 24px; text-align: center;
    border: 2px dashed var(--border); border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer; transition: border-color .15s, background .15s, transform .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.drag { transform: scale(1.01); }
.dropzone:focus-within { box-shadow: var(--focus); border-color: var(--accent); }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.dz-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: var(--accent-text); margin-bottom: 6px; }
.dz-icon svg { width: 30px; height: 30px; stroke-width: 2.2; }
.dz-title { font-size: 20px; font-weight: 700; }
.dz-hint { color: var(--text-muted); font-size: 15px; }
@media (hover: none) { .only-pointer { display: none; } }

.file-card {
    margin-top: 16px;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
}
.file-icon { color: var(--ok); display: grid; }
.file-icon svg { width: 30px; height: 30px; }
.file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .muted { font-size: 14px; }
.btn-ghost {
    min-height: 44px; padding: 0 16px; border-radius: 999px; flex: none;
    border: 1px solid var(--border); background: var(--surface); font-size: 15px; font-weight: 600;
}
.btn-ghost:hover { border-color: var(--text-muted); }

.privacy { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 14px; color: var(--text-muted); }
.privacy svg { width: 18px; height: 18px; }
.error { margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--error-bg); color: var(--error-text); font-weight: 500; }

/* ---------- Auswahl-Kacheln ---------- */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.choice {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    min-height: 64px; padding: 12px 14px;
    border: 2px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); cursor: pointer; user-select: none;
    transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--text-muted); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check {
    display: grid; place-items: center; flex: none;
    width: 28px; height: 28px; border-radius: 8px;
    border: 2px solid var(--border); background: var(--surface);
    transition: background .12s, border-color .12s;
}
.check svg { width: 18px; height: 18px; stroke-width: 3; color: var(--accent-text); opacity: 0; }
.choice:has(input:checked) .check { background: var(--accent); border-color: var(--accent); }
.choice:has(input:checked) .check svg { opacity: 1; }
.choice-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.choice-text strong { font-size: 17px; }
.choice-text span { font-size: 14px; color: var(--text-muted); }

/* ---------- Vorschau ---------- */
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px 44px; }
.preview-bar .step-hint { margin: 0; }
@media (max-width: 560px) { .preview-bar { margin-left: 0; } }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button {
    min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent;
    font-size: 15px; font-weight: 600; color: var(--text-muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.plan { width: 100%; border-collapse: collapse; font-size: 15px; }
.plan th {
    position: sticky; top: 0;
    text-align: left; font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-muted); background: var(--surface-2);
    padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.plan td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.plan tbody tr:last-child td { border-bottom: 0; }
.plan tr.excluded td { opacity: .45; }
.plan tr.excluded .col-title strong { text-decoration: line-through; }
.plan tr.month td {
    background: var(--bg); font-weight: 700; font-size: 14px; color: var(--text-muted);
    padding-top: 14px; padding-bottom: 6px; opacity: 1;
}
.plan .col-date { white-space: nowrap; }
.plan .col-date .wd { color: var(--text-muted); font-size: 14px; }
.m-only { display: none; }
@media (max-width: 720px) { .d-only { display: none !important; } .m-only { display: initial; } }
.step.nudge { animation: nudge .5s ease; border-color: var(--accent); }
@keyframes nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.plan .col-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.plan .col-title strong { font-weight: 600; }
.plan .group-task { white-space: nowrap; }
.plan .group-task.mine { font-weight: 600; }
.cell-label { display: none; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-muted); }

.tag {
    display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 700; letter-spacing: .02em; vertical-align: 1px;
    background: var(--tag-x); color: var(--tag-x-text);
}
.tag.PA { background: var(--tag-pa); color: var(--tag-pa-text); }
.tag.DL { background: var(--tag-dl); color: var(--tag-dl-text); }
.tag.VS { background: var(--tag-vs); color: var(--tag-vs-text); }
.tag.warn { background: var(--warn-bg); color: var(--warn-text); }
.tag.off { background: transparent; border: 1px solid var(--border); color: var(--text-muted); font-weight: 600; }

/* Handy: Tabelle wird zu Karten */
@media (max-width: 720px) {
    .table-wrap { border: 0; overflow: visible; }
    table.plan, .plan tbody { display: block; }
    .plan thead { display: none; }
    .plan tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 14px; padding: 14px; margin-bottom: 10px;
        background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
    .plan tr.month { display: block; padding: 10px 2px 2px; margin: 0; background: transparent; border: 0; }
    .plan tr.month td { background: transparent; padding: 0; font-size: 15px; }
    .plan td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
    .plan tr.excluded { opacity: .5; }
    .plan tr.excluded td { opacity: 1; }
    .plan .col-date { grid-row: 1 / span 3; text-align: center; min-width: 52px; padding-right: 12px; border-right: 1px solid var(--border); }
    .plan .col-date { display: flex; flex-direction: column-reverse; justify-content: flex-end; }
    .plan .col-date .day { font-size: 24px; font-weight: 700; display: block; line-height: 1.1; }
    .plan .col-date .wd { font-size: 13px; display: block; }
    .plan td.col-extra.m-only, .plan span.m-only { display: block; }
    .plan span.m-only { display: inline; }
    .plan .col-time { grid-column: 2; color: var(--text-muted); font-size: 14px; white-space: normal; }
    .plan .col-title { grid-column: 2; grid-row: 1; font-size: 16px; }
    .plan .col-extra { grid-column: 2; font-size: 14px; color: var(--text-muted); }
    .plan .col-extra:empty { display: none; }
    .cell-label { display: inline; color: var(--text-muted); }
    .plan .group-task { white-space: normal; color: var(--text); }
}
@media (min-width: 721px) {
    .plan .col-date .day { font-weight: 600; }
}

/* ---------- Weitere Einstellungen ---------- */
details.more { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 8px; }
details.more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--text-muted); list-style: none; gap: 8px; }
details.more summary::before { content: "›"; font-size: 22px; line-height: 1; transition: transform .15s; }
details.more[open] summary::before { transform: rotate(90deg); }
details.more summary::-webkit-details-marker { display: none; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--border); flex: none; transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { box-shadow: var(--focus); }

/* ---------- Hilfe ---------- */
.help h2 { font-size: 17px; }
.help ol { margin: 10px 0; padding-left: 22px; }
.help li { margin: 6px 0; }
.help p { margin: 0; font-size: 15px; }

/* ---------- Aktionsleiste ---------- */
.actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--border);
}
.actionbar-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.action-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.action-text strong { font-size: 18px; }
.action-text .muted { font-size: 14px; }
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 56px; padding: 0 28px; border: 0; border-radius: 999px;
    background: var(--accent); color: var(--accent-text);
    font-size: 18px; font-weight: 700; flex: none;
    transition: background .12s, transform .08s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
@media (max-width: 420px) { .btn-primary { padding: 0 20px; } }

.toast {
    position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 30;
    width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; text-align: center;
    background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 480px) {
    .file-card { flex-wrap: wrap; }
    .file-meta { flex-basis: calc(100% - 50px); }
    .file-card .btn-ghost { width: 100%; }
}
