/* =========================================================================
   TM Guitar — GuitarTuna-grade shell (v9)
   Bottom tab bar · flat dark canvas · mint accent · pill controls
   ========================================================================= */

/* ---------- canvas ---------- */
body {
  /* Morabba's space glyph is ~0.1em — restore a normal word gap */
  word-spacing: .14em;
  background-image: none;
  background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0px));
  font-size: 15px;
  line-height: 1.6;
}
.wrap { padding-top: 6px; }

/* ---------- top bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.appbar.is-stuck { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}
.brand-mark img { width: 20px; height: 20px; }
.brand-text { min-width: 0; }
.brand-name {
  font-size: 15px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15;
  color: var(--ink);
}
.brand-name span { color: var(--primary); }
.brand-sub { display: none; }
.appbar-spacer { flex: 1; }
.appbar-tools { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  color: var(--ink-2); background: transparent;
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn svg { width: 21px; height: 21px; }

/* ---------- bottom tab bar ---------- */
.tabnav {
  position: fixed; inset-inline: 0; bottom: 0; top: auto; z-index: 60;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-flow: row;
  align-items: stretch;
  background: var(--bg-2);
  border: 0; border-top: 1px solid var(--line); border-bottom: 0;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, .9);
}
.tabnav-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 4px;
  padding-top: 15px;
  color: var(--ink-3);
  transition: color .16s;
  -webkit-tap-highlight-color: transparent;
}
.tabnav-btn svg {
  width: 24px; height: 24px; flex: none;
  stroke-width: 1.9;
  transition: transform .18s cubic-bezier(.3, 1.5, .5, 1);
}
.tabnav-btn span {
  font-size: 11px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em;
}
.tabnav-btn:hover { background: transparent; color: var(--ink-2); }
.tabnav-btn.active,
html[data-theme="dark"] .tabnav-btn.active,
html[data-theme="light"] .tabnav-btn.active {
  color: var(--primary);
  background: transparent;
  box-shadow: none;
}
.tabnav-btn.active svg { transform: translateY(-1px) scale(1.04); }
.tabnav-btn:active svg { transform: scale(.92); }
.tabnav-btn:focus-visible { outline-offset: -4px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: none;
}
html[data-theme="dark"] .card { background: var(--surface); border-color: var(--line); }

/* ---------- buttons ---------- */
.btn {
  min-height: 46px; padding: 0 20px; border-radius: var(--r-pill);
  font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s, filter .16s, background .16s;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--surface-3); }
.btn-block { width: 100%; }

/* ---------- segmented pill (GuitarTuna "Simplified / Original / Tabs") ---------- */
.seg {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--surface); border-radius: var(--r-pill);
  border: 1px solid var(--line);
}
.seg-btn {
  height: 34px; padding: 0 14px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 700; color: var(--ink-2);
  transition: background .16s, color .16s;
  white-space: nowrap;
}
.seg-btn[aria-selected="true"] {
  background: var(--primary); color: var(--primary-ink);
}

