/* Drum Central - phone-first styles. Colors are tokens; dark mode redefines them. */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --text: #151821;
  --muted: #5d6374;
  --faint: #8a90a0;
  --border: #e1e4eb;
  --accent: #e8531c;
  --accent-ink: #ffffff;
  --accent-soft: #fde7dd;
  --blue: #2f6fe4;
  --good: #1f9d55;
  --warn: #c98a00;
  --master: #7c4dff;
  --danger: #d33b3b;
  --paper: #ffffff;
  --paper-ink: #111111;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 4px 16px rgba(20, 24, 33, .06);
  --radius: 16px;
  --nav-h: 64px;
  --head-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14;
    --surface: #161922;
    --surface-2: #1f232e;
    --text: #eef0f6;
    --muted: #a3a9b8;
    --faint: #6f7686;
    --border: #2a2f3c;
    --accent: #ff6a2b;
    --accent-ink: #160a04;
    --accent-soft: #3a1d10;
    --blue: #5b8ff5;
    --good: #3cc47a;
    --warn: #f0b429;
    --master: #a38bff;
    --danger: #ff6b6b;
    --paper: #f7f5ef;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14;
  --surface: #161922;
  --surface-2: #1f232e;
  --text: #eef0f6;
  --muted: #a3a9b8;
  --faint: #6f7686;
  --border: #2a2f3c;
  --accent: #ff6a2b;
  --accent-ink: #160a04;
  --accent-soft: #3a1d10;
  --blue: #5b8ff5;
  --good: #3cc47a;
  --warn: #f0b429;
  --master: #a38bff;
  --danger: #ff6b6b;
  --paper: #f7f5ef;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

