/* =========================================================
   Stundenplan — Dark Mode Design System
   ========================================================= */

@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,600,700&display=swap');

:root {
    /* Typography */
    --font-sans: 'Satoshi', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    /* Dark palette — academic/productivity tone */
    --bg-base: #0f1117;
    --bg-surface: #161b27;
    --bg-elevated: #1e2536;
    --bg-hover: #252d40;
    --border: rgba(255,255,255,0.08);
    --border-subtle: rgba(255,255,255,0.05);
    /* Text */
    --text-primary: #f0f2f8;
    --text-secondary: #8b95b0;
    --text-muted: #505870;
    /* Accent */
    --accent: #6366f1;
    --accent-hover: #7577f5;
    --accent-dim: rgba(99, 102, 241, 0.18);
    /* Status */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    /* Spacing */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    /* Week grid */
    --col-time: 52px;
    /* Mindestbreite je Tagesspalte: darunter wird horizontal gescrollt,
       statt dass die Spalten unlesbar zusammengedrueckt werden. */
    --col-day: minmax(96px, 1fr);
    --hour-height: 60px;
    --day-count: 7;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* ─── App Shell ──────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* ─── Topbar ─────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 54px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
    position: relative;
    z-index: 10;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 9px;
    /* Die Marke darf schrumpfen, damit die Navigation nie aus der Leiste laeuft. */
    min-width: 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

    .topbar__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.topbar__logo {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: block;
    border-radius: 5px; /* passt zum rx des Favicons bei 24px Kantenlaenge */
}

.topbar__nav {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.topbar__link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}

    .topbar__link:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    .topbar__link.is-active {
        background: var(--accent-dim);
        color: var(--accent-hover);
    }

/* ─── Main Content ───────────────────────────────────────── */

.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ─── Week Navigation ────────────────────────────────────── */

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    gap: 12px;
}

.week-nav__btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

    .week-nav__btn:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
        border-color: var(--border);
    }

.week-nav__center {
    display: flex;
    align-items: center;
    gap: 12px;
}

.week-nav__label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.week-nav__today {
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

    .week-nav__today:hover {
        background: var(--accent-dim);
        color: var(--accent-hover);
        border-color: var(--accent);
    }

/* ─── Week Grid ──────────────────────────────────────────── */

.week-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Scrollcontainer. Das Raster kann sich nicht selbst scrollen, solange seine
   eigene Mindestbreite es aufspannt — dafuer braucht es einen Elternknoten.
   Vorher stand overflow und min-width am selben Element: auf schmalen Geraeten
   wurde das Raster deshalb von .week-view abgeschnitten statt scrollbar. */
.week-scroll {
    flex: 1;
    overflow: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
    -webkit-overflow-scrolling: touch;
}

    .week-scroll::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    .week-scroll::-webkit-scrollbar-track {
        background: transparent;
    }

    .week-scroll::-webkit-scrollbar-thumb {
        background: var(--bg-hover);
        border-radius: 99px;
    }

.week-grid {
    display: grid;
    grid-template-columns: var(--col-time) repeat(7, var(--col-day));
    position: relative;
}

/* Sticky day headers */
.week-grid__day-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    gap: 4px;
}

/* sticky blank corner */
.week-grid__time-col {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border-subtle);
}

.day-header__name {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.day-header__num {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s;
}

    .day-header__num.is-today {
        background: var(--accent);
        color: #fff;
    }

.week-grid__day-header.is-today .day-header__name {
    color: var(--accent-hover);
}

/* Time labels — Zeile und Spalte setzt die Ansicht per "grid-area" */
.week-grid__time-label {
    height: var(--hour-height);
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0 8px;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    position: relative;
    top: -0.5em;
}

/* Hour cells */
.week-grid__cell {
    height: var(--hour-height);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}

/* Ganztagszeile — direkt unter den Tagesueberschriften, weil ein Termin ohne
   Uhrzeit keine Position im Stundenraster hat. Die Ansicht blendet sie nur ein,
   wenn es einen solchen Termin gibt. */
.week-grid__allday-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 8px;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border);
}

.week-grid__allday {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px;
    min-height: 28px;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border);
}

/* Event columns — one per day, absolutely positioned.
   Die Zeile setzt die Ansicht per Inline-Style: sie haengt davon ab, ob die
   Ganztagszeile eingeblendet ist. */
