:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --ink: #1d1b19;
  --muted: #6f6a63;
  --line: #e2ddd5;
  --accent: #b9532f;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3da;
  --good: #23885a;
  --good-soft: #d8f0e3;
  --bad: #cc3d33;
  --bad-soft: #f8dcd9;
  --mid: #c8901a;
  --key-white: #fffdf9;
  --key-black: #22201e;
  --key-edge: #b8b2a8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 30, 20, 0.06), 0 4px 16px rgba(40, 30, 20, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #212126;
    --surface-2: #2a2a30;
    --ink: #eeebe6;
    --muted: #9c978f;
    --line: #34343b;
    --accent: #e0774f;
    --accent-ink: #1a1210;
    --accent-soft: #3d2a22;
    --good: #4cc488;
    --good-soft: #1f3a2d;
    --bad: #f0675c;
    --bad-soft: #43231f;
    --mid: #e2b04a;
    --key-white: #ecebe7;
    --key-black: #0f0f12;
    --key-edge: #55555c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h3 { font-size: 1rem; margin-bottom: 8px; }
svg { display: block; }

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
body.in-drill .container { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
body.in-drill .tabbar { display: none; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.hint { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

/* ---- hero ---- */
.hero { padding: 12px 2px 18px; }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.02em; font-weight: 800; }
.hero h1::after { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-left: 4px; }
.hero p { margin: 4px 0 0; color: var(--muted); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; flex-wrap: wrap; }
.label { font-weight: 600; font-size: 0.95rem; }

/* ---- segmented ---- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; font-weight: 600;
  padding: 7px 12px; border-radius: 9px; cursor: pointer; min-height: 36px;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---- toggle ---- */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 6px; cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); }
.toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings .row + .toggle { border-top: 1px solid var(--line); margin-top: 6px; }

/* ---- drill cards ---- */
.drills { display: grid; gap: 12px; margin-bottom: 14px; }
.drill-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none;
  border: 1px solid transparent; transition: transform .08s, border-color .15s;
}
.drill-card:active { transform: scale(0.985); }
.drill-card:hover { border-color: var(--line); }
.drill-card .icon { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.drill-card .icon svg { width: 34px; height: 34px; }
.drill-card .text { display: flex; flex-direction: column; flex: 1; }
.drill-card small { color: var(--muted); font-size: 0.88rem; }
.badge { font-size: 0.8rem; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 3px 9px; border-radius: 99px; }
.badge::before { content: "seri "; font-weight: 500; }

.install { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.install div { display: flex; flex-direction: column; }
.install small { color: var(--muted); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700;
  padding: 12px 20px; border-radius: 12px; cursor: pointer; text-decoration: none; min-height: 48px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--ink); flex: none; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--surface-2); }

