/* BlaulichtIQ – Web-Testversion.
   Farben, Formen und Schriftgrößen wie app-blaulichtiq (ui/theme/Color.kt, Theme.kt, Material 3).
   1 dp ≙ 1 CSS-Pixel. Die App ist für Handy-Hochformat gebaut – am PC als mittige Spalte. */

@font-face {
    font-family: "Roboto App";
    src: url("fonts/Roboto.ttf") format("truetype");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: light;
    --primary: #C62828;
    --on-primary: #FFFFFF;
    --primary-container: #FFDAD6;
    --on-primary-container: #410002;
    --secondary-container: #FFEDEA;
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --on-surface: #1C1B1F;
    --surface-variant: #F3EDEC;
    --on-surface-variant: #5F5B5B;
    --surface-container: #F7F2F1;
    --surface-container-high: #F1ECEB;
    --outline: #D8C2BF;
    --outline-variant: #EDE0DE;
    --error: #B3261E;
    --success: #2E7D32;
    --success-container: #DCEFD9;
    --on-success-container: #1B3A1C;
    --page: #E9E4E3;

    --tile-0: #D32F2F;
    --tile-1: #1E88E5;
    --tile-2: #F9A825;
    --tile-3: #8E24AA;
    --tile-4: #546E7A;

    --r-s: 10px;
    --r-m: 16px;
    --r-l: 24px;
    --el1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
    --el2: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
    --font: "Roboto App", Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --primary: #FF5F52;
        --on-primary: #690003;
        --primary-container: #8E0000;
        --on-primary-container: #FFDAD6;
        --bg: #151515;
        --surface: #1F1F1F;
        --on-surface: #EDE0DE;
        --surface-variant: #2B2727;
        --on-surface-variant: #D8C2BF;
        --surface-container: #242222;
        --surface-container-high: #2B2930;
        --outline: #6E5A58;
        --outline-variant: #49454F;
        --error: #F2B8B5;
        --page: #0B0B0B;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: var(--font); color: var(--on-surface); background: var(--page);
    -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
    font-size: 14px; line-height: 20px; letter-spacing: .25px;
}
button { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, p { margin: 0; }
.ic { display: block; fill: currentColor; flex: none; }

#root { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.test-banner {
    flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
    padding: 4px 12px; background: #8E0000; color: #fff; font-size: 12px; line-height: 16px; letter-spacing: .3px; text-align: center;
}
.test-banner a { color: #fff; font-weight: 600; white-space: nowrap; }

/* App-Spalte */
.app {
    flex: 1 1 auto; min-height: 0; width: 100%; max-width: 600px; margin: 0 auto;
    display: flex; flex-direction: column; background: var(--bg); position: relative; overflow: hidden;
}
@media (min-width: 640px) {
    .app { box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 8px 32px rgba(0, 0, 0, .12); }
}
.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; animation: fade-in .3s ease-out; }
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Typografie (Theme.kt) */
.t-title-medium, .section-label, .section-title, .cc-stat-v, .qh-title, .qh-count, .fb-title, .empty-title,
.result-section, .all-right, .wc-q, .mo-title { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px; }

/* ---- Bausteine ---- */
.card { background: var(--surface); box-shadow: var(--el1); }
.icon-btn {
    width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%; background: transparent; color: inherit;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: rgba(127, 127, 127, .12); }
.icon-btn:focus-visible, .btn-primary:focus-visible, .btn-outlined:focus-visible, .text-btn:focus-visible,
.chip:focus-visible, .mode-option:focus-visible, .play-btn:focus-visible, .tile:focus-visible, .catalog-card:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px;
}
.icon-btn-muted { color: var(--on-surface); }

.btn-primary {
    width: 100%; height: 56px; border: 0; border-radius: var(--r-m); background: var(--primary); color: var(--on-primary);
    font-size: 16px; line-height: 20px; font-weight: 600; letter-spacing: .2px; cursor: pointer; transition: filter .15s, background .15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); cursor: default; }
