/* SprachLernApp – mobile-first, hell und dunkel */

:root {
    color-scheme: light dark;

    --rot: #b3122c;
    --rot-dunkel: #8d0d22;
    --bg: #f5f5f7;
    --bg-karte: #ffffff;
    --text: #1c1c1e;
    --text-leise: #6b6b70;
    --linie: #e3e3e8;
    --gruen: #1f8a4c;
    --gelb: #b8860b;
    --radius: 14px;
    --safe-unten: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101013;
        --bg-karte: #1c1c20;
        --text: #f2f2f5;
        --text-leise: #9a9aa2;
        --linie: #2e2e35;
        --rot: #e0546c;
        --rot-dunkel: #c23a53;
        --gruen: #3fbb74;
        --gelb: #d8a72a;
    }
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss immer gewinnen – sonst überschreiben Regeln wie
   .btn { display: inline-block } es und ausgeblendete Knöpfe bleiben sichtbar. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

/* Kopf- und Fußleiste ------------------------------------------------ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
    background: var(--rot);
    color: #fff;
}

.brand { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; }
.topbar-user { color: #fff; opacity: .85; text-decoration: none; font-size: .9rem; }

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px calc(96px + var(--safe-unten));
}

.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex;
    background: var(--bg-karte);
    border-top: 1px solid var(--linie);
    padding-bottom: var(--safe-unten);
    z-index: 20;
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 10px;
    font-size: .72rem;
    color: var(--text-leise);
    text-decoration: none;
}

.tabbar a.active { color: var(--rot); font-weight: 600; }
.tab-icon { font-size: 1.15rem; line-height: 1; }

/* Bausteine ----------------------------------------------------------- */

h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }

a { color: var(--rot); }
.muted { color: var(--text-leise); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.due { color: var(--rot); }

.card {
    background: var(--bg-karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--linie);
    color: var(--text-leise);
    font-size: .72rem;
    vertical-align: middle;
}

/* Formulare ----------------------------------------------------------- */

label { display: block; font-size: .85rem; color: var(--text-leise); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=file], textarea, select {
    width: 100%;
    margin-top: 4px;
    padding: 12px;
    font-size: 16px; /* verhindert das Zoomen auf iOS */
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--linie);
    border-radius: 10px;
}

textarea { resize: vertical; }

.switch { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text); }
.switch input { width: 20px; height: 20px; margin: 0; }

.btn {
    display: inline-block;
    padding: 12px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--linie);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--rot); color: #fff; }
.btn-primary:active { background: var(--rot-dunkel); }
.btn-ghost { background: transparent; border-color: var(--linie); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--rot); color: var(--rot); }
.btn-big { display: block; width: 100%; padding: 16px; font-size: 1.05rem; margin: 6px 0 4px; }
.btn-mini { padding: 6px 10px; font-size: .8rem; font-weight: 500; }

/* Meldungen ----------------------------------------------------------- */

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: .92rem;
    border: 1px solid var(--linie);
    background: var(--bg-karte);
}

.flash-success { border-color: var(--gruen); color: var(--gruen); }
.flash-error { border-color: var(--rot); color: var(--rot); }

/* Anmeldung ----------------------------------------------------------- */

.auth-card {
    background: var(--bg-karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 24px;
}

/* Kacheln und Fortschritt --------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }

.tile {
    background: var(--bg-karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-align: center;
}

.tile-value { display: block; font-size: 1.6rem; font-weight: 700; }
.tile-label { display: block; font-size: .75rem; color: var(--text-leise); }

.goal-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: .9rem; }

.progress { height: 10px; background: var(--linie); border-radius: 999px; overflow: hidden; }
.progress.slim { height: 5px; margin-bottom: 18px; }
.progress-bar { height: 100%; background: var(--rot); transition: width .3s ease; }

/* Balkengrafiken ------------------------------------------------------ */

.boxbars, .daybars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.boxbar, .daybar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.boxbar-track, .daybar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }

.boxbar-fill, .daybar-fill {
    width: 100%;
    min-height: 2px;
    background: var(--rot);
    border-radius: 4px 4px 0 0;
}

.boxbar-count { font-size: .75rem; font-weight: 600; }
.boxbar-label, .daybar-label { font-size: .7rem; color: var(--text-leise); }

/* Listen und Tabellen ------------------------------------------------- */

.list { list-style: none; padding: 0; margin: 0; }

.list li { border-bottom: 1px solid var(--linie); }
.list li:last-child { border-bottom: none; }

