/* Führerschein Theorie — dark, high-contrast, built for phone-first practice.
   The palette is deliberately calm: the only saturated colours are the verdict
   states, so a right or wrong answer is unmistakable at a glance. */

:root {
    --bg: #0e1116;
    --surface: #161b23;
    --surface-2: #1d232d;
    --border: #2a323e;
    --text: #e8edf4;
    --text-dim: #97a3b4;
    --accent: #4c8dff;
    --accent-dim: #2f5fb0;
    --ok: #35c07a;
    --ok-dim: #1b5f3c;
    --bad: #ff5f57;
    --bad-dim: #6b2320;
    --warn: #f0b429;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 28px rgba(0, 0, 0, .38);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
}

/* ---------- top bar ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font-weight: 650; }
.brand__mark {
    display: grid; place-items: center;
    width: 30px; height: 30px;
    background: var(--accent); color: #fff;
    border-radius: 9px; font-size: 18px; font-weight: 700;
}
.brand__text { letter-spacing: .2px; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav__link {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
    font-size: 15px;
}
.nav__link:hover { color: var(--text); background: var(--surface-2); }
.nav__link--active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }

.topbar__right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.langswitch { display: flex; gap: 2px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; }
.langswitch__btn {
    padding: 4px 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}
.langswitch__btn:hover { color: var(--text); }
.langswitch__btn--active { background: var(--accent); color: #fff; }

.avatar {
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--border);
}

/* ---------- layout ---------- */

.main {
    max-width: 780px;
    margin: 0 auto;
    padding: 22px 18px 60px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.footer {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 18px 40px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--text-dim);
    font-size: 13px;
}

/* ---------- cards ---------- */

.card, .question, .tutor, .sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card--narrow { max-width: 440px; margin: 0 auto; width: 100%; }
.card__title { margin: 0 0 8px; font-size: 21px; letter-spacing: -.2px; }
.card__lead { margin: 0 0 16px; color: var(--text-dim); }

/* ---------- alerts ---------- */