/* ---------- chip / tag ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 7px;
  background: var(--surface-2); color: var(--ink-2);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
}
.chip-green { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }

/* ---------- section header ---------- */
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 18px 2px 10px;
}
.sec-title { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.sec-link { font-size: 13px; font-weight: 700; color: var(--primary); }

/* ---------- list rows ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 14px;
  background: var(--surface); border-radius: var(--r-l);
}
.row + .row { margin-top: 8px; }
.row-ico {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
}
.row-ico svg { width: 19px; height: 19px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14.5px; font-weight: 700; }
.row-sub { font-size: 12.5px; color: var(--ink-3); }

/* ---------- empty state ---------- */
.empty {
  display: grid; justify-items: center; gap: 10px;
  padding: 40px 20px; text-align: center; color: var(--ink-3);
}
.empty svg { width: 44px; height: 44px; opacity: .5; }
.empty b { color: var(--ink); font-size: 15px; }

/* ---------- sheet ---------- */
.sheet {
  background: var(--surface); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .tabnav {
    position: sticky; bottom: 0; top: auto;
    max-width: 620px; margin: 0 auto 14px;
    border-radius: 20px; border: 1px solid var(--line);
  }
  body { padding-bottom: 20px; }
}

/* =========================================================================
   CHORD LIBRARY
   ========================================================================= */
.ch-wrap { padding: 4px 14px 0; max-width: 760px; margin: 0 auto; }
.ch-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.ch-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.ch-top { margin: 6px 2px 14px; }

.ch-search-wrap { position: relative; margin-bottom: 12px; }
.ch-search {
  width: 100%; height: 46px; padding-block: 0; padding-inline: 42px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); color: var(--ink); font-size: 14px;
  -webkit-appearance: none; appearance: none;
}
.ch-search::placeholder { color: var(--ink-3); }
.ch-search:focus { outline: none; border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); }
.ch-search-ico {
  position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-3); pointer-events: none;
}
.ch-search::-webkit-search-cancel-button { display: none; }

.ch-filters {
  display: flex; gap: 6px; padding: 0 0 4px; margin-bottom: 14px;
  overflow-x: auto; scrollbar-width: none;
  background: none; border: 0;
}
.ch-filters::-webkit-scrollbar { display: none; }
.ch-filters .seg-btn {
  flex: none; height: 34px; padding: 0 15px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 13px;
}
.ch-filters .seg-btn[aria-selected="true"] {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
}

.ch-detail { padding: 16px; }
.ch-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ch-detail-sym { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.ch-detail-fa { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.ch-play { min-height: 42px; padding: 0 18px; font-size: 14px; }
.ch-play svg { width: 16px; height: 16px; }
.ch-detail-body { display: flex; gap: 18px; align-items: center; margin-top: 14px; }
.cd-svg { width: 132px; height: 176px; flex: none; }
.ch-facts { display: grid; gap: 8px; flex: 1; min-width: 0; }
.ch-fact {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 11px; border-radius: 11px; background: var(--surface-2);
}
.ch-fact span { font-size: 11px; color: var(--ink-3); }
.ch-fact b { font-size: 13px; font-weight: 700; }

.ch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 520px) { .ch-grid { grid-template-columns: repeat(6, 1fr); } }
.ch-cell {
  aspect-ratio: 1 / 1; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; color: var(--ink);
  transition: transform .1s, border-color .16s, background .16s;
}
.ch-cell:active { transform: scale(.95); }
.ch-cell.is-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.ch-sym { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.ch-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-3); padding: 26px 0; font-size: 14px; }

/* =========================================================================
   PROFILE / SETTINGS
   ========================================================================= */
.pf-wrap { padding: 4px 14px 0; max-width: 620px; margin: 0 auto; }
.pf-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 18px; border-radius: var(--r-xl);
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 18%, var(--surface)) 0%, var(--surface) 62%);
  border: 1px solid var(--line);
}
.pf-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink);
  font-size: 20px; font-weight: 800;
}
.pf-name { font-size: 17px; font-weight: 800; }
.pf-meta { font-size: 12.5px; color: var(--ink-2); }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pf-stat {
  padding: 12px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); text-align: center;
}
.pf-stat b { display: block; font-size: 19px; font-weight: 800; }
.pf-stat span { font-size: 11px; color: var(--ink-3); }

.pf-group { margin-top: 18px; }
.pf-group-t { font-size: 12px; font-weight: 700; color: var(--ink-3); margin: 0 4px 8px; letter-spacing: .04em; }
.pf-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 54px; padding: 10px 14px; text-align: start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 8px; color: var(--ink);
}
.pf-row:active { background: var(--surface-2); }
.pf-row-ico { width: 30px; height: 30px; flex: none; display: grid; place-items: center; color: var(--primary); }
.pf-row-ico svg { width: 20px; height: 20px; }
.pf-row-main { flex: 1; min-width: 0; }
.pf-row-main { display: flex; flex-direction: column; gap: 1px; }
.pf-row-t { display: block; font-size: 14.5px; font-weight: 700; }
.pf-row-s { display: block; font-size: 12px; color: var(--ink-3); }
.pf-row-v { font-size: 13px; color: var(--ink-3); }

