/* =====================================================================
   urPiano — app shell & piano
   Materials: lacquer (black or white grand), ivory & ebony keys,
   crimson key-slip felt, brass hardware. One accent: brass.
   ===================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Hebrew", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Hebrew", sans-serif;
  --font-serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-round: ui-rounded, "SF Pro Rounded", var(--font);

  --brass: #c9a15b;
  --brass-hi: #ecd6a2;
  --brass-lo: #9b7433;
  --brass-ink: #6e501c;
  --felt: #7e1428;
  --felt-hi: #a8283f;
  --ivory: #fbfaf6;
  --ebony: #121213;

  /* white lacquer (light) */
  --lacquer: #f4f3f1;
  --lacquer-2: #ffffff;
  --lacquer-edge: rgba(0, 0, 0, 0.09);
  --stage-1: #ffffff;
  --stage-2: #efeeeb;
  --stage-3: #dedcd7;
  --stage-grid: rgba(0, 0, 0, 0.06);
  --stage-line: rgba(176, 134, 58, 0.5);
  --ink: #1d1d1f;
  --ink-2: #4b4b4f;
  --ink-3: #86868b;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #e8e8ed;
  --line: rgba(0, 0, 0, 0.1);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --pop-bg: rgba(252, 252, 252, 0.84);
  --seg-on: #ffffff;
  --hl: #d1a148;
  --hl-left: #d4526c;
  --wrong: #e5484d;
  --nav-white: #ffffff;
  --nav-black: #2c2c2f;
  --nav-dim: rgba(244, 243, 241, 0.62);
  --kb-bed: #1a1a1b;
  --link: #8a6420;
  --shadow-pop: 0 24px 64px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(0, 0, 0, 0.08);
  --focus: 0 0 0 3px rgba(201, 161, 91, 0.55);

  --bar-h: 52px;
  --nav-h: 30px;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-word { --bw-hi: #f1dfae; --bw-mid: #c9a15b; --bw-lo: #9b7433; }
  :root:not([data-theme="light"]) {
    --lacquer: #0d0d0f;
    --lacquer-2: #19191c;
    --lacquer-edge: rgba(255, 255, 255, 0.08);
    --stage-1: #26262b;
    --stage-2: #111113;
    --stage-3: #050506;
    --stage-grid: rgba(255, 255, 255, 0.055);
    --stage-line: rgba(212, 168, 83, 0.55);
    --ink: #f5f5f7;
    --ink-2: #c7c7cc;
    --ink-3: #8e8e93;
    --surface: #141416;
    --surface-2: #1c1c1f;
    --surface-3: #2a2a2e;
    --line: rgba(255, 255, 255, 0.12);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --pop-bg: rgba(36, 36, 40, 0.82);
    --seg-on: #5c5c62;
    --nav-white: #d6d3cb;
    --nav-black: #0a0a0b;
    --nav-dim: rgba(5, 5, 6, 0.58);
    --kb-bed: #050505;
    --link: #e2c27f;
    --shadow-pop: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] .brand-word { --bw-hi: #f1dfae; --bw-mid: #c9a15b; --bw-lo: #9b7433; }
:root[data-theme="dark"] {
  --lacquer: #0d0d0f;
  --lacquer-2: #19191c;
  --lacquer-edge: rgba(255, 255, 255, 0.08);
  --stage-1: #26262b;
  --stage-2: #111113;
  --stage-3: #050506;
  --stage-grid: rgba(255, 255, 255, 0.055);
  --stage-line: rgba(212, 168, 83, 0.55);
  --ink: #f5f5f7;
  --ink-2: #c7c7cc;
  --ink-3: #8e8e93;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --surface-3: #2a2a2e;
  --line: rgba(255, 255, 255, 0.12);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-2: rgba(120, 120, 128, 0.36);
  --pop-bg: rgba(36, 36, 40, 0.82);
  --seg-on: #5c5c62;
  --nav-white: #d6d3cb;
  --nav-black: #0a0a0b;
  --nav-dim: rgba(5, 5, 6, 0.58);
  --kb-bed: #050505;
  --link: #e2c27f;
  --shadow-pop: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
  color-scheme: dark;
}

/* highlight colour choices */
:root[data-hl="blue"] { --hl: #4a9eff; --stage-line: rgba(74, 158, 255, 0.55); }
:root[data-hl="green"] { --hl: #34c27a; --stage-line: rgba(52, 194, 122, 0.55); }
:root[data-hl="rose"] { --hl: #ff6b8b; --hl-left: #4a9eff; --stage-line: rgba(255, 107, 139, 0.55); }
:root[data-hl="violet"] { --hl: #a078ff; --stage-line: rgba(160, 120, 255, 0.55); }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html.is-locked, html.is-locked body { overflow: hidden; overscroll-behavior: none; height: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i--fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.18em; }

/* ---------------------------------------------------------------- app shell */
.app {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  background: var(--lacquer);
  color: var(--ink);
  overflow: hidden;
  isolation: isolate;
  container: app / inline-size;
  -webkit-tap-highlight-color: transparent;
}
.app.is-fullscreen { position: fixed; inset: 0; z-index: 1000; height: 100%; width: 100%; }
.app:fullscreen { height: 100%; }
.app.is-rotated {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vh;
  width: 100dvh;
  height: 100vw;
  min-height: 0;
  transform-origin: top left;
  transform: translateX(100vw) rotate(90deg);
}
@media (max-height: 520px) { :root { --bar-h: 44px; --nav-h: 26px; } }
.app.is-short { --bar-h: 44px; --nav-h: 26px; }

.bar {
  position: relative;
  z-index: 20;
  flex: none;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: linear-gradient(180deg, var(--lacquer-2), var(--lacquer));
  box-shadow: inset 0 -1px 0 var(--lacquer-edge), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.app.is-rotated .bar { padding: 0 10px; }
.bar-start, .bar-mid, .bar-end { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bar-start { flex: 1 1 0; }
.bar-mid { flex: none; justify-content: center; }
.bar-end { flex: 1 1 0; justify-content: flex-end; }

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; color: inherit; text-decoration: none; border-radius: 10px; padding: 4px 6px 4px 2px; }
.brand:hover { text-decoration: none; background: var(--fill); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-word {
  --bw-hi: #c9a15b; --bw-mid: #a57d36; --bw-lo: #7a5a22;
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: 0.01em;
  line-height: 1;
  background: linear-gradient(180deg, var(--bw-hi), var(--bw-mid) 55%, var(--bw-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bar-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
  display: flex;
}
.title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.title-btn {
  display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%;
  background: none; border: 0; padding: 6px 8px; border-radius: 10px; color: inherit;
  font: inherit;
}
.title-btn:hover { background: var(--fill); }
.title-btn .i { width: 14px; height: 14px; opacity: 0.6; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-width: 36px;
  padding: 0 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover { background: var(--fill); }
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn .i { width: 21px; height: 21px; }
.btn--icon { padding: 0; width: 36px; }
.btn.is-on, .btn[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 60%, #b58b44);
  color: #2b1e07;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.btn--sound { padding: 0 8px 0 10px; max-width: 220px; }
.btn--sound span { overflow: hidden; text-overflow: ellipsis; }
.btn--sound .chev { width: 14px; height: 14px; opacity: 0.55; }
.btn--rec .rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.25); }
.btn--rec.is-recording { background: rgba(229, 72, 77, 0.14); color: #e5484d; }
.btn--rec.is-recording .rec-dot { animation: pulse 1.2s ease-in-out infinite; }
.btn-group { display: inline-flex; align-items: center; background: var(--fill); border-radius: 10px; padding: 2px; }
.btn-group .btn { height: 32px; min-width: 32px; border-radius: 8px; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; flex: none; }
@keyframes pulse { 50% { opacity: 0.35; } }

.metro-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fill-2); margin: 0 4px; transition: background 0.06s; }
.metro-dot.is-beat { background: var(--brass); }
.metro-dot.is-accent { background: var(--felt-hi); }

/* responsive bar — container queries follow the app, so the rotated phone layout adapts too */
@container app (max-width: 1080px) { .btn-label { display: none; } }
@container app (max-width: 820px) { .brand-word { display: none; } .hide-md { display: none !important; } }
@container app (max-width: 600px) {
  .hide-sm { display: none !important; }
  .btn--sound span { display: none; }
  .btn--sound { padding: 0 6px; }
  .bar { gap: 2px; }
  .bar-title { font-size: 14px; }
}
@container app (max-width: 480px) {
  .title-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .title-btn { padding: 6px 4px; }
  .bar-end, .bar-mid { gap: 2px; }
}
@container app (max-width: 400px) { .hide-xs { display: none !important; } }
.show-touch { display: none !important; }
html.is-touch.is-portrait .show-touch { display: inline-flex !important; }
.app.is-rotated .show-touch { display: inline-flex !important; }

/* ---------------------------------------------------------------- popovers & sheets */
.pop {
  position: absolute;
  z-index: 60;
  width: 320px;
  max-width: calc(100% - 16px);
  max-height: calc(100% - var(--bar-h) - 16px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border-radius: 18px;
  background: var(--pop-bg);
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  backdrop-filter: blur(30px) saturate(1.8);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: var(--arrow, 50%) 0;
  transition: opacity 0.16s ease, transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.pop.is-open { opacity: 1; transform: none; }
.pop--wide { width: 400px; }
.pop--xl { width: 460px; }
.pop.is-sheet {
  left: 8px !important;
  right: 8px;
  top: auto !important;
  bottom: max(8px, env(safe-area-inset-bottom));
  width: auto;
  max-width: none;
  max-height: min(78%, 640px);
  border-radius: 22px;
  transform: translateY(24px);
  transform-origin: 50% 100%;
}
.pop.is-sheet.is-open { transform: none; }
.pop.is-sheet::before {
  content: "";
  display: block;
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--fill-2);
  margin: 0 auto 6px;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; }
.pop-head h2, .pop-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.pop-sec { padding: 6px 8px 10px; }
.pop-sec + .pop-sec { border-top: 0.5px solid var(--line); padding-top: 12px; }
.pop-label { display: block; margin: 0 0 7px; font-size: 13px; color: var(--ink-3); font-weight: 500; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.row + .row { margin-top: 4px; }
.row-text { font-size: 14px; }
.row-text small { display: block; color: var(--ink-3); font-size: 12px; line-height: 1.3; }

/* menu list */
.menu { display: flex; flex-direction: column; gap: 1px; }
.menu-group { padding: 8px 10px 4px; font-size: 12px; color: var(--ink-3); font-weight: 500; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font-size: 15px;
  text-align: start;
  text-decoration: none;
}
.menu-item:hover { background: var(--fill); text-decoration: none; }
.menu-item .i { width: 22px; height: 22px; color: var(--ink-2); }
.menu-item .check { margin-inline-start: auto; width: 16px; height: 16px; color: var(--brass); opacity: 0; }
.menu-item.is-on .check, .menu-item[aria-checked="true"] .check, .menu-item[aria-current="page"] .check { opacity: 1; }
.menu-item small { display: block; font-size: 12px; color: var(--ink-3); }
.menu-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }

/* segmented control */
.seg {
  display: flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
  gap: 2px;
}
.seg button {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  transition: background 0.15s;
}
.seg button.is-on { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.seg--sm button { height: 28px; font-size: 12px; padding: 0 7px; }
.learnbar .seg button, .bar .seg button { flex: none; padding: 0 11px; }
.row .seg { flex: none; min-width: 236px; }
.row .seg button { flex: 1 1 auto; padding: 0 10px; }
.row .swatches { flex: none; }
.pop.is-sheet .row:has(.seg) { flex-direction: column; align-items: stretch; gap: 6px; padding: 4px 0; }
.pop.is-sheet .row .seg { min-width: 0; width: 100%; }

.swatches { display: flex; gap: 10px; }
.swatches button {
  width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.swatches button.is-on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }

/* switch */
.switch { position: relative; display: inline-flex; flex: none; width: 46px; height: 28px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 14px; background: var(--fill-2);
  transition: background 0.2s;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1.3);
}
.switch input:checked + span { background: var(--brass); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

/* range */
.range { width: 100%; accent-color: var(--brass); height: 28px; margin: 0; }

/* stepper */
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--fill); border-radius: 9px; padding: 2px; }
.stepper button { width: 32px; height: 28px; border: 0; border-radius: 7px; background: none; font-size: 17px; line-height: 1; }
.stepper button:hover { background: var(--seg-on); }
.stepper output { min-width: 44px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 500; }

.cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 20px; border: 0;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 60%, #b28842);
  color: #2b1e07; font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 2px 6px rgba(120, 80, 20, 0.25);
  text-decoration: none;
}
.cta:hover { text-decoration: none; filter: brightness(1.04); }
.cta--ghost { background: var(--fill); color: var(--ink); box-shadow: none; }
.link-btn { border: 0; background: none; color: var(--link); padding: 0; font-size: 14px; }

/* toasts */
.toasts { position: absolute; z-index: 80; left: 50%; top: calc(var(--bar-h) + 14px); transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast {
  padding: 9px 16px; border-radius: 20px; font-size: 14px; font-weight: 500;
  background: var(--pop-bg); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(-8px); transition: all 0.25s;
  white-space: nowrap;
}
.toast.is-in { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- stage */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(104deg, transparent 32%, rgba(255, 255, 255, 0.05) 46%, transparent 58%),
    radial-gradient(130% 100% at 50% -20%, var(--stage-1) 0%, var(--stage-2) 52%, var(--stage-3) 100%);
}
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.readout {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  text-align: center;
  transition: opacity 0.35s ease;
  opacity: 0;
}
.readout.is-on { opacity: 1; transition-duration: 0.08s; }
.readout-name {
  font-family: var(--font-display);
  font-size: clamp(30px, 9cqh, 76px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink);
  opacity: 0.92;
}
.readout-sub { margin-top: 8px; font-size: clamp(12px, 2.2cqh, 15px); color: var(--ink-3); letter-spacing: 0.01em; }
.stage { container-type: size; }
@container (max-height: 120px) { .readout-sub { display: none; } .readout-name { font-size: clamp(22px, 40cqh, 40px); } }
@container (max-height: 60px) { .readout { display: none; } }

.welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.welcome.is-gone { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.welcome-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 3.2cqw, 30px);
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--ink);
  opacity: 0.88;
}
.welcome-songs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; }
.chip-song {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px 0 12px; border-radius: 19px; border: 0;
  background: var(--fill); color: var(--ink); font-size: 14px; font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}
.chip-song:hover { background: var(--fill-2); }
.chip-song:active { transform: scale(0.97); }
.chip-song .i { width: 16px; height: 16px; color: var(--brass); }
@container (max-height: 230px) { .welcome-songs { display: none; } .welcome { gap: 10px; } }
@container (max-height: 150px) { .welcome-title { display: none; } }
.hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--fill);
  white-space: nowrap;
  transition: opacity 0.4s;
}
.hint kbd {
  font-family: var(--font);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line), inset 0 0 0 0.5px var(--line);
}
html.is-touch .hint-keys, html:not(.is-touch) .hint-touch { display: none; }
@container (max-height: 80px) { .welcome { display: none; } }

/* tip shown to phone visitors, pointing to the mobile piano */
.mobile-tip {
  position: absolute;
  z-index: 6;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 20px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 12px;
  border-radius: 18px;
  background: var(--pop-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
  font-size: 13px;
  line-height: 1.3;
}
.mobile-tip > .i { width: 18px; height: 18px; color: var(--brass); }
.mobile-tip a { color: var(--ink); font-weight: 500; }
.mobile-tip-close { flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--fill); color: var(--ink-2); display: grid; place-items: center; touch-action: manipulation; }
.mobile-tip-close .i { width: 14px; height: 14px; }

.loading {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--pop-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: 12px;
  color: var(--ink-2);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  z-index: 5;
}
.loading i { display: block; width: 64px; height: 3px; border-radius: 2px; background: var(--fill-2); overflow: hidden; }
.loading b { display: block; height: 100%; background: var(--brass); transform-origin: left; transform: scaleX(0); transition: transform 0.2s; }

/* floating panels in the stage (recording, results) */
.float {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 260px;
  max-width: calc(100% - 24px);
  padding: 18px;
  border-radius: 20px;
  background: var(--pop-bg);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  backdrop-filter: blur(30px) saturate(1.6);
  box-shadow: var(--shadow-pop);
  text-align: center;
}
.float h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.float p { margin: 0 0 14px; color: var(--ink-3); font-size: 14px; }
.float-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.float--corner { top: auto; bottom: 12px; transform: translateX(-50%); padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 10px; text-align: start; min-width: 0; border-radius: 26px; }
.float--corner .rec-time { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 10px; }
.stars svg { width: 30px; height: 30px; fill: var(--fill-2); }
.stars svg.on { fill: var(--brass); filter: drop-shadow(0 2px 6px rgba(201, 161, 91, 0.45)); }
.result-stats { display: flex; justify-content: center; gap: 22px; margin: 6px 0 16px; }
.result-stats div { display: flex; flex-direction: column; }
.result-stats b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.result-stats span { font-size: 12px; color: var(--ink-3); }

/* ---------------------------------------------------------------- learn bar */
.learnbar {
  flex: none;
  position: relative;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 10px;
  background: var(--lacquer);
  box-shadow: inset 0 -1px 0 var(--lacquer-edge);
}
.learnbar-title { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.15; }
.learnbar-title strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.learnbar-title span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.learn-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: transparent; }
.learn-progress i { display: block; height: 100%; width: 100%; background: var(--brass); transform-origin: left; transform: scaleX(0); }
.tempo { display: inline-flex; align-items: center; }
.tempo output { min-width: 46px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
@container app (max-width: 760px) { .learnbar .seg--hands { display: none; } }
@container app (max-width: 560px) { .learnbar .seg--mode, .learnbar .tempo { display: none; } }

/* song list */
.search {
  display: flex; align-items: center; gap: 8px; margin: 2px 4px 8px; padding: 0 10px; height: 36px;
  border-radius: 10px; background: var(--fill);
}
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; min-width: 0; }
.search .i { width: 17px; height: 17px; color: var(--ink-3); }
.song-list { display: flex; flex-direction: column; gap: 1px; max-height: 360px; overflow: auto; }
.song-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: start; color: var(--ink); }
.song-item:hover, .song-item:focus-visible { background: var(--fill); }
.song-item b { display: block; font-size: 15px; font-weight: 500; }
.song-item small { display: block; font-size: 12px; color: var(--ink-3); }
.song-item .lvl { margin-inline-start: auto; flex: none; }
.lvl { display: inline-flex; gap: 2px; }
.lvl i { width: 5px; height: 12px; border-radius: 2px; background: var(--fill-2); }
.lvl[data-level="1"] i:nth-child(-n+1), .lvl[data-level="2"] i:nth-child(-n+2), .lvl[data-level="3"] i:nth-child(-n+3) { background: var(--brass); }

/* ---------------------------------------------------------------- navigator strip */
.navstrip {
  direction: ltr;
  flex: none;
  position: relative;
  z-index: 3;
  height: var(--nav-h);
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0 max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  background: linear-gradient(180deg, var(--lacquer), var(--lacquer-2));
  box-shadow: inset 0 1px 0 var(--lacquer-edge);
}
.app.is-rotated .navstrip { padding: 0 4px; }
.nav-canvas {
  flex: 1 1 auto; min-width: 0; height: calc(100% - 8px); margin: 4px 0; display: block; cursor: grab; touch-action: none;
  border-radius: 6px; background: #19191b; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5), 0 0.5px 0 rgba(255, 255, 255, 0.4);
  --nav-white: #ebe8e1; --nav-black: #141415; --nav-dim: rgba(12, 12, 14, 0.58);
}
.nav-btn { flex: none; width: 34px; height: 100%; border: 0; background: none; color: var(--ink-2); border-radius: 8px; display: grid; place-items: center; }
.nav-btn:hover { background: var(--fill); color: var(--ink); }
.nav-btn .i { width: 16px; height: 16px; }
.nav-btn.is-on { color: var(--brass); }

/* ---------------------------------------------------------------- felt + keyboard */
.felt {
  flex: none;
  position: relative;
  z-index: 3;
  height: 6px;
  background: linear-gradient(180deg, #4a0b17 0%, var(--felt) 35%, var(--felt-hi) 60%, #5a0d1b 100%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.35);
}
.felt::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0 1px, transparent 1px 3px); }