.alert {
    max-width: 780px;
    margin: 14px auto 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: baseline;
    font-size: 15px;
}
.alert--error { background: var(--bad-dim); border: 1px solid var(--bad); }
.alert--warning { background: #4a3a12; border: 1px solid var(--warn); }
.alert__title { font-weight: 650; }
.alert__message { color: var(--text); opacity: .92; }
.alert__detail { width: 100%; }
.alert__detail pre { white-space: pre-wrap; font-size: 13px; margin: 8px 0 0; }
.alert__link { color: var(--text); }

.flash { max-width: 780px; margin: 14px auto 0; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------- question ---------- */

.question__meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }

.chip {
    padding: 3px 9px;
    border-radius: 100px;
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 12.5px;
    box-shadow: inset 0 0 0 1px var(--border);
}
.chip--id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.chip--why { color: var(--accent); }
.chip--warn { background: #4a3a12; color: #f2d99a; box-shadow: inset 0 0 0 1px var(--warn); }
.chip--ok { background: var(--ok-dim); color: #bdf0d4; }
.chip--state { background: var(--accent-dim); color: #dfe9ff; }
.chip--ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.question__text { margin: 0 0 14px; font-size: 20px; line-height: 1.4; letter-spacing: -.2px; }
.question__original { margin: -8px 0 14px; color: var(--text-dim); font-size: 15px; }

.media { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.media__image, .media__video { width: 100%; border-radius: var(--radius-sm); background: #000; }
.media__hint { margin: 0; color: var(--text-dim); font-size: 13px; }

/* ---------- options ---------- */

.options { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 9px; }

.option {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: #3d4756; }
.option__label { display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px; cursor: pointer; }
.option__label input { margin: 3px 0 0; width: 19px; height: 19px; accent-color: var(--accent); flex: none; }
.option__letter { font-weight: 650; color: var(--text-dim); min-width: 16px; }
.option__text { flex: 1; }
.option__original { display: block; margin-top: 3px; color: var(--text-dim); font-size: 13.5px; }
.option__image { max-width: 190px; border-radius: 6px; background: #fff; padding: 6px; }

.option--correct { border-color: var(--ok); background: var(--ok-dim); }
.option--wrong { border-color: var(--bad); background: var(--bad-dim); }

.numeric { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.numeric__label { color: var(--text-dim); font-size: 14px; }
.numeric__input, .field__input, .field__textarea, .select {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}
.numeric__input:focus, .field__input:focus, .field__textarea:focus, .select:focus {
    outline: none; border-color: var(--accent);
}
.numeric__key { color: var(--text-dim); }

.hint { color: var(--text-dim); font-size: 14px; margin: 6px 0 0; }

/* ---------- verdict ---------- */

.verdict { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.verdict--right { background: var(--ok-dim); border: 1px solid var(--ok); }
.verdict--wrong { background: var(--bad-dim); border: 1px solid var(--bad); }

.explanation { margin: 14px 0; padding: 12px 15px; background: var(--surface-2); border-radius: var(--radius-sm); }
.explanation summary { cursor: pointer; color: var(--text-dim); }
.explanation p { margin: 10px 0 0; }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { border-color: #3d4756; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #3f7ff0; border-color: #3f7ff0; }
.btn--ghost { background: transparent; }
.btn--small { padding: 6px 12px; font-size: 14px; }
.btn--wide { width: 100%; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.inline { display: inline; }

/* ---------- forms ---------- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { color: var(--text-dim); font-size: 14px; }
.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- sidebar ---------- */

.sidebar__title { margin: 0 0 12px; font-size: 16px; }
.sidebar__form { display: flex; gap: 9px; flex-wrap: wrap; }
.sidebar__form .select { flex: 1; min-width: 200px; }
.sidebar__links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- tutor ---------- */

.tutor__header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tutor__title { margin: 0; font-size: 20px; }

.evidence { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.evidence__item {
    padding: 5px 11px;
    border-radius: 100px;
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 13px;
    box-shadow: inset 0 0 0 1px var(--border);
}
.evidence__item--done { background: var(--ok-dim); color: #bdf0d4; box-shadow: inset 0 0 0 1px var(--ok); }

.original { margin-bottom: 16px; padding: 12px 15px; background: var(--surface-2); border-radius: var(--radius-sm); }
.original summary { cursor: pointer; color: var(--text-dim); }
.original__answers { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 5px; }
.original__answer--correct { color: #9ce6bd; }

.dialogue { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.turn { padding: 12px 15px; border-radius: var(--radius-sm); background: var(--surface-2); }
.turn--user { background: var(--accent-dim); }
.turn--system { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); font-size: 14px; }
.turn__text { margin: 0; white-space: pre-wrap; }

.generated { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.generated__badge { display: inline-block; padding: 2px 8px; border-radius: 100px; background: var(--warn); color: #221a05; font-size: 12px; font-weight: 600; }
.generated__text { margin: 9px 0; }
.generated__answers { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; color: var(--text-dim); }
.generated__verdict { margin: 9px 0 0; color: var(--ok); }

.refs { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.refs__label { color: var(--text-dim); font-size: 14px; }

.terms { margin-bottom: 16px; }
.terms__title { font-size: 15px; margin: 0 0 8px; }
.terms dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.terms dt { font-weight: 600; }
.terms dd { margin: 0; color: var(--text-dim); }

.tutor__done { padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm); }

/* ---------- exam ---------- */

.exam__progress { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; color: var(--text-dim); font-size: 14px; }
.progressbar { height: 5px; border-radius: 100px; background: var(--surface-2); overflow: hidden; }
.progressbar__fill { height: 100%; background: var(--accent); }

.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 3px; }
.stat__value { font-size: 25px; font-weight: 650; letter-spacing: -.5px; }
.stat__label { color: var(--text-dim); font-size: 13px; }
.result__reason { color: var(--bad); }

.wrong-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.wrong-item { padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.wrong-item__head { display: flex; gap: 7px; margin-bottom: 8px; }
.wrong-item__text { margin: 0 0 8px; }

/* ---------- tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; padding: 9px 8px; color: var(--text-dim); font-weight: 550; border-bottom: 1px solid var(--border); font-size: 13px; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

.badge { padding: 2px 9px; border-radius: 100px; background: var(--surface-2); font-size: 13px; }
.badge--ok { background: var(--ok-dim); color: #bdf0d4; }
.badge--fail { background: var(--bad-dim); color: #ffc9c5; }

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

.mastery { height: 6px; border-radius: 100px; background: var(--surface-2); overflow: hidden; min-width: 90px; }
.mastery__fill { height: 100%; background: var(--text-dim); }
.mastery--solid .mastery__fill { background: var(--ok); }
.mastery--fair .mastery__fill { background: var(--warn); }
.mastery--weak .mastery__fill { background: var(--bad); }
.mastery__value { font-size: 13px; color: var(--text-dim); }

.activity { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.activity__bar { flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.activity__fill { width: 100%; background: var(--accent); border-radius: 3px; }

.pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 13px; margin: 0; }

/* ---------- landing ---------- */

.landing { padding: 26px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.landing__title { margin: 0 0 12px; font-size: 27px; line-height: 1.2; letter-spacing: -.5px; }
.landing__lead { margin: 0 0 18px; color: var(--text-dim); }
.landing__points { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-direction: column; gap: 11px; }
.landing__points li { padding-left: 20px; position: relative; }
.landing__points li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }

.magic-link { word-break: break-all; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); }
.magic-link a { color: var(--accent); }

@media (max-width: 560px) {
    .topbar { padding: 10px 12px; gap: 10px; }
    .brand__text { display: none; }
    .main { padding: 16px 12px 48px; }
    .question__text { font-size: 18px; }
    .card, .question, .tutor, .sidebar { padding: 16px; }
}