.week-grid__events-col {
    position: relative;
    pointer-events: none;
}

/* ─── Event Card ─────────────────────────────────────────── */

.event-card {
    position: absolute;
    /* left/width kommen pro Termin inline von EventCard.razor (Spaltenaufteilung
       bei Ueberlappung, siehe GridLayout.Layout). */
    /* Die Karte ist ein <button> — ohne diese Angaben erbt sie weder
       Schrift noch Textausrichtung vom Raster. */
    font-family: inherit;
    text-align: left;
    color: inherit;
    padding: 4px 6px 4px 10px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--event-color) 18%, var(--bg-elevated));
    border: 1px solid color-mix(in srgb, var(--event-color) 40%, transparent);
    cursor: pointer;
    overflow: hidden;
    pointer-events: all;
    transition: background 0.12s, transform 0.12s;
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

    .event-card:hover {
        background: color-mix(in srgb, var(--event-color) 28%, var(--bg-elevated));
        transform: translateX(1px);
    }

    .event-card:focus-visible {
        outline: 2px solid var(--accent-hover);
        outline-offset: 1px;
    }

.event-card__stripe {
    width: 3px;
    border-radius: 2px;
    background: var(--event-color);
    flex-shrink: 0;
    align-self: stretch;
    min-height: 12px;
}

.event-card__body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    min-width: 0;
}

.event-card__title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.event-card__time {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.event-card__location {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Ganztags-Karte ─────────────────────────────────────── */

/* Flach im Fluss der Ganztagszeile statt absolut positioniert wie die
   .event-card — Hoehe und Reihenfolge ergeben sich aus dem Inhalt. */
.allday-card {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 3px 7px;
    font-family: inherit;
    text-align: left;
    color: inherit;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--event-color) 18%, var(--bg-elevated));
    border: 1px solid color-mix(in srgb, var(--event-color) 40%, transparent);
    cursor: pointer;
    overflow: hidden;
    transition: background 0.12s;
}

    .allday-card:hover {
        background: color-mix(in srgb, var(--event-color) 28%, var(--bg-elevated));
    }

    .allday-card:focus-visible {
        outline: 2px solid var(--accent-hover);
        outline-offset: 1px;
    }

.allday-card__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--event-color);
    flex-shrink: 0;
}

.allday-card__title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Modal ──────────────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
    overflow: hidden;
    /* Lange Beschreibungen duerfen den Dialog nicht ueber den Rand
       hinauswachsen lassen — der Rumpf scrollt stattdessen. */
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 40px);
}

.modal-backdrop:focus,
.modal-backdrop:focus-visible {
    outline: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal__color-bar {
    height: 3px;
    background: var(--event-color, var(--accent));
}

.modal__header {
    flex-shrink: 0;
}

.modal__header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 16px 12px;
    gap: 12px;
}

.modal__heading {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.modal__source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.modal__source-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--event-color, var(--accent));
    flex-shrink: 0;
}

.modal__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.modal__close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

    .modal__close:hover {
        background: var(--danger);
        color: #fff;
    }

.modal__body {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    min-height: 0;
}

.modal__row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 0;
}

    .modal__row > span,
    .modal__row > a {
        min-width: 0;
        overflow-wrap: anywhere;
    }

.modal__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.modal__tag {
    padding: 1px 8px;
    border-radius: 99px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
}

.modal__link {
    color: var(--accent-hover);
    text-decoration: none;
}

    .modal__link:hover {
        text-decoration: underline;
    }

.modal__meta {
    color: var(--text-muted);
    margin-left: 4px;
}

    .modal__row svg {
        flex-shrink: 0;
        margin-top: 2px;
        opacity: 0.7;
    }

.modal__row--description {
    align-items: flex-start;
}

.modal__description {
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 0.82rem;
}

.modal__row--duration {
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── Settings Page ──────────────────────────────────────── */

.settings-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 28px 20px 40px;
    width: 100%;
    overflow-y: auto;
    height: 100%;
}

.settings-header {
    margin-bottom: 24px;
}

.settings-header__title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-header__sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Source list */
.source-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
}

.source-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s;
}

    .source-card.is-disabled {
        opacity: 0.5;
    }

.source-card__color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.source-card__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.source-card__name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.source-card__url {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
}

