/* keyissue look (same in every app; only the accent changes): soft grey ground,
   white cards, the phone's own font. Light and dark follow the phone. */
:root {
  --bg: #F2F2F5; --surface: #FFFFFF; --sunk: #EDEDF1; --line: #E4E4E9;
  --fg: #111114; --muted: #5F5F6B;
  --accent: #6D28D9; --accent-ink: #FFFFFF; --accent-soft: #EEE8FB;
  --warn: #B42318; --good: #15803D; --good-soft: #E3F4E8; --wait: #A15C07; --wait-soft: #FBEFD9;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgb(17 17 20 / .04), 0 4px 16px rgb(17 17 20 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0B0E; --surface: #1C1C21; --sunk: #26262C; --line: #2E2E35;
    --fg: #F4F4F6; --muted: #A1A1AA;
    --accent: #A78BFA; --accent-ink: #0B0B0E; --accent-soft: #261C40;
    --warn: #F97066; --good: #4ADE80; --good-soft: #12301C; --wait: #F5B954; --wait-soft: #3A2C12; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0B0E; --surface: #1C1C21; --sunk: #26262C; --line: #2E2E35;
    --fg: #F4F4F6; --muted: #A1A1AA;
    --accent: #A78BFA; --accent-ink: #0B0B0E; --accent-soft: #261C40;
    --warn: #F97066; --good: #4ADE80; --good-soft: #12301C; --wait: #F5B954; --wait-soft: #3A2C12; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; text-wrap: balance; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 2.125rem; line-height: 1.1; letter-spacing: -.025em; }
h2 { font-size: 1.2rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 2.125rem; line-height: 1.1; letter-spacing: -.025em; }
.brand img { display: none; }
main { display: flex; flex-direction: column; gap: 18px; }
.section-title { font-size: .82rem; letter-spacing: .01em; color: var(--muted); font-weight: 600; margin: 6px 4px -8px; }

.btn { font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid transparent; background: var(--sunk); transition: transform .1s ease, filter .15s ease; color: var(--fg); }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--warn); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: progress; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; border: 0; background: var(--surface); box-shadow: var(--shadow); color: var(--fg); cursor: pointer; font-size: 1.1rem; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--sunk); position: sticky; top: calc(6px + env(safe-area-inset-top, 0px)); z-index: 2; }
.tabs button { flex: 1; font: inherit; font-weight: 600; font-size: .92rem; min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; position: relative; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.tabs { background: #E4E4EA; padding: 3px; border-radius: 12px; }
.tabs button { min-height: 36px; border-radius: 9px; }
.tabs button[aria-selected="true"] { box-shadow: 0 1px 3px rgb(17 17 20 / .12); }
.tabs .dot { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--wait); color: #fff; font-size: .72rem; }

.card { background: var(--surface); border: 1px solid transparent; border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.kid-head { display: flex; align-items: center; gap: 12px; }
.kid-head .grow { flex: 1; min-width: 0; }
.face { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; flex: none; background: var(--k, var(--accent)); }
.face.big { width: 64px; height: 64px; font-size: 2.1rem; }
.money { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.money.huge { font-size: clamp(2.6rem, 12vw, 3.6rem); line-height: 1; letter-spacing: -.02em; }
.money.neg { color: var(--warn); }
.money.pos { color: var(--good); }
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 16px; }

.goal { width: 100%; text-align: left; font: inherit; color: inherit; background: var(--bg); border: 1px dashed var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; margin-top: 6px; }
.bar { height: 8px; border-radius: 999px; background: var(--sunk); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--k, var(--accent)); border-radius: inherit; transition: width .4s ease; }

.chores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chore { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 16px; border: 1px solid transparent; background: var(--surface); box-shadow: var(--shadow); color: var(--fg); font: inherit; text-align: left; cursor: pointer; transition: transform .1s ease; }
.chore:active { transform: scale(.985); }
.chore .em { font-size: 1.6rem; width: 36px; text-align: center; flex: none; }
.chore .grow { flex: 1; min-width: 0; }
.chore .t { font-weight: 600; }
.chore .sub { color: var(--muted); font-size: .84rem; }
.chore .box { width: 30px; height: 30px; border-radius: 999px; border: 2px solid #C7C7D1; flex: none; display: grid; place-items: center; font-weight: 700; }
.chore.pending { border-color: var(--wait); background: var(--wait-soft); }
.chore.pending .box { border-color: var(--wait); color: var(--wait); }
.chore.approved { border-color: var(--good); background: var(--good-soft); }
.chore.approved .box { border-color: var(--good); background: var(--good); color: #fff; }
.chore.approved .t { text-decoration: line-through; text-decoration-thickness: 2px; }
.chore.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .chore.pop { animation: none; } .bar > i { transition: none; } }
.chore.plain { cursor: default; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: .84rem; }
.empty { color: var(--muted); font-size: .95rem; text-align: center; padding: 18px 8px; }

dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto; border: 0; border-radius: 22px; background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgb(0 0 0 / .25); }
dialog::backdrop { background: rgb(10 10 25 / .45); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-body { padding: 4px 16px 16px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.sheet-foot .left { margin-right: auto; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-weight: 600; font-size: .9rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
input, select { font: inherit; font-size: 1rem; padding: 10px 12px; min-height: 44px; border-radius: 12px; min-width: 0; width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: .88rem; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; }
.emojis label { width: 42px; height: 42px; display: grid; place-items: center; font-size: 1.4rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.emojis input { position: absolute; opacity: 0; pointer-events: none; }
.emojis label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.emojis label:has(input:focus-visible) { outline: 3px solid var(--accent); }
.msg { color: var(--warn); font-size: .92rem; margin-top: 10px; }
.msg:empty { display: none; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem; box-shadow: 0 8px 24px rgb(0 0 0 / .2); z-index: 10; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs { background: var(--sunk); } :root:not([data-theme="light"]) .chore .box { border-color: #4A4A52; } }
@media (max-width: 420px) { .pair { grid-template-columns: 1fr; } }
.card .chore:not(.pending):not(.approved) { background: var(--bg); box-shadow: none; }


/* Shared Key Issue finish: consistent surfaces, controls, and motion. */
:root {
  --ki-card-radius: 18px;
  --ki-control-radius: 12px;
  --ki-card-shadow: 0 2px 5px rgb(17 17 20 / .035), 0 10px 26px rgb(17 17 20 / .045);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ki-card-shadow: none; }
}
:root[data-theme="dark"] { --ki-card-shadow: none; }
.card {
  border-radius: var(--ki-card-radius);
  border-color: color-mix(in srgb, var(--line) 72%, transparent);
  box-shadow: var(--ki-card-shadow);
}
.btn, .icon-btn, button {
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.btn { border-radius: var(--ki-control-radius); }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select, textarea {
  border-radius: var(--ki-control-radius);
}
:focus-visible {
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* ---------- Music Lessons ---------- */
.who { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 0; background: var(--surface); box-shadow: var(--shadow); color: var(--fg); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .9rem; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: 18px; padding: 14px; box-shadow: var(--ki-card-shadow, var(--shadow)); }
.stat b { display: block; font-family: var(--display); font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .82rem; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 88px; margin-top: 12px; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.week i { display: block; width: 100%; max-width: 28px; border-radius: 6px; background: var(--accent); min-height: 3px; }
.week i.none { background: var(--sunk); }
.week span { font-size: .72rem; color: var(--muted); }
.week .today span { color: var(--fg); font-weight: 700; }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--sunk); }
.seg button { flex: 1; font: inherit; font-weight: 600; font-size: .9rem; min-height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(17 17 20 / .12); }
.lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lesson-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.lessons li:last-child .lesson-row { border-bottom: 0; }
.lesson-row .num { width: 30px; height: 30px; border-radius: 999px; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); flex: none; }
.lesson-row.done .num { background: var(--good); border-color: var(--good); color: #fff; }
.lesson-row.next .num { border-color: var(--accent); color: var(--accent); }
.lesson-row .grow { flex: 1; min-width: 0; }
.lesson-row .t { font-weight: 600; }
.lesson-row .sub { color: var(--muted); font-size: .84rem; }
.chev { color: var(--muted); flex: none; }
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 0; min-height: 40px; }
.steps { margin: 8px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.chords { display: flex; flex-wrap: wrap; gap: 12px; }
.chord { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: var(--bg); border-radius: 14px; padding: 8px 10px 10px; color: var(--fg); font: inherit; cursor: pointer; }
.chord b { font-family: var(--display); font-size: 1.05rem; }
.chord svg { width: 92px; height: 110px; }
.chord .s { stroke: currentColor; stroke-width: 1.2; }
.chord .nut { stroke: currentColor; stroke-width: 4; }
.chord .dot { fill: var(--accent); }
.chord .fnum { fill: var(--accent-ink); font-size: 9px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.chord .mark { fill: none; stroke: currentColor; stroke-width: 1.3; }
.chord .xm { font-size: 10px; text-anchor: middle; fill: var(--muted); }
.grid { display: grid; gap: 2px; overflow-x: auto; font-variant-numeric: tabular-nums; }
.grid .lab { font-size: .78rem; color: var(--muted); font-weight: 600; padding-right: 6px; align-self: center; white-space: nowrap; }
.grid .cnt { font-size: .7rem; color: var(--muted); text-align: center; }
.grid .cnt.on { color: var(--fg); font-weight: 700; }
.grid .c { aspect-ratio: 1; min-width: 0; border-radius: 5px; background: var(--sunk); display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--accent-ink); }
.grid .c.beat { box-shadow: inset 2px 0 0 var(--line); }
.grid .c.hit { background: var(--accent); }
.grid .c.open { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.grid .c.now { outline: 2px solid var(--fg); outline-offset: 1px; }
.strum { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; text-align: center; }
.strum div { border-radius: 10px; background: var(--bg); padding: 8px 0; font-weight: 700; font-size: 1.1rem; }
.strum div.miss { color: var(--muted); font-weight: 400; }
.strum small { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }
.strum div.now { background: var(--accent-soft); outline: 2px solid var(--accent); }
.tab { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; line-height: 1.35; background: var(--bg); border-radius: 12px; padding: 10px 12px; overflow-x: auto; margin: 0; white-space: pre; }
.tab .now { background: var(--accent); color: var(--accent-ink); border-radius: 3px; }
.sticks { display: flex; flex-wrap: wrap; gap: 6px; }
.sticks span { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--bg); font-weight: 700; font-size: 1.1rem; }
.sticks span.L { color: var(--accent); }
.player { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.player input[type=range] { flex: 1; min-width: 120px; padding: 0; min-height: 32px; accent-color: var(--accent); border: 0; background: none; }
.bpm { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 64px; }
.links { display: flex; flex-direction: column; gap: 8px; }
.linkbtn { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); background: var(--bg); border-radius: 14px; padding: 12px 14px; font-weight: 600; }
.linkbtn .sub { color: var(--muted); font-size: .84rem; font-weight: 400; }
.linkbtn svg { color: var(--accent); flex: none; }
.timer { font-family: var(--display); font-weight: 700; font-size: clamp(3.2rem, 16vw, 4.6rem); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metro-bpm { font-family: var(--display); font-weight: 700; font-size: clamp(3.4rem, 18vw, 5rem); line-height: 1; font-variant-numeric: tabular-nums; }
.beats { display: flex; justify-content: center; gap: 10px; min-height: 26px; }
.beats i { width: 18px; height: 18px; border-radius: 50%; background: var(--sunk); transition: transform .06s ease, background-color .06s ease; }
.beats i.first { box-shadow: inset 0 0 0 2px var(--accent); }
.beats i.on { background: var(--accent); transform: scale(1.25); }
.round { width: 52px; height: 52px; border-radius: 999px; font-size: 1.4rem; padding: 0; }
.tuner-note { font-family: var(--display); font-weight: 700; font-size: clamp(4rem, 22vw, 6rem); line-height: 1; }
.tuner-note sub { font-size: .3em; color: var(--muted); }
.meter { position: relative; height: 54px; margin: 6px 0; width: 100%; max-width: 420px; }
.meter .scale { position: absolute; inset: 24px 0 auto; height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--warn), var(--wait) 35%, var(--good) 46%, var(--good) 54%, var(--wait) 65%, var(--warn)); opacity: .35; }
.meter .mid { position: absolute; left: 50%; top: 8px; bottom: 8px; width: 2px; background: var(--muted); transform: translateX(-1px); }
.meter .needle { position: absolute; top: 4px; bottom: 4px; width: 6px; border-radius: 3px; background: var(--fg); left: 50%; transform: translateX(-3px); transition: left .12s ease, background-color .12s ease; }
.meter.ok .needle { background: var(--good); }
.board li .avatar { width: 36px; height: 36px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .76rem; font-weight: 700; }
.fire { color: var(--wait); font-weight: 700; }
textarea { font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 12px; width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--fg); min-height: 70px; }
@media (max-width: 420px) { .stats { gap: 8px; } .stat { padding: 12px 10px; } .stat b { font-size: 1.4rem; } .chord svg { width: 80px; height: 96px; } }