/* =========================================================================
   METRONOME WHEEL
   ========================================================================= */
.mt-card {
  margin: 0 0 14px; padding: 16px 16px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl);
}
.mt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mt-title { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.mt-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.mt-sig-pill {
  flex: none; min-width: 52px; height: 30px; padding: 0 12px;
  display: grid; place-items: center;
  background: var(--surface-2); border-radius: var(--r-pill);
  font-size: 13px; font-weight: 800; color: var(--ink-2);
}

.mt-stage { display: grid; justify-items: center; margin: 8px 0 2px; }
.mt-wheel {
  position: relative; width: 275px; height: 275px; max-width: 100%;
  touch-action: none; cursor: grab; outline: none;
}
.mt-wheel:active { cursor: grabbing; }
.mt-svg { width: 100%; height: 100%; display: block; }
#mt-knob { transition: transform .07s linear; }

.mt-center {
  position: absolute; inset: 0; display: grid; place-content: center;
  justify-items: center; gap: 0; pointer-events: none;
}
.mt-bpm {
  font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.mt-bpm-lbl { font-size: 10px; font-weight: 700; letter-spacing: .16em; color: var(--ink-3); margin-top: 3px; }
.mt-tempo-name { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.mt-lights { display: flex; align-items: center; justify-content: center; gap: 9px; height: 20px; margin-top: 2px; }
.mt-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface-3); transition: background .09s, transform .09s;
}
.mt-dot.is-first { width: 16px; height: 16px; }
.mt-dot.is-on { background: var(--primary); transform: scale(1.14); }
.mt-dot.is-on.is-accent { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent); }

.mt-controls { display: flex; direction: ltr; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 4px; }
.mt-round {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2);
  transition: transform .1s, background .16s;
}
.mt-round svg { width: 20px; height: 20px; fill: none; }
.mt-round:active { transform: scale(.93); }
.mt-play {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--primary) 75%, transparent);
  transition: transform .1s, filter .16s;
}
.mt-play svg { width: 26px; height: 26px; }
.mt-play:active { transform: scale(.94); }
.mt-play .mt-ico-stop { display: none; }
.mt-card.is-running .mt-play .mt-ico-play { display: none; }
.mt-card.is-running .mt-play .mt-ico-stop { display: block; }

.mt-foot { display: flex; gap: 8px; margin-top: 6px; }
.mt-tap, .mt-sig-btn {
  flex: 1; height: 40px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--ink-2);
  font-size: 13px; font-weight: 700;
  border: 1px solid var(--line);
  transition: background .16s, color .16s;
}
.mt-tap.is-tap { background: var(--primary); color: var(--primary-ink); }

/* =========================================================================
   TUNER — GuitarTuna layout
   ========================================================================= */
.tuner-wrap { padding: 4px 14px 0; max-width: 560px; margin: 0 auto; }

.tuner-bar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 12px 11px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--line);
}
.tb-row { display: flex; align-items: center; gap: 10px; }
.tb-row-2 { gap: 8px; }
.tb-inst { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.tb-inst-ico {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}
.tb-inst-ico svg { width: 19px; height: 19px; }
.tb-inst-name { font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; }

.tuner-preset { display: none; }
.tp-select {
  position: relative; display: flex; align-items: center; min-width: 0; flex: 1;
  height: 36px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line);
}
.tp-select select {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 100%; padding: 0 18px 0 0;
  font-size: 14.5px; font-weight: 800; letter-spacing: -.01em;
  background: none; border: 0; color: var(--ink);
  font-family: inherit; cursor: pointer;
}
.tp-chev {
  position: absolute; inset-inline-end: 11px; width: 14px; height: 14px;
  color: var(--ink-3); pointer-events: none;
}
.tp-notes {
  flex: none; font-size: 11px; font-weight: 700;
  color: var(--ink-3); letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
}
.tuner-gear {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 0; color: var(--ink-2);
}
.tuner-gear svg { width: 19px; height: 19px; }
.tuner-gear.on { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }

/* mode segmented control */
.tmodes {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
  padding: 3px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
}
.tmode {
  height: 34px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  transition: background .16s, color .16s;
}
.tmode.active {
  background: var(--primary); color: var(--primary-ink);
  box-shadow: none;
}
html[data-theme="dark"] .tmode.active { background: var(--primary); color: var(--primary-ink); }

/* gauge card */
.tuner-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl);
}
.tc-reads { border-top: 1px solid var(--line); padding-top: 6px; }
.tc-read span, .tc-read small { color: var(--ink-3); }
.tc-cents { background: var(--surface-2); }

/* primary CTA */
.tuner-controls {
  background: transparent;
  border-top: 0;
  box-shadow: none;
}
.tuner-controls .btn, .tuner-start {
  border-radius: var(--r-pill);
  min-height: 50px;
  font-size: 15.5px;
}

/* tighten the gauge card */
.tg { margin: 0 0 -2px; }
.tg svg { width: 100%; height: auto; }
.tg-note { bottom: -4px; }
.tg-letter { font-size: clamp(34px, 10vw, 42px); }
.tg-letter.is-empty { font-size: 22px; opacity: .22; letter-spacing: 0; }
.tc-reads { margin-top: 0; gap: 5px; }
.tc-read { padding: 5px 4px 4px; }
.tc-read b { font-size: 15px; }
.tc-status { margin-top: 6px; }
.tuner-guide { display: none; }
.tuner-head { margin-top: 2px; }
.th-stock .headstock { width: clamp(112px, 32vw, 132px); }

/* ---------- notation on the dark canvas (abcjs uses currentColor) ---------- */
.score-panel,
html[data-theme="dark"] .score-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  color: var(--ink);
  box-shadow: none;
  padding: 14px 0;
}
.score-panel svg { color: inherit; }
.score-panel .abcjs-note_selected path { fill: var(--primary); }
.score-panel .abcjs-chord path, .score-panel .abcjs-chord text { fill: var(--primary); }

/* fretboard / hud inherit the flat canvas */
.hud {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  color: var(--ink);
}
html[data-theme="dark"] .hud { border-color: var(--line); }
.score-panel > div, .score-panel svg, .score-panel .abcjs-container { background: transparent !important; }
.score-panel svg, .score-panel svg * { color: var(--ink) !important; }
.score-panel .abcjs-chord, .score-panel .abcjs-chord * { color: var(--primary) !important; }
.score-panel .abcjs-title, .score-panel .abcjs-title * { color: var(--ink) !important; }
.score-panel .abcjs-composer, .score-panel .abcjs-composer * { color: var(--ink-3) !important; }