.source-card__sync {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.source-card__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Add source form */
.add-source-form {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.add-source-form__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-input {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}

.form-input--mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.form-error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 0.82rem;
    color: #fca5a5;
    margin-bottom: 12px;
}

.form-success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 0.82rem;
    color: #6ee7b7;
    margin-bottom: 12px;
}

/* Color picker */
.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}

    .color-swatch:hover {
        transform: scale(1.15);
    }

    .color-swatch.is-selected {
        border-color: var(--text-primary);
        transform: scale(1.1);
    }

/* ─── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    outline: none;
    text-decoration: none;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}

    .btn--primary:hover:not(:disabled) {
        background: var(--accent-hover);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(99,102,241,0.3);
    }

    .btn--primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Icon button */
.icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

    .icon-btn:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

.icon-btn--danger:hover {
    background: rgba(239,68,68,0.12);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
}

/* ─── Toggle ─────────────────────────────────────────────── */

.toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.toggle__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__track {
    width: 36px;
    height: 20px;
    background: var(--bg-hover);
    border-radius: 10px;
    border: 1px solid var(--border);
    position: relative;
    transition: background 0.2s;
}

    .toggle__track::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 14px;
        height: 14px;
        background: var(--text-muted);
        border-radius: 50%;
        transition: transform 0.2s, background 0.2s;
    }

.toggle__input:checked + .toggle__track {
    background: var(--accent);
    border-color: var(--accent);
}

    .toggle__input:checked + .toggle__track::after {
        transform: translateX(16px);
        background: #fff;
    }

/* ─── States ─────────────────────────────────────────────── */

.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.875rem;
    flex: 1;
}

.empty-state--sm {
    padding: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ─── Scrollbar ──────────────────────────────────────────── */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 640px) {
    .topbar {
        padding: 0 12px;
        gap: 10px;
    }

    /* Etwas mehr Hoehe, weil ohne Beschriftung nur das Icon als Ziel bleibt. */
    .topbar__link {
        padding: 9px 11px;
    }

    /* Nur die Icons zeigen: mit Beschriftung passen die vier Links neben der
       Marke nicht mehr auf ein Telefon im Hochformat. Den Namen liefert das
       aria-label am Link. */
    .topbar__label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .week-nav {
        padding: 10px 12px;
    }

    .week-nav__label {
        font-size: 0.82rem;
    }

    :root {
        --col-time: 40px;
        /* 40 + 5 x 68 = 380px: eine Woche ohne Wochenende passt damit auf
           uebliche Telefone im Hochformat, ohne zu scrollen. */
        --col-day: minmax(68px, 1fr);
    }

    .settings-page {
        padding: 20px 14px 32px;
    }
}

/* ─── Load errors & week notices ─────────────────────────── */

.load-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 12px 10px;
    padding: 10px 12px;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 0.8rem;
}

    .load-error svg {
        flex-shrink: 0;
        margin-top: 2px;
    }

