:root {
    --bg:        #0e0b16;
    --bg-2:      #16111f;
    --card:      #1c1526;
    --card-2:    #241a30;
    --border:    #2f2440;
    --text:      #ece7f5;
    --muted:     #9a8fb0;
    --purple:    #a855f7;
    --purple-2:  #7c3aed;
    --purple-dk: #5b21b6;
    --green:     #22c55e;
    --green-bg:  rgba(34,197,94,.12);
    --red:       #ef4444;
    --red-bg:    rgba(239,68,68,.12);
    --shadow:    0 10px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(1100px 600px at 100% -10%, rgba(124,58,237,.18), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(168,85,247,.12), transparent 55%),
        var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
}

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ---------- Header ---------- */
.app-header {
    text-align: center;
    padding: 26px 16px 10px;
}
.app-header .badge {
    display: inline-block;
    font-size: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--purple);
    background: rgba(168,85,247,.10);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 12px;
}
.app-header h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.5px;
    background: linear-gradient(90deg, #fff, var(--purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.app-header p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Meta-Leiste ---------- */
.meta {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 18px 0 8px;
}
.meta .chip {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--muted);
}
.meta .chip b { color: var(--text); }

/* ---------- Fortschritt ---------- */
.progress-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 6px;
    background: var(--bg-2);
}
.progress-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--purple-2), var(--purple));
    transition: width .25s ease;
}

/* ---------- Karten ---------- */
.card {
    background: linear-gradient(180deg, var(--card), var(--card-2));
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 16px;
    margin: 14px 0;
    box-shadow: var(--shadow);
}

.q-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.q-num {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--purple-2), var(--purple));
}
.q-cat {
    font-size: 11px;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--purple);
}
.q-text {
    font-size: 16.5px;
    font-weight: 600;
    margin: 0 0 14px;
}

/* ---------- Multiple Choice ---------- */
.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    margin: 9px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-2);
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .05s;
    user-select: none;
}
.option:active { transform: scale(.99); }
.option input { display: none; }
.option .mark {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: grid; place-items: center;
    transition: border-color .15s;
}
.option .mark::after {
    content: "";
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--purple);
    transform: scale(0);
    transition: transform .15s;
}
.option input:checked ~ .mark { border-color: var(--purple); }
.option input:checked ~ .mark::after { transform: scale(1); }
.option:has(input:checked) {
    border-color: var(--purple);
    background: rgba(168,85,247,.10);
}
.option .label { font-size: 15px; }

/* ---------- Freitext ---------- */
.text-input {
    width: 100%;
    padding: 13px 14px;
    font-size: 16px;
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.text-input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(168,85,247,.18);
}
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--purple-2), var(--purple));
    border: none;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(124,58,237,.35);
    transition: transform .06s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn.secondary {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: none;
    color: var(--text);
}

.submit-wrap { margin: 22px 0 10px; }

/* ---------- Ergebnis ---------- */
.result-hero {
    text-align: center;
    padding: 26px 18px;
    border-radius: 20px;
    margin: 10px 0 18px;
    border: 1px solid var(--border);
}
.result-hero.pass { background: linear-gradient(180deg, rgba(34,197,94,.14), var(--card)); }
.result-hero.fail { background: linear-gradient(180deg, rgba(239,68,68,.14), var(--card)); }
.result-hero .status { font-size: 24px; font-weight: 800; margin: 6px 0; }
.result-hero.pass .status { color: var(--green); }
.result-hero.fail .status { color: var(--red); }

.score-ring {
    --p: 0;
    width: 128px; height: 128px;
    border-radius: 50%;
    margin: 6px auto 14px;
    display: grid; place-items: center;
    background: conic-gradient(var(--purple) calc(var(--p) * 1%), var(--border) 0);
    position: relative;
}
.score-ring::before {
    content: "";
    position: absolute; inset: 10px;
    border-radius: 50%;
    background: var(--card);
}
.score-ring .val { position: relative; font-size: 30px; font-weight: 800; }
.score-ring .val small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }

.result-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.result-stats .s {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
    min-width: 92px;
}
.result-stats .s .n { font-size: 22px; font-weight: 800; }
.result-stats .s.correct .n { color: var(--green); }
.result-stats .s.wrong   .n { color: var(--red); }
.result-stats .s .l { font-size: 12px; color: var(--muted); }

.review-title {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 26px 0 6px;
}

