:root {
  --orange: #ff8a00;
  --orange-d: #e87a00;
  --orange-l: #fff3e3;
  --bg: #f3f3f6;
  --card: #ffffff;
  --text: #2b2b33;
  --muted: #8b8b96;
  --line: #ececf1;
  --ok: #3aa845;
  --ok-bg: #e4f5e3;
  --warn: #c98200;
  --warn-bg: #fff4d6;
  --bad: #e5484d;
  --bad-bg: #fde8e8;
  --p1: #e5484d; --p2: #ff8a00; --p3: #f5c400; --p4: #8cc63f; --p5: #2bb3a3; --p6: #5b6ee1; --pn: #c8c8d0;
  --r: 18px;
  --shadow: 0 2px 12px rgba(40, 40, 60, .07);
  --maxw: 560px;
  --tabbar: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4;
}
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .84rem; }
.hidden { display: none !important; }
.center { text-align: center; }
button { font: inherit; color: inherit; }

#app { max-width: var(--maxw); margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabbar) + 20px); }
#app.no-tabbar { padding-bottom: 20px; }
.page { padding: 0 14px; }
.title-bar { display: flex; align-items: center; gap: .6rem; padding: 18px 14px 10px; }
.title-bar h1 { font-size: 1.5rem; flex: 1; margin: 0; }
.back { border: 0; background: none; color: var(--orange); font-size: 1.6rem; line-height: 1; padding: 0 6px 0 0; cursor: pointer; }

/* Karten */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.section-title { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 4px 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 0; border-radius: 14px;
  padding: 12px 18px; font-weight: 700; cursor: pointer; background: var(--orange-l); color: var(--orange-d);
  text-decoration: none; transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--orange); color: #fff; box-shadow: 0 4px 12px rgba(255, 138, 0, .3); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.block { display: flex; width: 100%; }
.btn.big { padding: 15px 18px; font-size: 1.08rem; border-radius: 16px; }
.btn.plain { background: none; color: var(--orange-d); padding: 8px 10px; }
.btn.grey { background: var(--bg); color: var(--text); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { padding: 7px 11px; font-size: .86rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; padding: 6px 8px; }
.linkbtn:hover { color: var(--orange-d); }

/* Formulare */
.field { margin: 10px 0; }
.field > label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin: 0 0 5px 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 12px 14px; border: 1.5px solid transparent; border-radius: 12px; background: var(--bg); color: var(--text);
}
textarea { min-height: 130px; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); background: #fff; }
.err { color: var(--bad); font-size: .9rem; min-height: 1.2em; margin: 6px 4px; }

