/* ==========================================================================
   LernBesser – Oberfläche (mobil zuerst). Nutzt ausschließlich Theme-Tokens.
   ========================================================================== */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: env(safe-area-inset-bottom);
}
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 16px 96px;
}

/* --- Topbar (Desktop/Tablet) --- */
.topbar {
    display: flex; align-items: center; gap: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }
.topnav { display: none; gap: 4px; margin-left: 8px; }
.topnav a {
    text-decoration: none; color: var(--text-muted);
    padding: 6px 12px; border-radius: var(--radius); font-weight: 500;
}
.topnav a.active, .topnav a:hover { background: var(--surface-2); color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* --- Bottom Tabbar (Mobil) --- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
    flex: 1; text-align: center; text-decoration: none;
    color: var(--text-muted); font-size: .7rem; padding: 8px 2px 6px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar a.active { color: var(--accent); }
.tabbar .ic { font-size: 1.15rem; line-height: 1; }

@media (min-width: 720px) {
    .topnav { display: flex; }
    .tabbar { display: none; }
    .container { padding-bottom: 40px; }
}

/* --- Avatar --- */
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: var(--accent-text);
    font-weight: 700; text-transform: uppercase;
}
.avatar-link { text-decoration: none; }

/* --- Flash --- */
.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: var(--radius); font-size: .95rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--warn-bg); color: var(--text); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 16px; font: inherit; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-small { padding: 6px 10px; font-size: .85rem; }
.btn-link { background: none; border: none; color: var(--text-muted); cursor: pointer; font: inherit; padding: 6px; }
.btn-link:hover { color: var(--text); }
.big-cta { margin: 16px 0; padding: 16px; font-size: 1.1rem; }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Forms --- */
.form { display: grid; gap: 12px; margin: 12px 0; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
input, select, textarea {
    font: inherit; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface); color: var(--text);
    width: 100%;
}
input[type="color"] { padding: 2px; height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
.hint { color: var(--text-muted); font-size: .85rem; }
.muted { color: var(--text-muted); }
.inline { display: inline; }
.inline-form { grid-auto-flow: row; }
@media (min-width: 560px) {
    .inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
    .inline-form label { flex: 1 1 auto; }
}

/* --- Auth --- */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; font-weight: 700; font-size: 1.6rem; margin-bottom: 16px; }
.auth-brand span { color: var(--accent); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: .9rem; flex-wrap: wrap; gap: 8px; }

/* --- Page head --- */
.page-head { margin-bottom: 8px; }
.page-head .back { display: inline-block; margin-bottom: 6px; color: var(--text-muted); text-decoration: none; font-size: .9rem; }
.page-head .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--subject-color, var(--accent)); vertical-align: middle; margin-right: 4px; }
.head-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.section-title { margin: 24px 0 8px; }

/* --- Stats --- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; text-align: center; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: .8rem; color: var(--text-muted); }

/* --- Empty state --- */
.card-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: 20px; color: var(--text-muted); text-align: center; }