/* ---- drill ---- */
.drill-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.progress { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress[hidden] { display: block; visibility: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.score { display: flex; gap: 10px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.score span::before { margin-right: 3px; font-weight: 800; }
.score .ok { color: var(--good); }
.score .ok::before { content: "✓"; }
.score .bad { color: var(--bad); }
.score .bad::before { content: "✗"; }
.score .streak { color: var(--muted); }
.score .streak::before { content: "seri"; font-weight: 500; font-size: 0.8rem; }

.drill { display: flex; flex-direction: column; min-height: calc(100dvh - 90px); }
.prompt { text-align: center; color: var(--muted); margin: 10px 0 6px; font-weight: 600; }
.clef-tag { display: inline-block; background: var(--surface-2); color: var(--ink); border-radius: 99px; padding: 1px 10px; margin-right: 8px; font-size: 0.82rem; }
.stage {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 18px; display: flex; justify-content: center; align-items: center; min-height: 220px;
}
.stage .staff { width: 100%; max-width: 330px; height: auto; color: var(--ink); }
.stage-keys { padding: 18px 12px; }
.stage .keyboard { width: 100%; max-width: 520px; }
.feedback { text-align: center; min-height: 1.6em; margin: 12px 0; font-weight: 600; }
.feedback .good { color: var(--good); }
.feedback .bad { color: var(--bad); }
.input { margin-top: auto; padding-bottom: 8px; }
.staff-key .input { overflow-x: auto; }

.note.correct { color: var(--good); }
.note.wrong { color: var(--bad); }
.note.lvl-good { color: var(--good); }
.note.lvl-mid { color: var(--mid); }
.note.lvl-bad { color: var(--bad); }
.note.none { color: var(--key-edge); }
.staff-label { font-size: 9px; fill: var(--muted); font-family: inherit; font-weight: 600; }

.answers { display: grid; gap: 8px; }
.answer-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ans {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700;
  font-size: 1.05rem; border-radius: 12px; min-height: 58px; cursor: pointer; padding: 0 2px;
  box-shadow: 0 2px 0 var(--line); transition: transform .05s;
}
.ans:active { transform: translateY(2px); box-shadow: none; }
.ans.acc { min-height: 46px; font-size: 0.92rem; background: var(--surface-2); }
.with-acc .ans:not(.acc) { min-height: 54px; }
.ans.correct { background: var(--good); border-color: var(--good); color: #fff; box-shadow: none; }
.ans.wrong { background: var(--bad); border-color: var(--bad); color: #fff; box-shadow: none; }
.ans:disabled { cursor: default; }
.ans-gap { display: block; }

/* ---- keyboard ---- */
.keyboard { width: 100%; height: auto; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.key.white rect { fill: var(--key-white); stroke: var(--key-edge); stroke-width: 1; }
.key.black rect { fill: var(--key-black); stroke: var(--key-black); }
.key text { font-size: 10px; fill: var(--muted); font-weight: 700; font-family: inherit; }
.key .dot { fill: var(--accent); }
.key.black .dot { fill: var(--accent); }
.key.target.white rect { fill: var(--accent-soft); }
.key.target.black rect { fill: #5a3324; }
.key.correct rect { fill: var(--good) !important; }
.key.correct text { fill: #fff; }
.key.wrong rect { fill: var(--bad) !important; }
.key.wrong text { fill: #fff; }
.keyboard.interactive .key { cursor: pointer; }
.keyboard.interactive .key.white:active rect { fill: var(--surface-2); }
.keyboard.interactive .key.black:active rect { fill: #444; }
.staff-key .input .keyboard { min-width: 340px; }

/* ---- results ---- */
.results { text-align: center; padding-top: 32px; }
.results h2 { font-size: 1.6rem; }
.results .big { font-size: 4.5rem; font-weight: 800; letter-spacing: -0.03em; color: var(--accent); line-height: 1.1; margin: 10px 0 16px; }
.results .big small { font-size: 2rem; }
.results h3 { margin-top: 22px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-row div { display: flex; flex-direction: column; }
.stat-row b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat-row small { color: var(--muted); font-size: 0.8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.card .chips { justify-content: flex-start; }
.chip { background: var(--bad-soft); color: var(--ink); border-radius: 99px; padding: 4px 12px; font-weight: 600; font-size: 0.9rem; }
.chip em { font-style: normal; color: var(--bad); margin-left: 4px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; }

/* ---- pages ---- */
.page-top { display: flex; align-items: center; gap: 8px; margin: 8px 0 16px; min-height: 40px; }
.page-top h2 { font-size: 1.5rem; }
.list { display: grid; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none; font-weight: 600;
}
.list-item .num { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; flex: none; }
.list-item .chev { margin-left: auto; color: var(--muted); font-size: 1.4rem; }
.lesson p { margin: 12px 0; }
.lesson .staff { color: var(--ink); width: 100%; height: auto; }
.lesson .keyboard { margin: 12px auto; max-width: 340px; }
.lesson-staves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lesson-staves figure { margin: 0; }
.lesson-staves figcaption { font-size: 0.82rem; color: var(--muted); }
.scroll-x { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.scroll-x .staff { min-width: 460px; color: var(--ink); }
.scroll-x .keyboard { min-width: 440px; }
.sessions { list-style: none; padding: 0; margin: 0; }
.sessions li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.sessions li:last-child { border-bottom: 0; }

/* ---- tab bar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600; border-radius: 12px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }

@media (max-width: 380px) {
  .ans { font-size: 0.92rem; min-height: 52px; }
  .ans.acc { font-size: 0.8rem; }
  .seg button { padding: 7px 9px; font-size: 0.85rem; }
}
@media (min-height: 760px) {
  .stage { min-height: 260px; }
}

/* ---- öğrenme seviyeleri ---- */
:root { --l0: #cc3d33; --l1: #e08a3c; --l2: #d8b43a; --l3: #7cbf6a; --l4: #35a066; --l5: #1f7a4f; --lnone: #c9c3ba; }
@media (prefers-color-scheme: dark) {
  :root { --l0: #f0675c; --l1: #f09a52; --l2: #e6c450; --l3: #8fd27c; --l4: #4cc488; --l5: #2fa36b; --lnone: #55555c; }
}
.note.lvl-0 { color: var(--l0); } .note.lvl-1 { color: var(--l1); } .note.lvl-2 { color: var(--l2); }
.note.lvl-3 { color: var(--l3); } .note.lvl-4 { color: var(--l4); } .note.lvl-5 { color: var(--l5); }
.note.none { color: var(--lnone); }
.key.white.lvl-0 rect { fill: var(--l0); } .key.white.lvl-1 rect { fill: var(--l1); } .key.white.lvl-2 rect { fill: var(--l2); }
.key.white.lvl-3 rect { fill: var(--l3); } .key.white.lvl-4 rect { fill: var(--l4); } .key.white.lvl-5 rect { fill: var(--l5); }
.key.black.lvl-0 rect { fill: var(--l0); } .key.black.lvl-1 rect { fill: var(--l1); } .key.black.lvl-2 rect { fill: var(--l2); }
.key.black.lvl-3 rect { fill: var(--l3); } .key.black.lvl-4 rect { fill: var(--l4); } .key.black.lvl-5 rect { fill: var(--l5); }
.key[class*="lvl-"] text { fill: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend i.lvl-0 { background: var(--l0); } .legend i.lvl-1 { background: var(--l1); } .legend i.lvl-2 { background: var(--l2); }
.legend i.lvl-3 { background: var(--l3); } .legend i.lvl-4 { background: var(--l4); } .legend i.lvl-5 { background: var(--l5); }
.legend i.none { background: var(--lnone); }
.legend p { flex-basis: 100%; margin: 6px 0 0; font-weight: 400; }
.mastery-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 4px 0 6px; }
.mastery-bar i { display: block; height: 100%; }
.b-known { background: var(--l4); } .b-learning { background: var(--l2); } .b-weak { background: var(--l0); } .b-unseen { background: var(--lnone); opacity: .5; }
.map .keyboard { max-width: 340px; margin: 8px auto 0; }
.mini-progress { display: block; height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 3px; }
.mini-progress i { display: block; height: 100%; background: var(--l4); border-radius: 99px; }
.drill-card .progress-text { font-size: 0.78rem; }
.new-tag { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 1px 10px; margin-right: 8px; font-size: 0.82rem; }
.chip.good { background: var(--good-soft); }
.chip.neutral { background: var(--surface-2); }
.mastery-card { margin-top: 18px; text-align: left; }
.mastery-bar.mini { height: 6px; margin: 8px 0 3px; }

/* ---- öğretici kartlar ---- */
.drill.teaching { min-height: auto; }
.teach { text-align: center; }
.teach-tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.82rem; border-radius: 99px; padding: 2px 12px; }
.teach-name { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 2px; color: var(--accent); }
.teach-staff { background: var(--surface); border-radius: var(--radius); padding: 4px 12px; display: flex; justify-content: center; }
.teach-staff .staff { width: 100%; max-width: 230px; height: auto; color: var(--ink); }
.teach .note.teach { color: var(--accent); }
.teach-keys { margin: 6px auto 4px; max-width: 250px; }
.teach-tips { text-align: left; padding-left: 20px; margin: 10px 0 0; font-size: 0.92rem; }
.teach-tips li { margin: 6px 0; }
.drill.teaching .teach { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 8px; }
.teach-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 16px; }
.hint-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px 8px; }
.cards-seg { display: flex; margin-bottom: 14px; }
.cards-seg button { flex: 1; }
.card-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; }
.list-item.featured { margin-bottom: 14px; border: 1px solid var(--accent-soft); }
.list-item.featured > span:nth-child(2) { display: flex; flex-direction: column; }
.list-item.featured small { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
