:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }

/* App-Wrapper (alles in einem großen DIV) */
.app { position: relative; min-height: 100vh; }

/* Hauptmenü oben rechts (ohne Kopfzeile) */
.hauptmenu {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 12;
}

.nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.hamburger {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    position: relative;
    z-index: 12;
}

.hamburger-icon {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}

.nav {
    position: absolute;
    top: 54px;
    right: 0;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    min-width: 220px;
    padding: 10px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    z-index: 11;
}

.nav a {
    display: block;
    padding: 10px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: #111;
}

.nav a:hover { background: #f4f4f4; }
.nav a.active { background: #efefef; font-weight: 600; }

.nav-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ececec;
}

.nav-section-title {
    list-style: none;
    cursor: pointer;
    padding: 6px 10px 4px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    user-select: none;
    transition: background 0.15s;
}

.nav-section-title::-webkit-details-marker { display: none; }

.nav-section-title::after {
    content: '\25B8';
    font-size: 0.8em;
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 6px;
}

.nav-section[open] > .nav-section-title::after {
    transform: rotate(90deg);
}

.nav-section-title:hover {
    background: #f4f4f4;
}

.nav-submenu a {
    padding-left: 18px;
}

.nav-small {
    font-size: 0.83rem;
    opacity: 0.9;
}

.nav-user {
    padding: 10px 10px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 6px;
}

.nav-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #ececec;
}

.nav-footer-link {
    display: block;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: #888;
    font-size: 0.78rem;
}

