/* Prüfungstrainer – Basis-Styles
 * --accent und --ink kommen pro Tenant aus index.php. Alles andere ist neutral.
 */
:root {
  --accent: #0B6E8F;
  --ink: #0F2A3F;
  --bg: #EEF2F4;
  --surface: #FFFFFF;
  --text: #17222B;
  --muted: #5B6B78;
  --line: #D6DEE4;
  --ok: #1F7A4D;
  --ok-bg: #E4F3EA;
  --bad: #B9382C;
  --bad-bg: #F9E6E3;
  /* Leitner-Boxen 0–5 für die Katalogskala */
  --box0: #D9E0E5;
  --box1: #B9382C;
  --box2: #D9862A;
  --box3: #9DBBCC;
  --box4: var(--accent);
  --box5: var(--ink);
  --radius: 14px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  /* Android Firefox liefert safe-area-inset-bottom teils sprunghaft zu gross.
     Standard deshalb 0; nur WebKit/iOS bekommt den echten Home-Indicator-Abstand. */
  --safe-bottom: 0px;
  --bottomnav-height: 64px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  box-sizing: border-box;
}
*, *::before, *::after { box-sizing: inherit; }
@supports (-webkit-touch-callout: none) {
  :root { --safe-bottom: env(safe-area-inset-bottom, 0px); }
}
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--safe-top); }
body {
  margin: 0; height: 100%;
  font-family: var(--font); font-size: 17px; line-height: 1.45;
  color: var(--text); background: var(--bg);
}
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Boot ---------- */
.boot { min-height: 100dvh; display: grid; place-content: center; text-align: center; color: var(--muted); }
.boot-mark {
  width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 16px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 2rem;
  display: grid; place-content: center;
}
.boot-logo { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 auto 1rem; }