/* --- Deck grid --- */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0; }
.deck-tile {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--surface); border: 1px solid var(--border);
    border-left: 5px solid var(--subject-color, var(--accent));
    border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text);
    box-shadow: var(--shadow);
}
.deck-tile:hover { box-shadow: var(--shadow-lg); }
.deck-subject { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.deck-name { font-weight: 700; }
.deck-count { font-size: .8rem; color: var(--text-muted); }

/* --- Lists --- */
.list { display: grid; gap: 8px; margin: 12px 0; }
.list-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px;
}
.list-main { display: flex; align-items: center; gap: 10px; flex: 1; text-decoration: none; color: var(--text); }
.list-row .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--subject-color, var(--accent)); flex-shrink: 0; }
.list-title { font-weight: 600; }
.list-meta { margin-left: auto; color: var(--text-muted); font-size: .85rem; }
.row-menu > summary { list-style: none; cursor: pointer; padding: 4px 8px; border-radius: var(--radius); }
.row-menu > summary::-webkit-details-marker { display: none; }
.menu-pop { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-top: 6px; display: grid; gap: 8px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Add panel (details/summary) --- */
.add-panel { margin: 12px 0; }
.add-panel > summary { list-style: none; display: inline-flex; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary { margin-bottom: 10px; }

/* --- Card list (deck detail) --- */
.cardlist { display: grid; gap: 8px; }
.card-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.card-item > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.card-front { flex: 1; }
.badge { font-size: .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; color: var(--text-muted); }
.badge-active { color: var(--ok); border-color: var(--ok); }
.badge-blocked { color: var(--danger); border-color: var(--danger); }
.badge-pending { color: var(--text-muted); }
.form-inline-delete { margin-top: -4px; }

/* --- Tables (admin) --- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table th { background: var(--surface-2); font-weight: 600; }
.copy-field { font-size: .8rem; }
.admin-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.price-model { font-weight: 600; align-self: center; }

/* --- Settings --- */
.settings-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin: 16px 0; }
.avatar-choose { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-pick input { position: absolute; opacity: 0; }
.avatar-pick .avatar { border: 3px solid transparent; cursor: pointer; }
.avatar-pick input:checked + .avatar { border-color: var(--accent); }

/* --- Theme switcher --- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.theme-option {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    background: var(--surface-2); border: 2px solid var(--border);
    border-radius: var(--radius); padding: 12px; cursor: pointer; color: var(--text);
    position: relative;
}
.theme-option.selected { border-color: var(--accent); }
.theme-option.disabled { opacity: .55; cursor: not-allowed; }
.theme-swatch { display: flex; border-radius: 8px; overflow: hidden; width: 72px; height: 40px; border: 1px solid var(--border); }
.theme-swatch span { flex: 1; }
.theme-label { font-size: .85rem; font-weight: 600; }
.theme-soon { font-size: .65rem; color: var(--text-muted); text-transform: uppercase; }

/* --- QR / secret --- */
.qr-box { display: flex; justify-content: center; margin: 16px 0; }
.qr-box svg { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: var(--radius); }
.secret { font-size: 1.1rem; letter-spacing: .1em; background: var(--surface-2); padding: 6px 10px; border-radius: var(--radius); display: inline-block; }
.steps { color: var(--text-muted); }

/* ==========================================================================
   Lernmodus (Fokus): Karte im Mittelpunkt
   ========================================================================== */
.learn-screen { max-width: 560px; margin: 0 auto; }
.learn-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.learn-head .back { color: var(--text-muted); text-decoration: none; }
.learn-deckname { font-weight: 600; }
.learn-progress { margin-left: auto; color: var(--text-muted); font-size: .9rem; }

.learn-stage { perspective: 1200px; min-height: 320px; display: flex; align-items: center; justify-content: center; }
.flashcard {
    width: 100%; min-height: 300px; position: relative;
    transform-style: preserve-3d; transition: transform .4s ease; cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard .face {
    position: absolute; inset: 0; backface-visibility: hidden;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center;
    padding: 28px; text-align: center; font-family: var(--font-card);
    font-size: 1.3rem; overflow-y: auto;
}
.flashcard .face-back { transform: rotateY(180deg); }
.face-tag { position: absolute; top: 10px; left: 14px; font-family: var(--font-ui); font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

.learn-controls { margin-top: 20px; display: grid; gap: 12px; }
.grade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-wrong { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); padding: 16px; font-size: 1.05rem; }
.btn-right { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); padding: 16px; font-size: 1.05rem; }

.learn-done { text-align: center; padding: 40px 20px; }
.done-emoji { font-size: 3rem; color: var(--ok); }
.loading { color: var(--text-muted); }

/* Upload status colors */
.status-done { color: var(--ok); }
.status-failed { color: var(--danger); }
.status-processing, .status-queued { color: var(--text-muted); }
.upload-form input[type=file] { padding: 8px; }

@media (max-width: 400px) {
    .grade-buttons .btn { font-size: .95rem; padding: 14px 6px; }
}

/* ==========================================================================
   Update Stufe 5: Auswahl Karten/Zusammenfassung, Zusammenfassungen, Budget
   ========================================================================== */

/* --- Auswahl Karten vs. Zusammenfassung (Radio-Kacheln) --- */
.job-choice { border: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.job-choice legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 2px; }
.radio-tile {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--surface); border: 2px solid var(--border);
    border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.radio-tile input { width: auto; margin-top: 3px; }
.radio-tile:has(input:checked) { border-color: var(--accent); }
.radio-tile-body { display: grid; gap: 2px; }
.radio-tile-title { font-weight: 700; }
.radio-tile-desc { font-size: .85rem; color: var(--text-muted); }

/* --- Zusammenfassungen --- */
.summary-section { margin: 20px 0; }
.summary-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.summary-head .section-title { margin: 0; }
.summary-head form { margin-left: auto; }
.summary-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.summary-item > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.summary-title { flex: 1; font-weight: 600; }
.summary-body {
    margin: 12px 0 8px; padding: 12px 14px;
    background: var(--surface-2); border-radius: var(--radius);
    line-height: 1.6; white-space: normal;
}

/* --- Budget-Balken --- */
.budget-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin: 12px 0; }
.budget-bar { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; height: 14px; overflow: hidden; }
.budget-bar-sm { height: 10px; width: 120px; }
.budget-fill { display: block; height: 100%; background: var(--accent); border-radius: 20px; transition: width .3s ease; }
.budget-text { margin: 10px 0 4px; }
.budget-cell { display: flex; flex-direction: column; gap: 4px; }
.budget-cell-text { font-size: .8rem; color: var(--text-muted); }

/* ==========================================================================
   Update: Mehrfachauswahl, Drag-and-drop, Material-Ansicht, Quiz
   ========================================================================== */

/* --- Checkbox-Kacheln (Upload) --- */
.check-tile {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--surface); border: 2px solid var(--border);
    border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.check-tile input { width: auto; margin-top: 3px; }
.check-tile:has(input:checked) { border-color: var(--accent); }
.check-tile-body { display: grid; gap: 2px; }
.check-tile-title { font-weight: 700; }
.check-tile-desc { font-size: .85rem; color: var(--text-muted); }

/* --- Schwierigkeit (Pills) --- */
.difficulty-row { display: grid; gap: 6px; }
.difficulty-label { font-weight: 600; font-size: .9rem; }
.difficulty-options { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill span {
    display: inline-block; padding: 8px 16px; border-radius: 20px;
    border: 2px solid var(--border); background: var(--surface);
    cursor: pointer; font-weight: 600; font-size: .9rem;
}
.pill input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }

/* --- Drag-and-drop-Dropzone --- */
.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius-lg);
    background: var(--surface-2); padding: 28px 16px; text-align: center;
    cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); outline: none; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-text, var(--surface)); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.dropzone-inner { display: grid; gap: 6px; justify-items: center; }