.card.correct { border-color: rgba(34,197,94,.45); }
.card.wrong   { border-color: rgba(239,68,68,.45); }

.answer-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 10px;
    margin-top: 8px;
}
.answer-row.given.ok  { background: var(--green-bg); }
.answer-row.given.bad { background: var(--red-bg); }
.answer-row.solution  { background: var(--green-bg); }
.answer-row .k { color: var(--muted); flex: 0 0 auto; min-width: 108px; }
.answer-row .v { font-weight: 600; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tag.ok  { background: var(--green-bg); color: var(--green); }
.tag.bad { background: var(--red-bg);   color: var(--red); }

.explanation {
    font-size: 13.5px;
    color: var(--muted);
    margin-top: 10px;
    padding-left: 12px;
    border-left: 2px solid var(--purple);
}

/* ---------- Setup-Seite Helfer ---------- */
.ok   { color: var(--green); }
.warn { color: #eab308; }
.err  { color: var(--red); }
code  { background: var(--bg-2); padding: 2px 6px; border-radius: 6px; }

footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }

@media (min-width: 560px) {
    .app-header h1 { font-size: 30px; }
}

/* ---------- Personalisierung / Motivation ---------- */
.app-header .subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.app-header .subtitle b { color: var(--text); }
.app-header .motivation {
    margin: 14px auto 0;
    max-width: 520px;
    font-size: 14.5px;
    color: var(--text);
    background: rgba(168,85,247,.12);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
}
.result-hero .hero-msg {
    font-size: 15px;
    color: var(--text);
    max-width: 460px;
    margin: 2px auto 10px;
    line-height: 1.5;
}
.saved-note {
    font-size: 13px;
    color: var(--muted);
    margin: 6px 0 0;
}
.saved-note a { color: var(--purple); }

/* ---------- "Warum falsch" + Quelle ---------- */
.why {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.30);
    border-radius: 12px;
}
.why-head { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.why p { margin: 4px 0 0; font-size: 14px; color: var(--text); }
.why .reference {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
    color: var(--muted);
}
.why .reference b { color: var(--text); }

/* ---------- Verlaufsliste ---------- */
.history-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.history-item {
    display: flex;
    align-items: stretch;
    background: linear-gradient(180deg, var(--card), var(--card-2));
    border: 1px solid var(--border);
    border-left: 4px solid var(--purple);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.history-item.pass { border-left-color: var(--green); }
.history-item.fail { border-left-color: var(--red); }
.history-item .hi-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    transition: background .12s;
}
.history-item .hi-main:active { background: rgba(168,85,247,.08); }
.history-item .hi-date { font-weight: 700; font-size: 15px; }
.history-item .hi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.history-item .hi-pct { font-size: 22px; font-weight: 800; }
.history-item .hi-pct.ok { color: var(--green); }
.history-item .hi-pct.bad { color: var(--red); }
.history-item .hi-del { display: flex; margin: 0; }
.del-btn {
    background: transparent;
    border: none;
    border-left: 1px solid var(--border);
    color: var(--muted);
    font-size: 17px;
    padding: 0 16px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.del-btn:hover, .del-btn:active { color: var(--red); background: rgba(239,68,68,.12); }

.btn.danger {
    background: linear-gradient(135deg, #b91c1c, var(--red));
    box-shadow: 0 8px 20px rgba(239,68,68,.30);
}

/* ---------- Chaka-Zeile ---------- */
.app-header .cheer {
    margin: 12px auto 0;
    max-width: 520px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .2px;
    color: #fff;
    background: linear-gradient(135deg, var(--purple-2), var(--purple));
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 8px 20px rgba(124,58,237,.30);
}

/* ---------- Mehrfachauswahl ---------- */
.multi-note {
    display: inline-block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--purple);
    background: rgba(168,85,247,.12);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 12px;
    margin: 0 0 10px;
}
.option .mark.box { border-radius: 6px; }
.option .mark.box::after {
    content: "";
    width: 6px; height: 11px;
    border: solid var(--purple);
    border-width: 0 3px 3px 0;
    border-radius: 1px;
    background: transparent;
    margin-top: -2px;
    transform: rotate(45deg) scale(0);
}
.option input:checked ~ .mark.box { border-color: var(--purple); }
.option input:checked ~ .mark.box::after { transform: rotate(45deg) scale(1); }