.nav-footer-link:hover { background: #f4f4f4; color: #333; }
.nav-footer-link.active { background: #efefef; color: #111; font-weight: 600; }

.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.10);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.nav-toggle:checked ~ .nav {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.nav-toggle:checked ~ .backdrop {
    opacity: 1;
    pointer-events: auto;
}

.main { max-width: 980px; margin: 0 auto; padding: 18px 14px 40px; }

/* Klassenwahl braucht mehr Platz für alle Spalten inkl. Startseite */
.page-klassewahl .main {
    max-width: 1200px;
}

/* Schülerarbeitsplatz + Startseite (Schülerarbeitsplatz-Look): Hauptbereich soll den Bildschirm füllen */
.page-schuelerarbeitsplatz .main,
.page-startseite .main {
    max-width: none;
    margin: 0;
    padding: 0;
}

.page-smartboard .main {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* Listen ohne Bulletpoints (Klasse einrichten) */
.page-klassewahl ul {
    list-style: none;
    padding-left: 0;
    margin-left: 0;
}

/* Klasse einrichten: Spaltenlayout (Klassenliste) */
.page-klassewahl .klassewahl-liste {
    padding-left: 0;
    margin-left: 0;
    overflow-x: auto;
}

.page-klassewahl .klassewahl-zeile {
    display: grid;
    grid-template-columns: minmax(10ch, 0.9fr) 132px minmax(38ch, 1.6fr) 160px 96px;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
    min-width: 780px;
}

.page-klassewahl .klassewahl-zeile.klassewahl-ohne-direktstartcode {
    grid-template-columns: minmax(10ch, 1fr) 132px minmax(38ch, 1.8fr) 96px;
    min-width: 620px;
}

.page-klassewahl .klassewahl-kopf {
    font-weight: 700;
}

.page-klassewahl .klassewahl-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
    min-width: 140px;
}

.page-klassewahl .klassewahl-spalte-direktstart {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.page-klassewahl .klassewahl-direktstart-code,
.page-klassewahl .klassewahl-direktstart-link {
    padding: 6px 8px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    box-sizing: border-box;
}

.page-klassewahl .klassewahl-direktstart-code {
    width: 12ch;
    min-width: 10ch;
}

.page-klassewahl .klassewahl-direktstart-link {
    width: 100%;
    min-width: 38ch;
}

.page-klassewahl .direktstart-code-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 999px;
    font-weight: 700;
    line-height: 1;
    min-height: 34px;
}

.page-klassewahl .direktstart-code-status.ok {
    background: green;
    border-color: green;
    color: #fff;
    background-image: url('../../media/pics/richtig.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    min-width: 34px;
}

.page-klassewahl .direktstart-code-status.fehler {
    background: #d32f2f;
    border-color: #d32f2f;
    color: #fff;
}

/* Diagnosehinweise: sichtbar nur bei No-JS oder explizitem Debugmodus */
.nojs-hinweis {
    position: sticky;
    top: 0;
    z-index: 3000;
    padding: 10px 14px;
    background: #b71c1c;
    color: #fff;
    font-weight: 700;
    text-align: center;
}

.js-diagnose-badge {
    position: fixed;
    right: 8px;
    bottom: 8px;
    z-index: 3100;
    max-width: min(92vw, 620px);
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(20, 20, 20, 0.9);
    color: #fff;
    font-size: 12px;
    line-height: 1.25;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.page-klassewahl .klassewahl-startseite {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}

.page-klassewahl .klassewahl-spalte-klasse {
    min-width: 0;
}

.page-klassewahl .klassewahl-klasse {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.page-klassewahl .klassewahl-umbenennen-form {
    grid-column: 1 / -1;
}

/* Seitenkopf (Titel + Zurück) */
.seitenkopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.seitenkopf h1 { margin: 0; }

.btn-zurueck {
    display: inline-block;
    padding: 9px 12px;
    border: 1px solid #e5e5e5;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    color: #111;
}

.btn-zurueck:hover { background: #f4f4f4; }

/* Button-Variante: grün (wie + Buttons) */
.btn-gruen {
    border-color: green;
    background: green;
    color: #fff;
    font-weight: 700;
}

.btn-gruen:hover { filter: brightness(0.95); }
.btn-gruen:active { filter: brightness(0.90); }

/* Icons in Buttons/Links (z.B. Löschen/Umbenennen) */
.btn-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

/* Seite: Klasse (Tabelle darf browserbreit werden) */
.page-klasse .main { max-width: 980px; }

/* Nur die Tabelle darf volle Breite nutzen */
.page-klasse .klasse-tabelle {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 14px;
    padding-right: 14px;
}

/* Tabelle: keine festen Breiten erzwingen */
.page-klasse .matrix th.formatkopf { vertical-align: top; }

/* Klasse einrichten: Schüler-Tabelle -> alle Spalten fix 120px */
.page-klasse .matrix {
    table-layout: fixed;
    width: max-content;
}

.page-klasse .matrix th,
.page-klasse .matrix td {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

.page-klasse .matrix th:first-child,
.page-klasse .matrix td:first-child {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
}

/* Erste Spalte (Schüler) beim horizontalen Scrollen sichtbar lassen */
.page-klasse .matrix th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #efefef;
}

.page-klasse .matrix td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    overflow: hidden;
}

/* Klasse einrichten: jede zweite Zeile hellgrau */
.page-klasse .matrix tbody tr:nth-child(even) td {
    background: #f4f4f4;
}

/* Sticky Schüler-Spalte soll das Zebra-Striping mitmachen */
.page-klasse .matrix tbody tr:nth-child(even) td:first-child {
    background: #f4f4f4;
}

/* Klasse-Modul */
.klasse-toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin: 10px 0 12px;
}

/* Klasse-Seite: Kopfzeile (Klasse wählen) zentrieren */
.page-klasse .klasse-toolbar { justify-content: center; }
.page-klasse .klasse-toolbar label { text-align: center; }

/* Klassenwahl-Seite: Toolbar zentrieren */
.page-klassewahl .klasse-toolbar { justify-content: center; }
.page-klassewahl .klasse-toolbar label { text-align: center; }

/* Klassenwahl-Seite: bestimmte Toolbars bewusst linksbündig */
.page-klassewahl .klasse-toolbar.klasse-toolbar-links { justify-content: flex-start; }
.page-klassewahl .klasse-toolbar.klasse-toolbar-links label { text-align: left; }

/* Klassen-Buttons (z.B. Klasse einrichten + Schülerarbeitsplatz): einheitliche Breite */
.klassewahl-klasse {
    min-width: calc(10ch + 24px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Klasse einrichten: gelb */
.page-klassewahl .klassewahl-klasse { background: #fff3a6; }

/* Hover-Effekt für Klassen-Labels (Klasse einrichten) */
.page-klassewahl .klassewahl-klasse:hover {
    background: #ffe77a;
}

.klasse-toolbar label { display: block; font-size: 14px; }
.klasse-select, .klasse-input { min-width: 220px; padding: 8px; border: 1px solid #e5e5e5; border-radius: 10px; }
.klasse-toolbar button, .klasse-actions button {
    padding: 9px 12px;
    border: 1px solid #e5e5e5;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
}

.klasse-toolbar .btn-gruen, .klasse-actions .btn-gruen {
    background: green;
    border-color: green;
    color: #fff;
}

/* Buttons unter der Tabelle */
.klasse-actions { display: flex; justify-content: flex-start; margin: 10px 0 0; }

/* Tabelle + Spalten-Button rechts daneben */
.tabelle-scroll { overflow-x: auto; }
.tabelle-in {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    align-items: flex-start;
    margin-left: auto;
    margin-right: auto;
}
.klasse-tabelle { overflow: visible; }

/* Tabellen-Inhalt links, Container zentriert */
.page-klasse .tabelle-scroll .matrix {
    text-align: left;
    margin-left: auto;
    margin-right: auto;
}

.tabelle-seite { align-self: flex-start; }
.tabelle-seite button {
    padding: 9px 12px;
    border: 1px solid #e5e5e5;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
}

/* Spalte hinzufügen: + Button grün */
.tabelle-seite .spalte-plus {
    min-width: 44px;
    padding: 9px 0;
    font-weight: 700;
    font-size: 18px;
    line-height: 1;
    border-color: green;
    background: green;
    color: #fff;
}

.tabelle-seite .spalte-plus:hover { filter: brightness(0.95); }
.tabelle-seite .spalte-plus:active { filter: brightness(0.90); }

/* Neue Zeile: + SchülerIn grün */
.klasse-actions .schueler-plus {
    border-color: green;
    background: green;
    color: #fff;
    font-weight: 700;
}

.klasse-actions .schueler-plus:hover { filter: brightness(0.95); }
.klasse-actions .schueler-plus:active { filter: brightness(0.90); }

.klasse-status { min-height: 18px; margin: 6px 0 10px; color: #111; }

/* Klasse: Direktstart (Code + Status + kompletter Link) */
.page-klasse .klasse-direktstart {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin: 10px 0 6px;
}

.page-klasse .klasse-direktstart label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-klasse .klasse-direktstart input[type="text"] {
    padding: 8px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
}

.page-klasse #direktstart-code {
    width: 12ch;
    min-width: 10ch;
}

.page-klasse .direktstart-code-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 999px;
    font-weight: 700;
    line-height: 1;
    min-height: 34px;
}

.page-klasse .direktstart-code-status.ok {
    background: green;
    border-color: green;
    color: #fff;
    background-image: url('../../media/pics/richtig.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    min-width: 34px;
}

.page-klasse .direktstart-code-status.fehler {
    background: #d32f2f;
    border-color: #d32f2f;
    color: #fff;
}

.page-klasse #direktstart-link {
    flex: 1 1 420px;
    min-width: 260px;
    width: 100%;
}

.klasse-hinweis { max-width: 980px; margin: 0 auto; }
.klasse-hinweis p { margin: 0; }

.matrix { width: 100%; border-collapse: collapse; }
.matrix th, .matrix td { border: 1px solid #e5e5e5; }
.matrix th { background: #efefef; text-align: left; }
.matrix td.chk, .matrix th.formatkopf { text-align: center; }
.matrix input[type="text"] { width: 100%; padding: 8px; border: 1px solid #e5e5e5; border-radius: 10px; }
.matrix .anzahl-override { width: 90px; margin-left: 8px; padding: 6px 8px; border: 1px solid #e5e5e5; border-radius: 10px; }

.page-klasse .matrix .schueler-zeile-in { display: flex; gap: 8px; align-items: center; min-width: 0; width: 100%; }
.page-klasse .matrix .schueler-zeile-in .schueler-name { flex: 1 1 auto; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; }
.schueler-delete {
    flex: 0 0 auto;
    padding: 6px 10px;
    border: 1px solid #e5e5e5;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
}
.schueler-delete:hover { background: #f4f4f4; }

/* Kopfzeile: Überschrift + 3 Buttons untereinander */
.formatkopf-in {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
.formatkopf-in > span { display: block; text-align: center; line-height: 1.15; }
.kopfbuttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
}
.format-edit { padding: 6px 10px; border: 1px solid #e5e5e5; background: #fff; border-radius: 10px; cursor: pointer; }
.webspiel-start { display: inline-block; padding: 6px 10px; border: 1px solid #e5e5e5; background: #fff; border-radius: 10px; cursor: pointer; text-decoration: none; color: #111; }
.webspiel-start:hover { background: #f4f4f4; }
.spalte-dup { padding: 6px 10px; border: 1px solid #e5e5e5; background: #fff; border-radius: 10px; cursor: pointer; }
.spalte-dup:hover { background: #f4f4f4; }
.spalte-delete { padding: 6px 10px; border: 1px solid #e5e5e5; background: #fff; border-radius: 10px; cursor: pointer; }
.spalte-delete:hover { background: #f4f4f4; }

.klasse-optionen { margin-top: 10px; }
/* Card-basierte Tabs */
.tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 10px 0;
}

@media (max-width: 760px) {
    .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
    .tabs { grid-template-columns: 1fr; }
}
.tab {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid #e5e5e5;
    background: #fff;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    line-height: 1.15;
}
.tab:hover { background: #f4f4f4; }
.tab.active { background: #efefef; font-weight: 600; }
.optionen-panel { border: 1px solid #e5e5e5; border-radius: 12px; padding: 10px; }
.optionen-panel.loading { opacity: 0.75; }

/* Optionen-Tabs: Tab-Leiste (an CSS-Tabs angelehnt, aber neutral) */
.page-klasse .klasse-optionen .tabs {
    display: flex;
    /* Wenn viele Reiter vorhanden sind, nicht zu schmal quetschen,
       sondern in mehrere Reihen umbrechen. */
    flex-wrap: wrap;
    gap: 0;
    margin: 10px 0 8px;
    background: #fff;
    border: 0;
    border-radius: 12px;
    overflow-x: hidden;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.page-klasse .klasse-optionen .tab {
    flex: 1 1 10em;
    min-width: 10em;
    border: 0;
    border-right: 1px solid #e5e5e5;
    border-radius: 10px 10px 0 0;
    background: #fff;
    color: #111;
    padding: 0.675em 0.8em 0.825em;
    font-size: 14px;
    min-height: 4.8em;
    position: relative;
    top: 0;
    transition: top 0.25s, background 0.25s, color 0.25s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.15;
}

/* Plus-Reiter soll immer sichtbar sein und grün sein */
.page-klasse .klasse-optionen .tab.tab-add,
.page-klasse .klasse-optionen .tab.tab-plus {
    flex: 0 0 3.2em;
    min-width: 3.2em;
    font-weight: 700;
    background: green;
    color: #fff;
}

.page-klasse .klasse-optionen .tab.tab-add:hover,
.page-klasse .klasse-optionen .tab.tab-plus:hover {
    background: green;
    filter: brightness(0.95);
}

.page-klasse .klasse-optionen .tab.tab-add.active,
.page-klasse .klasse-optionen .tab.tab-plus.active {
    background: green;
    color: #fff;
}

.page-klasse .klasse-optionen .tab .formatname {
    display: block;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-klasse .klasse-optionen .tab .tab-btns {
	display: flex;
    flex-wrap: wrap;
	gap: 6px;
	margin-top: 6px;
}

.page-klasse .klasse-optionen .tab .tab-btns .spalte-dup,
.page-klasse .klasse-optionen .tab .tab-btns .spalte-delete,
.page-klasse .klasse-optionen .tab .tab-btns .spalte-test {
	font-size: 0.9em;
	padding: 2px 6px;
}

/* Icons (Löschen/Duplizieren) in den Reitern 50% größer */
.page-klasse .klasse-optionen .tab .tab-btns .spalte-dup .btn-icon,
.page-klasse .klasse-optionen .tab .tab-btns .spalte-delete .btn-icon,
.page-klasse .klasse-optionen .tab .tab-btns .spalte-test .btn-icon {
    width: 24px;
    height: 24px;
}

/* Test-Button unten im Webspiel-Optionenbereich: Optik wie im Reiter */
.page-klasse .klasse-optionen .optionen-panel .webspiel-testen-unten .tab-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.page-klasse .klasse-optionen .optionen-panel .webspiel-testen-unten .spalte-test {
    font-size: 0.9em;
    padding: 2px 6px;
}

.page-klasse .klasse-optionen .optionen-panel .webspiel-testen-unten .spalte-test .btn-icon {
    width: 24px;
    height: 24px;
}

/* Sticker-Bilder Galerie */
.sticker-upload-bereich { margin: 6px 0 4px; }
.sticker-upload-bereich > label { display: block; font-size: 13px; margin-bottom: 4px; }
.sticker-reihe { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.sticker-galerie { display: contents; }
.sticker-thumb {
    position: relative; width: 72px; height: 72px;
    border-radius: 8px; overflow: hidden;
    border: 1px solid #ddd; background: #f5f5f5; flex-shrink: 0;
}
.sticker-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sticker-thumb-x {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; padding: 0; border: none;
    border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff;
    font-size: 10px; line-height: 18px; text-align: center;
    cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.sticker-thumb:hover .sticker-thumb-x { opacity: 1; }
.sticker-mehr {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 72px; height: 72px; padding: 4px 6px;
    border: 2px solid #bbb; border-radius: 8px;
    font-size: 11px; font-weight: 600; color: #666; flex-shrink: 0;
    background: #fff; text-align: center; box-sizing: border-box;
    cursor: default; line-height: 1.3;
}
.sticker-mehr.drag-over { border-color: green; background: #e8f5e9; }
.sticker-upload-box {
    display: inline-flex; align-items: center; justify-content: center;
    width: 72px; height: 72px; border: 2px dashed #bbb;
    border-radius: 8px; cursor: pointer; background: #fafafa;
    text-align: center; overflow: hidden; box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s; outline: none; flex-shrink: 0;
}
.sticker-upload-box:hover, .sticker-upload-box:focus { border-color: #555; background: #f1f1f1; }
.sticker-upload-box.drag-over { border-color: green; background: #e8f5e9; }
.sticker-placeholder {
    font-size: 18px; color: #999; text-align: center;
    line-height: 1.2; padding: 2px; pointer-events: none; user-select: none;
}

.page-klasse .klasse-optionen .tab:hover { top: -0.20rem; background: #f4f4f4; }

.page-klasse .klasse-optionen .tab.active {
    background: #d32f2f;
    color: #fff;
    font-weight: 600;
    top: -0.06rem;
    z-index: 1;
}

.page-klasse .klasse-optionen .tab:focus-visible {
    outline: 2px solid #111;
    outline-offset: -2px;
}

.page-klasse .klasse-optionen .optionen-panel {
    border: 1px solid #d32f2f;
    border-radius: 12px;
    margin: 0;
    background: rgba(211, 47, 47, 0.08);
}

@media (max-width: 760px) {
    .page-klasse .klasse-optionen .tabs { flex-wrap: wrap; }
    .page-klasse .klasse-optionen .tab { flex: 1 1 50%; }
}

@media (max-width: 480px) {
    .page-klasse .klasse-optionen .tabs { flex-wrap: wrap; }
    .page-klasse .klasse-optionen .tab { flex: 1 1 100%; }
}

/* Optionen-Formular: Radio + Label zusammenhalten */
.optionen-panel .radio-paar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 3px 0;
    white-space: nowrap;
}
.optionen-panel .radio-paar label { min-width: 0; }

/* Wortliste (manuelle Wortauswahl): Checkboxen in mehrere Spalten */
.optionen-panel fieldset.wortliste > div {
    column-count: 3;
    column-gap: 18px;
}

.optionen-panel fieldset.wortliste > div > div {
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin: 2px 0;
}

.optionen-panel fieldset.wortliste label,
.optionen-panel fieldset.wortliste label.links {
    min-width: 0;
    display: inline;
}

.optionen-panel fieldset.wortliste input[type="checkbox"] {
    margin-right: 8px;
}

@media (max-width: 760px) {
    .optionen-panel fieldset.wortliste > div { column-count: 2; }
}

@media (max-width: 480px) {
    .optionen-panel fieldset.wortliste > div { column-count: 1; }
}

/* Modal */
.modal { display: none; }
.modal.open { display: block; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.10);
    z-index: 20;
}
.modal-dialog {
    position: fixed;
    left: 50%;
    top: 8vh;
    transform: translateX(-50%);
    width: min(980px, calc(100vw - 24px));
    max-height: 84vh;
    overflow: auto;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    z-index: 21;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e5e5;
}
.modal-title { font-weight: 600; }
.modal-close { padding: 8px 10px; border: 1px solid #e5e5e5; background: #fff; border-radius: 10px; cursor: pointer; }
.modal-body { padding: 12px; }

/* Formular-Layout im Optionen-Panel: einheitliche Fieldset-Umrandung */
.optionen-panel fieldset { border: 2px groove #c0c0c0; border-radius: 0; padding: 10px; margin: 12px 0; }
.optionen-panel legend { padding: 0 8px; font-weight: 600; }
.fa label {
    display: inline-block;
    min-width: 220px;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}
.fa input, .fa select, .fa textarea { max-width: 100%; }
.fa textarea { width: 100%; }
.optionen-panel input[name="titel"] { width: 15ch; max-width: 100%; }

/* Lesen > Filter für Wortauswahl: robuste Zeilenumbrüche + kompaktere Felder */
.optionen-panel fieldset.dep-wortauswahl-auto {
    white-space: normal;
    overflow-wrap: anywhere;
}

.optionen-panel fieldset.dep-wortauswahl-auto > div.schmal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.optionen-panel fieldset.dep-wortauswahl-auto > div.schmal > label {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    flex: 0 1 auto;
    max-width: 100%;
}

.optionen-panel fieldset.dep-wortauswahl-auto > div.schmal > input[type="checkbox"] {
    flex: 0 0 auto;
}

.optionen-panel fieldset.dep-wortauswahl-auto > div.daneben,
.optionen-panel fieldset.dep-wortauswahl-auto > div.daneben.ausgrauen {
    margin: 4px 0 10px;
}

.optionen-panel fieldset.dep-wortauswahl-auto > div.daneben > label,
.optionen-panel fieldset.dep-wortauswahl-auto > div.daneben.ausgrauen > label {
    display: none;
}

.optionen-panel fieldset.dep-wortauswahl-auto > div.daneben > input[type="text"],
.optionen-panel fieldset.dep-wortauswahl-auto > div.daneben.ausgrauen > input[type="text"] {
    width: 22ch;
    max-width: 100%;
}

/* Uhr > "Nur folgende Zeiten": Eingabefeld darf auf Handy nicht überlaufen */
.optionen-panel input[name="uhrZeiten"] {
    max-width: 100%;
}

@media (max-width: 760px) {
    .optionen-panel .fa label {
        display: inline;
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .optionen-panel .fa div {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .optionen-panel .radio-paar {
        white-space: normal;
        align-items: flex-start;
    }

    .optionen-panel fieldset.wortliste label,
    .optionen-panel fieldset.wortliste label.links {
        overflow-wrap: anywhere;
    }

    .optionen-panel fieldset.dep-wortauswahl-auto > div.schmal {
        align-items: flex-start;
    }

    .optionen-panel fieldset.dep-wortauswahl-auto > div.daneben > input[type="text"],
    .optionen-panel fieldset.dep-wortauswahl-auto > div.daneben.ausgrauen > input[type="text"] {
        width: 100%;
    }

    .optionen-panel input[name="uhrZeiten"] {
        width: 100%;
        display: block;
    }
}

/* Schülerarbeitsplatz (neue Seite, Layout ähnlich alt) */
.sus-toolbar { margin: 10px 0 12px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.sus-arbeitsplatz .sus-haupt {
    position: relative;
    margin: 10px auto;
    width: min(1080px, 100%);
    min-height: 590px;
    padding: 18px;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    /* app.css liegt in /public/css/, daher 2x hoch zum Projekt-Root */
    background-image: url('../../media/pics/fichte.jpg');
    background-size: 100% 100%;
    background-position: center;
}
.sus-arbeitsplatz .sus-titel { text-align: center; }
.sus-arbeitsplatz .sus-titel h1 { margin: 0 0 10px; }
.sus-arbeitsplatz .sus-spielladen { margin-top: 120px; font-size: 22px; }
.sus-arbeitsplatz .sus-spielladen h1 { margin: 0 0 12px; }
.sus-arbeitsplatz .sus-knopf { display: inline-block; margin: 12px; }
.sus-arbeitsplatz .sus-knopf a:not(.btn-zurueck) {
    display: inline-block;
    min-width: 150px;
    padding: 12px 14px;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    background: #fff;
    color: #111;
    text-decoration: none;
    text-align: center;
}
.sus-arbeitsplatz .sus-knopf a:not(.btn-zurueck):hover { background: #ffd3a6; }

@media (prefers-reduced-motion: reduce) {
    .hamburger span { transition: none; }
    .nav { transition: none; }
}

/* Sticky Meldungszeile am unteren Bildschirmrand */
.app-message {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: #333228;
    color: #fff;
    font-size: 1.15em;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    margin: 0 auto;
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0.97;
    letter-spacing: 0.02em;
}

/* ===== Quiz-Verwaltung (Übersichtsseite) ===== */
.page-quizverwaltung ul {
    list-style: none;
    padding-left: 0;
    margin-left: 0;
}

.page-quizverwaltung .quizverwaltung-liste {
    padding-left: 0;
    margin-left: 0;
    overflow-x: auto;
}

.page-quizverwaltung .quizverwaltung-zeile {
    display: grid;
    grid-template-columns: minmax(14ch, 1fr) 80px 140px 132px;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
    min-width: 640px;
}

.page-quizverwaltung .quizverwaltung-kopf {
    font-weight: 700;
}

.page-quizverwaltung .quizverwaltung-spalte-name {
    min-width: 0;
}

.page-quizverwaltung .quizverwaltung-name {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: #fff3a6;
}

.page-quizverwaltung .quizverwaltung-name:hover {
    background: #ffe566;
    border-color: #bfa000;
}

.page-quizverwaltung .quizverwaltung-umbenennen-form {
    grid-column: 1 / -1;
    margin-top: 6px;
}

.quiz-anzahl-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e8f0e8;
    border: 1px solid #c0d8c0;
    font-weight: 700;
    font-size: 0.9em;
    color: #2a6a2a;
}

.quiz-global-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    background: #e0ecff;
    border: 1px solid #aac4e8;
    color: #2255aa;
    font-size: 0.75em;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 4px;
}

.quiz-lokal-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    background: #f2f2f2;
    border: 1px solid #d0d0d0;
    color: #666;
    font-size: 0.75em;
    font-weight: 700;
}

.quiz-freigabe-form {
    margin: 0;
}

.quiz-freigabe-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ===== Quiz-Editor: Zurück-Header ===== */
.page-quizeditor .main {
    max-width: none;
    margin: 0;
}

.page-quizeditor .quiz-editor {
    width: 100%;
    overflow-x: auto;
}

.page-quizeditor .quiz-editor-tabelle {
    width: 100%;
}

.page-quizeditor .quiz-editor-tabelle th {
    text-align: left;
}

.page-quizeditor .seitenkopf {
    margin-bottom: 14px;
}

/* ===== Eigene Bilder ===== */

.eb-hinweis {
    margin: 0 0 18px;
    color: #555;
}

.eb-upload-bereich {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}

.eb-zone {
    flex: 1 1 130px;
    min-width: 120px;
    max-width: 180px;
    min-height: 110px;
    border: 2px dashed #a0a8b8;
    border-radius: 8px;
    background: #f7f8fb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    padding: 12px 8px;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.eb-zone:hover,
.eb-zone:focus {
    border-color: #5580c0;
    background: #edf2fb;
    outline: none;
}

.eb-zone.drag-over {
    border-color: #3060b0;
    background: #dce8fc;
}

.eb-zone.eb-zone-loading {
    opacity: 0.6;
    cursor: wait;
}

.eb-zone-label {
    font-weight: 700;
    font-size: 0.92em;
    text-align: center;
    color: #334;
}

.eb-zone-hint {
    font-size: 0.78em;
    color: #778;
    text-align: center;
    line-height: 1.3;
}

.eb-status {
    min-height: 24px;
    margin-bottom: 10px;
    font-size: 0.9em;
    padding: 0 4px;
}

.eb-status-ok { color: #1a7a2a; }
.eb-status-fehler { color: #c0201a; }

.eb-zeile {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    border-bottom: 1px solid #e0e4ea;
    padding: 10px 0;
}

.eb-wort-spalte {
    flex: 0 0 200px;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.eb-wort-label {
    font-weight: 700;
    font-size: 1em;
    color: #223;
    word-break: break-word;
}

.eb-zeile-aktionen {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.eb-umbenennen-input {
    width: 110px;
    padding: 3px 6px;
    border: 1px solid #b0b8c8;
    border-radius: 4px;
    font-size: 0.85em;
}

.eb-umbenennen-btn,
.eb-alle-loeschen-btn {
    padding: 3px 9px;
    border-radius: 4px;
    border: 1px solid;
    font-size: 0.82em;
    cursor: pointer;
    white-space: nowrap;
}

.eb-umbenennen-btn {
    background: #e8edf8;
    border-color: #9daac8;
    color: #334;
}

.eb-umbenennen-btn:hover {
    background: #d0dbf0;
}

.eb-alle-loeschen-btn {
    background: #fbe8e8;
    border-color: #d09090;
    color: #8b1a1a;
}

.eb-alle-loeschen-btn:hover {
    background: #f5cece;
}

.eb-bilder-spalte {
    flex: 1 1 200px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.eb-bild-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.eb-bild-wrap img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border: 1px solid #d0d8e5;
    border-radius: 5px;
    background: #f5f5f5;
    display: block;
}

.eb-kat-label {
    font-size: 0.7em;
    color: #778;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.eb-bild-loeschen-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #b04040;
    background: #fff;
    color: #a03030;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: none;
}

.eb-bild-wrap:hover .eb-bild-loeschen-btn {
    display: block;
}

.eb-leer {
    color: #888;
    font-style: italic;
    padding: 10px 0;
}
