:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --text: #1c1c1e;
    --muted: #6b6b73;
    --border: #e1e1e6;
    --accent: #c62828;
    --accent-text: #ffffff;
    --accent-soft: #fdecea;
    --ok: #2e7d32;
    --ok-soft: #e8f5e9;
    --bad: #c62828;
    --bad-soft: #fdecea;
    --warn: #ef8f00;
    --radius: 14px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121214;
        --surface: #1e1e22;
        --text: #f2f2f5;
        --muted: #a0a0aa;
        --border: #34343a;
        --accent: #ef5350;
        --accent-text: #ffffff;
        --accent-soft: #3a1f1f;
        --ok: #66bb6a;
        --ok-soft: #1f3322;
        --bad: #ef5350;
        --bad-soft: #3a1f1f;
        --warn: #ffb74d;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }

.appbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.appbar nav { display: flex; gap: 2px; overflow-x: auto; }
.appbar nav a {
    padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 0.95rem;
}
.appbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.content { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 1.5rem; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 0;
}

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 10px 16px;
    border: 1px solid var(--accent); border-radius: 10px;
    background: var(--accent); color: var(--accent-text);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button.ghost { background: transparent; border-color: var(--border); color: var(--text); }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row > * { flex: 1 1 140px; }

input[type=text], input[type=password], textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); color: var(--text); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
label.field { display: block; font-weight: 600; font-size: 0.9rem; margin: 10px 0 4px; }

/* topic tiles on the home page */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.topic { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.topic h2 { display: flex; gap: 8px; align-items: center; }
.topic .btn-row { margin-top: auto; }
.topic .btn-row > * { flex: 1 1 90px; min-height: 40px; padding: 8px 10px; }

.progress { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.progress .sicher { background: var(--ok); }
.progress .lernend { background: var(--warn); }

.exam-card { background: var(--accent); color: var(--accent-text); border: none; }
.exam-card .muted { color: inherit; opacity: 0.85; }
.exam-card button { background: var(--accent-text); color: var(--accent); border-color: var(--accent-text); }

/* choice lists (onboarding, profile) */
.choices { display: grid; gap: 8px; }
.choice {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.choice b { display: block; }

/* quiz */
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.question { font-size: 1.15rem; font-weight: 600; margin: 8px 0 14px; }
.answers { display: grid; gap: 8px; }
.answer {
    justify-content: flex-start; text-align: left; font-weight: 500;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.answer:disabled { opacity: 1; cursor: default; }
.answer:disabled:not(.correct):not(.wrong) { color: var(--muted); }
.answer.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
.answer.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }
.feedback { margin-top: 12px; padding: 12px; border-radius: 10px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.flashcard-back { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.8rem; font-weight: 600; }
.result { font-size: 2.2rem; font-weight: 700; margin: 4px 0; }

/* progress table */
.stat-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-row .progress { grid-column: 1 / -1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

/* Beladung editor */
.fach { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 10px; }
.fach-head { display: flex; gap: 8px; align-items: center; }
.fach-head input { flex: 1; }
.icon-btn { min-height: 40px; min-width: 40px; padding: 6px 10px; }
details summary { cursor: pointer; font-weight: 600; }

/* login, registration, account */
[hidden] { display: none !important; }
.auth { max-width: 420px; margin: 0 auto; }
.form .btn-row { margin-top: 16px; }
.fehler { color: var(--bad); font-weight: 600; margin: 10px 0 0; }
.status {
    padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
    background: var(--warn); color: #1c1c1e;
}
.sticky-save { position: sticky; bottom: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }
.sticky-save p { margin: 0; }

/* admin */
.user-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row .btn-row { margin-top: 8px; }
.user-row .btn-row > * { flex: 0 1 auto; min-height: 38px; padding: 6px 12px; font-size: 0.9rem; }
