@font-face {
  font-family: Bravura;
  src: url('fonts/bravura.woff2') format('woff2');
  font-display: block;
}

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --line: #dfe2e8;
  --accent: #3b6fe0;
  --ok: #2e9e5b;
  --ok-bg: #e3f5ea;
  --bad: #d64545;
  --bad-bg: #fbe6e6;
  --mark: #e8a33a;
  --ink: #1d2330;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181e;
    --card: #1f232b;
    --text: #e6e8ec;
    --muted: #9198a6;
    --line: #333946;
    --accent: #6d95f0;
    --ok: #4cc27c;
    --ok-bg: #1d3527;
    --bad: #ee6a6a;
    --bad-bg: #3d2224;
    --ink: #e6e8ec;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app { max-width: 960px; margin: 0 auto; padding: 16px; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }

/* Übersicht */
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.top h1 { font-size: 1.5rem; margin: 0; }
.top-right { display: flex; align-items: center; gap: 12px; }
.icon { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 40px; height: 40px; }
.unit { margin-top: 28px; }
.unit h2 { margin: 0; font-size: 1.15rem; }
.unit > p { margin: 2px 0 12px; font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 12px 14px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px;
}
.card:hover { border-color: var(--accent); }
.card.done { border-color: var(--ok); }
.card.last { box-shadow: 0 0 0 2px var(--accent); }
.card .num { font-size: .8rem; color: var(--muted); }
.card .check { position: absolute; top: 10px; right: 12px; color: var(--ok); font-weight: 700; }
.card .title { font-weight: 600; font-size: .95rem; }
.card .sub { font-size: .82rem; color: var(--muted); }
.card .bar { width: 100%; height: 4px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.card .bar span { display: block; height: 100%; background: var(--ok); }
footer { margin: 40px 0 20px; text-align: center; }
.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 8px; }

/* Lektion */
.lesson { display: flex; flex-direction: column; min-height: calc(100vh - 32px); }
.lesson-top { display: flex; align-items: center; gap: 12px; }
.progress { flex: 1; height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .25s; }
.lesson-title { margin-top: 8px; font-size: .85rem; }
#q { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 12px 0 110px; }
.prompt { font-size: 1.15rem; font-weight: 600; margin: 8px 0 0; text-align: center; }
.display { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px 20px; }
.display .staff { max-width: 70vw; max-height: 34vh; height: auto; display: block; }
.display.text { padding: 20px 32px; text-align: center; }
.big { font-size: 2rem; font-weight: 700; }

.staff line { stroke: var(--ink); stroke-width: 1.3; }
.staff line.ledger { stroke-width: 1.6; }
.staff text { font-family: Bravura; fill: var(--ink); }

.piano-wrap { width: 100%; overflow-x: auto; padding-bottom: 4px; }
.piano { display: block; width: 100%; user-select: none; touch-action: manipulation; }
.piano .white { fill: #fff; stroke: #9aa1ae; stroke-width: 1; }
.piano .black { fill: #22262e; stroke: #22262e; }
.piano.interactive .key { cursor: pointer; }
.piano .key.sel { fill: var(--accent); }
.piano .key.mark { fill: var(--mark); }
.piano .key.hl { fill: var(--mark); }
.piano .key.ok { fill: var(--ok); }
.piano .key.bad { fill: var(--bad); }
.piano .c4 { font-size: 9px; fill: #8a91a0; text-anchor: middle; pointer-events: none; }

.answers { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.name-row { display: flex; gap: 6px; width: 100%; justify-content: center; }
.opt {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 0; font-size: 1.1rem; font-weight: 600;
}
.opt:hover { border-color: var(--accent); }
.opt.name { flex: 1; max-width: 72px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 520px; }
.opt.choice { padding: 12px; font-size: 1rem; }
.opt.choice .staff { width: 100%; max-width: 200px; height: auto; display: block; margin: 0 auto; }
.opt.ok { background: var(--ok-bg); border-color: var(--ok); }
.opt.bad { background: var(--bad-bg); border-color: var(--bad); }

.btn { background: var(--accent); color: #fff; border: none; border-radius: 12px; padding: 12px 22px; font-weight: 600; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }

.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; display: none;
  justify-content: center; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px; border-top: 1px solid var(--line);
}
.feedback.show { display: flex; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback.ok .btn { background: var(--ok); }
.feedback.bad .btn { background: var(--bad); }

.result { text-align: center; margin-top: 40px; }
.result .row { display: flex; gap: 10px; justify-content: center; margin: 20px 0 8px; }

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .opt.name { font-size: 1rem; padding: 10px 0; }
}