.dropzone-icon { font-size: 1.8rem; color: var(--accent); }
.dropzone-text { font-weight: 600; }
.dropzone-link { color: var(--accent); text-decoration: underline; }
.dropzone-hint { font-size: .8rem; color: var(--text-muted); }

/* --- Material-Detailseite --- */
.material-preview { margin: 16px 0; text-align: center; }
.material-preview img { max-width: 100%; max-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); }
.regen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 12px 0; }
.regen-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 10px; margin: 0; }
.regen-card h3 { margin: 0; font-size: 1rem; }
.regen-field { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; }

/* --- Quiz-Erzeugen-Form im Deck --- */
.quiz-section { margin: 20px 0; }
.quiz-create-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.quiz-create-diff { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; }
.quiz-create-diff select { width: auto; }

/* --- Quiz spielen --- */
.quiz-screen { max-width: 620px; margin: 0 auto; }
.quiz-stage { margin-top: 8px; }
.quiz-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; }
.quiz-question { font-size: 1.2rem; font-weight: 600; margin-bottom: 16px; font-family: var(--font-card); }
.quiz-options { display: grid; gap: 10px; }
.quiz-option {
    text-align: left; padding: 14px 16px; border: 2px solid var(--border);
    border-radius: var(--radius); background: var(--surface-2); color: var(--text);
    font: inherit; cursor: pointer; transition: border-color .12s, background .12s;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); }
