:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #1e2430;
    --muted: #6a7486;
    --border: #d7deea;
    --primary: #2558e0;
    --primary-soft: #e8efff;
    --danger: #c83737;
    --danger-soft: #fde9e9;
    --success: #1f8b4c;
    --success-soft: #e8f8ee;
    --warning: #b7791f;
    --warning-soft: #fff5e6;
    --shadow: 0 12px 30px rgba(27, 44, 94, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0 0 0.6rem;
}

p {
    margin: 0 0 1rem;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #f1f4fa;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    font-size: 1.2rem;
    font-weight: 800;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-pill {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.8rem;
    background: var(--primary-soft);
    border-radius: 12px;
    font-size: 0.9rem;
}

.shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 82px);
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 1rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-link {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text);
    font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary);
    text-decoration: none;
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    font-weight: 800;
}

.link-button:hover {
    text-decoration: underline;
}

.content {
    padding: 1.5rem;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.form-panel {
    min-width: 0;
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-wrapper.wide {
    align-items: flex-start;
}

.auth-panel {
    width: min(460px, 100%);
}

.auth-panel.wide {
    width: min(840px, 100%);
}

/* Gast-Anmeldung (ohne Topbar): ruhiger Hintergrund, klare Karte */
body.auth-page {
    background:
        radial-gradient(1100px 520px at 10% -8%, rgba(37, 88, 224, 0.12), transparent 52%),
        radial-gradient(800px 420px at 92% 108%, rgba(37, 88, 224, 0.07), transparent 50%),
        var(--bg);
}

body.auth-page .auth-wrapper {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: clamp(1.25rem, 5vw, 2.75rem);
}

body.auth-page .auth-wrapper > .flash {
    width: min(420px, 100%);
    margin-bottom: 0;
}

body.auth-page .auth-login-card {
    position: relative;
    overflow: hidden;
    padding: clamp(1.4rem, 4vw, 2rem) clamp(1.2rem, 4vw, 1.85rem);
    margin-bottom: 0;
    border-radius: calc(var(--radius) + 2px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.65) inset,
        0 22px 48px rgba(27, 44, 94, 0.1),
        var(--shadow);
}

body.auth-page .auth-login-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #5b8cff);
}

body.auth-page .auth-login-app {
    margin: 0 0 0.4rem;
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--primary);
    line-height: 1.2;
}

body.auth-page .auth-login-heading {
    margin: 0 0 0.55rem;
    font-size: clamp(1.45rem, 4vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text);
}

body.auth-page .auth-login-lead {
    margin: 0 0 1.35rem;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 36em;
}

body.auth-page .auth-login-form {
    gap: 1rem;
}

body.auth-page .auth-login-form label span {
    font-size: 0.9rem;
}

