:root {
  --bg: #f6f7fb;
  --fg: #172033;
  --muted: #5d6b82;
  --card: #ffffff;
  --line: #e1e6ef;
  --accent: #2f5bea;
  --accent-soft: #e6ecff;
  --ok: #16884a;
  --ok-soft: #e2f5ea;
  --warn: #b26a00;
  --warn-soft: #fff1d9;
  --bad: #c62f2f;
  --bad-soft: #fde6e6;
  --gold: #c08a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --fg: #e7ecf5; --muted: #9aa7bd; --card: #182031; --line: #2a3448;
    --accent: #7c9cff; --accent-soft: #1f2b4d; --ok: #4cc786; --ok-soft: #173326;
    --warn: #f0b14a; --warn-soft: #3a2c12; --bad: #ff7b7b; --bad-soft: #3d1c1c; --gold: #f2c14e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
main { max-width: 640px; margin: 0 auto; }
main.wide { max-width: 1040px; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-block;
  touch-action: manipulation;
}
button.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
button.quiet { background: transparent; color: var(--muted); padding: 8px 10px; font-weight: 500; }
button.ok { background: var(--ok); }
button.bad { background: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
button.big { width: 100%; padding: 16px; font-size: 1.1rem; }
input[type=text], input[type=password], input[type=number], input[type=time] {
  font: inherit; width: 100%; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--bg); color: var(--fg);
}
input[type=text]:focus, input[type=password]:focus { outline: none; border-color: var(--accent); }
.error { color: var(--bad); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); }

/* Profile */
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.profile-tile { text-align: center; padding: 20px 10px; cursor: pointer; }
.profile-tile .avatar { font-size: 2.6rem; }
.profile-tile .name { font-weight: 700; margin-top: 6px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 16px auto; }
.pinpad button { font-size: 1.4rem; padding: 16px 0; background: var(--card); color: var(--fg); border: 1px solid var(--line); }
.pindots { display: flex; gap: 12px; justify-content: center; margin: 12px 0; }
.pindots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); }
.pindots span.on { background: var(--accent); }

/* Start */
.hero { display: flex; gap: 14px; align-items: center; }
.hero .avatar { font-size: 2.4rem; }
.rank { font-weight: 700; color: var(--gold); }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 999px; }
.bar.ok > div { background: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { text-align: center; padding: 12px 6px; }
.stat .v { font-size: 1.4rem; font-weight: 800; }
.stat .l { font-size: .8rem; color: var(--muted); }
.deck { display: flex; gap: 12px; align-items: center; }
.deck .t { font-weight: 700; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; background: transparent; color: var(--fg); padding: 9px 6px; font-weight: 600; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* Lernen */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.topbar .bar { flex: 1; }
.q { font-size: 1.7rem; font-weight: 800; line-height: 1.2; word-break: break-word; }
.info { color: var(--muted); font-size: .95rem; }
.example { color: var(--muted); font-style: italic; white-space: pre-line; }
.meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .85rem; }
.phases { display: inline-flex; gap: 3px; }
.phases i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.phases i.on { background: var(--accent); }
.choices { display: grid; gap: 10px; }
.choices button { background: var(--card); color: var(--fg); border: 1.5px solid var(--line); text-align: left; font-weight: 500; }
.choices button:disabled { opacity: 1; }
.choices button.right { border-color: var(--ok); background: var(--ok-soft); }
.choices button.picked-wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { border-radius: var(--radius); padding: 14px 16px; }
.feedback.good { background: var(--ok-soft); }
.feedback.mid { background: var(--warn-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback .title { font-weight: 800; font-size: 1.15rem; }
.groups span { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border-radius: 8px; background: var(--card); }
.groups span.hit { outline: 2px solid var(--ok); }
.groups span.miss { opacity: .75; }
.given s { color: var(--bad); }
.xpfloat { color: var(--gold); font-weight: 800; }
.answer-reveal { font-size: 1.25rem; font-weight: 700; }

/* Eltern */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.tablewrap { overflow-x: auto; }
.phasebar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; min-width: 120px; background: var(--line); }
.phasebar div { height: 100%; }
.res-correct, .res-typo, .res-partial, .res-self_known { color: var(--ok); }
.res-almost, .res-aborted { color: var(--warn); }
.res-wrong, .res-confusion, .res-self_unknown, .res-self_failed { color: var(--bad); }
.days { display: flex; gap: 4px; align-items: flex-end; height: 90px; }
.days div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.days div.met { background: var(--ok); }
.daylabels { display: flex; gap: 4px; font-size: .7rem; color: var(--muted); }
.daylabels span { flex: 1; text-align: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: .9rem; z-index: 10; }

/* Aktionsleiste unten, volle Breite, über der Bildschirmtastatur */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.actionbar.kb { padding-bottom: 6px; padding-top: 6px; }
.actionbar button { flex: 1; padding: 16px; font-size: 1.1rem; }
.actionbar button.ghost { flex: 0 0 auto; }
main:has(.actionbar) { padding-bottom: 96px; }
input.checked { opacity: .7; }

/* Lektionen freischalten */
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lesson { display: flex; flex-direction: column; gap: 4px; align-items: stretch; text-align: left;
  background: var(--card); color: var(--muted); border: 1.5px dashed var(--line); padding: 10px; font-weight: 500; }
.lesson.on { color: var(--fg); border: 1.5px solid var(--ok); background: var(--ok-soft); }
.lesson .lt { font-weight: 700; }
.lesson .phasebar { display: flex; height: 8px; min-width: 0; }
.lesson .phasebar span { height: 100%; }
.lesson.pick { border: 2px solid var(--accent); color: var(--fg); }
.forms { font-weight: 600; }
.forms .muted { font-weight: 500; margin-right: 6px; }
.hint { background: var(--card); border-radius: 10px; padding: 8px 10px; }
.hint button.small, button.small { font-size: .85rem; padding: 6px 10px; }
.hints-table td:nth-child(3) { width: 50%; }
.hints-table input { min-width: 240px; padding: 8px 10px; }