.btn-outlined {
    width: 100%; height: 52px; border: 1px solid var(--outline); border-radius: var(--r-m); background: transparent;
    color: var(--primary); font-size: 16px; line-height: 20px; font-weight: 600; letter-spacing: .2px; cursor: pointer;
}
.btn-outlined:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }

/* LinearProgressIndicator (M3): gefüllter Teil und Spur mit 4 dp Lücke, ohne Stopp-Punkt */
.bar { --track: var(--surface-variant); --fill: var(--primary); height: 8px; display: flex; gap: 4px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--fill); transition: width .4s ease; flex: none; }
.bar-fill[style^="width:0.00%"] { display: none; }
.bar-track { flex: 1 1 auto; height: 100%; border-radius: 999px; background: var(--track); }
.bar-success { --fill: var(--success); }

.bottom-bar { flex: none; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }

/* ---- Home ---- */
.home-header {
    flex: none; background: var(--primary); color: #fff; padding: 28px 24px; border-radius: 0 0 28px 28px;
}
.home-title { font-size: 28px; line-height: 36px; font-weight: 700; color: #fff; }
.home-sub { margin-top: 4px; color: rgba(255, 255, 255, .85); font-size: 14px; line-height: 20px; }
.home-list { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.section-label { color: var(--on-surface-variant); padding: 4px 0 0 4px; }
.catalog-card { border-radius: var(--r-l); box-shadow: var(--el2); padding: 20px; cursor: pointer; transition: background .15s; }
.catalog-card:hover { background: color-mix(in srgb, var(--on-surface) 4%, var(--surface)); }
.cc-top { display: flex; align-items: center; }
.cc-text { flex: 1 1 auto; min-width: 0; }
.cc-title { font-size: 22px; line-height: 28px; font-weight: 600; }
.cc-desc { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.play-btn {
    width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%; background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.catalog-card .bar { margin-top: 16px; }
.cc-stats { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.cc-stat { display: inline-flex; align-items: baseline; gap: 4px; }
.cc-stat-v.is-alert { color: var(--primary); }
.cc-stat-l { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.web-note { margin: 4px 4px 0; font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }

/* ---- TopAppBar ---- */
.appbar {
    flex: none; height: 64px; display: flex; align-items: center; gap: 4px; padding: 0 4px;
    background: var(--primary); color: #fff;
}
.appbar-title { flex: 1 1 auto; min-width: 0; font-size: 22px; line-height: 28px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }

/* ---- Setup ---- */
.setup-body { padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.info-card { background: var(--primary-container); color: var(--on-primary-container); border-radius: var(--r-l); padding: 20px; }
.ic-row { display: flex; justify-content: space-between; }
.ic-col { display: flex; flex-direction: column; align-items: center; }
.ic-v { font-size: 24px; line-height: 32px; font-weight: 700; color: var(--primary); }
.ic-l { font-size: 12px; line-height: 16px; letter-spacing: .4px; }
.ic-rule { margin-top: 12px; }
.section { display: flex; flex-direction: column; gap: 8px; }
.mode-option {
    display: flex; flex-direction: column; align-items: flex-start; text-align: left; width: 100%;
    background: var(--surface); border: 1px solid var(--outline-variant); border-radius: var(--r-m); padding: 16px; cursor: pointer;
    transition: border-color .15s;
}
.mode-option.is-selected { border: 2px solid var(--primary); padding: 15px; }
.mode-option.is-selected .mo-title { color: var(--primary); }
.mode-option:disabled { cursor: default; }
.mode-option:disabled .mo-title { color: var(--on-surface-variant); }
.mo-sub { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    min-height: 32px; border: 1px solid var(--outline); border-radius: var(--r-s); background: transparent; color: var(--on-surface-variant);
    min-width: 58px; padding: 10px 16px; font-size: 16px; line-height: 20px; font-weight: 600; letter-spacing: .2px; cursor: pointer;
}
.chip:hover { background: color-mix(in srgb, var(--on-surface) 6%, transparent); }
.chip.is-selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.hint { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }

/* ---- Quiz ---- */
.quiz-header { flex: none; background: var(--primary); color: #fff; padding: 4px 16px 14px 4px; }
.qh-row { display: flex; align-items: center; }
.qh-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-onred { --track: rgba(255, 255, 255, .3); --fill: #fff; height: 6px; margin-left: 12px; }
.quiz-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 14px; }
.question-card { border-radius: var(--r-l); box-shadow: var(--el2); padding: 20px; }
.qc-cat { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .5px; color: var(--primary); margin-bottom: 6px; }
.qc-text { font-size: 22px; line-height: 28px; font-weight: 600; hyphens: auto; overflow-wrap: break-word; }
.qc-hint { margin-top: 10px; font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }

.tiles { display: flex; flex-direction: column; gap: 10px; }
.tile-row { display: flex; gap: 10px; }
.tile-row > * { flex: 1 1 0; min-width: 0; }
.tile {
    --accent: var(--accent-i);
    position: relative; display: flex; align-items: center; width: 100%; min-height: 64px; padding: 14px; text-align: left;
    background: var(--surface); color: var(--on-surface); border: 2px solid var(--accent); border-radius: var(--r-m);
    box-shadow: none; cursor: pointer;
    transition: border-color .3s, background-color .3s, opacity .3s, transform .2s, box-shadow .2s;
}
.tile-grid { min-height: 110px; }
.tile:disabled { cursor: default; }
.tile-idle { box-shadow: var(--el1); }
.tile-idle:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.tile-selected, .tile-correct, .tile-wrong, .tile-missed { border-width: 4px; padding: 12px; }
.tile-selected { transform: scale(.97); }
.tile-correct, .tile-missed { --accent: var(--success); }
.tile-wrong { --accent: var(--error); }
.tile-selected, .tile-correct, .tile-wrong { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.tile-dimmed { opacity: .4; }
.tile-sym { flex: none; font-size: 20px; line-height: 24px; color: var(--accent); transition: color .3s; margin-right: 10px; }
.tile-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tile-missed-label { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .5px; color: var(--success); }
.tile-text { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .5px; hyphens: auto; overflow-wrap: break-word; }
.tile-badge {
    flex: none; width: 26px; height: 26px; margin-left: 8px; border-radius: 50%; background: var(--accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; animation: pop .2s ease-out;
}
.tile-spacer { display: block; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* OutlinedTextField */
.outlined { position: relative; display: block; }
.outlined-input {
    width: 100%; height: 56px; padding: 16px; border: 1px solid var(--outline); border-radius: var(--r-m);
    background: transparent; color: var(--on-surface); font: inherit; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px;
    outline: none; transition: border-color .15s;
}
.outlined-input:focus { border: 2px solid var(--primary); padding: 15px; }
.outlined-label {
    position: absolute; left: 12px; top: 16px; padding: 0 4px; font-size: 16px; line-height: 24px; color: var(--on-surface-variant);
    background: var(--bg); pointer-events: none; transition: top .15s, font-size .15s, line-height .15s, color .15s;
}
.outlined-input:focus + .outlined-label, .outlined.has-value .outlined-label { top: -8px; font-size: 12px; line-height: 16px; }
.outlined-input:focus + .outlined-label { color: var(--primary); }
.outlined.is-correct .outlined-input { border: 2px solid var(--success); padding: 15px; }
.outlined.is-correct .outlined-label { color: var(--success); }
.outlined.is-wrong .outlined-input { border: 2px solid var(--error); padding: 15px; }
.outlined.is-wrong .outlined-label { color: var(--error); }

.feedback {
    display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-radius: var(--r-m);
    animation: expand-in .35s ease-out; transform-origin: bottom;
}
.feedback.is-correct { background: var(--success-container); color: var(--on-success-container); --badge: var(--success); }
.feedback.is-wrong { background: var(--primary-container); color: var(--on-primary-container); --badge: var(--primary); }
.fb-badge { flex: none; border-radius: 50%; background: var(--badge); color: #fff; padding: 6px; }
.fb-col { flex: 1 1 auto; min-width: 0; }
.fb-title { color: var(--badge); }
.fb-expl { margin-top: 4px; font-size: 12px; line-height: 16px; letter-spacing: .4px; opacity: .8; }
@keyframes expand-in { from { opacity: 0; transform: translateY(12px); max-height: 0; } to { opacity: 1; transform: none; max-height: 600px; } }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; gap: 24px; text-align: center; }

/* ---- Ergebnis ---- */
.result-scroll { padding-bottom: 16px; }
.result-header {
    color: #fff; padding: 24px; border-radius: 0 0 32px 32px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.result-header.is-passed { background: #2E7D32; }
.result-header.is-failed { background: var(--primary); }
.rh-cat { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px; color: rgba(255, 255, 255, .85); }
.rh-verdict { margin-top: 8px; font-size: 30px; line-height: 38px; font-weight: 900; letter-spacing: 1px; }
.donut-box { position: relative; width: 170px; height: 170px; margin-top: 20px; }
.donut { width: 170px; height: 170px; display: block; }
.donut circle { fill: none; stroke-width: 16; }
.donut-track { stroke: rgba(255, 255, 255, .25); }
.donut-arc { stroke: #fff; stroke-linecap: round; animation: draw .9s ease-out; }
@keyframes draw { from { stroke-dasharray: 0 999; } }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-pct { font-size: 32px; line-height: 40px; font-weight: 700; }
.donut-sub { font-size: 14px; line-height: 20px; }
.rh-rule { margin-top: 16px; }
.result-section { padding: 20px 20px 8px; }
.all-right { padding: 20px; color: var(--success); }
.wrong-card { margin: 6px 16px; border-radius: var(--r-m); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.wc-label { font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .5px; }
.wc-label.is-red { color: var(--primary); }
.wc-label.is-green { color: var(--success); }
.wc-value { white-space: pre-line; }
.wc-expl { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.result-screen-bottom { gap: 10px; }

/* ---- Statistik ---- */
.stats-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.stats-title { font-size: 22px; line-height: 28px; font-weight: 600; }
.stat-row { display: flex; gap: 12px; }
.stat-row > * { flex: 1 1 0; min-width: 0; }
.stat-tile { border-radius: var(--r-m); padding: 16px; display: flex; flex-direction: column; }
.st-v { font-size: 24px; line-height: 32px; font-weight: 700; }
.st-v.is-green { color: var(--success); }
.st-v.is-red { color: var(--primary); }
.st-l { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.runs-title { margin-top: 8px; }
.run-card { border-radius: var(--r-m); padding: 16px; display: flex; align-items: center; box-shadow: none; }
.rc-col { flex: 1 1 auto; min-width: 0; }
.rc-sub { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.rc-verdict { font-size: 16px; line-height: 20px; font-weight: 600; letter-spacing: .2px; }
.rc-verdict.is-green { color: var(--success); }
.rc-verdict.is-red { color: var(--primary); }
.muted { color: var(--on-surface-variant); font-size: 16px; line-height: 24px; }

/* ---- AlertDialog ---- */
.dialogs:empty { display: none; }
.scrim {
    position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .32); display: flex; align-items: center; justify-content: center;
    padding: 24px; animation: fade-in .15s ease-out;
}
.dialog {
    width: 100%; max-width: 560px; min-width: 280px; background: var(--surface-container-high); border-radius: 28px; padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .2); animation: dialog-in .2s ease-out;
}
@media (min-width: 400px) { .dialog { width: auto; max-width: 400px; } }
@keyframes dialog-in { from { transform: scale(.92); opacity: 0; } }
.dialog-title { font-size: 24px; line-height: 32px; font-weight: 700; margin-bottom: 16px; }
.dialog-text { color: var(--on-surface-variant); }
.dialog-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 8px; }
.text-btn {
    height: 40px; padding: 0 12px; border: 0; border-radius: 20px; background: transparent; color: var(--primary);
    font-size: 16px; line-height: 20px; font-weight: 600; letter-spacing: .2px; cursor: pointer;
}
.text-btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 479px) { .test-banner .tb-long { display: none; } }