/* ---------- Layout ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand small { display: block; font-weight: 400; font-size: 0.8rem; opacity: 0.75; }
.topbar button { background: transparent; border: 1px solid rgba(255,255,255,0.35); color: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.topbar .timer { font-variant-numeric: tabular-nums; font-weight: 700; }

.main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 16px 16px calc(var(--bottomnav-height) + 20px + var(--safe-bottom)); }
.sidebar { display: none; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: 1fr;
  height: calc(var(--bottomnav-height) + var(--safe-bottom));
  min-height: calc(var(--bottomnav-height) + var(--safe-bottom));
  max-height: calc(var(--bottomnav-height) + var(--safe-bottom));
  overflow: hidden;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.bottomnav button {
  min-width: 0; min-height: 0; height: calc(var(--bottomnav-height) - 1px);
  border: 0; background: none; padding: 7px 4px 5px; cursor: pointer;
  color: var(--muted); font-size: 0.74rem; line-height: 1.05;
  display: grid; grid-template-rows: 24px 18px; align-content: center; justify-items: center; gap: 2px;
  white-space: nowrap; overflow: hidden;
  appearance: none; -webkit-appearance: none;
}
.bottomnav button svg { display: block; width: 24px; height: 24px; }
.bottomnav button.active { color: var(--accent); }

/* Desktop: Sidebar links, Bottom-Nav weg */
@media (min-width: 900px) {
  .app { flex-direction: row; }
  .topbar { display: none; }
  .bottomnav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px;
    width: 280px; flex: 0 0 280px; position: sticky; top: 0; height: 100dvh; overflow: auto;
    background: var(--ink); color: #fff; padding: 28px 20px;
  }
  .sidebar .brand { font-weight: 700; font-size: 1.25rem; margin-bottom: 18px; }
  .sidebar .brand small { display: block; font-weight: 400; font-size: 0.85rem; opacity: 0.7; margin-top: 4px; }
  .sidebar button {
    text-align: left; border: 0; background: none; color: #fff; cursor: pointer;
    padding: 10px 12px; border-radius: var(--radius-sm); opacity: 0.8;
  }
  .sidebar button:hover { background: rgba(255,255,255,0.08); opacity: 1; }
  .sidebar button.active { background: var(--accent); opacity: 1; }
  .sidebar .topics { margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.15); font-size: 0.92rem; }
  .sidebar .topics button { display: flex; justify-content: space-between; gap: 8px; }
  .sidebar .topics span.n { opacity: 0.6; font-variant-numeric: tabular-nums; }
  .sidebar .foot { margin-top: auto; font-size: 0.78rem; opacity: 0.55; }
  .main { max-width: 760px; padding: 40px 48px; }
}

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card h2 { margin-bottom: 6px; }
.card .meta { color: var(--muted); font-size: 0.9rem; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 13px 20px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.dark { background: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Themenliste auf Start */
.topic {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer;
  background: var(--surface); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
}
.topic .t { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.topic .t strong { font-size: 1.02rem; }
.topic .t span { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.topic .d { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }

/* Katalogskala: eine Zelle pro Frage, Farbe = Leitner-Box.
   Das ist das eine markante Element der App; alles andere bleibt ruhig. */
.scale { display: flex; flex-wrap: wrap; gap: 3px; margin: 10px 0 6px; }
.scale i { display: block; width: 9px; height: 14px; border-radius: 2px; background: var(--box0); }
.scale i.b1 { background: var(--box1); }
.scale i.b2 { background: var(--box2); }
.scale i.b3 { background: var(--box3); }
.scale i.b4 { background: var(--box4); }
.scale i.b5 { background: var(--box5); }
.scale.mini i { width: 5px; height: 9px; gap: 2px; }
.scale.mini { gap: 2px; margin: 8px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 5px; }

/* Frage */
.q-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 10px; }
.q-progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
.q-progress i { display: block; height: 100%; background: var(--accent); transition: width 0.25s; }
.q-text { font-size: 1.18rem; font-weight: 600; line-height: 1.35; margin-bottom: 16px; }
.q-img { max-width: 100%; border-radius: var(--radius-sm); margin-bottom: 14px; display: block; }

.ans {
  display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid var(--surface); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px; line-height: 1.4;
}
.ans .k {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-content: center;
  background: var(--bg); color: var(--muted); font-weight: 700; font-size: 0.9rem;
}
.ans.sel { border-color: var(--ink); }
.ans.sel .k { background: var(--ink); color: #fff; }
.ans.ok { background: var(--ok-bg); border-color: var(--ok); }
.ans.ok .k { background: var(--ok); color: #fff; }
.ans.bad { background: var(--bad-bg); border-color: var(--bad); }
.ans.bad .k { background: var(--bad); color: #fff; }
.ans:disabled { cursor: default; }

/* Auto-Scroll nach einer Antwort: Ziel bleibt oberhalb der festen Bottom-Navigation sichtbar. */
[data-next], [data-check] {
  scroll-margin-bottom: calc(var(--bottomnav-height) + var(--safe-bottom) + 18px);
}

.verdict { border-radius: var(--radius); padding: 14px 16px; margin: 6px 0 12px; font-weight: 600; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict p { font-weight: 400; color: var(--text); margin: 6px 0 0; }

/* Prüfungsergebnis */
.result { text-align: center; padding: 28px 18px; }
.result .big { font-size: 3rem; font-weight: 700; line-height: 1; margin: 6px 0; font-variant-numeric: tabular-nums; }
.result.pass .big { color: var(--ok); }
.result.fail .big { color: var(--bad); }
.exam-list { display: grid; gap: 6px; }
.exam-list .e { display: flex; justify-content: space-between; padding: 10px 12px; background: var(--surface); border-radius: var(--radius-sm); font-size: 0.92rem; }
.exam-list .e b.pass { color: var(--ok); }
.exam-list .e b.fail { color: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.notice { background: #FFF4D6; color: #6B4E00; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.88rem; margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


.pwa-card { border-left: 4px solid var(--accent); }
.pwa-card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.pwa-card-icon { width: 56px; height: 56px; border-radius: 14px; object-fit: contain; flex: 0 0 auto; }
@media (max-width: 520px) {
  .pwa-card-head { align-items: flex-start; }
  .pwa-card .row { display: grid; width: 100%; }
  .pwa-card .btn { width: 100%; }
}

/* ---------- Zugriff / Konto ---------- */
.access-card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  border-left: 4px solid var(--accent);
}
.access-card strong { grid-column: 1; }
.access-card span { grid-column: 1; color: var(--muted); font-size: 0.9rem; }
.access-card .btn { grid-column: 2; grid-row: 1 / span 2; }
.access-card.paid { border-left-color: var(--ok); }
.auth-form { display: grid; gap: 12px; margin-top: 14px; }
.auth-form label { display: grid; gap: 5px; color: var(--muted); font-size: 0.9rem; }
.auth-form input {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px 13px;
  font: inherit; color: var(--text); background: var(--surface);
}
.account-status, .price-box { display: grid; gap: 4px; padding: 13px 14px; border-radius: var(--radius-sm); background: var(--bg); margin: 14px 0; }
.account-status span, .price-box span { color: var(--muted); font-size: 0.9rem; }
.account-status.paid { background: var(--ok-bg); color: var(--ok); }
.account-status.paid span { color: var(--text); }

@media (max-width: 520px) {
  .access-card { grid-template-columns: 1fr; }
  .access-card .btn { grid-column: 1; grid-row: auto; margin-top: 8px; }
}

/* ---------- Gast-Hinweis / Pricing / Conversion-Modal ---------- */
.guest-progress-notice {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.guest-progress-notice .btn { flex: 0 0 auto; }

.pricing-hero { text-align: left; }
.pricing-kicker {
  display: inline-block; margin-bottom: 8px; padding: 4px 9px; border-radius: 999px;
  background: var(--bg); color: var(--accent); font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.pricing-price { display: flex; align-items: baseline; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.pricing-price strong { font-size: 2.35rem; line-height: 1; }
.pricing-price span { color: var(--muted); }
.pricing-features { display: grid; gap: 8px; margin: 18px 0; }
.pricing-compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.pricing-compare > div { display: grid; gap: 4px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); }
.pricing-compare span { color: var(--muted); font-size: 0.86rem; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: 18px; background: rgba(15, 42, 63, 0.64);
}
.modal-card {
  position: relative; width: min(100%, 520px); max-height: calc(100dvh - 36px); overflow: auto;
  background: var(--surface); border-radius: calc(var(--radius) + 4px); padding: 24px;
  box-shadow: 0 20px 70px rgba(0,0,0,0.25);
}
.modal-card h2 { font-size: 1.45rem; margin: 6px 36px 12px 0; }
.modal-card p { color: var(--text); }
.modal-card .btn + .btn { margin-top: 9px; }
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0;
  border-radius: 50%; background: var(--bg); cursor: pointer; font-size: 1.4rem; line-height: 1;
}
.modal-badge {
  display: inline-block; padding: 5px 9px; border-radius: 999px; background: var(--bg);
  color: var(--accent); font-size: 0.8rem; font-weight: 700;
}
.modal-price { font-size: 2rem; font-weight: 700; margin: 16px 0; }
.modal-price span { display: block; font-size: 0.86rem; font-weight: 400; color: var(--muted); margin-top: 3px; }

@media (max-width: 620px) {
  .guest-progress-notice { display: grid; }
  .guest-progress-notice .btn { width: 100%; }
  .pricing-compare { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: 88dvh; border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + var(--safe-bottom)); }
}


/* ---------- Konto: Lernstand & PWA ---------- */
.account-progress {
  display: grid; gap: 12px; padding: 15px; margin: 14px 0;
  background: var(--bg); border-radius: var(--radius-sm);
}
.account-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.account-progress-head > div:first-child { display: grid; gap: 1px; }
.account-progress-head strong { font-size: 1.2rem; }
.account-score { font-size: 1.55rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.account-score span { font-size: 0.8rem; margin-left: 2px; color: var(--muted); font-weight: 600; }
.account-meter { height: 8px; border-radius: 999px; overflow: hidden; background: var(--line); }
.account-meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.account-progress-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.account-progress-grid > div { display: grid; gap: 1px; padding: 9px 8px; border-radius: 8px; background: var(--surface); text-align: center; }
.account-progress-grid strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.account-progress-grid span { color: var(--muted); font-size: 0.75rem; }
.account-install {
  display: grid; grid-template-columns: 1fr 52px; gap: 10px 14px; align-items: center;
  padding: 15px; margin-top: 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
}
.account-install-copy { display: grid; gap: 3px; }
.account-install-copy span, .account-install.installed span { color: var(--muted); font-size: 0.86rem; }
.account-install img { width: 52px; height: 52px; object-fit: contain; border-radius: 12px; }
.account-install .btn { grid-column: 1 / -1; }
.account-install.installed { grid-template-columns: 1fr 52px; background: var(--ok-bg); border-color: transparent; }
.account-install.installed > div { display: grid; gap: 3px; }
.pwa-install-logo { width: 72px; height: 72px; display: block; object-fit: contain; border-radius: 16px; margin-bottom: 8px; }

@media (max-width: 420px) {
  .account-progress-grid { grid-template-columns: 1fr; }
  .account-progress-grid > div { grid-template-columns: auto 1fr; align-items: baseline; text-align: left; gap: 8px; }
}


/* ---------- Voucher ---------- */
.voucher-card h2 { margin-bottom: 6px; }
.voucher-form { display: grid; gap: 7px; margin-top: 14px; }
.voucher-form label { color: var(--muted); font-size: 0.9rem; }
.voucher-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: center; }
.voucher-row input {
  width: 100%; min-width: 0; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 13px; font: 700 1rem ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text); background: var(--surface);
}
.voucher-message { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.voucher-message.ok { background: var(--ok-bg); color: var(--ok); }
.voucher-message.bad { background: var(--bad-bg); color: var(--bad); }
@media (max-width: 520px) {
  .voucher-row { grid-template-columns: 1fr; }
  .voucher-row .btn { width: 100%; }
}

/* ---------- Rechtliche Links ---------- */
.app-legal-footer { display:flex; justify-content:center; align-items:center; gap:8px; margin:28px 0 6px; color:var(--muted); font-size:.8rem; }
.app-legal-footer a, .legal-inline a { color:var(--muted); text-underline-offset:3px; }
.app-legal-footer a:hover, .legal-inline a:hover { color:var(--ink); }