.quiz-option:disabled { cursor: default; }
.quiz-option.correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.quiz-feedback { margin: 14px 0; padding: 12px 14px; border-radius: var(--radius); font-size: .95rem; }
.quiz-feedback.ok { background: var(--ok-bg); color: var(--ok); }
.quiz-feedback.bad { background: var(--danger-bg); color: var(--danger); }

/* ==========================================================================
   Fix/Update: Kartennavigation (Lernmodus + Deck-Kartenliste)
   ========================================================================== */
.card-nav {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    justify-content: center; margin: 16px 0;
}
.card-nav-arrow {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; color: var(--text);
}
.card-nav-arrow:hover:not(:disabled) { background: var(--surface-2); }
.card-nav-arrow:disabled { opacity: .45; cursor: not-allowed; }
.card-nav-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.card-nav-page {
    min-width: 38px; padding: 8px 10px; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    font: inherit; cursor: pointer; color: var(--text);
}
.card-nav-page:hover:not(.active) { background: var(--surface-2); }
.card-nav-page.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
.card-nav-gap { padding: 0 4px; color: var(--text-muted); }
.card-num { color: var(--text-muted); font-variant-numeric: tabular-nums; margin-right: 2px; }

/* ==========================================================================
   Update: Switches, Ampel, Theme-Toggle, Dateisymbole, Chips, Lern-Start
   ========================================================================== */

/* --- Switches (Upload-Ausgaben) --- */
.switch-group { border: none; padding: 0; margin: 8px 0; display: grid; gap: 10px; }
.switch-group legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 2px; }
.switch-row {
    display: flex; align-items: center; gap: 14px; justify-content: space-between;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 14px 16px; cursor: pointer;
}
.switch-text { display: grid; gap: 2px; }
.switch-title { font-weight: 700; }
.switch-desc { font-size: .85rem; color: var(--text-muted); }
.switch { position: relative; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    display: inline-block; width: 52px; height: 30px; border-radius: 30px;
    background: var(--surface-2); border: 1px solid var(--border);
    position: relative; transition: background .18s, border-color .18s;
}
.switch-thumb {
    position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35);
    transition: transform .18s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Quiz-Optionen (Klasse + Ampel) --- */
.quiz-options-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 14px; }
.grade-field { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; max-width: 260px; }
.difficulty-field { display: grid; gap: 6px; }
.difficulty-label { font-weight: 600; font-size: .9rem; }
.traffic { display: flex; gap: 10px; flex-wrap: wrap; }
.traffic-pill { position: relative; display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-radius: 24px; border: 2px solid var(--border);
    background: var(--surface); cursor: pointer; font-weight: 600; }
