:root {
    --sp-accent: #a83023;
    --sp-ink: #22262b;
    --sp-muted: #5d646d;
    --sp-line: #d9dde2;
    --sp-soft: #f4f5f7;
    --sp-paper: #ffffff;
}

/* Akzentfarbe: feste Auswahl, gesetzt über die Klasse am body */
.sp_accent_blau { --sp-accent: #1f5a96; }
.sp_accent_petrol { --sp-accent: #0f6b74; }
.sp_accent_gruen { --sp-accent: #2d6a4f; }
.sp_accent_anthrazit { --sp-accent: #3a3f47; }

/* Farben je Fach */
.sp_c0 { --sp-tint: #e6eef8; --sp-edge: #3f6fb0; }
.sp_c1 { --sp-tint: #fcebd6; --sp-edge: #c7772a; }
.sp_c2 { --sp-tint: #e2f1e6; --sp-edge: #3c8a55; }
.sp_c3 { --sp-tint: #f7e4ea; --sp-edge: #b4567a; }
.sp_c4 { --sp-tint: #ebe6f6; --sp-edge: #7458b3; }
.sp_c5 { --sp-tint: #dff0f1; --sp-edge: #2b8790; }
.sp_c6 { --sp-tint: #f5f0d6; --sp-edge: #9a8420; }
.sp_c7 { --sp-tint: #ebebeb; --sp-edge: #6f6f6f; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--sp-ink);
    background: var(--sp-soft);
}

a { color: var(--sp-accent); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #0b57d0; outline-offset: 2px; }
[hidden] { display: none !important; }

.sp_vh {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.sp_wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; }

/* Kopf */
.sp_head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin: 0 -16px;
    padding: 12px 16px;
    background: var(--sp-paper);
    border-bottom: 3px solid var(--sp-accent);
}
.sp_logo img { display: block; height: 36px; width: auto; }
.sp_headtext { order: 3; flex-basis: 100%; }
.sp_title { margin: 0; font-size: 22px; letter-spacing: .02em; line-height: 1.2; }
.sp_sub { margin: 2px 0 0; font-size: 14px; color: var(--sp-muted); }

.sp_classes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sp_classes a { padding: 8px 14px; background: var(--sp-paper); border: 1px solid var(--sp-line); border-radius: 8px; text-decoration: none; font-weight: 600; }
.sp_classes a[aria-current="page"] { background: var(--sp-accent); border-color: var(--sp-accent); color: #fff; }

.sp_preview { margin: 14px 0 0; padding: 10px 12px; background: #fff6d6; border: 2px solid #8a5a00; border-radius: 10px; }

/* Umschalter, nur mit Skript und nur auf schmalen Bildschirmen */
.sp_controls { display: none; }
.sp_js .sp_controls { display: block; }

.sp_mode { display: flex; margin-top: 14px; padding: 3px; background: #e3e5e9; border-radius: 10px; }
.sp_modebtn { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 8px; font-weight: 600; }
.sp_modebtn[aria-pressed="true"] { background: var(--sp-paper); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }

.sp_daytabs { display: flex; gap: 6px; margin-top: 12px; }
.sp_daytab {
    flex: 1;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    background: var(--sp-paper);
    border: 1px solid var(--sp-line);
    border-radius: 10px;
    font-weight: 700;
}
.sp_daytab small { font-size: 11px; font-weight: 600; color: var(--sp-muted); }
.sp_daytab[aria-pressed="true"] { background: var(--sp-accent); border-color: var(--sp-accent); color: #fff; }
.sp_daytab[aria-pressed="true"] small { color: #fff; }

.sp_js .sp_plan[data-mode="week"] .sp_daytabs,
.sp_js .sp_plan[data-mode="week"] .sp_dayview,
.sp_js .sp_plan[data-mode="day"] .sp_weekview { display: none; }

/* Tagesansicht */
.sp_weekview { display: none; }
.sp_js .sp_weekview { display: block; }

.sp_day h2 { margin: 16px 0 8px; font-size: 15px; color: var(--sp-muted); }
.sp_list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.sp_card {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 68px;
    padding: 12px;
    color: inherit;
    text-decoration: none;
    background: var(--sp-paper);
    border: 1px solid var(--sp-line);
    border-left: 5px solid var(--sp-edge, var(--sp-line));
    border-radius: 12px;
}
.sp_card:hover { border-color: var(--sp-edge, var(--sp-accent)); }
.sp_time { font-size: 14px; font-weight: 700; line-height: 1.25; }
.sp_to { display: block; font-weight: 400; color: var(--sp-muted); }
.sp_cardmain strong { display: block; font-size: 17px; line-height: 1.25; }
.sp_who { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; color: var(--sp-muted); }
.sp_chev { font-size: 20px; color: var(--sp-muted); }
.sp_gap { margin: 0; padding: 8px 12px; font-size: 14px; color: var(--sp-muted); border: 1px dashed #b5bcc5; border-radius: 12px; }
.sp_end { margin: 10px 0 0; font-size: 14px; color: var(--sp-muted); }

.sp_avatar {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #5f6772;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}
.sp_avatar_l { width: 52px; height: 52px; font-size: 19px; }
img.sp_avatar { object-fit: cover; }

/* Wochenraster, auf dem Handy kompakt mit Kürzeln */
.sp_weekview { margin-top: 14px; }
.sp_grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.sp_grid th { padding: 4px 0; font-size: 12px; font-weight: 700; }
.sp_grid thead th:first-child { width: 40px; }
.sp_grid tbody th { font-size: 11px; font-weight: 400; line-height: 1.25; color: var(--sp-muted); text-align: left; }
.sp_grid tbody th span { display: block; }
.sp_grid td { padding: 0; height: 58px; }
.sp_grid td.sp_free { border: 1px dashed #c3c9d0; border-radius: 8px; }
.sp_cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    min-height: 58px;
    padding: 4px 2px;
    color: inherit;
    text-decoration: none;
    text-align: center;
    font-size: 13px;
    background: var(--sp-tint, var(--sp-paper));
    border-top: 4px solid var(--sp-edge, var(--sp-line));
    border-radius: 8px;
}
.sp_cell:hover { box-shadow: inset 0 0 0 2px var(--sp-edge, var(--sp-accent)); }
.sp_cellwho { font-size: 11px; color: var(--sp-muted); }
.sp_full, .sp_bis {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Hinweis */
.sp_info { margin: 20px 0; padding: 12px 14px; font-size: 15px; background: #fff6d6; border: 1px solid #ecd98a; border-radius: 10px; }
.sp_info p { margin: 0; }
.sp_info p + p { margin-top: 4px; }

/* Lehrkräfte */
.sp_teachers h2 { margin: 28px 0 12px; font-size: 20px; }
.sp_teacher { margin-bottom: 8px; padding: 0 14px; background: var(--sp-paper); border: 1px solid var(--sp-line); border-radius: 12px; }
.sp_teacher summary { display: flex; align-items: center; gap: 14px; padding: 12px 0; cursor: pointer; list-style: none; }
.sp_teacher summary::-webkit-details-marker { display: none; }
.sp_teacher summary::after { content: "▾"; margin-left: auto; font-size: 18px; color: var(--sp-muted); }
.sp_teacher[open] summary::after { content: "▴"; }
.sp_summarytext strong { display: block; }
.sp_summarytext span { font-size: 14px; color: var(--sp-muted); }
.sp_contact { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 4px; padding: 10px 12px; background: var(--sp-soft); border-radius: 8px; font-size: 15px; }
.sp_contact a { word-break: break-all; }
.sp_topic h3 { margin: 16px 0 4px; font-size: 16px; }
.sp_topic h3 small { display: block; font-size: 14px; font-weight: 400; color: var(--sp-muted); }
.sp_topic ul { margin: 4px 0 14px; padding-left: 20px; font-size: 15px; }

/* Detailblatt: auf dem Handy von unten, sonst mittig */
.sp_sheet {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    border-radius: 18px 18px 0 0;
    color: var(--sp-ink);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .25);
}
.sp_sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sp_sheet_in { padding: 16px 18px 28px; }
.sp_sheet_head { display: flex; align-items: center; gap: 12px; }
.sp_sheet_head h2 { margin: 0; font-size: 19px; }
.sp_sheet_head p { margin: 2px 0 0; font-size: 14px; color: var(--sp-muted); }
.sp_close { margin-left: auto; flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--sp-soft); font-size: 22px; line-height: 1; }
.sp_sheet_mail { display: inline-block; margin-top: 12px; word-break: break-all; }
.sp_sheet_more { margin: 4px 0 0; font-size: 14px; color: var(--sp-muted); }

/* Ab Tablet-Breite: volles Raster statt Tagesansicht */
@media (min-width: 760px) {
    .sp_head { flex-wrap: nowrap; padding: 16px; }
    .sp_logo img { height: 64px; }
    .sp_headtext { order: 0; flex-basis: auto; text-align: center; }
    .sp_title { font-size: 30px; }
    .sp_sub { font-size: 16px; }

    .sp_controls, .sp_js .sp_controls { display: none; }
    .sp_dayview, .sp_js .sp_plan[data-mode="day"] .sp_dayview { display: none; }
    .sp_weekview, .sp_js .sp_plan[data-mode="day"] .sp_weekview { display: block; margin-top: 24px; }

    .sp_short { display: none; }
    .sp_full, .sp_bis { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; }

    .sp_grid { border-spacing: 4px; }
    .sp_grid th { padding: 12px 6px; font-size: 15px; background: #333; color: #fff; border-radius: 6px; }
    .sp_grid thead th:first-child { width: 110px; }
    .sp_grid tbody th { font-size: 14px; font-weight: 700; color: #fff; text-align: center; }
    .sp_grid tbody th span { display: inline; }
    .sp_grid td { height: 76px; }
    .sp_cell { align-items: flex-start; min-height: 76px; padding: 10px 12px; text-align: left; font-size: 16px; }
    .sp_cellwho { font-size: 14px; }

    .sp_sheet { width: 480px; margin: auto; border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
}

@media print {
    body { background: #fff; }
    .sp_controls, .sp_js .sp_controls, .sp_info p + p, .sp_preview { display: none; }
}