/* ---------- bottom stack: dock sits above the tab bar ---------- */
html[data-theme="dark"] .tabnav,
html[data-theme="light"] .tabnav {
  background: var(--bg-2);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-top: 1px solid var(--line);
}
html[data-theme="light"] .tabnav { background: #FFFFFF; }
.dock {
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  height: var(--dock-h);
  padding-bottom: 0;
  background: var(--surface);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.toasts { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
body.has-dock { padding-bottom: calc(var(--dock-h) + var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px)); }
body.has-dock .toasts { bottom: calc(var(--dock-h) + var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 620px) {
  .dock { padding-bottom: 0; }
}

/* =========================================================================
   SONGS
   ========================================================================= */
.sg-wrap { padding: 16px 14px 0; max-width: 760px; margin: 0 auto; }
.sg-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.sg-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; line-height: 1.6; }

.sg-search-wrap { position: relative; margin: 14px 0 10px; }
.sg-search {
  width: 100%; height: 44px; padding-block: 0; padding-inline: 42px 14px;
  border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); font-size: 14px; font-family: inherit;
}
.sg-search::placeholder { color: var(--ink-3); }
.sg-search-ico { position: absolute; top: 50%; inset-inline-start: 15px; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }

.sg-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.sg-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  padding: 10px 12px; border-radius: var(--r-m);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s;
}
.sg-card:active { transform: scale(.99); }
.sg-card:hover { border-color: var(--line-2); }
.sg-art {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--primary); font-size: 14px; font-weight: 800; direction: ltr;
}
.sg-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sg-name { font-size: 14.5px; font-weight: 700; }
.sg-meta { font-size: 11.5px; color: var(--ink-3); }
.sg-right { flex: none; }
.sg-dots { display: inline-flex; gap: 3px; }
.sg-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.sg-dots i.on { background: var(--primary); }
.sg-play {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2);
}
.sg-play svg { width: 15px; height: 15px; margin-inline-start: 1px; }
.sg-empty { color: var(--ink-3); font-size: 13px; text-align: center; padding: 24px 0; }

/* =========================================================================
   GAMES
   ========================================================================= */
.gm-wrap { padding: 16px 14px 0; max-width: 760px; margin: 0 auto; }
.gm-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.gm-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; line-height: 1.6; }