/* ---- shell ------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--head-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 16px;
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text);
  display: inline-grid; place-items: center; cursor: pointer; text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.timer-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600;
  font-size: .9rem; cursor: pointer; font-variant-numeric: tabular-nums;
}
.timer-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.timer-chip.running { border-color: var(--accent); }
.timer-chip.running .dot { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

main {
  max-width: 720px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--faint); font-size: .7rem; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--accent); }

/* ---- building blocks ----------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 16px; }
.card h2 { margin-bottom: 8px; }
.card-link { display: block; text-decoration: none; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 10px; }
.section-title h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.section-title a { color: var(--accent); font-weight: 600; font-size: .9rem; text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 650;
  cursor: pointer; text-decoration: none; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.1rem; border-radius: 16px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn:disabled { opacity: .5; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px;
}
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1; min-height: 36px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font: inherit; font-weight: 650; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.status-new { background: var(--surface-2); color: var(--muted); }
.status-learning { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.status-learned { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.status-mastered { background: color-mix(in srgb, var(--master) 20%, transparent); color: var(--master); }
.chip.hybrid { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.dots i.on { background: var(--accent); }

.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s; }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* ---- home ---------------------------------------------------------------------------- */
.hello { margin: 4px 4px 14px; }
.hello h1 { font-size: 1.6rem; }
.hero { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.ring { width: 108px; height: 108px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .label b { font-size: 1.6rem; display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.level-row { display: flex; align-items: center; gap: 12px; }
.level-badge {
  width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #ffb347); color: #1a0d05; font-weight: 900; font-size: 1.35rem;
}
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 92px; margin-top: 10px; }
.week .col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.week .col i { width: 100%; max-width: 26px; border-radius: 4px 4px 0 0; background: var(--accent); min-height: 2px; }
.week .col i.zero { background: var(--border); }
.week .col span { font-size: .7rem; color: var(--faint); font-weight: 600; }
.ach-mini { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.ach-mini .a { flex: none; width: 92px; text-align: center; font-size: .75rem; }
.ach-mini .a .ic { font-size: 1.8rem; width: 56px; height: 56px; margin: 0 auto 4px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); }
.ach-mini .a.locked .ic { filter: grayscale(1); opacity: .45; }

/* ---- notation ------------------------------------------------------------------------ */
.paper { background: var(--paper); color: var(--paper-ink); border-radius: 12px; padding: 6px 4px; overflow: hidden; border: 1px solid var(--border); }
.paper svg { display: block; max-width: 100%; height: auto; }
.paper .vf-hl path, .paper .vf-hl rect { fill: var(--accent) !important; stroke: var(--accent) !important; }
.sticking { font-weight: 700; font-size: 1.05rem; line-height: 1.4; letter-spacing: .04em; word-spacing: .3em; }

/* ---- rudiments ----------------------------------------------------------------------- */
.filters { display: grid; gap: 10px; margin-bottom: 8px; }
.rud-list { display: grid; gap: 8px; }
.rud {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none;
}
.rud .num-badge { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; font-size: .85rem; color: var(--muted); }
.rud .name { font-weight: 700; }
.rud .sub { font-size: .78rem; color: var(--muted); letter-spacing: .03em; word-spacing: .15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rud.rotd { border-color: var(--accent); }
.level-head { display: flex; align-items: center; gap: 10px; margin: 20px 4px 8px; }
.level-head h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.status-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.status-pick button {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; padding: 4px;
}
.status-pick button.on.s-new { border-color: var(--faint); color: var(--text); }
.status-pick button.on.s-learning { border-color: var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.status-pick button.on.s-learned { border-color: var(--good); color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.status-pick button.on.s-mastered { border-color: var(--master); color: var(--master); background: color-mix(in srgb, var(--master) 14%, transparent); }
.tips { margin: 6px 0 0; padding-left: 20px; }
.tips li + li { margin-top: 4px; }
.spark { width: 100%; height: 70px; display: block; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.spark .goal { stroke: var(--faint); stroke-dasharray: 4 4; stroke-width: 1; }

/* ---- metronome ----------------------------------------------------------------------- */
.met-display { text-align: center; padding: 8px 0 4px; }
.bpm { font-size: 5.2rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.bpm-label { color: var(--muted); font-weight: 600; font-size: .9rem; }
.bpm-row { display: grid; grid-template-columns: 56px 56px 1fr 56px 56px; gap: 8px; align-items: center; margin-top: 12px; }
.bpm-row .btn { min-height: 52px; padding: 0; font-size: 1.1rem; }
.beats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 16px 0 6px; }
.beat {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center; font-weight: 800; color: var(--muted); cursor: pointer; position: relative;
  transition: transform .06s, background .06s;
}
.beat[data-level="3"] { border-color: var(--accent); color: var(--accent); }
.beat[data-level="1"] { border-style: dashed; }
.beat[data-level="0"] { opacity: .35; }
.beat.now { background: var(--accent); color: var(--accent-ink); transform: scale(1.12); border-color: var(--accent); }
.beat.now[data-level="0"] { background: var(--surface-2); color: var(--muted); }
.beat-help { text-align: center; font-size: .75rem; color: var(--faint); }
.flash-overlay { position: fixed; inset: 0; background: var(--accent); opacity: 0; pointer-events: none; z-index: 30; transition: opacity .12s; }
.play-btn { width: 100%; min-height: 64px; font-size: 1.25rem; border-radius: 18px; margin-top: 14px; }
.met-status { text-align: center; min-height: 1.4em; margin-top: 8px; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; box-shadow: var(--shadow); }
details.panel > summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; font-size: 1.3rem; color: var(--muted); }
details.panel[open] > summary::after { content: "–"; }
details.panel > .body { padding: 0 16px 16px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch input { width: 46px; height: 28px; accent-color: var(--accent); }
.preset-list { display: grid; gap: 6px; margin-top: 10px; }
.preset { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.preset .grow { font-weight: 600; }
.mini-met { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; }
.mini-met .val { text-align: center; font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---- reading ------------------------------------------------------------------------- */
.reading-controls { display: grid; gap: 10px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.level-desc { font-size: .85rem; color: var(--muted); }

/* ---- Drum Tech ----------------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.assistant p:first-child, .msg.assistant ul:first-child { margin-top: 0; }
.msg.assistant p:last-child, .msg.assistant ul:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { padding-left: 20px; margin: .4em 0; }
.msg.assistant code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; font-size: .92em; }
.msg.assistant pre { background: var(--surface-2); padding: 10px; border-radius: 10px; overflow-x: auto; }
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant h3, .msg.assistant h4 { margin: .6em 0 .3em; font-size: 1rem; }
.msg.error { align-self: stretch; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-radius: 12px; font-size: .9rem; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); margin-right: 4px; animation: bounce 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 50% { transform: translateY(-5px); opacity: .5; } }
.composer {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 10px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.composer form { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; border-radius: 22px; padding: 11px 16px; }
.composer .btn { border-radius: 50%; width: 44px; min-height: 44px; padding: 0; flex: none; }
.tech-main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 100px); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .88rem; cursor: pointer; text-align: left; }
.tech-intro { text-align: center; padding: 18px 8px 8px; }
.tech-intro .avatar { width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 22px; }

/* ---- stats --------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.chart { position: relative; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .goal { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .axis { fill: var(--faint); font-size: 10px; font-family: inherit; }
.chart .b { fill: var(--accent); }
.chart .b.zero { fill: var(--border); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .b, .chart .b.sel { fill: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%); white-space: nowrap;
  background: var(--text); color: var(--bg); padding: 5px 9px; border-radius: 8px; font-size: .78rem; font-weight: 600;
}
.hbars { display: grid; gap: 10px; }
.hbar .top { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 4px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 999px; }
.hbar .track i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.list { display: grid; }
.list .item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.list .item:first-child { border-top: 0; }

/* ---- achievements -------------------------------------------------------------------- */
.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ach { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 12px; text-align: center; }
.ach .ic { font-size: 2rem; }
.ach b { display: block; margin-top: 4px; }
.ach.locked .ic { filter: grayscale(1); opacity: .4; }
.ach.locked { background: transparent; }
.ranks { display: grid; gap: 6px; }
.rank { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; }
.rank.cur { outline: 2px solid var(--accent); }

/* ---- toasts & sheets ----------------------------------------------------------------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 64px); z-index: 50; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 420px; width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: drop .35s ease-out;
}
.toast .ic { font-size: 1.6rem; }
.toast.big { border-color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin-bottom: 12px; }
.big-clock { font-size: 3.4rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .7; } }

@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .ach-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Grid and flex children may shrink below their content (keeps scrollable segments inside the card). */
.filters > *, .reading-controls > *, .stack > *, .card > *, .seg { min-width: 0; }
.rud-list > *, .kpis > *, .stat-grid > * { min-width: 0; }
.brand span { white-space: nowrap; font-size: .98rem; }
.topbar { gap: 4px; }
.icon-btn { width: 36px; }
.timer-chip { padding: 0 10px; }
@media (max-width: 370px) { .brand span { display: none; } }
.bpm-row { grid-template-columns: repeat(4, 1fr); }
.bpm-row input[type=range] { grid-column: 1 / -1; order: -1; }
.stat-grid.four { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-grid.four .stat { padding: 10px 4px; }
.stat-grid.four .stat span { font-size: .62rem; letter-spacing: .02em; }

/* ---- v2: catalog pictures, levels, medals, belts, quests --------------------------------- */
.rud { display: block; }
.rud-top { display: flex; align-items: center; gap: 12px; }
.rud .num-badge.tenor { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.thumb { margin-top: 10px; min-height: 64px; padding: 2px; }
.thumb svg { max-height: 120px; }
.chip.tenor { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.lvl {
  display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .75rem;
}
.seg.tight button { padding: 0 4px; min-width: 0; font-size: .85rem; }
.bar.thin { height: 6px; }

.medal { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18), 0 0 0 2px color-mix(in srgb, var(--surface) 70%, transparent); }
.medal.big { width: 28px; height: 28px; }
.medal-bronze { background: radial-gradient(circle at 35% 30%, #f2b27a, #a0602a); }
.medal-silver { background: radial-gradient(circle at 35% 30%, #ffffff, #9aa3ad); }
.medal-gold { background: radial-gradient(circle at 35% 30%, #fff1a8, #d4a017); }
.medal-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.medal-step { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px; border-radius: 12px;
  background: var(--surface-2); text-align: center; font-size: .85rem; opacity: .55; }
.medal-step.got { opacity: 1; outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.medal-step .medal { width: 26px; height: 26px; }

.belt { display: inline-block; width: 30px; height: 12px; border-radius: 4px; background: var(--belt);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); position: relative; vertical-align: middle; }
.belt::after { content: ""; position: absolute; left: 50%; top: -3px; width: 8px; height: 18px; margin-left: -4px;
  border-radius: 3px; background: var(--belt); box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.belt.sm { width: 22px; height: 9px; }
.belt.sm::after { top: -2px; height: 13px; width: 6px; margin-left: -3px; }
.belt-card { display: flex; align-items: center; gap: 14px; }
.belt-card > .belt { width: 44px; height: 16px; flex: none; }
.belt-card > .belt::after { height: 24px; top: -4px; width: 10px; margin-left: -5px; }
.belts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.belt-step { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 2px; border-radius: 12px;
  background: var(--surface-2); font-size: .78rem; text-align: center; opacity: .45; }
.belt-step.got { opacity: 1; }
.belt-step.next { opacity: 1; outline: 2px dashed var(--accent); }
.belt-step .belt { margin-top: 4px; }

.quests { display: grid; gap: 12px; }
.quest { display: flex; align-items: center; gap: 12px; }
.quest .check { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-weight: 800; font-size: .85rem; color: var(--muted); }
.quest.done .check { background: var(--good); color: #fff; }
.quest.done .grow > div:first-child { color: var(--muted); text-decoration: line-through; }
.quest.done .bar > span { background: var(--good); }

/* ---- v3: chop builder ------------------------------------------------------------------ */
.tabbar a { font-size: .66rem; }
.num-badge.chop { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.plan .item { gap: 12px; }
.plan .check { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-weight: 800; font-size: .8rem; color: var(--muted); }
.run-light { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border);
  vertical-align: middle; margin-left: 6px; transition: background .05s; }
.run-light.on { background: var(--accent); }
.paper.dim { opacity: .4; }
.seg.wrap { flex-wrap: wrap; overflow: visible; }
.seg.wrap button { flex: 1 1 30%; }

/* ---- v4: section nav, scales, quiz, note names, calendar --------------------------------- */
.section-nav a { flex: 1; text-align: center; min-height: 36px; display: grid; place-items: center; border-radius: 9px;
  text-decoration: none; color: var(--muted); font-weight: 650; font-size: .9rem; }
.section-nav a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.num-badge.scale, .chip.scale { background: color-mix(in srgb, var(--master) 16%, transparent); color: var(--master); }
.rud .num-badge.scale { font-size: .75rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices .btn { min-height: 56px; font-size: .92rem; line-height: 1.2; white-space: normal; text-align: center; padding: 6px 8px; }
.choices .btn.right { background: color-mix(in srgb, var(--good) 22%, var(--surface-2)); border-color: var(--good); color: var(--text); }
.choices .btn.wrong { background: color-mix(in srgb, var(--danger) 22%, var(--surface-2)); border-color: var(--danger); }
.nn-staff { min-height: 150px; }
.nn-staff svg { max-height: 190px; }
.nn-feedback { min-height: 1.6em; text-align: center; font-weight: 700; }
.nn-feedback.right { color: var(--good); }
.nn-feedback.wrong { color: var(--danger); }
.nn-letters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.nn-letters .btn { min-height: 56px; padding: 0; font-size: 1.25rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-h { font-size: .7rem; color: var(--faint); font-weight: 700; padding-bottom: 2px; }
.cal-d { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; font-size: .8rem;
  font-weight: 600; background: var(--surface-2); color: var(--muted); }
.cal-d.practiced { background: var(--accent); color: var(--accent-ink); }
.cal-d.frozen { background: color-mix(in srgb, var(--blue) 30%, var(--surface-2)); color: var(--text); }
.cal-d.goal { box-shadow: inset 0 0 0 2px var(--good); }
.cal-d.today { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-d.future { opacity: .35; }
.cal-d .star { position: absolute; top: -5px; right: -3px; font-size: .6rem; font-style: normal; }
.cal-key { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; background: var(--surface-2); }
.cal-key.practiced { background: var(--accent); }
.cal-key.goal { box-shadow: inset 0 0 0 2px var(--good); }
.cal-key.frozen { background: color-mix(in srgb, var(--blue) 30%, var(--surface-2)); }

.thumb svg { max-height: 210px; }
.nn-staff { display: grid; place-items: center; }

/* ---- accounts and profile pictures ---------------------------------------------------- */
main.auth { max-width: 440px; margin: 0 auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.auth-hero { text-align: center; margin: 12px 4px 16px; }
.auth-hero img { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); }
.auth-hero h1 { margin: 12px 0 6px; }
.auth-hero p { margin: 0 auto; max-width: 34ch; }
.auth-alt { text-align: center; margin: 16px 4px 0; }
.auth input[readonly] { color: var(--muted); }
.form-error { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: .9rem;
  background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  overflow: hidden; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 2.4rem; box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.me-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; text-decoration: none; }
.me-btn img, .me-btn span { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: grid;
  place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .95rem;
  box-shadow: 0 0 0 2px var(--border); }
.me-btn:active img, .me-btn:active span { box-shadow: 0 0 0 2px var(--accent); }

.profile-head { display: flex; align-items: center; gap: 16px; margin: 8px 4px 16px; }
.profile-head h1 { margin: 0 0 2px; }
.profile-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-height: 56px; }
.profile-link .faint { font-size: 1.6rem; }

.avatar-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px;
  border: 2px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; min-height: 44px; }
.avatar-pick .avatar { width: 64px; height: 64px; font-size: 1.8rem; background: var(--surface-2); }
.avatar-pick b { font-size: .78rem; line-height: 1.15; text-align: center; }
.avatar-pick.on { border-color: var(--accent); background: var(--accent-soft); }
.avatar-pick:active { transform: scale(.97); }
label.btn { cursor: pointer; }

/* ---- admin ------------------------------------------------------------------------------ */
.bars30 { display: grid; grid-template-columns: repeat(30, 1fr); gap: 2px; align-items: end; height: 90px; margin: 10px 0 4px; }
.bars30 span { height: 100%; display: flex; align-items: flex-end; }
.bars30 i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: var(--accent); }
.bars30 i.zero { background: var(--border); }
.list-cards { display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; }
.user-row + .user-row { margin-top: 0; }
.stat-grid .stat b { overflow-wrap: anywhere; }

/* ---- friends ---------------------------------------------------------------------------- */
.me-btn { position: relative; }
.dot-badge { position: absolute; top: 5px; right: 4px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--bg); }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar.xs { width: 22px; height: 22px; font-size: .7rem; vertical-align: middle; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; text-decoration: none; }
.board-row + .board-row { border-top: 1px solid var(--border); }
.board-row.me { background: var(--accent-soft); }
.board-row .place { width: 28px; text-align: center; font-weight: 800; color: var(--muted); font-size: 1rem; }
.podium-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.podium-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); font-size: .8rem; font-weight: 600; }
.podium-chip.me { outline: 2px solid var(--accent); }
.cheer-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cheer-row .btn { font-size: 1.6rem; padding: 0; }
.cheer-note { display: flex; align-items: center; gap: 10px; border-color: var(--accent); }
.cheer-big { font-size: 1.6rem; }

/* Drum Tech budget */
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--good); transition: width .3s; }
.tech-budget { padding: 10px 14px; margin-bottom: 12px; }
.tech-budget.over .meter i { background: var(--warn); }
.tech-budget.over { border-color: var(--warn); }