.list a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 2px;
    text-decoration: none;
    color: var(--text);
}

.list-title { font-weight: 600; }
.list-meta { font-size: .8rem; color: var(--text-leise); }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; color: var(--text-leise); padding: 8px 6px; }
.table td { padding: 10px 6px; border-top: 1px solid var(--linie); vertical-align: top; }

.speak-link {
    border: none;
    background: none;
    padding: 0 4px 0 0;
    font-size: 1rem;
    cursor: pointer;
}

.box-chip {
    display: inline-block;
    min-width: 54px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--linie);
    color: var(--text-leise);
    font-size: .72rem;
    text-align: center;
}

.box-4, .box-5, .box-6 { background: color-mix(in srgb, var(--gruen) 18%, transparent); color: var(--gruen); }
.box-1, .box-2, .box-3 { background: color-mix(in srgb, var(--gelb) 18%, transparent); color: var(--gelb); }

/* Lernkarte ----------------------------------------------------------- */

.session-head { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 8px; }

.flashcard {
    background: var(--bg-karte);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 28px 20px 18px;
    min-height: 210px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
}

.flashcard-kicker { font-size: .72rem; color: var(--text-leise); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 12px; }
.flashcard-front { font-size: 1.9rem; font-weight: 600; margin: 0; line-height: 1.25; }
.flashcard-hint { font-size: .85rem; color: var(--text-leise); margin: 10px 0 0; }
.flashcard-back { font-size: 1.35rem; margin: 0; }
.flashcard-example { font-size: .9rem; color: var(--text-leise); margin: 10px 0 0; font-style: italic; }
.flashcard hr { border: none; border-top: 1px solid var(--linie); margin: 18px 0; }

.tts-row { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.tts-row .btn { padding: 8px 14px; font-size: .85rem; font-weight: 500; }

/* Abstand zur Karte: die Bewertung soll nicht direkt unter dem Text kleben,
   sonst tippt man beim Aufdecken versehentlich schon eine Bewertung an. */
.answer-bar { margin-top: 28px; }
.answer-bar .btn-reveal { display: block; width: 100%; padding: 16px; background: var(--rot); color: #fff; }

.rating-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rating-row .btn { padding: 16px 6px; }
.btn-again { background: color-mix(in srgb, var(--rot) 15%, transparent); color: var(--rot); }
.btn-good { background: var(--rot); color: #fff; }
.btn-easy { background: color-mix(in srgb, var(--gruen) 15%, transparent); color: var(--gruen); }

.session-options { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }

/* Lückentext ---------------------------------------------------------- */

.flashcard-front .gap {
    display: inline-block;
    min-width: 2.2em;
    padding: 0 .15em;
    border-bottom: 3px solid var(--rot);
    color: var(--rot);
    line-height: 1.1;
}

/* Nach der Antwort steht die Lösung direkt am Wortstamm: sklep|u → sklepu */
.flashcard-front .gap.gap-filled {
    min-width: 0;
    padding: 0;
    border-color: var(--gruen);
    color: var(--gruen);
}

.flashcard-context { font-size: .95rem; color: var(--text-leise); margin: 12px 0 0; }

.cloze-choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 22px;
}

.cloze-choice {
    padding: 14px 8px;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--bg);
    border: 2px solid var(--linie);
    color: var(--text);
}

.cloze-choice:disabled { cursor: default; opacity: .55; }
.cloze-choice.is-right { border-color: var(--gruen); color: var(--gruen); opacity: 1; }
.cloze-choice.is-wrong { border-color: var(--rot); color: var(--rot); opacity: 1; text-decoration: line-through; }

.cloze-feedback { font-weight: 600; margin: 16px 0 0; }
.cloze-feedback.is-right { color: var(--gruen); }
.cloze-feedback.is-wrong { color: var(--rot); }

.flashcard-rule { font-size: .92rem; margin: 0; }

.rating-row.is-single { grid-template-columns: 1fr; }
.rating-row.is-double { grid-template-columns: repeat(2, 1fr); }

.gap-filled { color: var(--rot); }

/* Kursliste nach Niveau --------------------------------------------- */

.level-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 28px 0 10px;
}

.level-head h2 { margin: 0; }

/* Tastaturbedienung am Rechner */
@media (min-width: 720px) {
    .rating-row .btn::after {
        display: block;
        font-size: .68rem;
        font-weight: 400;
        opacity: .7;
    }
    .btn-again::after { content: "1"; }
    .btn-good::after { content: "2"; }
    .btn-easy::after { content: "3"; }
}