.load-error__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.load-error__retry {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

    .load-error__retry:hover {
        background: rgba(239,68,68,0.18);
    }

.week-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 12px 10px;
    padding: 9px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.week-notice__jump {
    background: var(--accent-dim);
    border: 1px solid rgba(99,102,241,0.35);
    border-radius: var(--radius-sm);
    color: var(--accent-hover);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

    .week-notice__jump:hover {
        background: rgba(99,102,241,0.28);
    }

/* ─── Day view ───────────────────────────────────────────── */

.day-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Tagesueberschriften der Wochenansicht sind Links in die Tagesansicht */
a.week-grid__day-header {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

    a.week-grid__day-header:hover {
        background: var(--bg-hover);
    }

    a.week-grid__day-header:hover .day-header__name {
        color: var(--text-secondary);
    }

/* ─── Tagesmarkierungen: frei, Ferien, wichtig ───────────── */

.week-grid__day-header.is-free {
    background: color-mix(in srgb, var(--warning) 12%, var(--bg-surface));
}

.week-grid__day-header.is-holiday {
    background: color-mix(in srgb, var(--info) 12%, var(--bg-surface));
}

.day-header__note {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.week-grid__day-header.is-holiday .day-header__note {
    color: var(--info);
}

.day-header__note--important,
.week-grid__day-header.is-holiday .day-header__note--important,
.week-grid__day-header.is-free .day-header__note--important {
    color: var(--danger);
}

/* Tint ueber der Tagesspalte; der Container faengt ohnehin keine Klicks ab.
   Die Ganztagszeile liegt ausserhalb dieser Spalte und braucht ihn separat. */
.week-grid__events-col.is-free,
.week-grid__allday.is-free {
    background: color-mix(in srgb, var(--warning) 7%, transparent);
}

.week-grid__events-col.is-holiday,
.week-grid__allday.is-holiday {
    background: color-mix(in srgb, var(--info) 7%, transparent);
}

.week-notice--free {
    background: color-mix(in srgb, var(--warning) 12%, var(--bg-surface));
    border-color: color-mix(in srgb, var(--warning) 35%, transparent);
    color: var(--warning);
}

.week-notice--holiday {
    background: color-mix(in srgb, var(--info) 12%, var(--bg-surface));
    border-color: color-mix(in srgb, var(--info) 35%, transparent);
    color: var(--info);
}

.week-notice--important {
    background: color-mix(in srgb, var(--danger) 12%, var(--bg-surface));
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    color: #fca5a5;
}

/* ─── Karte fuer wichtige Termine ────────────────────────── */

.important-card {
    position: absolute;
    left: 0;
    width: calc(100% - 4px);
    padding: 3px 6px 3px 8px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--danger) 22%, var(--bg-elevated));
    border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 18%, transparent);
    overflow: hidden;
    pointer-events: all;
    display: flex;
    gap: 6px;
    align-items: stretch;
    z-index: 2;
}

.important-card__stripe {
    width: 3px;
    border-radius: 2px;
    background: var(--danger);
    flex-shrink: 0;
}

.important-card__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.important-card__title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fecaca;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.important-card__time {
    font-size: 0.62rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--danger) 70%, var(--text-secondary));
    font-variant-numeric: tabular-nums;
}

/* ─── Adminbereich ───────────────────────────────────────── */

.admin-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.admin-bar__status {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--success);
}

.admin-save {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ─── Blazor-Fehlerbalken ────────────────────────────────── */
/* Gehoert zum Blazor-Standardtemplate und ging beim CSS-Neubau verloren.
   Ohne "display: none" war der Balken bei jedem Seitenaufruf sichtbar,
   ohne dass ueberhaupt eine Exception aufgetreten war. */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 12px 44px 12px 16px;
    background: rgba(239,68,68,0.14);
    border-top: 1px solid rgba(239,68,68,0.4);
    backdrop-filter: blur(8px);
    color: #fca5a5;
    font-size: 0.82rem;
}

    #blazor-error-ui .reload {
        color: var(--accent-hover);
        text-decoration: underline;
        margin-left: 6px;
    }

    #blazor-error-ui .dismiss {
        position: absolute;
        top: 10px;
        right: 14px;
        cursor: pointer;
        font-size: 1rem;
        line-height: 1;
    }

/* ─── Admin: Abschnitte und Eingabezeilen ────────────────── */

.admin-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

    .admin-section:last-of-type {
        border-bottom: none;
    }

.admin-section__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.admin-section__hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.admin-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 12px;
}

    .admin-row .form-group {
        margin-bottom: 0;
    }

.form-group--grow {
    flex: 1;
    min-width: 180px;
}

.source-card__badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 99px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Moodle-Abgaben ───────────────────────────────────────────────────── */

/* Abgaben haben keine Dauer: gestrichelter Rand statt Vollflaeche setzt sie
   optisch von Vorlesungen ab. */
.event-card--deadline {
    border-style: dashed;
    border-color: var(--event-color);
}

.source-card__badge {
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent-hover);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text-primary);
    cursor: pointer;
}

.deadline-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.deadline-group__title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.deadline-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    text-align: left;
    color: inherit;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--event-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s;
}

    .deadline-row:hover {
        background: var(--bg-hover);
    }

    .deadline-row:focus-visible {
        outline: 2px solid var(--accent-hover);
        outline-offset: 1px;
    }

.deadline-row__time {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.deadline-row__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.deadline-row__title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.deadline-row__course {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.deadline-row__due {
    font-size: 0.78rem;
    white-space: nowrap;
    color: var(--text-secondary);
}

.deadline-row.is-soon .deadline-row__due {
    color: var(--warning);
}

.deadline-row.is-urgent .deadline-row__due {
    color: var(--danger);
    font-weight: 600;
}