body.auth-page .auth-login-form input[type="text"],
body.auth-page .auth-login-form input[type="password"] {
    padding: 0.82rem 1rem;
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.auth-page .auth-login-form input[type="text"]:focus,
body.auth-page .auth-login-form input[type="password"]:focus {
    outline: none;
    border-color: rgba(37, 88, 224, 0.45);
    box-shadow: 0 0 0 3px rgba(37, 88, 224, 0.18);
}

body.auth-page .auth-login-submit {
    width: 100%;
    margin-top: 0.15rem;
    padding: 0.82rem 1rem;
    font-size: 1rem;
    font-weight: 600;
}

body.auth-page .auth-login-footer {
    margin: 1.4rem 0 0;
    padding-top: 1.05rem;
    border-top: 1px solid var(--border);
    line-height: 1.45;
}

body.auth-page .auth-login-footer a {
    font-weight: 600;
    text-underline-offset: 0.12em;
}

@media (max-width: 420px) {
    body.auth-page .auth-login-card {
        padding: 1.25rem 1.1rem;
    }
}

.narrow {
    max-width: 520px;
}

.grid-two,
.grid-three,
.panel-split,
.teacher-selection-layout,
.teacher-assignment-layout,
.planner-layout {
    display: grid;
    gap: 1rem;
}

.grid-two,
.panel-split,
.teacher-selection-layout,
.planner-layout {
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
}

.grid-three {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.teacher-assignment-layout {
    grid-template-columns: minmax(240px, 280px) 1fr;
    gap: 0.65rem;
    align-items: start;
    /* Topbar klebt bei 0; Lehrer-Zuteilungs-Leiste bei 84px — Raster/Pool darunter einrasten */
    --teacher-assign-sticky-top: calc(84px + 6.25rem);
    --teacher-assign-panel-max: max(13rem, calc(100vh - var(--teacher-assign-sticky-top) - 1.25rem));
}

/* Lehrer-Zuteilung: Pool + Wochenraster */
.teacher-assign-toolbar .teacher-assign-toolbar-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.65rem 1rem;
}

.teacher-assign-hint {
    margin: 0;
    max-width: 32rem;
    line-height: 1.35;
}

.teacher-assign-chip-row {
    margin-top: 0.55rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
}

.teacher-assign-print-row {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.75rem;
}

.teacher-assign-filter-chips {
    margin-top: 0.45rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.65rem;
}

.teacher-choose-toolbar-chips {
    margin-top: 0.35rem;
}

.teacher-choose-toolbar-legend {
    margin: 0 0 0.35rem;
}

.teacher-choose-selection-closed {
    margin-top: 0.35rem;
}

.teacher-choose-toolbar-fold.planner-fold,
.teacher-timetable-toolbar-fold.planner-fold {
    margin-top: 0;
    border: 0;
    background: transparent;
}

.teacher-choose-toolbar-fold .planner-fold__body,
.teacher-timetable-toolbar-fold .planner-fold__body {
    padding-top: 0.4rem;
    margin-top: 0.35rem;
    border-radius: 0 0 8px 8px;
}

.teacher-choose-toolbar-fold__heading,
.teacher-timetable-toolbar-fold__heading {
    font-size: 1.08rem;
    font-weight: 700;
}

.teacher-selection-layout--selection-closed .teacher-choose-pool-panel {
    opacity: 0.72;
}

.teacher-selection-layout--selection-closed .teacher-choose-pool-panel .inline-form .button {
    pointer-events: none;
    opacity: 0.55;
}

.teacher-dashboard-legend {
    margin: 0 0 0.65rem;
    max-width: 42rem;
    line-height: 1.4;
}

.teacher-dashboard-metrics .metric-card.metric-ok {
    border-color: #9dcea8;
    background: #f4fbf5;
}

.teacher-dashboard-metrics .metric-card.metric-warn {
    border-color: #e4ab56;
    background: var(--warning-soft);
}

.teacher-dashboard-hint {
    margin: 0.5rem 0 0;
    max-width: 28rem;
}

.teacher-dashboard-actions .chip-link--action {
    font-weight: 600;
}

.chip-link.chip-link--muted {
    opacity: 0.68;
}

.teacher-choose-selection-scope {
    margin: 0 0 0.45rem;
}

.teacher-choose-result-dialog {
    border: none;
    padding: 0;
    border-radius: calc(var(--radius) + 4px);
    max-width: min(26rem, calc(100vw - 2rem));
    box-shadow: 0 24px 60px rgba(27, 44, 94, 0.18), var(--shadow);
    background: var(--panel);
    color: var(--text);
}

.teacher-choose-result-dialog::backdrop {
    background: rgba(30, 36, 48, 0.42);
    backdrop-filter: blur(2px);
}

.teacher-choose-result-dialog__inner {
    padding: 1.35rem 1.45rem 1.5rem;
}

.teacher-choose-result-dialog__title {
    margin: 0 0 0.65rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.teacher-choose-result-dialog__message {
    margin: 0 0 1.25rem;
    font-size: 1.02rem;
    line-height: 1.45;
}

.teacher-choose-result-dialog__close {
    width: 100%;
}

/* ——— Lehrkräfte: einheitliches Layout (nicht Admin-kompakt), touch-freundlich ——— */
.teacher-app .content {
    padding: clamp(1rem, 2.5vw, 1.65rem);
}

.teacher-app .page-head {
    flex-wrap: wrap;
    gap: 0.65rem;
}

.teacher-app .page-head h1 {
    font-size: clamp(1.2rem, 2.6vw, 1.65rem);
    line-height: 1.2;
}

.teacher-app .panel,
.teacher-app .sticky-toolbar.panel {
    border-radius: 14px;
}

.teacher-app .teacher-app-chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.85rem;
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
}

.teacher-app .teacher-choose-toolbar-fold__body .teacher-app-chip-row {
    margin-top: 0.35rem;
    padding-top: 0.2rem;
    border-top: 0;
}

.teacher-app .chip-list--compact {
    gap: 0.5rem;
}

.teacher-app .chip-list--compact .chip-link {
    padding: 0.55rem 1.05rem;
    font-size: 0.95rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.teacher-app .planner-grid.planner-grid--teacher.phase-sized-rows {
    --phase-size-base: clamp(1.08rem, 2.2vw, 1.52rem);
}

.teacher-app .planner-grid.planner-grid--teacher .phase-head {
    width: 6.75rem;
    min-width: 6.75rem;
    max-width: 6.75rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
    line-height: 1.3;
}

.teacher-app .planner-grid.planner-grid--teacher .phase-head-stunde {
    font-size: 0.88rem;
}

.teacher-app .planner-grid.planner-grid--teacher .phase-head-stunde-time {
    margin-top: 0.08rem;
    font-size: 0.75rem;
}

.teacher-app .planner-grid.planner-grid--teacher thead th {
    padding: 0.45rem 0.55rem;
    font-size: 0.9rem;
}

.teacher-app .planner-grid.planner-grid--teacher .teacher-timetable-slot {
    padding: 0.48rem 0.58rem;
    gap: 0.12rem;
    border-radius: 10px;
}

.teacher-app .planner-grid.planner-grid--teacher .teacher-timetable-slot strong {
    font-size: 0.98rem;
    line-height: 1.2;
}

.teacher-app .planner-grid.planner-grid--teacher .teacher-timetable-slot span {
    font-size: 0.86rem;
    line-height: 1.32;
}

.teacher-app .planner-grid.planner-grid--teacher .pause-scope-details--inline summary {
    font-size: 0.82rem;
}

.teacher-app .planner-grid.planner-grid--teacher .warning-text {
    font-size: 0.82rem;
}

.teacher-app .planner-grid.planner-grid--teacher.phase-sized-rows tbody tr.phase-sized-row > td.scheduled-cell {
    padding: 0.32rem 0.42rem;
    vertical-align: top;
}

.teacher-app .planner-grid.planner-grid--teacher .scheduled-cell .teacher-timetable-slot {
    box-sizing: border-box;
    min-height: 100%;
}

.teacher-app .slot-chip,
.teacher-app .assigned-slot-chip {
    padding: 0.72rem 0.88rem;
    gap: 0.32rem;
    border-radius: 12px;
}

.teacher-app .slot-chip strong,
.teacher-app .assigned-slot-chip strong {
    font-size: 1.02rem;
    line-height: 1.2;
}

.teacher-app .slot-chip span,
.teacher-app .assigned-slot-chip span {
    font-size: 0.9rem;
    line-height: 1.35;
}

.teacher-app .slot-chip .button,
.teacher-app .assigned-slot-chip .button,
.teacher-app .slot-chip .button-small,
.teacher-app .assigned-slot-chip .button-small {
    min-height: 2.5rem;
    padding: 0.42rem 0.9rem;
    font-size: 0.9rem;
}

.teacher-app .teacher-choose-toolbar-fold__heading,
.teacher-app .teacher-timetable-toolbar-fold__heading {
    font-size: 1.2rem;
}

.teacher-app .teacher-choose-toolbar-fold .planner-fold__summary,
.teacher-app .teacher-timetable-toolbar-fold .planner-fold__summary {
    min-height: 2.75rem;
    padding: 0.55rem 0.75rem;
    align-items: center;
}

.teacher-app .teacher-choose-toolbar-fold .planner-fold__meta,
.teacher-app .teacher-timetable-toolbar-fold .planner-fold__meta {
    font-size: 0.9rem;
}

.teacher-app .teacher-dashboard-metrics {
    gap: 1rem;
}

.teacher-app .metric-card span {
    font-size: 0.88rem;
}

.teacher-app .metric-card strong {
    font-size: 1.32rem;
}

.teacher-app .sidebar nav {
    gap: 0.45rem;
}

.teacher-app .nav-link {
    padding: 0.95rem 1.05rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
}

@media (max-width: 960px) {
    .teacher-app .teacher-selection-layout {
        grid-template-columns: 1fr !important;
        gap: 1.1rem;
    }
}

@media (max-width: 720px) {
    .teacher-app .planner-grid {
        /* allow dense timetable on phones; still scrollable if needed */
        min-width: 460px;
    }

    .teacher-app .planner-grid-wrap {
        /* use full width on mobile so horizontal scroll feels natural */
        margin-left: -0.65rem;
        margin-right: -0.65rem;
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .teacher-app .teacher-choose-toolbar-fold .planner-fold__summary,
    .teacher-app .teacher-timetable-toolbar-fold .planner-fold__summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .teacher-app .teacher-choose-toolbar-fold .planner-fold__meta,
    .teacher-app .teacher-timetable-toolbar-fold .planner-fold__meta {
        text-align: left;
        width: 100%;
        max-width: none;
    }

    .teacher-app .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .teacher-app .topbar-actions {
        justify-content: flex-start;
    }

    /* Teacher timetable on phones: keep grid, but make it much denser */
    .teacher-app .timetable-mobile {
        display: none !important;
    }

    .teacher-app .planner-grid.planner-grid--teacher.phase-sized-rows {
        --phase-size-base: clamp(0.86rem, 1.9vw, 1.05rem);
    }

    .teacher-app .planner-grid.planner-grid--teacher .phase-head {
        width: 5.1rem;
        min-width: 5.1rem;
        max-width: 5.1rem;
        padding: 0.25rem 0.35rem;
        font-size: 0.72rem;
        line-height: 1.2;
    }

    .teacher-app .planner-grid.planner-grid--teacher thead th {
        padding: 0.3rem 0.35rem;
        font-size: 0.78rem;
    }

    .teacher-app .planner-grid.planner-grid--teacher.phase-sized-rows tbody tr.phase-sized-row > td.scheduled-cell {
        padding: 0.18rem 0.22rem;
    }

    .teacher-app .planner-grid.planner-grid--teacher .teacher-timetable-slot {
        padding: 0.32rem 0.35rem;
        border-radius: 9px;
    }

    .teacher-app .planner-grid.planner-grid--teacher .teacher-timetable-slot strong {
        font-size: 0.86rem;
        line-height: 1.15;
    }

    .teacher-app .planner-grid.planner-grid--teacher .teacher-timetable-slot span {
        font-size: 0.74rem;
        line-height: 1.2;
    }

    .teacher-app .planner-grid.planner-grid--teacher .pause-scope-details--inline summary {
        font-size: 0.74rem;
    }
}

/* Default: hide mobile list on desktop */
.timetable-mobile {
    display: none;
}

.teacher-assign-toolbar-fold.planner-fold {
    margin-top: 0;
    border: 0;
    background: transparent;
}

.teacher-assign-toolbar-fold .planner-fold__body {
    padding-top: 0.4rem;
    margin-top: 0.35rem;
    border-radius: 0 0 8px 8px;
}

.teacher-assign-toolbar-fold__heading {
    font-size: 1.08rem;
    font-weight: 700;
}

/* Eingeklappte Leiste: weniger Abstand für Sticky-Pool/Raster */
body:has(.teacher-assign-workspace):has(.teacher-assign-toolbar-fold:not([open])) .teacher-assignment-layout {
    --teacher-assign-sticky-top: calc(84px + 3.35rem);
}

.teacher-assign-raster-panel .teacher-assign-raster-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.55rem;
    flex-shrink: 0;
}

/* Lehrer-Zuteilung: linke Liste + rechtes Raster beim Scrollen nutzbar halten */
.teacher-assignment-layout .teacher-assign-pool-panel {
    position: sticky;
    top: var(--teacher-assign-sticky-top);
    align-self: start;
    max-height: var(--teacher-assign-panel-max);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.teacher-assignment-layout .teacher-assign-pool-panel #teacher-slot-pool {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.teacher-assignment-layout .teacher-assign-raster-panel {
    position: sticky;
    top: var(--teacher-assign-sticky-top);
    align-self: start;
    max-height: var(--teacher-assign-panel-max);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    z-index: 4;
}

.teacher-assignment-layout .teacher-assign-raster-body-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Vertikales Scrollen nur im gemeinsamen Raster-Bereich; waagerecht weiter im Tabellen-Wrapper */
.teacher-assignment-layout .teacher-assign-raster-body-scroll .planner-grid-wrap {
    overflow-x: auto;
    overflow-y: visible;
}

/* Lehrer-Zuteilung: Karten nutzen die Monitorhöhe, Seite scrollt nur oben; Inhalt in den Panels scrollt */
body:has(.teacher-assign-workspace) .shell {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: calc(100dvh - 82px);
}

body:has(.teacher-assign-workspace) .sidebar {
    flex: 0 0 260px;
}

body:has(.teacher-assign-workspace) .content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body:has(.teacher-assign-workspace) .content .page-head,
body:has(.teacher-assign-workspace) .content .flash,
body:has(.teacher-assign-workspace) .teacher-assign-toolbar {
    flex-shrink: 0;
}

.teacher-assign-workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.teacher-assign-workspace .teacher-assignment-layout {
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

@media (min-width: 1101px) {
    .teacher-assign-workspace .teacher-assignment-layout {
        grid-template-rows: minmax(0, 1fr);
    }
}

.teacher-assign-workspace .teacher-assign-pool-panel,
.teacher-assign-workspace .teacher-assign-raster-panel {
    max-height: none;
    min-height: 0;
    align-self: stretch;
    margin-bottom: 0;
}

.teacher-assign-workspace .teacher-assign-pool-panel > h2 {
    flex-shrink: 0;
}

.teacher-assign-raster-header h2 {
    margin: 0 0 0.12rem;
    font-size: 0.98rem;
}

.teacher-assign-points {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.teacher-assign-assign-hint {
    flex: 1 1 11rem;
    max-width: 18rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.55rem;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #f8fafc;
}

.teacher-assign-assign-hint strong {
    display: block;
    margin-bottom: 0.08rem;
    font-size: 0.88rem;
}

.teacher-assign-assign-hint .muted.small {
    font-size: 0.72rem;
    line-height: 1.25;
}

.teacher-assign-pool-hint {
    margin: 0 0 0.45rem;
}

.teacher-assignment-layout .slot-chip.slot-chip--assign-click {
    cursor: pointer;
    user-select: none;
}

.teacher-assign-dialog {
    width: min(22rem, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.teacher-assign-dialog::backdrop {
    background: rgba(15, 23, 42, 0.35);
}

.teacher-assign-dialog form {
    padding: 1rem 1.1rem 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.teacher-assign-dialog-title {
    margin: 0;
    font-size: 1.05rem;
}

.teacher-assign-dialog-slot {
    margin: 0;
    line-height: 1.35;
}

.teacher-assign-dialog-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.teacher-assign-dialog-select {
    width: 100%;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

.teacher-assign-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.35rem;
}

.teacher-assign-unscheduled {
    margin-bottom: 0.85rem;
}

.teacher-assign-subheading {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
}

/* Lehrer-Zuteilung: dichtere Darstellung (nur diese Seite) */
.teacher-assignment-layout .slot-pool {
    gap: 0.4rem;
    min-height: 72px;
}

.teacher-assignment-layout .slot-pool-secondary {
    padding: 0.45rem;
    border-radius: 9px;
}

.teacher-assignment-layout .slot-chip,
.teacher-assignment-layout .assigned-slot-chip,
.teacher-assignment-layout .teacher-timetable-slot {
    padding: 0.38rem 0.48rem;
    border-radius: 9px;
    gap: 0.1rem;
}

.teacher-assignment-layout .slot-chip strong,
.teacher-assignment-layout .assigned-slot-chip strong,
.teacher-assignment-layout .teacher-timetable-slot strong {
    font-size: 0.84rem;
    line-height: 1.2;
}

.teacher-assignment-layout .slot-chip span,
.teacher-assignment-layout .assigned-slot-chip span,
.teacher-assignment-layout .teacher-timetable-slot span {
    font-size: 0.72rem;
    line-height: 1.25;
}

.teacher-assignment-layout .slot-chip .small,
.teacher-assignment-layout .assigned-slot-chip .small,
.teacher-assignment-layout .teacher-timetable-slot .small {
    font-size: 0.68rem;
}

.teacher-assignment-layout .slot-chip.slot-chip--assigned-this-teacher {
    border-color: #e4ab56;
    background: var(--warning-soft);
}

.teacher-assignment-layout .slot-chip.full.slot-chip--assigned-this-teacher {
    background: #f5ead4;
    border-color: #d9a24e;
}

.teacher-assignment-layout .slot-chip-teacher-hint {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--warning);
    margin-top: 0.08rem;
}

.teacher-assignment-layout [data-dnd-item][draggable="true"] {
    user-select: none;
    -webkit-user-drag: element;
}

.teacher-assignment-layout .slot-chip.slot-chip--assign-click:focus-visible {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 2px;
}

.teacher-assignment-layout form.inline-form,
.teacher-assignment-layout form.inline-form button {
    -webkit-user-drag: none;
}

.teacher-assignment-layout section.panel > h2 {
    font-size: 0.95rem;
    margin: 0 0 0.45rem;
}

.teacher-assignment-layout .pause-scope-details--inline summary {
    font-size: 0.72rem;
}

.teacher-assignment-layout .button-small {
    padding: 0.15rem 0.45rem;
    font-size: 0.72rem;
}

.planner-layout {
    grid-template-columns: 360px 1fr;
}

.grid-two.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-column-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

select[multiple] {
    min-height: 14rem;
}

textarea {
    resize: vertical;
}

.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 0.65rem;
    font-weight: 500;
}

.checkbox-row input {
    width: auto;
}

.checkbox-fieldset {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 1rem 1rem;
    margin: 0 0 1rem;
}

.checkbox-fieldset legend {
    padding: 0 0.35rem;
    font-weight: 600;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 0.35rem 0.75rem;
    margin-top: 0.35rem;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 12px;
    padding: 0.65rem 0.95rem;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.button:hover,
button:hover {
    text-decoration: none;
    filter: brightness(0.98);
}

.button-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.button-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.button-light {
    background: #fff;
}

.button-small {
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.button-row,
.button-list,
.filter-row,
.toolbar-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.slots-filter-form {
    margin-bottom: 1rem;
}

.filter-search-label {
    flex: 1 1 220px;
    min-width: 180px;
    margin: 0;
    font-weight: 600;
    position: relative;
}

.filter-search-label .filter-search {
    width: 100%;
    margin-top: 0.25rem;
    padding-right: 2rem;
}

.filter-search-label .filter-search-clear {
    position: absolute;
    right: 0.35rem;
    bottom: 0.35rem;
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.filter-search-label .filter-search-clear:hover {
    color: var(--text);
    background: #f3f5f9;
}

.button-list.vertical {
    flex-direction: column;
    align-items: stretch;
}

.inline-form {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0;
}

.hidden-form {
    display: none;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.88rem;
}

.tiny {
    font-size: 0.75rem;
}

.flash {
    border-radius: 14px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success-soft);
    border-color: #cdeed8;
    color: var(--success);
}

.flash-error {
    background: var(--danger-soft);
    border-color: #f7c8c8;
    color: var(--danger);
}

.flash-warning {
    background: var(--warning-soft);
    border-color: #f4deaa;
    color: var(--warning);
}

.info-box {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8faff;
    padding: 0.85rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: var(--shadow);
}

.metric-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.metric-card strong {
    font-size: 1.5rem;
}

.metric-ok {
    border-color: #b9e7ca;
    background: var(--success-soft);
}

.metric-warn {
    border-color: #f2cf9c;
    background: var(--warning-soft);
}

.meta-list {
    display: grid;
    gap: 0.5rem;
}

.meta-list div {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 0.5rem;
    align-items: baseline;
}

.meta-list dt {
    font-weight: 700;
}

.meta-list dd {
    margin: 0;
}

.slots-group {
    margin-bottom: 1.1rem;
}

.slots-group:last-child {
    margin-bottom: 0;
}

.slots-group-heading {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.65rem;
}

.slots-group-heading .muted {
    font-weight: 500;
}

.slot-aggregate-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.35rem;
    padding: 0.08rem 0.4rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    background: #e4e9f2;
    color: #4a5568;
    vertical-align: middle;
}

.slot-bucket-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 12rem;
}

.slot-bucket-actions__line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px dashed var(--border);
}

.slot-bucket-actions__line:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.slot-bucket-actions__form {
    display: inline-flex;
    margin: 0;
}

.pause-scope-details summary {
    cursor: pointer;
    list-style-position: outside;
}

.pause-scope-details--inline {
    margin-top: 0.25rem;
}

.pause-scope-details--inline summary {
    font-size: 0.8rem;
    color: var(--muted);
}

.pause-scope-list {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
}

.slot-chip--pause,
.slot-card--pause-supervision,
.teacher-timetable-slot--pause {
    border-left: 3px solid #8b95a8;
}

.table-wrap {
    overflow: auto;
}

.table-wrap.large table {
    min-width: 860px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

th {
    background: #fafcff;
    position: sticky;
    top: 0;
    z-index: 1;
}

tr.is-current {
    background: #f8fbff;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: #eef2f8;
    color: var(--muted);
    margin-right: 0.3rem;
    margin-top: 0.2rem;
}

.status-pill.success {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.neutral {
    background: #eef2f8;
    color: var(--muted);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.chip-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-weight: 600;
}

.chip-link span {
    color: var(--muted);
    font-size: 0.85rem;
}

.chip-link.active,
.chip-link:hover {
    background: var(--primary-soft);
    color: var(--primary);
    text-decoration: none;
    border-color: #b9cbff;
}

.chip-choice {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    background: #fff;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.chip-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip-choice:has(input:checked) {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: #b9cbff;
}

.chip-choice span {
    font-size: 0.9rem;
}

.sticky-toolbar {
    position: sticky;
    top: 84px;
    z-index: 15;
}

.slot-pool,
.assigned-slot-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    min-height: 120px;
}

/* Wochenraster: Slot-Pool (nicht platziert) als Grid, nicht nur Liste */
.planner-class-fold-body .slot-pool.drop-zone {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-content: start;
    gap: 0.7rem;
}

.planner-class-fold-body .slot-pool.drop-zone > p {
    grid-column: 1 / -1;
}

.planner-pool-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.planner-pool-section .pool-section-title {
    margin: 0 0 0.15rem;
    font-size: 1rem;
}

.planner-pool-section .pool-section-sub {
    margin: 0 0 0.5rem;
}

.slot-pool-secondary {
    background: #f8f9fc;
    border-radius: 12px;
    padding: 0.65rem;
    border: 1px dashed var(--border);
}

.pool-filter-form {
    margin-bottom: 0.25rem;
}

.planner-weekdays-panel {
    margin-bottom: 1rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.planner-toolbar-panel {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.planner-toolbar-main {
    align-items: flex-end;
    margin-bottom: 0;
}

.planner-toolbar-print-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin-bottom: 0.55rem;
}

.planner-toolbar-print-year {
    flex: 1 1 12rem;
    min-width: 0;
}

.planner-toolbar-print-all {
    flex: 0 0 auto;
}

.planner-chips-row {
    margin-top: 0.15rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
}

.planner-class-chip-form {
    margin: 0;
}

.planner-chip-fieldset--bare {
    border: 0;
    padding: 0;
    margin: 0.35rem 0 0;
    min-width: 0;
}

.chip-toggle {
    position: relative;
    cursor: pointer;
    margin: 0;
}

.chip-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.chip-toggle-face {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.45rem;
    padding: 0.42rem 0.72rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.25;
}

.chip-toggle-name {
    font-weight: 600;
}

.chip-toggle-meta {
    font-weight: 500;
    color: var(--muted);
    font-size: 0.78rem;
}

.chip-toggle input:checked + .chip-toggle-face {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: #b9cbff;
}

.chip-toggle input:focus-visible + .chip-toggle-face {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.planner-inline-label {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.chip-list--compact {
    gap: 0.35rem;
}

.chip-list--compact .chip-link {
    padding: 0.42rem 0.72rem;
    font-size: 0.88rem;
}

.button-list--compact {
    gap: 0.45rem;
}

.planner-class-picker {
    margin-top: 0;
}

.planner-fold {
    margin-top: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafbff;
}

.planner-fold--weekdays {
    margin-top: 0;
}

.planner-fold__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    padding: 0.42rem 0.65rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    list-style: none;
}

.planner-fold__summary::-webkit-details-marker {
    display: none;
}

.planner-fold__title::before {
    content: '';
    display: inline-block;
    width: 0.35em;
    height: 0.35em;
    margin-right: 0.35em;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    vertical-align: 0.12em;
    transition: transform 0.12s ease;
}

.planner-fold[open] > .planner-fold__summary .planner-fold__title::before {
    transform: rotate(45deg);
    vertical-align: 0.08em;
}

.planner-fold__meta {
    font-weight: 500;
    color: var(--muted);
    font-size: 0.85rem;
    max-width: 100%;
    text-align: right;
}

.planner-fold__body {
    padding: 0 0.65rem 0.55rem;
    border-top: 1px solid var(--border);
    background: #fff;
}

.planner-fold__hint {
    margin: 0.5rem 0 0.35rem;
    line-height: 1.35;
}

.planner-compact-fieldset {
    position: relative;
    padding: 0.5rem 0.65rem 0.55rem;
    margin: 0.45rem 0 0.35rem;
}

.planner-fold .planner-compact-fieldset {
    margin-top: 0.35rem;
}

.checkbox-grid--compact {
    grid-template-columns: repeat(auto-fill, minmax(7.25rem, 1fr));
    gap: 0.15rem 0.45rem;
    margin-top: 0.15rem;
}

.checkbox-row--compact {
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.button-row--tight {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

.planner-sr-legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.planner-class-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 0.35rem;
}

.planner-class-heading h2 {
    margin: 0;
    font-size: 1.15rem;
}

.planner-class-block,
.planner-class-fold {
    scroll-margin-top: 4.5rem;
}

.planner-class-fold {
    overflow: hidden;
}

.planner-class-fold > summary {
    list-style: none;
    cursor: pointer;
}

.planner-class-fold > summary::-webkit-details-marker {
    display: none;
}

.planner-class-fold-summary {
    padding: 0;
}

.planner-class-fold-body {
    padding-top: 0.25rem;
}

.planner-subheading {
    margin: 1rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.planner-class-block > .planner-subheading:first-of-type {
    margin-top: 0.75rem;
}

.pool-mode-fieldset {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.85rem 0.85rem;
    margin: 0 0 0.75rem;
}

.pool-mode-fieldset legend {
    padding: 0 0.35rem;
    font-weight: 600;
}

.slot-chip-readonly {
    opacity: 0.72;
    cursor: not-allowed;
}

.slot-chip,
.assigned-slot-chip,
.slot-card,
.teacher-timetable-slot {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.75rem 0.8rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.slot-chip strong,
.assigned-slot-chip strong,
.slot-card strong,
.teacher-timetable-slot strong {
    font-size: 1rem;
}

.slot-chip span,
.assigned-slot-chip span,
.slot-card span,
.teacher-timetable-slot span {
    color: var(--muted);
    font-size: 0.9rem;
}

.slot-chip[draggable="true"],
.assigned-slot-chip[draggable="true"],
.slot-card[draggable="true"] {
    cursor: grab;
}

.dragging {
    opacity: 0.55;
}

.slot-chip.full {
    background: #f0f2f6;
    color: #8893a5;
    border-style: dashed;
}

.slot-chip.inactive {
    background: #f7f8fb;
    border-style: dashed;
}

.assigned-slot-chip.conflict,
.teacher-timetable-slot.conflict,
.slot-card.conflict {
    border-color: #e4ab56;
    background: var(--warning-soft);
}

.warning-text {
    color: var(--warning) !important;
    font-weight: 700;
}

.planner-grid-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable both-edges;
}

.planner-grid {
    min-width: 920px;
    table-layout: fixed;
}

/* Teacher timetable: override global min-width for better mobile UX */
.teacher-app .planner-grid.planner-grid--teacher {
    min-width: 640px;
}

.planner-class-fold-body .planner-grid {
    border-collapse: separate;
    border-spacing: 0;
}

.room-planner-grid {
    border-collapse: separate;
    border-spacing: 0;
}

.planner-class-fold-body .planner-grid th,
.planner-class-fold-body .planner-grid td {
    border: 0;
    border-bottom: 1px dashed #d5dbe6;
    border-left: 1px dashed #d5dbe6;
}

.room-planner-grid th,
.room-planner-grid td {
    border: 0;
    border-bottom: 1px dashed #d5dbe6;
    border-left: 1px dashed #d5dbe6;
}

.planner-class-fold-body .planner-grid th:first-child,
.planner-class-fold-body .planner-grid td:first-child {
    border-left: 0;
}

.room-planner-grid th:first-child,
.room-planner-grid td:first-child {
    border-left: 0;
}

.planner-grid th,
.planner-grid td {
    width: 12.5%;
}

.phase-head {
    width: 10rem;
    min-width: 10rem;
}

.phase-head-stunde {
    display: block;
    font-weight: 700;
}

.phase-head-stunde-time {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    line-height: 1.2;
}

/* Zeilenhöhe ~ proportional zu unit_length; Pause (0) = halbe Basis */
.planner-grid.phase-sized-rows {
    --phase-size-base: clamp(2rem, 2.6vw, 3.15rem);
}

/* Kompaktes Wochenraster (Klassen-Planner, Lehrer-Zuteilung, veröffentlichter Lehrerplan) */
.planner-grid.planner-grid--compact.phase-sized-rows {
    --phase-size-base: clamp(0.72rem, 1vw, 0.92rem);
}

.planner-grid.planner-grid--compact .phase-head {
    width: 4.5rem;
    min-width: 4.5rem;
    max-width: 4.5rem;
    padding: 0.15rem 0.3rem;
    font-size: 0.65rem;
    line-height: 1.2;
}

.planner-grid.planner-grid--compact .phase-head-stunde {
    font-size: 0.68rem;
}

.planner-grid.planner-grid--compact .phase-head-stunde-time {
    margin-top: 0.04rem;
    font-size: 0.58rem;
}

.planner-grid.planner-grid--compact thead th {
    padding: 0.28rem 0.25rem;
    font-size: 0.68rem;
    line-height: 1.15;
}

.planner-grid.planner-grid--compact .slot-card,
.planner-grid.planner-grid--compact .teacher-timetable-slot {
    padding: 0.22rem 0.28rem;
    gap: 0.04rem;
    border-radius: 6px;
}

.planner-grid.planner-grid--compact .slot-card strong,
.planner-grid.planner-grid--compact .teacher-timetable-slot strong {
    font-size: 0.74rem;
    line-height: 1.15;
}

.planner-grid.planner-grid--compact .slot-card span,
.planner-grid.planner-grid--compact .teacher-timetable-slot span {
    font-size: 0.62rem;
    line-height: 1.2;
}

.planner-grid.planner-grid--compact .slot-card .small,
.planner-grid.planner-grid--compact .slot-card .muted.small,
.planner-grid.planner-grid--compact .teacher-timetable-slot .small,
.planner-grid.planner-grid--compact .teacher-timetable-slot .muted.small {
    font-size: 0.58rem;
}

.planner-grid.planner-grid--compact .slot-card .inline-form,
.planner-grid.planner-grid--compact .teacher-timetable-slot .inline-form {
    margin-top: 0.08rem;
}

.planner-grid.planner-grid--compact .pause-scope-details--inline summary {
    font-size: 0.58rem;
}

.planner-grid.planner-grid--compact .warning-text {
    font-size: 0.58rem;
}

.planner-grid.planner-grid--compact .button-small {
    padding: 0.1rem 0.32rem;
    font-size: 0.62rem;
}

.planner-grid.phase-sized-rows tbody tr.phase-sized-row > th.phase-head,
.planner-grid.phase-sized-rows tbody tr.phase-sized-row > td {
    min-height: calc(var(--phase-size-base) * var(--phase-h, 1));
    vertical-align: top;
}

.planner-grid.phase-sized-rows tbody tr.phase-sized-row > td.drop-cell {
    min-height: calc(var(--phase-size-base) * var(--phase-h, 1));
}

.teacher-grid.phase-sized-rows tbody tr.phase-sized-row > td {
    min-height: calc(var(--phase-size-base) * var(--phase-h, 1));
}

.teacher-grid.phase-sized-rows tbody tr.phase-sized-row > th.phase-head {
    min-height: calc(var(--phase-size-base) * var(--phase-h, 1));
}

.phase-hide-yl-title {
    margin: 1rem 0 0.35rem;
    font-size: 1rem;
}

.phase-hide-table-wrap {
    margin-bottom: 0.75rem;
}

.phase-hide-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.phase-hide-matrix th,
.phase-hide-matrix td {
    border: 1px solid var(--border);
    text-align: center;
    padding: 0.25rem 0.2rem;
}

.checkbox-fieldset-select-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.45rem;
}

.phase-bulk-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

.phase-bulk-col {
    width: 2.35rem;
    text-align: center;
    vertical-align: middle;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.phase-bulk-cb {
    margin: 0;
    cursor: pointer;
}

/* Zeitphasen / Stundenraster: kompaktere Darstellung */
.time-phases-page .grid-two {
    gap: 0.75rem;
}

.time-phases-page section.panel {
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.65rem;
}

.time-phases-page .panel h2 {
    font-size: 1.12rem;
    margin: 0 0 0.45rem;
}

.time-phases-page .panel h3 {
    font-size: 0.9rem;
    margin: 0.55rem 0 0.28rem;
}

.time-phases-page .panel > p.muted.small {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
}

.time-phases-page .stack-form {
    gap: 0.55rem;
}

.time-phases-page .checkbox-fieldset {
    padding: 0.5rem 0.65rem 0.6rem;
    margin: 0 0 0.55rem;
}

.time-phases-page .checkbox-fieldset legend {
    font-size: 0.86rem;
}

.time-phases-page .checkbox-grid {
    grid-template-columns: repeat(auto-fill, minmax(8.25rem, 1fr));
    gap: 0.15rem 0.45rem;
    margin-top: 0.2rem;
}

.time-phases-page .checkbox-row {
    gap: 0.4rem;
    font-size: 0.88rem;
}

.time-phases-page .checkbox-fieldset .muted.small {
    margin: 0 0 0.3rem;
    font-size: 0.76rem;
    line-height: 1.32;
}

.time-phases-page .checkbox-fieldset-select-row {
    margin: 0 0 0.28rem;
    gap: 0.3rem;
}

.time-phases-page label > span:first-child {
    font-size: 0.86rem;
}

.time-phases-page input[type="text"],
.time-phases-page input[type="number"],
.time-phases-page input[type="time"],
.time-phases-page select {
    padding: 0.48rem 0.58rem;
    border-radius: 10px;
}

.time-phases-page .button-row {
    margin-top: 0.25rem;
}

.time-phases-page .table-wrap.compact table th,
.time-phases-page .table-wrap.compact table td {
    padding: 0.32rem 0.42rem;
    font-size: 0.81rem;
}

.time-phases-page .table-wrap.compact th {
    font-size: 0.76rem;
}

.time-phases-page .actions-cell {
    gap: 0.28rem;
}

.time-phases-page .phase-bulk-toolbar {
    margin-bottom: 0.5rem;
}

.time-phases-page .phase-bulk-col {
    width: 1.95rem;
    font-size: 0.7rem;
}

.time-phases-page .phase-hide-yl-title {
    margin-top: 0.45rem;
    margin-bottom: 0.22rem;
    font-size: 0.88rem;
}

.time-phases-page .phase-hide-table-wrap {
    margin-bottom: 0.3rem;
}

.time-phases-page .phase-hide-matrix {
    font-size: 0.74rem;
}

.time-phases-page .phase-hide-matrix th,
.time-phases-page .phase-hide-matrix td {
    padding: 0.08rem 0.1rem;
}

.time-phases-page .phase-hide-corner {
    text-align: left;
    min-width: 5.25rem;
    padding: 0.2rem 0.3rem;
    font-size: 0.74rem;
}

.time-phases-page .phase-hide-matrix tbody th {
    padding: 0.12rem 0.28rem 0.12rem 0;
    font-size: 0.74rem;
}

.time-phases-page .phase-hide-cell {
    width: 1.55rem;
}

.time-phases-page .phase-hide-label {
    min-height: 1.25rem;
}

.time-phases-page .phase-hide-label input {
    width: 0.9rem;
    height: 0.9rem;
}

.time-phases-page section.time-phases-exceptions-panel {
    padding: 0.55rem 0.65rem;
}

.time-phases-exceptions-panel .planner-fold {
    margin-top: 0;
}

.planner-fold--time-exceptions {
    background: #f9fafc;
}

.time-phases-exceptions-intro {
    margin: 0 0 0.5rem;
    max-width: 48rem;
    line-height: 1.35;
}

.time-phases-exceptions-form {
    gap: 0.45rem;
}

.time-phases-exceptions-form .phase-hide-yl-block + .phase-hide-yl-block {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
}

.time-phases-exceptions-actions {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

.phase-hide-yl-block {
    min-width: 0;
}

.phase-hide-corner {
    text-align: left;
    min-width: 7rem;
}

.phase-hide-matrix tbody th {
    text-align: right;
    padding-right: 0.5rem;
    white-space: nowrap;
    font-weight: 600;
}

.phase-hide-cell {
    width: 2.25rem;
}

.phase-hide-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.75rem;
    cursor: pointer;
}

.phase-hide-label input {
    width: auto;
    margin: 0;
}

.drop-cell,
.drop-zone,
.teacher-card {
    transition: background 0.15s ease, border-color 0.15s ease;
}

.drop-cell {
    min-height: 88px;
    background: #fbfcff;
}

.drop-cell-pause {
    background: #f4f5f7;
    border-style: dashed;
    border-bottom: 1px dashed #d5dbe6;
    border-top: 1px dashed #d5dbe6;
    border-bottom-color: #d5dbe6;
    border-top-color: #d5dbe6;
}

.scheduled-cell-pause {
    border-bottom: 1px dashed #d5dbe6;
    border-top: 1px dashed #d5dbe6;
}

.drop-label {
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.na-cell {
    background: #f0f3f8;
}

.drop-zone-hover {
    background: #eef4ff !important;
    border-color: var(--primary) !important;
}

.scheduled-cell {
    background: #f8fbff;
}

/* Wochenraster: Slots optisch vom Raster abtrennen (grün, wenn kein Konflikt) */
.planner-class-fold-body .slot-pool .slot-chip:not(.conflict):not(.full):not(.inactive) {
    background: var(--success-soft);
    border-color: #bfe7cc;
}

.planner-grid.planner-grid--compact .slot-card:not(.conflict) {
    background: var(--success-soft);
    border-color: #bfe7cc;
}

/* Rowspan-Zelle: Inhalt über die zusammengefassten Zeilen mitziehen */
.planner-grid.phase-sized-rows tbody tr.phase-sized-row > td.scheduled-cell {
    padding: 0.4rem;
    vertical-align: top;
}

.planner-grid.planner-grid--compact.phase-sized-rows tbody tr.phase-sized-row > td.scheduled-cell {
    padding: 0.18rem 0.22rem;
    vertical-align: top;
}

.planner-grid.planner-grid--compact .scheduled-cell .slot-card,
.planner-grid.planner-grid--compact .scheduled-cell .teacher-timetable-slot {
    box-sizing: border-box;
    min-height: 100%;
}

.planner-grid .scheduled-cell .slot-card {
    box-sizing: border-box;
    min-height: 100%;
    height: 100%;
}

.print-grid.phase-sized-rows tbody tr.phase-sized-row > td.scheduled-cell {
    padding: 0.25rem;
    vertical-align: top;
}

.print-grid .scheduled-cell.print-slot {
    box-sizing: border-box;
    min-height: 100%;
    height: 100%;
}

.teacher-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.teacher-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.9rem;
    background: #fbfcff;
}

.teacher-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.teacher-points {
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
    background: var(--warning-soft);
    color: var(--warning);
}

.teacher-points.ok {
    background: var(--success-soft);
    color: var(--success);
}

.teacher-points.warn {
    background: var(--warning-soft);
    color: var(--warning);
}

.teacher-points.bad {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Nutzerübersicht: Fortschritts-Markierung in Tabellenzeilen (subtil) */
tr.users-progress-row--ok > td {
    background: rgba(31, 139, 76, 0.06);
}

tr.users-progress-row--warn > td {
    background: rgba(183, 121, 31, 0.08);
}

tr.users-progress-row--bad > td {
    background: rgba(200, 55, 55, 0.07);
}

/* keep action buttons readable */
tr.users-progress-row--ok > td.actions-cell,
tr.users-progress-row--warn > td.actions-cell,
tr.users-progress-row--bad > td.actions-cell {
    background: transparent;
}

.print-wrapper {
    padding: 1.25rem;
}

.print-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.credentials-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 1rem;
}

.credential-card {
    min-height: 160px;
    padding: 1rem;
    border: 2px dashed #9098a8;
    border-radius: 14px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    page-break-inside: avoid;
}

.credential-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.print-class-block {
    margin-bottom: 2rem;
    page-break-inside: avoid;
}

.print-classes-pages {
    display: block;
}

.print-class-table-wrap {
    display: block;
}

.only-print {
    display: none !important;
}

/* Klassen-Stundenpläne: benannte Druckseite A4 quer (nur Blöcke mit page: timetable) */
@page timetable {
    size: A4 landscape;
    margin: 5mm;
}

.print-grid .scheduled-cell {
    background: #fff;
}

.teacher-grid td {
    min-height: 90px;
}

.compact-list {
    padding-left: 1.1rem;
    margin: 0 0 1rem;
}

.compact-list li {
    margin-bottom: 0.35rem;
}

.week-switcher {
    gap: 0.5rem;
}

.no-print {
    display: block;
}

@media (max-width: 1100px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .grid-two,
    .panel-split,
    .teacher-selection-layout,
    .teacher-assignment-layout,
    .teacher-assign-layout,
    .planner-layout,
    .grid-three {
        grid-template-columns: 1fr;
    }

    .teacher-assignment-layout {
        --teacher-assign-sticky-top: calc(84px + 7.25rem);
    }

    body:has(.teacher-assign-workspace):has(.teacher-assign-toolbar-fold:not([open])) .teacher-assignment-layout {
        --teacher-assign-sticky-top: calc(84px + 4.35rem);
    }

    body:has(.teacher-assign-workspace) .shell {
        flex-direction: column;
    }

    body:has(.teacher-assign-workspace) .sidebar {
        flex: 0 0 auto;
        width: 100%;
    }
}

@media (max-width: 720px) {
    .content {
        padding: 1rem;
    }

    .topbar {
        padding: 1rem;
    }

    .planner-grid {
        min-width: 760px;
    }

    .credentials-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    body {
        background: #fff;
    }

    .no-print {
        display: none !important;
    }

    .only-print {
        display: block !important;
    }

    .panel,
    .metric-card {
        box-shadow: none;
        border-color: #bfc7d7;
    }

    .print-wrapper {
        padding: 0;
    }

    .credential-card,
    .print-class-block {
        break-inside: avoid;
    }

    .planner-grid,
    .teacher-grid {
        min-width: 0;
        width: 100%;
    }

    /* Beim Drucken normaler Admin-Seiten (z. B. Wochenraster, Lehrer-Zuteilung)
       sind die "compact" Screen-Werte zu klein. Daher im Print auf cm-basierte
       Basishöhen und lesbare Typografie umstellen. */
    .planner-grid.planner-grid--compact.phase-sized-rows,
    .teacher-grid.phase-sized-rows {
        --phase-size-base: clamp(1.05rem, 0.32cm, 1.55rem);
    }

    .planner-grid.planner-grid--compact .phase-head {
        width: 2.3cm;
        min-width: 2.3cm;
        max-width: 2.3cm;
        font-size: 8pt;
        line-height: 1.15;
        padding: 2pt 3pt;
    }

    .planner-grid.planner-grid--compact thead th {
        font-size: 8pt;
        padding: 2pt 3pt;
    }

    .planner-grid.planner-grid--compact .slot-card strong,
    .planner-grid.planner-grid--compact .teacher-timetable-slot strong {
        font-size: 8.5pt;
    }

    .planner-grid.planner-grid--compact .slot-card span,
    .planner-grid.planner-grid--compact .teacher-timetable-slot span,
    .planner-grid.planner-grid--compact .slot-card .muted.small,
    .planner-grid.planner-grid--compact .warning-text {
        font-size: 7.5pt;
    }

    /* Eine Klasse = eine A4-Querseite */
    body.print-class-timetables .print-classes-pages {
        margin: 0;
        padding: 0;
    }

    body.print-class-timetables .print-class-block {
        page: timetable;
        page-break-after: always;
        break-after: page;
        page-break-inside: avoid;
        break-inside: avoid;
        box-sizing: border-box;
        width: 100%;
        min-height: 190mm;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    body.print-class-timetables .print-class-block:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    body.print-class-timetables .print-sheet-context {
        font-size: 8pt;
        margin: 0 0 2mm;
        color: #444;
    }

    body.print-class-timetables .print-class-title {
        font-size: 13pt;
        line-height: 1.15;
        margin: 0 0 3mm;
        font-weight: 700;
    }

    body.print-class-timetables .print-class-table-wrap {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    body.print-class-timetables .print-class-table-wrap .print-grid {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0 !important;
        table-layout: fixed;
        border-collapse: collapse;
        font-size: 8pt;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    body.print-class-timetables .print-class-table-wrap .print-grid th,
    body.print-class-timetables .print-class-table-wrap .print-grid td {
        padding: 2pt 3pt;
        border: 1px solid #999;
        vertical-align: top;
        overflow-wrap: anywhere;
        word-wrap: break-word;
    }

    body.print-class-timetables .print-class-table-wrap .print-grid.phase-sized-rows {
        /* Default; wird in den Druck-Views per inline style mm-genau überschrieben. */
        --phase-size-base: clamp(1.05rem, 0.32cm, 1.55rem);
    }

    body.print-class-timetables .print-class-table-wrap .print-grid.phase-sized-rows tbody tr.phase-sized-row > th.phase-head,
    body.print-class-timetables .print-class-table-wrap .print-grid.phase-sized-rows tbody tr.phase-sized-row > td {
        min-height: calc(var(--phase-size-base) * var(--phase-h, 1));
    }

    /* Tabellen ignorieren min-height teils im Drucklayout → Höhe direkt auf die Zeile legen. */
    body.print-class-timetables .print-class-table-wrap .print-grid.phase-sized-rows tbody tr.phase-sized-row {
        height: calc(var(--phase-size-base) * var(--phase-h, 1));
    }

    /* 0-Länge: typografisch abwerten (Pausenzeilen/Pausenaufsichten/0-Slots). */
    body.print-class-timetables .print-slot.print-slot--zero strong {
        font-size: 8pt;
        font-weight: 700;
    }
    body.print-class-timetables .print-slot.print-slot--zero span {
        font-size: 7pt;
        color: #6b778c;
    }
    body.print-class-timetables .print-teacher-slot.print-teacher-slot--zero {
        opacity: 0.9;
    }

    body.print-class-timetables .print-class-table-wrap .print-grid thead th {
        font-weight: 700;
        background: #eef1f7;
    }

    body.print-class-timetables .print-class-table-wrap .phase-head {
        width: 8%;
        min-width: 0;
        font-size: 8pt;
        font-weight: 700;
        background: #f3f5f9;
    }

    body.print-class-timetables .print-slot {
        line-height: 1.2;
        background: #fff !important;
    }

    body.print-class-timetables .print-slot strong {
        font-size: 8.5pt;
    }

    body.print-class-timetables .print-slot span {
        font-size: 7.5pt;
    }

    body.print-class-timetables .print-teacher-slot {
        margin-bottom: 3pt;
        padding-bottom: 2pt;
        border-bottom: 1px solid #ddd;
        line-height: 1.25;
    }

    body.print-class-timetables .print-teacher-slot:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: 0;
    }

    body.print-class-timetables .print-teacher-slot--conflict {
        background: #fff5e6 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    body.print-class-timetables .print-teacher-conflict {
        display: block;
        font-size: 7pt;
        font-weight: 700;
        color: #a86b00;
        margin-top: 1pt;
    }

    body.print-class-timetables .print-class-table-wrap .na-cell {
        background: #f5f6f8 !important;
    }

    body.print-mode .teacher-grid.phase-sized-rows tbody tr.phase-sized-row > th.phase-head,
    body.print-mode .teacher-grid.phase-sized-rows tbody tr.phase-sized-row > td,
    .teacher-grid.phase-sized-rows tbody tr.phase-sized-row > th.phase-head,
    .teacher-grid.phase-sized-rows tbody tr.phase-sized-row > td {
        min-height: calc(var(--phase-size-base) * var(--phase-h, 1));
    }

    .teacher-grid.phase-sized-rows tbody tr.phase-sized-row {
        height: calc(var(--phase-size-base) * var(--phase-h, 1));
    }
}