.kb {
  position: relative;
  flex: none;
  height: var(--kb-h, 240px);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  direction: ltr;
  background: var(--kb-bed);
  padding-bottom: env(safe-area-inset-bottom);
  cursor: default;
}
.app.is-rotated .kb { padding-bottom: 0; }
.kb-track { position: absolute; top: 0; left: 0; bottom: 0; will-change: transform; }

.key { position: absolute; top: 0; }
.key--w {
  left: calc(var(--i) * var(--kw));
  width: var(--kw);
  height: 100%;
  border-radius: 0 0 max(3px, calc(var(--kw) * 0.1)) max(3px, calc(var(--kw) * 0.1));
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0, rgba(0, 0, 0, 0) 1.5px, rgba(0, 0, 0, 0) calc(100% - 1px), rgba(255, 255, 255, 0.7) 100%),
    linear-gradient(180deg, #d9d5cc 0, #f1efe9 7px, var(--ivory) 28%, var(--ivory) 82%, #f2f0ea 100%);
  box-shadow:
    inset 0 -8px 0 -1px #e7e3da,
    inset 0 -9px 0 -1px rgba(0, 0, 0, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.05s, background 0.05s;
}
.key--w.is-down {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0) calc(100% - 1px), rgba(0, 0, 0, 0.06) 100%),
    linear-gradient(180deg, #cdc8bd 0, #e7e3db 10px, #efebe2 45%, color-mix(in srgb, var(--hl) 34%, #f3eee2) 100%);
  box-shadow: inset 0 -3px 0 -1px #ddd7ca, inset 0 -1px 0 rgba(0, 0, 0, 0.14), inset 0 3px 4px rgba(0, 0, 0, 0.12);
}
.key--b {
  z-index: 2;
  left: calc((var(--i) + 1 + var(--o)) * var(--kw) - var(--bw) / 2);
  width: var(--bw);
  height: 62.5%;
  border-radius: 0 0 max(2px, calc(var(--bw) * 0.13)) max(2px, calc(var(--bw) * 0.13));
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0) 78%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(180deg, #0b0b0c 0, #252527 6%, #2e2e31 80%, #4b4b4f 85.5%, #2a2a2c 91%, #121213 100%);
  box-shadow: 1px 3px 4px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(0, 0, 0, 0.6);
  transition: background 0.05s, box-shadow 0.05s;
}
.key--b.is-down {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0) 78%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(180deg, #0b0b0c 0, #202022 6%, color-mix(in srgb, var(--hl) 22%, #2b2b2e) 88%, #3d3d41 93%, #151516 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.key-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(12px, calc(var(--kw) * 0.34));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  font-family: var(--font-round);
  line-height: 1;
}
.key--b .key-label { bottom: max(9px, calc(var(--kw) * 0.24)); gap: 3px; }
.key-note { white-space: nowrap; font-size: clamp(9px, calc(var(--kw) * 0.3), 14px); font-weight: 600; color: #9a958a; letter-spacing: -0.01em; }
.key--c .key-note { color: #57534b; }
.key--b .key-note { color: rgba(255, 255, 255, 0.62); font-size: clamp(7px, calc(var(--kw) * 0.24), 11px); }
.key-code {
  font-style: normal;
  font-family: var(--font);
  font-size: clamp(8px, calc(var(--kw) * 0.27), 12px);
  font-weight: 600;
  min-width: 1.6em;
  padding: 0.22em 0.32em;
  border-radius: 4px;
  text-align: center;
  color: #6c6860;
  background: rgba(0, 0, 0, 0.055);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}
.key--b .key-code { color: rgba(255, 255, 255, 0.75); background: rgba(255, 255, 255, 0.1); box-shadow: none; }
.key-note--mc { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); opacity: 0.85; }
.kb--narrow .key--b .key-note, .kb--narrow .key--b .key-code { display: none; }
.kb--tiny .key-label { display: none; }

/* learn marks */
.key.mark-r { --mark: var(--hl); }
.key.mark-l { --mark: var(--hl-left); }
.key--w.mark-r, .key--w.mark-l {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0, rgba(0, 0, 0, 0) 1.5px),
    linear-gradient(180deg, #d9d5cc 0, #f1efe9 7px, color-mix(in srgb, var(--mark) 22%, var(--ivory)) 30%, color-mix(in srgb, var(--mark) 62%, #fff) 100%);
}
.key--b.mark-r, .key--b.mark-l {
  background: linear-gradient(180deg, #0b0b0c 0, color-mix(in srgb, var(--mark) 45%, #222) 30%, color-mix(in srgb, var(--mark) 80%, #222) 85%, #2a2a2c 92%, #121213 100%);
}
.key.mark-r::after, .key.mark-l::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: 46%;
  aspect-ratio: 1;
  max-width: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--mark);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--mark) 60%, transparent);
  animation: ring 1.1s ease-out infinite;
}
.key.mark-next::after { animation: none; opacity: 0.55; }
.key.mark-next { filter: saturate(0.6); }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mark) 70%, transparent); } 100% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--mark) 0%, transparent); } }
.key.flash-wrong { background: linear-gradient(180deg, #d9d5cc, color-mix(in srgb, var(--wrong) 45%, #fff)) !important; }
.key--b.flash-wrong { background: linear-gradient(180deg, #111, color-mix(in srgb, var(--wrong) 70%, #222)) !important; }
.key.flash-hit::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--mark, var(--hl)); opacity: 0; animation: hit 0.38s ease-out; }
@keyframes hit { 0% { opacity: 0.55; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .key.mark-r::after, .key.mark-l::after { animation: none; }
  .pop, .toast, .readout { transition: none; }
}

/* scroll mode cursor */
.kb.is-scroll { cursor: grab; }
.kb.is-scroll:active { cursor: grabbing; }

/* noscript */
.noscript { position: absolute; inset: auto 16px 16px; z-index: 50; padding: 12px 16px; border-radius: 12px; background: var(--pop-bg); font-size: 14px; }