.gm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.gm-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 14px 13px 15px; border-radius: var(--r-l); text-align: start;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  transition: transform .1s, border-color .15s;
}
.gm-card:active { transform: scale(.98); }
.gm-card:hover { border-color: var(--line-2); }
.gm-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 2px; }
.gm-ico svg { width: 21px; height: 21px; }
.gm-ico.teal   { background: color-mix(in srgb, #2DD4BF 15%, transparent); color: #2DD4BF; }
.gm-ico.violet { background: color-mix(in srgb, #A99BFF 16%, transparent); color: #A99BFF; }
.gm-ico.gold   { background: color-mix(in srgb, #F5C518 15%, transparent); color: #F5C518; }
.gm-ico.rose   { background: color-mix(in srgb, #F87171 15%, transparent); color: #F87171; }
.gm-name { font-size: 14.5px; font-weight: 800; }
.gm-desc { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }
.gm-note { font-size: 11.5px; color: var(--ink-3); text-align: center; margin-top: 18px; }

.gm-play, .gm-result { padding-bottom: 20px; }
.gm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.gm-back {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.gm-back svg { width: 18px; height: 18px; }
.gm-head-t { flex: 1; min-width: 0; }
.gm-head-title { font-size: 16px; font-weight: 800; }
.gm-head-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.gm-score { font-size: 12.5px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; direction: rtl; }

.gm-progress { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 18px; direction: ltr; }
.gm-progress i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .25s; }

.gm-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 210px; justify-content: center; }
.gm-big { font-size: 46px; font-weight: 900; letter-spacing: -.02em; direction: ltr; }
.gm-hint { font-size: 12px; color: var(--ink-3); }
.gm-diagram svg { width: 150px; height: auto; }
.gm-hear {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px;
  border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 12.5px; font-weight: 700; font-family: inherit;
}
.gm-hear svg { width: 16px; height: 16px; }

.gm-actions { margin-top: 18px; }
.gm-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gm-opt {
  height: 54px; border-radius: var(--r-m); font-size: 16px; font-weight: 800; font-family: inherit;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  transition: background .15s, border-color .15s, transform .1s;
  direction: ltr;
}
.gm-opt:active { transform: scale(.97); }
.gm-opt:disabled { opacity: 1; }
.gm-opt.is-right { background: color-mix(in srgb, var(--primary) 20%, var(--surface)); border-color: var(--primary); color: var(--primary); }
.gm-opt.is-wrong { background: color-mix(in srgb, var(--red) 18%, var(--surface)); border-color: var(--red); color: var(--red); }
.gm-opts-2 { grid-template-columns: 1fr 1fr; }
.gm-opt-d { height: auto; padding: 8px 6px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gm-opt-svg svg { width: 84px; height: auto; }
.gm-opt-lbl { font-size: 13px; font-weight: 800; direction: ltr; }

.gm-ring {
  width: 150px; height: 150px; margin: 18px auto 10px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-3) 0);
}
.gm-ring::before { content: ""; position: absolute; }
.gm-ring-val {
  width: 122px; height: 122px; border-radius: 50%; background: var(--bg);
  display: grid; place-items: center; font-size: 30px; font-weight: 900;
}
.gm-res-msg { text-align: center; font-size: 16px; font-weight: 800; margin-top: 6px; }
.gm-res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 4px; }
.gm-res-stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 6px; text-align: center; }
.gm-res-stats b { display: block; font-size: 19px; font-weight: 900; }
.gm-res-stats span { font-size: 11px; color: var(--ink-3); }
.gm-res-actions { display: flex; gap: 8px; margin-top: 18px; }
.gm-res-actions .btn { flex: 1; }

/* strumming trainer */
.st-pattern { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 6px 0 4px; }
.st-slot {
  height: 56px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 22px; font-weight: 800; color: var(--ink-2);
  transition: background .1s, border-color .1s, color .1s, transform .1s;
}
.st-slot.is-rest { color: var(--ink-3); opacity: .45; }
.st-slot.is-now { background: color-mix(in srgb, var(--primary) 22%, var(--surface)); border-color: var(--primary); color: var(--primary); transform: translateY(-3px); }
.st-bpm { text-align: center; font-size: 12px; color: var(--ink-3); margin-bottom: 14px; direction: ltr; }
.st-tap {
  width: 132px; height: 132px; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px; font-weight: 800; font-family: inherit;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  border: 2px solid var(--primary); color: var(--primary);
  transition: transform .08s, background .12s;
}
.st-tap:active, .st-tap.is-hit { transform: scale(.94); background: color-mix(in srgb, var(--primary) 32%, var(--surface)); }
.st-tap.is-miss { border-color: var(--red); color: var(--red); background: color-mix(in srgb, var(--red) 18%, var(--surface)); }
.st-read { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 16px; font-size: 11.5px; color: var(--ink-3); }
.st-read b { font-size: 17px; font-weight: 900; color: var(--ink); }
.st-read span { margin-inline-end: 12px; }

/* =========================================================================
   ONBOARDING
   ========================================================================= */
.ob {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center;
  background: var(--bg);
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
}
.ob[hidden] { display: none; }
body.ob-open { overflow: hidden; }
.ob-card { width: 100%; max-width: 420px; text-align: center; }
.ob-art { color: var(--primary); display: grid; place-items: center; margin-bottom: 26px; }
.ob-art svg { width: clamp(160px, 46vw, 196px); height: auto; }
.ob-title { font-size: 24px; font-weight: 900; letter-spacing: -.02em; line-height: 1.3; }
.ob-desc { font-size: 13.5px; line-height: 1.9; color: var(--ink-2); margin-top: 10px; }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin: 26px 0 20px; }
.ob-dots i { width: 6px; height: 6px; border-radius: 99px; background: var(--line-2); transition: width .2s, background .2s; }
.ob-dots i.on { width: 20px; background: var(--primary); }
.ob-actions { display: flex; flex-direction: column; gap: 10px; }
.ob-next { width: 100%; height: 50px; }
.ob-skip { background: none; border: 0; color: var(--ink-3); font-size: 12.5px; font-weight: 700; font-family: inherit; padding: 8px; }

/* games: use the full height so the stage breathes */
.gm-play, .gm-result { display: flex; flex-direction: column; min-height: calc(100dvh - 190px); }
.gm-stage { flex: 1; }
.gm-opt-svg svg { width: 96px; height: auto; }
.gm-opt-d { padding: 10px 6px 8px; }

/* strumming: rhythm reads left→right, stats as labelled pairs */
.st-pattern { direction: ltr; }
.st-bpm { direction: ltr; unicode-bidi: isolate; }
.st-sep { margin: 0 6px; opacity: .5; }
.st-read { display: flex; justify-content: center; gap: 26px; direction: rtl; }
.st-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.st-stat b { font-size: 20px; font-weight: 900; color: var(--ink); line-height: 1.1; }
.st-stat span { font-size: 11px; color: var(--ink-3); }

/* ear trainer: never show the answer */
.gm-earmark {
  width: 132px; height: 132px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 6px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}
.gm-earmark svg { width: 58px; height: 58px; }

/* ---------- songs: add-song affordances ---------- */
.sg-top-row { display: flex; align-items: flex-start; gap: 10px; }
.sg-top-row > div:first-child { flex: 1; min-width: 0; }
.sg-add {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  display: grid; place-items: center; margin-top: 2px;
  background: var(--primary); color: var(--primary-ink); border: 0;
  box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}
.sg-add svg { width: 20px; height: 20px; }
.sg-add:active { transform: scale(.94); }

.sg-card { cursor: pointer; }
.sg-card.is-custom { border-color: color-mix(in srgb, var(--primary) 32%, var(--line)); }
.sg-badge {
  display: inline-block; margin-inline-start: 6px; padding: 1px 6px;
  border-radius: 99px; font-size: 9.5px; font-weight: 800; vertical-align: 1px;
  background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary);
}
.sg-del {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3);
}
.sg-del svg { width: 15px; height: 15px; }
.sg-del:active { color: var(--red); background: color-mix(in srgb, var(--red) 16%, var(--surface-2)); }

/* ---------- add-song sheet ---------- */
.sg-sheet { position: fixed; inset: 0; z-index: 420; display: flex; align-items: flex-end; }
.sg-sheet[hidden] { display: none; }
.sg-sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .58); }
.sg-sheet-card {
  position: relative; width: 100%; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-2);
  animation: sg-up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sg-up { from { transform: translateY(22px); opacity: .6; } to { transform: none; opacity: 1; } }