.traffic-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.traffic-dot { width: 14px; height: 14px; border-radius: 50%; background: #cbd5e1; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.traffic-green .traffic-dot { background: #22c55e; }
.traffic-yellow .traffic-dot { background: #f5c518; }
.traffic-red .traffic-dot { background: #ef4444; }
.traffic-pill input:checked ~ .traffic-text { color: var(--text); }
.traffic-yellow input:checked ~ .traffic-dot,
.traffic-pill:has(input:checked) { border-color: currentColor; }
.traffic-yellow:has(input:checked) { border-color: #f5c518; }
.traffic-red:has(input:checked) { border-color: #ef4444; }
.traffic-green:has(input:checked) { border-color: #22c55e; }

/* --- Theme-Toggle (hell/dunkel) --- */
.theme-toggle { display: inline-flex; align-items: center; gap: 12px; }
.theme-side {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: none; font: inherit; font-weight: 600;
    color: var(--text-muted); cursor: pointer; padding: 6px 4px;
}
.theme-side.active { color: var(--accent); }
.theme-side-icon { font-size: 1.1rem; }
.theme-toggle-track {
    display: inline-block; width: 60px; height: 32px; border-radius: 32px;
    background: var(--surface-2); border: 1px solid var(--border);
    position: relative; cursor: pointer; transition: background .18s;
}
.theme-toggle-thumb {
    position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
    border-radius: 50%; background: var(--accent); transition: transform .18s;
}
.theme-toggle-track[aria-checked="true"] .theme-toggle-thumb { transform: translateX(28px); }

/* --- Dateityp-Symbole --- */
.filetype {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 42px; height: 30px; padding: 0 6px; border-radius: 6px;
    font-size: .68rem; font-weight: 800; letter-spacing: .03em; color: #fff; flex-shrink: 0;
}
.filetype-pdf { background: #d64545; }
.filetype-png { background: #2563eb; }
.filetype-webp { background: #7c3aed; }
.filetype-img { background: #0891b2; }
h1 .filetype { height: 26px; min-width: 38px; vertical-align: middle; }

/* --- Dropzone-Dateiliste --- */
.dropzone-files { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; text-align: left; }
.dropzone-files li { font-size: .85rem; color: var(--text-muted); padding: 4px 8px; background: var(--surface); border-radius: 6px; }

/* --- Lern-Startseite: Modus-Tabs + Chips --- */
.learn-mode-tabs { display: flex; gap: 8px; margin: 12px 0; }
.learn-mode-tab {
    flex: 1; text-align: center; text-decoration: none; padding: 12px;
    border-radius: var(--radius); border: 2px solid var(--border);
    background: var(--surface); color: var(--text); font-weight: 700;
}
.learn-mode-tab.active { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    text-decoration: none; padding: 8px 14px; border-radius: 20px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-weight: 600; font-size: .9rem;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* --- Hell/Dunkel-Switch im Hauptmenü --- */
.topbar-theme {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 24px; padding: 4px 8px; cursor: pointer;
    color: var(--text-muted); line-height: 1;
}
.topbar-theme:hover { border-color: var(--accent); }
.topbar-theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar-theme-icon { font-size: .95rem; }
.topbar-theme-sun { color: #f5b301; }
.topbar-theme-moon { color: var(--text-muted); }
.topbar-theme-track {
    position: relative; display: inline-block; width: 40px; height: 22px;
    border-radius: 22px; background: var(--surface); border: 1px solid var(--border);
    transition: background .18s, border-color .18s;
}
.topbar-theme-thumb {
    position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: #f5b301; box-shadow: 0 1px 2px rgba(0,0,0,.35);
    transition: transform .18s, background .18s;
}
.topbar-theme.is-dark .topbar-theme-track { background: var(--accent); border-color: var(--accent); }
.topbar-theme.is-dark .topbar-theme-thumb { transform: translateX(18px); background: #cbd5e1; }
.topbar-theme.is-dark .topbar-theme-moon { color: var(--text); }
.topbar-theme.is-dark .topbar-theme-sun { color: var(--text-muted); }

/* --- Upload-Fortschritt --- */
.upload-progress {
    margin-top: 16px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 10px;
}
.progress-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.spinner {
    width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%;
    border: 3px solid var(--surface-2); border-top-color: var(--accent);
    animation: lb-spin .8s linear infinite;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }
.progress-bar {
    height: 12px; border-radius: 12px; background: var(--surface-2);
    overflow: hidden; border: 1px solid var(--border);
}
.progress-fill {
    display: block; height: 100%; width: 8%; background: var(--accent);
    border-radius: 12px; transition: width .4s ease;
}
.progress-detail { font-size: .85rem; }
.upload-progress.is-done .progress-fill { background: var(--ok); }
.upload-progress.is-done .spinner { display: none; }
.upload-progress.is-error .progress-fill { background: var(--danger); }
.upload-progress.is-error .spinner { display: none; }
@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
    .progress-fill { transition: none; }
}

/* --- Erfolge-Seite --- */
.ach-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px; margin: 16px 0 4px;
}
.ach-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px 16px; text-align: center;
    position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.ach-card::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
    background: var(--accent);
}
.ach-accent-blue::before { background: #2563eb; }
.ach-accent-green::before { background: #16a34a; }
.ach-accent-purple::before { background: #7c3aed; }
.ach-accent-gold::before { background: #f5b301; }
.ach-icon { font-size: 1.6rem; margin-bottom: 4px; }
.ach-num { font-size: 1.7rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.ach-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

.ach-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow);
}

/* Aktivitäts-Verlauf */
.activity-chart {
    display: flex; align-items: flex-end; gap: 6px; height: 120px;
}
.activity-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.activity-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.activity-bar {
    display: block; width: 70%; max-width: 22px; min-height: 4px;
    background: var(--accent); border-radius: 4px 4px 0 0;
}
.activity-bar.is-empty { background: var(--surface-2); }
.activity-day { font-size: .7rem; color: var(--text-muted); }
.activity-legend { margin-top: 10px; font-size: .8rem; text-align: center; }

/* Trefferquote je Fach */
.subject-bar-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.subject-bar-row:last-child { border-bottom: none; }
.subject-bar-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.subject-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.subject-bar-name { font-weight: 600; }
.subject-bar-val { margin-left: auto; font-weight: 700; }
.subject-bar-track {
    height: 10px; border-radius: 10px; background: var(--surface-2);
    overflow: hidden; border: 1px solid var(--border);
}
.subject-bar-fill { display: block; height: 100%; border-radius: 10px; background: var(--accent); }
.subject-bar-meta { font-size: .8rem; margin-top: 4px; }

/* Pills in den Listen */
.ach-pill {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    min-width: 52px; padding: 6px 10px; border-radius: 20px;
    font-weight: 700; font-size: .85rem; border: 1px solid var(--border);
}
.ach-pill-good { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.ach-pill-mid { background: var(--warn-bg); color: #b45309; border-color: #f5c518; }
.ach-pill-warn { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.ach-pill-new { background: var(--surface-2); color: var(--accent); border-color: var(--accent); }

/* --- Backups (Admin) --- */
.backup-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px; margin: 16px 0;
}
.backup-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px; display: flex;
    flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.backup-card-complete { border-color: var(--accent); }
.backup-head { display: flex; align-items: center; gap: 10px; }
.backup-icon { font-size: 1.5rem; }
.backup-title { font-weight: 700; font-size: 1.05rem; }
.backup-desc { color: var(--text-muted); font-size: .9rem; margin: 0; flex: 1; }
.backup-card .btn { margin-top: auto; }

/* --- Persönliche Begrüßung (Startseite) --- */
.greeting {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 22px; margin: 4px 0 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}
.greeting-special { border-left-color: #7c3aed; }
.greeting-hello { font-size: 1.5rem; margin: 0 0 2px; }
.greeting-day { color: var(--text-muted); margin: 0 0 10px; font-size: .95rem; }
.greeting-text { margin: 0 0 8px; line-height: 1.55; }
.greeting-text:last-child { margin-bottom: 0; }

/* --- FAQ / Hilfe --- */
.lead { font-size: 1.05rem; line-height: 1.6; margin: 4px 0 16px; }
.faq-toc {
    display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px;
    padding: 12px; background: var(--surface-2); border-radius: var(--radius-lg);
}
.faq-toc a {
    text-decoration: none; color: var(--accent); font-weight: 600; font-size: .9rem;
    padding: 4px 10px; border-radius: 16px; background: var(--surface);
    border: 1px solid var(--border);
}
.faq-toc a:hover { border-color: var(--accent); }
.faq-section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px 20px; margin: 0 0 14px;
    scroll-margin-top: 80px;
}
.faq-section h2 { margin: 0 0 8px; }
.faq-section p { line-height: 1.6; margin: 0 0 10px; }
.faq-section .btn { margin-top: 4px; }
.faq-step-list { margin: 8px 0 0; padding-left: 20px; line-height: 1.7; }
.faq-step-list li { margin-bottom: 8px; }

/* --- Besondere Lernmotivation --- */
.special-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.special-chip {
    display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 16px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: .82rem; font-weight: 600; color: var(--text);
}

/* ========================================================================
   Deck-Reiter (Alles / Karten / Quizze) + Lern-Einstiege + Erstellen-Menü
   ======================================================================== */
.deck-tabs {
    display: flex;
    gap: 4px;
    margin: 14px 0 18px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.deck-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.deck-tab:hover { color: var(--text); }
.deck-tab.is-active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-soft);
}
.deck-tab-count {
    font-size: .72rem;
    font-weight: 700;
    background: var(--chip);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 7px;
    color: var(--text-muted);
}
.deck-tab.is-active .deck-tab-count { color: var(--accent); border-color: var(--accent-dim); }

/* Große Lern-Einstiege im Reiter "Alles" */
.learn-launch {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.launch-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.launch-card:hover { box-shadow: var(--shadow-lg); }
.launch-card:active { transform: translateY(1px); }
.launch-card--due { border-color: var(--accent); }
.launch-card--empty {
    cursor: default;
    opacity: .6;
    box-shadow: none;
}
.launch-emoji { font-size: 1.7rem; line-height: 1; flex-shrink: 0; }
.launch-text { display: grid; gap: 2px; }
.launch-title { font-weight: 700; font-size: 1.05rem; }
.launch-sub { font-size: .85rem; color: var(--text-muted); }
.launch-card--due .launch-sub { color: var(--accent); font-weight: 600; }

.deck-overview { margin: 4px 0 20px; }

/* Aktionsleiste je Reiter */
.pane-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* Erstellen-Menü (kleines Auswahlmenü) */
.create-menu { position: relative; }
.create-menu > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.create-menu > summary::-webkit-details-marker { display: none; }
.create-menu-pop {
    margin-top: 8px;
    display: grid;
    gap: 4px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 460px;
}
.create-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}
a.create-option:hover,
details.add-panel--nested > summary.create-option:hover { background: var(--surface-2); }
.create-option--soon { color: var(--text-dim); cursor: default; }
.soon-tag {
    font-size: .68rem;
    font-weight: 700;
    background: var(--chip);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1px 8px;
    color: var(--text-muted);
}
.add-panel--nested { margin: 0; }
.add-panel--nested > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}
.add-panel--nested > summary::-webkit-details-marker { display: none; }
.add-panel--nested > summary::after { content: "▾"; color: var(--text-dim); }
.add-panel--nested[open] > summary::after { content: "▴"; }
.add-panel--nested > .form,
.add-panel--nested > .quiz-create-form { padding: 6px 12px 10px; }

/* Quiz-Version + Erstellzeit in der Quizliste */
.quiz-version {
    font-size: .72rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 20px;
    padding: 1px 8px;
    margin-left: 4px;
    vertical-align: middle;
}
.quiz-created {
    display: block;
    width: 100%;
    font-size: .74rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ========================================================================
   Papierkorb
   ======================================================================== */
.trash-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 12px 0;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.trash-selectall {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-right: auto;
}
.trash-list { display: grid; gap: 8px; margin: 12px 0; }
.trash-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: pointer;
}
.trash-check { flex-shrink: 0; margin: 0; }
.trash-body { min-width: 0; display: grid; gap: 2px; }
.trash-line1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.trash-line1 .badge { flex-shrink: 0; }
.trash-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-context { font-size: .8rem; color: var(--text-muted); }
.trash-daysleft {
    font-size: .75rem;
    color: var(--text-dim);
    white-space: nowrap;
    text-align: right;
}
@media (max-width: 460px) {
    .trash-title { white-space: normal; }
}
