:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, .72);
    --sidebar: #ececf0;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --border: #e3e3e8;
    --accent: #7a1f2b;
    --accent-hover: #5f1721;
    --on-accent: #ffffff;
    --ok: #2f6b3a;
    --warn: #8a5a00;
    --error: #a12a2a;
    --teacher: #f2c500;
    --teacher-edge: #c49b00;
    --scrim: rgba(0, 0, 0, .45);
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
    --ease: cubic-bezier(.22, 1, .36, 1);
    color-scheme: light;
}

/* Dunkel: ausdrücklich gewählt (Schalter) oder, ohne Wahl, vom System */
:root[data-theme="dark"] {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-glass: rgba(28, 28, 30, .72);
    --sidebar: #141416;
    --text: #f5f5f7;
    --muted: #98989f;
    --border: #38383a;
    --accent: #d0707c;
    --accent-hover: #e08a95;
    --on-accent: #1a1112;
    --ok: #7cc48a;
    --warn: #e0b45a;
    --error: #ef8a8a;
    --teacher: #c9a227;
    --teacher-edge: #e6c24a;
    --scrim: rgba(0, 0, 0, .65);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-glass: rgba(28, 28, 30, .72);
    --sidebar: #141416;
        --text: #f5f5f7;
        --muted: #98989f;
        --border: #38383a;
        --accent: #d0707c;
        --accent-hover: #e08a95;
        --on-accent: #1a1112;
        --ok: #7cc48a;
        --warn: #e0b45a;
        --error: #ef8a8a;
        --teacher: #c9a227;
        --teacher-edge: #e6c24a;
        --scrim: rgba(0, 0, 0, .65);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    caret-color: var(--accent);
    transition: background-color .25s var(--ease), color .25s var(--ease);
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { text-underline-offset: .18em; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.022em; font-weight: 700; margin: 0 0 1.5rem; text-wrap: balance; }
h2 { font-size: 1.15rem; letter-spacing: -.012em; font-weight: 650; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

/* Formulare */
label { display: block; font-weight: 600; margin: 1rem 0 .3rem; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.field-error { color: var(--error); font-size: .9rem; margin: .3rem 0 0; }
input[aria-invalid=true] { border-color: var(--error); }

.btn {
    display: inline-block;
    margin-top: 1.25rem;
    padding: .55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--border); margin: 0; }
.btn-quiet:hover { color: var(--text); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Hinweise */
.alert { padding: .7rem .9rem; border-radius: var(--radius); border: 1px solid; margin: 0 0 1rem; }
.alert-error { color: var(--error); border-color: currentColor; }
.alert-warning { color: var(--warn); border-color: currentColor; }
.status-ok { color: var(--ok); font-weight: 600; }
.status-warn { color: var(--warn); font-weight: 600; }
.status-error { color: var(--error); font-weight: 600; }
.result-box { margin: .8rem 0; }
.result-box:empty { display: none; }
.result-box ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Anmeldung / Einrichtung */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.auth-card .btn { width: 100%; }

.content { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.4rem 1.6rem;
    margin-bottom: 1rem;
}
.card.narrow { max-width: 560px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Meldungen (Toasts) */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 10; }
.toast {
    padding: .7rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--ok);
    box-shadow: var(--shadow);
    max-width: 360px;
}
.toast-error { border-left-color: var(--error); }

/* Tabellen, Werkzeugleiste, Dialog */
.toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .btn { margin: 0; }
label.inline { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 400; }
label.inline select { width: auto; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .75rem 0 0; }
.small { font-size: .9rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table thead th { color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .01em; }
.table tbody th { font-weight: 600; }
.table tr.is-inactive { color: var(--muted); }
.table input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.actions-col { text-align: right !important; white-space: nowrap; }
.btn-small { margin: 0 0 0 .4rem; padding: .3rem .7rem; font-size: .9rem; background: transparent; border-color: var(--border); color: var(--text); }
.btn-small:hover { border-color: var(--accent); }
.btn-danger { color: var(--error); }
dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: 1.5rem; width: min(440px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; box-shadow: var(--shadow); }
dialog::backdrop { background: var(--scrim); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.dialog-actions .btn { margin: 0; }

/* Status-Marken */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.badge-ok { color: var(--ok); }
.badge-warn { color: var(--warn); }
.badge-muted { color: var(--muted); }

/* Einstellungen und Sperrzeiten */
.field-grid { display: grid; gap: 0 1.25rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.field-grid label { margin-top: .75rem; }
.field { min-width: 0; }
.field-grid + .muted, .field + .muted { margin-top: .4rem; }
input[type=time], input[type=date] {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
textarea[aria-invalid=true], select[aria-invalid=true] { border-color: var(--error); }
.card h2 + .muted { margin-top: 0; }
.inline-form { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 160px; }
.inline-form .btn { margin-top: 0; }
.inline-form label { margin-top: 0; }
details.past { margin-top: 1.5rem; }
details.past summary { cursor: pointer; font-weight: 600; margin-bottom: .75rem; }
.section-gap { margin-top: 1.75rem; }

/* Öffentliche Studenten-Seiten (Handy zuerst) */
body.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 1rem; background: var(--surface-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.public-content { width: 100%; max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 2rem; flex: 1; }
.public-content h1 { font-size: 1.6rem; margin-bottom: .75rem; }
.public-content h1 .muted, .public-content h2 .muted { font-weight: 400; }
.public-content .card { padding: 1rem; }
.public-foot { max-width: 760px; margin: 0 auto; padding: 0 1rem 1.5rem; }
.public-message { margin-top: 1rem; }
body.public select, body.public .btn, body.public .btn-small { min-height: 44px; }
body.public .btn-small { margin: 0; }
.day-list { display: grid; gap: .75rem; margin-top: .75rem; }
fieldset.day { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem .75rem; margin: 0; min-width: 0; }
fieldset.day legend { font-weight: 600; padding: 0 .3rem; }
fieldset.day.is-past { opacity: .65; padding-bottom: .25rem; }
fieldset.day.is-past p { margin: .2rem 0 0; }
.window-list { display: grid; gap: .5rem; }
.window-row { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .6rem; align-items: end; padding: .5rem 0; border-bottom: 1px dashed var(--border); }
.window-row .field:nth-child(3) { grid-column: 1 / -1; }
.window-row label { margin: 0 0 .2rem; font-size: .85rem; }
.window-row .btn-remove { grid-column: 1 / -1; justify-self: start; color: var(--error); }
.window-empty { margin: .3rem 0; }
.btn-add { margin-top: .5rem !important; }
.mode-options { display: grid; gap: .1rem; }
.mode-options label.check { margin: .2rem 0; min-height: 44px; align-items: center; }
.mode-options input[type=radio] { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); flex: none; }
.mode-hint { margin-left: .2rem; }
[role=radiogroup][aria-invalid=true] { outline: 2px solid var(--error); outline-offset: 2px; border-radius: var(--radius); }
.form-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.form-actions .btn { margin: 0; }
.form-status { color: var(--ok); font-weight: 600; }
.form-message { color: var(--error); font-weight: 600; margin: 1rem 0 0; }
select[aria-invalid=true] { border-color: var(--error); }
@media (min-width: 640px) {
    .window-row { grid-template-columns: 1fr 1fr 1.6fr auto; }
    .window-row .field:nth-child(3), .window-row .btn-remove { grid-column: auto; }
}

/* Verwaltung: Verfügbarkeits-Dialog */
dialog.wide { width: min(600px, calc(100vw - 2rem)); }
.availability-overview ul { margin: .3rem 0 .8rem; padding-left: 1.2rem; }
.link-box { display: flex; gap: .5rem; margin-top: .5rem; }
.link-box input { flex: 1; min-width: 0; }
.link-box .btn { margin: 0; white-space: nowrap; }

/* Mail-Vorlagen und Mail-Protokoll */
.type-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; }
.type-nav a { padding: .3rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; }
.type-nav a:hover { border-color: var(--accent); }
.type-nav a[aria-current=page] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
fieldset.lang-block { border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0 0; padding: .25rem 1rem 1rem; min-width: 0; }
fieldset.lang-block legend { font-weight: 700; padding: 0 .4rem; }
fieldset.lang-block textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; line-height: 1.5; resize: vertical; }
.placeholder-box { margin-top: 1.25rem; }
.placeholder-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .35rem; }
.placeholder-list li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.placeholder-list .chip { margin: 0; }
.mail-preview { display: block; width: 100%; height: 640px; border: 1px solid var(--border); border-radius: var(--radius); background: #f6f5f2; }
.badge-error { color: var(--error); }
.mail-error { color: var(--error); margin-top: .25rem; max-width: 36ch; overflow-wrap: anywhere; }
#mail-table td, #mail-table th { vertical-align: top; }
.btn-small.is-sending { opacity: .6; }
.invite-meta { margin: .5rem 0 0; }

/* Wochenabfrage: Antwortseiten der Studenten */
.alert-ok { color: var(--ok); border-color: currentColor; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.answer-now { margin: .25rem 0 0; }
.answer-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.answer-buttons .btn { margin: 0; flex: 1 1 200px; }
.answer-buttons .btn[aria-pressed=true] { outline: 2px solid var(--ok); outline-offset: 2px; }
fieldset.answer-choice { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.answer-choice legend { font-weight: 600; padding: 0; }
fieldset.answer-choice label.check { min-height: 44px; }
fieldset.answer-choice input[type=radio] { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); flex: none; }

/* Übersicht: Wochenabfrage und Hintergrundjobs */
.round-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.round-head h3 { margin: 0; font-size: 1.05rem; }
.round { margin-top: 1rem; }
.week-block { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.week-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.week-head h4 { margin: 0; font-size: 1rem; }
.counts { display: flex; flex-wrap: wrap; gap: .4rem; }
.response-table select { width: auto; min-width: 9rem; padding: .3rem .5rem; }
.response-table tr.is-missing th { color: var(--warn); }
.minutes-form { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.minutes-form label { margin: 0 0 .2rem; font-size: .9rem; }
.minutes-form input { width: 7rem; }
.minutes-form .btn { margin: 0; }
.start-form { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.start-form label { margin: 0 0 .3rem; }
.start-form select { width: auto; }
.start-form .btn { margin: 0; }
.preview-box { margin-top: 1rem; }
.preview-box:empty { display: none; }
.job-table td { vertical-align: top; }
.job-table .job-message { max-width: 60ch; overflow-wrap: anywhere; }

/* Planung: Wochenliste und Freigabe-Ansicht */
.week-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; }
.week-link { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.week-link:hover { border-color: var(--accent); }
.week-link-title { font-weight: 600; }
.plan-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-top: 1rem; }
.plan-tools .btn { margin: 0; }
.plan-tools .minutes-form { margin: 0; }
.conflict-card { border-color: var(--error); }
.unplaced-list, .excluded-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .75rem; }
.unplaced { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; }
.unplaced h3 { margin: 0; font-size: 1rem; }
.reasons { margin: .3rem 0 .5rem; padding-left: 1.2rem; }
.suggestions { padding-left: 1.2rem; }
.suggestions li { margin-bottom: .4rem; }
.small-heading { font-size: .95rem; margin: 1rem 0 .3rem; }
.item-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.item-actions .btn-small, .suggestions .btn-small, .excluded-list .btn-small { margin: 0; min-height: 36px; }
.day-plan { border-top: 1px solid var(--border); padding-top: .75rem; margin-top: .75rem; }
.day-plan h3 { font-size: 1rem; margin: 0 0 .4rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.timeline li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; padding: .45rem .7rem; border-radius: var(--radius); border-left: 4px solid var(--border); background: var(--bg); }
.timeline .tl-lesson { border-left-color: var(--ok); }
.timeline .tl-gap { border-left-color: var(--warn); color: var(--warn); font-size: .9rem; }
.timeline .tl-free { color: var(--muted); font-size: .9rem; border-left-style: dashed; }
dialog.calendar-dialog { width: min(1000px, calc(100vw - 2rem)); }
.free-times { margin: .75rem 0; }
.free-times .small-heading { margin: 0 0 .4rem; }
.slot-legend { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.slot-legend li { display: inline-flex; align-items: center; gap: .4rem; }
.slot-key { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; border: 1px solid var(--border); }
.slot-ok { background: color-mix(in srgb, var(--ok) 38%, transparent); border-color: var(--ok); }
.slot-teacher { background: color-mix(in srgb, var(--teacher) 50%, transparent); border-color: var(--teacher-edge); }
.slot-lesson { background: color-mix(in srgb, var(--muted) 30%, transparent); border-color: var(--muted); }
.slot-board { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.slot-grid { display: grid; grid-template-columns: 2.8rem repeat(7, minmax(4.5rem, 1fr)); min-width: 620px; background: var(--surface); }
.slot-dayhead { padding: .35rem .2rem; text-align: center; font-weight: 600; font-size: .85rem; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.slot-dayhead.is-today { color: var(--accent); }
.slot-dayhead.is-past { color: var(--muted); font-weight: 400; }
.slot-gutter { position: relative; }
.slot-gutter span { position: absolute; right: .25rem; transform: translateY(-.55em); font-size: .7rem; color: var(--muted); }
.slot-gutter span:first-child { transform: none; }
.slot-day {
    position: relative; border-left: 1px solid var(--border); cursor: crosshair; touch-action: manipulation;
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour-px) - 1px), var(--border) calc(var(--hour-px) - 1px), var(--border) var(--hour-px));
}
.slot-day.is-past { background-color: color-mix(in srgb, var(--muted) 10%, transparent); cursor: default; }
.slot-band, .slot-lesson, .slot-own, .slot-ghost, .slot-selected { position: absolute; left: 2px; right: 2px; box-sizing: border-box; border-radius: 4px; font-size: .7rem; overflow: hidden; }
.slot-band, .slot-lesson, .slot-own { pointer-events: none; }
.slot-band.slot-ok { background: color-mix(in srgb, var(--ok) 38%, transparent); border: 1px solid var(--ok); }
.slot-band.slot-teacher { background: color-mix(in srgb, var(--teacher) 50%, transparent); border: 1px solid var(--teacher-edge); }
.slot-band.is-short { opacity: .35; }
.slot-lesson { background: color-mix(in srgb, var(--muted) 30%, var(--surface)); border: 1px solid var(--muted); padding: .1rem .25rem; color: var(--text); }
.slot-own { border: 2px dashed var(--accent); padding: .1rem .25rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.slot-ghost { pointer-events: none; padding: .1rem .25rem; font-weight: 600; color: var(--text); border: 2px solid; z-index: 2; }
.slot-ghost.slot-ok { border-color: var(--ok); }
.slot-ghost.slot-teacher { border-color: var(--teacher-edge); }
.slot-selected { pointer-events: none; border: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); z-index: 3; }
.slot-ghost[hidden], .slot-selected[hidden] { display: none; }
.tl-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 6.5rem; }
.tl-name { font-weight: 600; }
.tl-tags { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.tl-lesson .item-actions { margin-left: auto; }
.excluded-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; }
.excluded-list label.check { margin: 0; }
.publish-preview { padding-left: 1.2rem; }
.feasibility p { margin: .4rem 0 0; }
#plan-root[aria-busy=true] { opacity: .6; }

/* Änderungen & Absagen (Schritt 11) */
.tl-note { flex-basis: 100%; color: var(--text); }
.cancellation-list, .reason-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .75rem; }
.cancellation { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; }
.cancellation-head { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; margin-bottom: .4rem; }
.cancellation-comment { overflow-wrap: anywhere; }
.btn-danger-solid { background: var(--error); color: var(--on-accent); }
.reason.is-inactive input[type=text] { color: var(--muted); }
.reason-flags { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
.reason-usage { margin: .5rem 0 0; }
.reason .form-actions .btn-small { margin: 0; min-height: 36px; }
.lesson-slot { margin: .25rem 0 0; }
.changes-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; }
.changes-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; }
/* Hinweise der Übersicht */
.hint-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; }
.hint { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; }
.hint-count { min-width: 2rem; text-align: center; }

/* Historie (Schritt 12) */
.history-filter { margin-bottom: 1rem; }
.history-filter .form-actions { margin-top: 1rem; }
.history-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin: 0 0 1rem; }
.history-stats .facts { grid-template-columns: max-content 1fr; }
.history-table td, .history-table th { vertical-align: top; }
.history-comment { overflow-wrap: anywhere; margin-top: .2rem; }
.history-reason { font-weight: 600; }
#history-results[aria-busy=true] { opacity: .6; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0 0; }
.pager a { padding: .4rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }

@media (max-width: 640px) {
    .history-table { font-size: .9rem; }
    .history-table th, .history-table td { padding: .5rem .6rem; }
    .content { padding: 1.25rem 1rem; }
    .card { padding: 1rem; }
    .tl-lesson .item-actions { margin-left: 0; width: 100%; }
    .timeline .btn-small, .item-actions .btn-small { min-height: 44px; }
}

/* „Mein Bereich“ (angemeldete Studenten): Tab-Leiste am Handy unten, ab 720 px unter dem Kopf */
.student-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.student-head .brand { flex: 1 1 auto; min-width: 0; }
.student-logout { margin: 0; flex: none; }
.student-logout .btn { margin: 0; min-height: 44px; padding: .3rem .7rem; font-size: .9rem; }
.student-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
@media (max-width: 480px) { .student-name { display: none; } }
.student-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; background: var(--surface-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.student-tabs a {
    flex: 1 1 0; min-width: 0; min-height: 56px; padding: .4rem .25rem;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; text-decoration: none; color: var(--muted); font-size: .85rem; line-height: 1.2;
    border-top: 3px solid transparent; overflow-wrap: anywhere; hyphens: auto;
}
.student-tabs a .tab-en { font-size: .72rem; opacity: .85; }
.student-tabs a[aria-current=page] { color: var(--accent); font-weight: 600; border-top-color: var(--accent); }
.student-tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
body.student .student-content { padding-bottom: 5.5rem; }
body.student .public-foot { padding-bottom: 5.5rem; }
.student-panel[hidden] { display: none; }
.student-panel + .student-panel { margin-top: 1.5rem; }
body.has-tabs .student-panel + .student-panel { margin-top: 0; }
@media (min-width: 720px) {
    .student-tabs { position: static; padding-bottom: 0; border-top: 0; border-bottom: 1px solid var(--border); justify-content: center; }
    .student-tabs a { flex: 0 1 11rem; border-top: 0; border-bottom: 3px solid transparent; }
    .student-tabs a[aria-current=page] { border-bottom-color: var(--accent); }
    body.student .student-content { padding-bottom: 2rem; }
    body.student .public-foot { padding-bottom: 1.5rem; }
}

/* „Mein Bereich“: Status */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#status-flash:empty { display: none; }
.week-card, .offer-card { margin-bottom: 1rem; }
.offer-card { border-left: 4px solid var(--accent); }
.week-card .stage { margin: .25rem 0; }
.week-card .lesson { margin: .75rem 0; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.week-card .lesson-slot { margin: 0 0 .5rem; }
.week-card .lesson p { margin: .25rem 0; }
.answer { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.answer .btn { margin: 0; flex: 1 1 12rem; }
.reason-list { border: 0; padding: 0; margin: 0; }
dialog textarea { width: 100%; }
body.student .dialog-actions .btn { flex: 1 1 11rem; }
.offer-card .form-actions .btn { flex: 1 1 14rem; }
@media (max-width: 480px) {
    .student-tabs a { padding: .4rem .1rem; font-size: .76rem; }
    .student-tabs a .tab-en { font-size: .68rem; }
}

/* „Mein Bereich“: Wochenplan und Meine Unterrichte */
.week-nav { display: flex; align-items: center; gap: .75rem; margin: 0 0 1rem; }
.week-nav .btn { margin: 0; min-width: 48px; min-height: 48px; font-size: 1.4rem; line-height: 1; }
.week-title { flex: 1 1 auto; text-align: center; display: flex; flex-direction: column; }
.week-title:focus { outline: none; }
.plan-day { margin-bottom: 1rem; }
.plan-day h2 { font-size: 1rem; }
.plan-list, .lesson-list { list-style: none; margin: 0; padding: 0; }
.plan-entry { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem .5rem; border-top: 1px solid var(--border); }
.plan-entry:first-child { border-top: 0; }
.plan-entry.is-own { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-radius: var(--radius); border-top-color: transparent; font-weight: 600; }
.plan-time { font-variant-numeric: tabular-nums; min-width: 6.5rem; }
.plan-name { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .5rem 0; }
.stat-grid > div { text-align: center; padding: .5rem .25rem; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-grid dt { font-size: .8rem; color: var(--muted); }
.stat-grid dd { margin: 0; font-size: 1.6rem; font-weight: 700; }
.lesson-row { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .75rem 0; border-top: 1px solid var(--border); }
.lesson-row:first-child { border-top: 0; }
.lesson-state { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; }
#lessons-more { margin-top: .75rem; width: 100%; }

/* Kalenderansicht (/admin/kalender): Wochenraster und Liste, nur Ansicht */
.cal-toolbar { display: grid; gap: .75rem; }
.cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cal-nav .btn, .cal-options .btn { margin: 0; padding: .4rem .8rem; }
.cal-title { margin-left: .5rem; font-size: 1.05rem; }
.cal-options { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.cal-check { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-weight: 600; }
.cal-check input { width: 1.1rem; height: 1.1rem; margin: 0; }
.cal-check::before { content: ""; width: .8rem; height: .8rem; border-radius: 3px; order: 1; }
.cal-check input { order: 0; }
.cal-check span { order: 2; }
.cal-check-availability::before { background: color-mix(in srgb, var(--ok) 45%, transparent); border: 1px solid var(--ok); }
.cal-check-students::before { background: var(--accent); }
.cal-views { display: inline-flex; gap: .25rem; }
.cal-views .btn[aria-pressed=true] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cal-status { margin: 0; font-size: .9rem; }
.cal-errors .alert { margin-bottom: .75rem; }
.cal-board { overflow-x: auto; }
.cal-board.is-stale { opacity: .6; }
.cal-board[aria-busy=true] { opacity: .75; }

.cal-grid {
    display: grid;
    grid-template-columns: 3.6rem repeat(7, minmax(0, 1fr));
    min-width: 680px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.cal-corner, .cal-gutter-label { border-bottom: 1px solid var(--border); }
.cal-gutter-label { font-size: .65rem; color: var(--muted); padding: .35rem .25rem; text-align: right; }
.cal-dayhead {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .25rem;
    padding: .5rem .25rem; font-weight: 600; font-size: .9rem; text-align: center;
    border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.cal-dayhead .badge { font-size: .7rem; padding: 0 .4rem; }
.cal-dayhead.is-today { color: var(--accent); }
.cal-allday {
    display: flex; flex-direction: column; gap: 2px; padding: .25rem; min-height: 1.9rem;
    border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.cal-chip { font-size: .75rem; padding: 0 .4rem; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip-availability { background: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--text); }
.cal-chip-students { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); }
.cal-gutter { position: relative; }
.cal-gutter span { position: absolute; right: .3rem; transform: translateY(-.55em); font-size: .7rem; color: var(--muted); }
.cal-gutter span:first-child { transform: none; }
.cal-day {
    position: relative; border-left: 1px solid var(--border);
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour-px) - 1px), var(--border) calc(var(--hour-px) - 1px), var(--border) var(--hour-px));
}
.cal-day.is-today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-day.is-blocked, .cal-dayhead.is-blocked { background-color: color-mix(in srgb, var(--muted) 12%, transparent); }
.cal-band {
    position: absolute; left: 0; right: 0; overflow: hidden; padding: .1rem .3rem;
    background: color-mix(in srgb, var(--ok) 28%, transparent); border-left: 3px solid var(--ok);
    font-size: .7rem; color: var(--muted);
}
.cal-event {
    position: absolute; overflow: hidden; padding: .15rem .35rem; border-radius: 6px;
    background: var(--accent); color: var(--on-accent); border: 1px solid var(--surface);
    font-size: .78rem; line-height: 1.25; display: flex; flex-direction: column;
}
.cal-event-time { font-weight: 700; }
.cal-event-title { overflow: hidden; text-overflow: ellipsis; }

.cal-agenda { display: grid; gap: .75rem; }
.cal-agenda-day { margin: 0; padding: 1rem 1.25rem; }
.cal-agenda-day h2 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cal-agenda-day.is-today h2 { color: var(--accent); }
.cal-items { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.cal-item { display: grid; grid-template-columns: 6.5rem 1fr; gap: .1rem .75rem; padding: .4rem .6rem; border-radius: var(--radius); border-left: 4px solid; }
.cal-item-availability { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.cal-item-students { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cal-item-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.cal-item-kind { grid-column: 2; font-size: .8rem; color: var(--muted); }

@media (max-width: 720px) {
    .cal-toolbar { padding: 1rem; }
    .cal-title { flex-basis: 100%; margin-left: 0; }
}

/* Hell/Dunkel-Schalter */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; flex: none; transition: color .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease); }
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.theme-toggle[hidden] { display: none; }
body.auth .theme-toggle { position: fixed; top: 1rem; right: 1rem; }
@media (prefers-reduced-motion: reduce) { body, .btn, .theme-toggle, .side-link, .tab-link { transition: none; } }

/* Verwaltung: Seitenleiste (ab 860 px) bzw. Tab-Leiste und „Mehr“-Blatt (darunter) */
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); }
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.shell .content { flex: 1 1 auto; min-width: 0; margin: 0; max-width: none; padding: 2.5rem 3rem; }
.shell .content > * { max-width: 1100px; }
.sidebar { flex: none; width: 256px; box-sizing: border-box; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: .25rem; padding: 1.25rem .75rem 1rem; background: var(--sidebar); border-right: 1px solid var(--border); }
.sidebar .brand { padding: .25rem .75rem 1.1rem; }
.navgroup { display: flex; flex-direction: column; gap: 2px; margin-top: .9rem; }
.navgroup:first-of-type { margin-top: 0; }
.navgroup-label { padding: 0 .75rem .25rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
.side-link { display: flex; align-items: center; gap: .65rem; min-height: 36px; padding: 0 .75rem; border-radius: 9px; color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 500; transition: background-color .2s var(--ease), color .2s var(--ease); }
.side-link svg { flex: none; color: var(--muted); }
.side-link:hover { background: color-mix(in srgb, var(--muted) 14%, transparent); }
.side-link[aria-current=page] { background: color-mix(in srgb, var(--accent) 11%, transparent); color: var(--accent); font-weight: 600; }
.side-link[aria-current=page] svg { color: var(--accent); }
.side-foot { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; }
.side-foot .logout { flex: 1; margin: 0; }
.side-foot .logout .btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .5rem .9rem; min-height: 44px; background: var(--surface); }

.mobilebar, .tabbar, .sheet, .sheet-scrim { display: none; }

@media (max-width: 859px) {
    .sidebar { display: none; }
    .shell .content { padding: 1.25rem 1rem 6rem; }
    .mobilebar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: .4rem 1rem; background: var(--surface-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--border); }
    .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; box-sizing: border-box; padding-bottom: env(safe-area-inset-bottom); background: var(--surface-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--border); }
    .tab-link { flex: 1 1 0; min-width: 0; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: .25rem 0; margin: 0; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .69rem; font-weight: 500; text-decoration: none; cursor: pointer; transition: color .2s var(--ease); }
    .tab-link[aria-current=page], .tab-link.is-active, .tab-link[aria-expanded=true] { color: var(--accent); font-weight: 600; }
    .sheet-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
    .sheet:not([hidden]) { display: flex; flex-direction: column; gap: .75rem; position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 50; box-sizing: border-box; max-height: calc(100dvh - 5rem); overflow-y: auto; padding: .6rem 1rem 1rem; background: var(--sidebar); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .18); }
    .sheet-grip { align-self: center; width: 36px; height: 5px; border-radius: 3px; background: var(--border); }
    .sheet-group { display: flex; flex-direction: column; gap: .35rem; }
    .sheet-label { padding: 0 .4rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
    .sheet-list { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
    .sheet-link { display: flex; align-items: center; gap: .75rem; min-height: 48px; padding: 0 .9rem; color: var(--text); text-decoration: none; }
    .sheet-link + .sheet-link { border-top: 1px solid var(--border); }
    .sheet-link span { flex: 1; }
    .sheet-link svg:first-child { color: var(--muted); }
    .sheet-link svg:last-child { color: var(--border); }
    .sheet-link[aria-current=page] { color: var(--accent); font-weight: 600; }
    .sheet-link[aria-current=page] svg:first-child { color: var(--accent); }
    .sheet-logout { margin: 0; }
    .sheet-logout .btn { width: 100%; margin: 0; min-height: 48px; border-radius: 14px; background: var(--surface); border-color: var(--border); color: var(--error); }
    .toasts { bottom: 5rem; }
    body.sheet-open { overflow: hidden; }
}

/* Handy: Bedienelemente der Verwaltung mit mindestens 44 px Berührungsfläche */
@media (max-width: 640px) {
    select, .btn-secondary, .chip { min-height: 44px; }
    :is(.content, .public-content) .btn.btn-small { min-height: 44px; }
    input[type=checkbox], .table input[type=checkbox] { width: 1.4rem; height: 1.4rem; }
}