.sg-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sg-sheet-head > span { font-size: 16px; font-weight: 800; }
.sg-sheet-x {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 0; color: var(--ink-2);
}
.sg-sheet-x svg { width: 15px; height: 15px; }
.sg-fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; }
.sg-fld > span { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
.sg-fld input, .sg-fld textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-m); color: var(--ink); font-family: inherit; font-size: 14px;
  padding: 11px 12px; resize: vertical;
}
.sg-fld textarea { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 13px; line-height: 1.7; }
.sg-fld input:focus, .sg-fld textarea:focus {
  outline: none; border-color: color-mix(in srgb, var(--primary) 60%, var(--line));
}
.sg-hint { font-size: 11px; color: var(--ink-3); line-height: 1.7; margin-bottom: 10px; }
.sg-err { font-size: 12px; font-weight: 700; color: var(--red); margin-bottom: 10px; }
.sg-save { width: 100%; height: 48px; }

@media (min-width: 620px) {
  .sg-sheet { align-items: center; justify-content: center; }
  .sg-sheet-card { max-width: 460px; border-radius: 22px; border: 1px solid var(--line-2); }
}
.sg-fld textarea { min-height: 96px; max-height: 40dvh; }

/* chord shape: one box per string so RTL never reorders the digits */
.ch-shape { display: inline-flex; gap: 7px; direction: ltr; }
.ch-fr {
  min-width: 13px; text-align: center;
  font-variant-numeric: tabular-nums;
}