/* Segment-Auswahl / Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border-radius: 999px; background: var(--bg);
  cursor: pointer; user-select: none; font-size: .92rem; font-weight: 600; color: var(--muted); border: 1.5px solid transparent;
}
.chip input { display: none; }
.chip:has(input:checked), .chip.on { background: var(--orange-l); color: var(--orange-d); border-color: var(--orange); }
.flag { width: 22px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,.08); overflow: hidden; flex: none; }
.flag svg { width: 100%; height: 100%; display: block; }

/* Tab-Leiste */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar); background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 20; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .inner { display: flex; width: 100%; max-width: var(--maxw); }
.tabbar button {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .7rem; font-weight: 600; color: #a0a0aa; cursor: pointer;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--orange); }

/* Start: oranger Kopf */
.hero {
  background: linear-gradient(160deg, #ffa033, var(--orange) 60%, #ff7a00); color: #fff; border-radius: 0 0 32px 32px;
  padding: 18px 18px 64px; text-align: center; position: relative;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.hero-stat { display: flex; flex-direction: column; align-items: center; font-size: .8rem; min-width: 64px; opacity: .95; }
.hero-stat b { font-size: 1.25rem; }
.hero-name { font-size: 1.05rem; }
.avatar {
  width: 92px; height: 92px; border-radius: 50%; background: #fff; color: var(--orange); margin: 10px auto 8px;
  display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; box-shadow: 0 6px 18px rgba(150, 70, 0, .25);
}
.level { font-size: .82rem; font-weight: 700; }
.level .bar { width: 160px; margin: 5px auto 0; background: rgba(255,255,255,.35); }
.level .bar > div { background: #fff; }
.overlap { margin-top: -46px; position: relative; }
.today-card { display: flex; gap: 14px; align-items: center; }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; flex: none; background: conic-gradient(var(--orange) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.ring > div { width: 62px; height: 62px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; font-size: .7rem; color: var(--muted); line-height: 1.1; }
.ring b { display: block; font-size: 1.2rem; color: var(--text); }
.today-text { flex: 1; }
.today-text h2 { margin: 0 0 2px; font-size: 1.2rem; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--orange); border-radius: 99px; width: 0; transition: width .4s; }

/* Listen (wie die Bücherliste) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: #fafafa; }
.list .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--orange-l); color: var(--orange); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.list .main { flex: 1; min-width: 0; }
.list .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .main .bar { margin-top: 6px; }
.list .chev { color: #c8c8d0; font-size: 1.3rem; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #d4d4dc; display: grid; place-items: center; flex: none; color: #fff; font-size: .8rem; }
li.sel .check { background: var(--orange); border-color: var(--orange); }

/* Abfrage */
.learn { padding: 10px 14px 0; display: flex; flex-direction: column; min-height: 100vh; }
.learn-top { display: flex; align-items: center; gap: 10px; padding: 6px 2px 12px; font-weight: 700; color: var(--muted); font-size: .9rem; }
.learn-top .bar { flex: 1; height: 8px; }
.learn-top .x { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.qcard { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.qhalf { padding: 14px 16px 12px; position: relative; min-height: 190px; display: flex; flex-direction: column; }
.qhalf + .qhalf { border-top: 1px solid var(--line); }
.qhead { display: flex; align-items: center; gap: 6px; }
.qhead .space { flex: 1; }
.pill { font-size: .7rem; font-weight: 800; padding: 3px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.pill.phase { color: #fff; }
.pill.new { background: var(--orange-l); color: var(--orange-d); }
.pill.rep { background: var(--warn-bg); color: var(--warn); }
.qbody { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px 4px; gap: 6px; }
.qimg { max-width: 70%; max-height: 140px; object-fit: contain; border-radius: 12px; }
.qimg.small { max-height: 90px; }
.vimg { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: #fff; box-shadow: 0 0 0 1px var(--line); flex: none; }
.qword { font-size: 1.6rem; font-weight: 700; word-break: break-word; }
.qsentence { color: var(--muted); font-size: .98rem; }
.qsentence .gap { display: inline-block; min-width: 3.5em; border-bottom: 2px solid #cfcfd6; margin: 0 2px; }
.qsentence mark { background: none; color: var(--text); font-weight: 700; }
.qfoot { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.qfoot .space { flex: 1; }
.iconbtn { border: 0; background: none; cursor: pointer; color: var(--muted); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.iconbtn:hover { background: var(--bg); color: var(--orange-d); }
.iconbtn svg { width: 22px; height: 22px; }
.listen-btn { width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--orange-l); color: var(--orange); cursor: pointer; display: grid; place-items: center; }
.listen-btn svg { width: 46px; height: 46px; }
.answer-input {
  width: 100%; font-size: 1.3rem !important; text-align: center; padding: 14px !important; border-radius: 14px !important;
  background: var(--bg) !important; font-weight: 600;
}
.answer-box { width: 100%; border-radius: 14px; padding: 13px 44px; font-size: 1.25rem; font-weight: 700; position: relative; text-align: center; word-break: break-word; }
.answer-box .face { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 1.4rem; }
.answer-box.richtig { background: var(--ok-bg); color: var(--ok); }
.answer-box.tippfehler { background: var(--warn-bg); color: var(--warn); }
.answer-box.falsch { background: var(--bad-bg); color: var(--bad); }
.solution { font-size: 1.5rem; font-weight: 700; }
.verdict { font-weight: 800; font-size: .95rem; }
.verdict.richtig { color: var(--ok); } .verdict.tippfehler { color: var(--warn); } .verdict.falsch { color: var(--bad); }
.diff-bad { background: rgba(229, 72, 77, .15); border-radius: 3px; text-decoration: line-through; }
.diff-miss { background: rgba(58, 168, 69, .2); color: var(--ok); border-radius: 3px; }
.note { font-size: .88rem; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 6px 10px; }
.phase-info { font-size: .85rem; color: var(--muted); }
.hintline { color: var(--orange-d); font-weight: 600; font-size: .95rem; }
.learn-actions { position: sticky; bottom: 0; padding: 14px 0 18px; background: linear-gradient(transparent, var(--bg) 30%); margin-top: auto; }
.learn-actions .row { display: flex; justify-content: center; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.pop { animation: pop .3s; }
@keyframes pop { 0% { transform: scale(.97); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }

/* Ergebnis */
.done-emoji { font-size: 4rem; margin-top: 10px; }
.stats-row { display: flex; gap: 10px; margin: 14px 0; }
.stats-row > div { flex: 1; background: var(--bg); border-radius: 14px; padding: 10px 6px; text-align: center; }
.stats-row b { display: block; font-size: 1.4rem; }
.stats-row span { font-size: .75rem; color: var(--muted); }

/* Vokabel-Liste */
.vrow { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.vrow:last-child { border-bottom: 0; }
.vrow .main { flex: 1; min-width: 0; }
.vrow .main b { display: block; }
.vrow .ex { font-size: .82rem; color: var(--muted); font-style: italic; }
.dots { display: flex; gap: 3px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Statistik */
.phase-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--line); margin: 6px 0 2px; }
.phase-bar > div { display: grid; place-items: center; color: #fff; font-size: .75rem; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: 6px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.chart .ok { background: var(--ok); width: 100%; border-radius: 4px 4px 0 0; }
.chart .bad { background: var(--p1); width: 100%; }
.chart .fc { background: var(--orange); width: 100%; border-radius: 4px 4px 0 0; }
.chart .lbl { font-size: .66rem; color: var(--muted); margin-top: 3px; }
.chart .val { font-size: .66rem; color: var(--muted); }

/* Abzeichen */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { background: var(--card); border-radius: 16px; padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.badge.earned { background: linear-gradient(180deg, #fff7ea, #fff); box-shadow: 0 0 0 2px #ffd28a inset, var(--shadow); }
.badge.locked { opacity: .45; filter: grayscale(1); }
.badge .ic { font-size: 2.2rem; }
.badge .nm { font-weight: 800; margin-top: 4px; font-size: .95rem; }
.badge .ds { font-size: .78rem; color: var(--muted); }

/* Mehr-Menü */
.menu li { cursor: pointer; }
.copybox { display: flex; gap: 8px; margin-top: 8px; }
.copybox input { font-size: .85rem; }

/* Anmeldung */
.login-hero { background: linear-gradient(160deg, #ffa033, var(--orange) 60%, #ff7a00); color: #fff; border-radius: 0 0 32px 32px; padding: 50px 20px 80px; text-align: center; }
.login-hero .logo { width: 84px; height: 84px; border-radius: 24px; background: #fff; display: grid; place-items: center; margin: 0 auto 12px; box-shadow: 0 6px 18px rgba(150, 70, 0, .25); }
.login-hero .logo svg { width: 52px; height: 52px; }
.login-hero h1 { font-size: 1.6rem; }

/* Toast */
.toast {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: #2b2b33; color: #fff;
  padding: 12px 18px; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 50; font-weight: 600; max-width: 90vw; text-align: center;
}
.toast.badge-toast { background: #fff7ea; color: #6b4300; box-shadow: 0 0 0 2px #ffd28a inset, 0 6px 24px rgba(0,0,0,.15); }

@media (min-width: 700px) {
  body { padding-top: 10px; }
  .hero, .login-hero { border-radius: 28px; margin: 0 14px; }
  .qword { font-size: 1.9rem; }
}
