/* Piano Tuner: mobile-first dark UI. Theme tokens mirror the Forrest Matter site. */

@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/tools/piano-tuner/fonts/chakra-petch-400.woff2") format("woff2");
}
@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/tools/piano-tuner/fonts/chakra-petch-600.woff2") format("woff2");
}
@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/tools/piano-tuner/fonts/chakra-petch-700.woff2") format("woff2");
}
@font-face {
  font-family: "Rajdhani";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/tools/piano-tuner/fonts/rajdhani-700.woff2") format("woff2");
}

/* mute diagram */
.mutes-diagram {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.md-wrap {
  flex: 1;
  min-height: 150px;
  position: relative;
}
.md-wrap svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.md-legend {
  flex: none;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 0.75rem;
  color: var(--muted);
}
.md-legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.md-sw {
  display: inline-block;
  width: 16px;
  height: 10px;
  border-radius: 2px;
}
.md-sw-sounding { background: var(--accent); height: 3px; }
.md-sw-muted { background: color-mix(in srgb, var(--muted) 60%, transparent); height: 3px; }
.md-sw-tune { background: transparent; border: 2px solid var(--accent2); height: 10px; }
.md-sw-felt { background: var(--felt); }
.md-sw-wedge { background: var(--rubber); clip-path: polygon(0 0, 100% 0, 65% 100%, 35% 100%); }
.md-caption {
  flex: none;
  font-size: 0.88rem;
  line-height: 1.3;
  min-height: 2.6em;
}
.md-cur { fill: var(--accent2); fill-opacity: 0.1; stroke: var(--accent2); stroke-opacity: 0.7; stroke-width: 1.5; }
.md-s { stroke-linecap: round; }
.md-s-on { stroke: var(--accent); stroke-width: 2.6; }
.md-s-muted { stroke: var(--muted); stroke-opacity: 0.45; stroke-width: 1.6; }
.md-s-neutral { stroke: var(--muted); stroke-opacity: 0.8; stroke-width: 1.8; }
.md-halo { stroke: var(--accent2); stroke-width: 7; stroke-linecap: round; stroke-opacity: 0.85; }
.md-x { stroke: var(--fg); stroke-opacity: 0.85; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.md-felt { fill: var(--felt); fill-opacity: 0.93; stroke: color-mix(in srgb, var(--felt) 60%, var(--fg)); stroke-width: 1; }
.md-felt.md-ghost { fill-opacity: 0.18; stroke-dasharray: 5 4; }
.md-felt-tex { stroke: #fff; stroke-opacity: 0.12; stroke-width: 1.5; }
.md-felt-label { fill: var(--fg); fill-opacity: 0.85; font-weight: 700; letter-spacing: 0.1em; pointer-events: none; }
.md-wedge { fill: var(--rubber); stroke: #000; stroke-opacity: 0.5; stroke-width: 1; }
.md-wedge-label { fill: var(--rubber); font-weight: 700; letter-spacing: 0.08em; }
.md-n { fill: var(--fg); fill-opacity: 0.8; font-weight: 600; }
.md-n-cur { fill: var(--accent2); fill-opacity: 1; font-weight: 700; }
.md-sub { fill: var(--muted); }
.md-t { fill: var(--muted); }
.md-tag-tune { fill: var(--accent2); font-weight: 700; letter-spacing: 0.06em; }
.md-tag-ref { fill: var(--accent); font-weight: 700; letter-spacing: 0.06em; }
.md-root text { font-family: var(--font-body); }

/* Piano Tuner, direction "A / Focus". Tokens mirror the Forrest Matter site. Vanilla CSS, no build. */

:root {
  --bg: #0b0c10;
  --bg-deep: #0f1015;
  --drawer: #101116;
  --surface: #14151b;
  --surface2: #1b1d25;
  --fg: #eef0f4;
  --text2: #b8bcc9;
  --muted: #8f93a3;
  --accent: #5bd9e6;
  --accent2: #e264b8;
  --accent3: #9d8cff;
  --accent3-soft: #b9adff;
  --line: #262833;
  --line2: #3a3d4a;
  --line-mute: #4a4e5e;
  --teal: #2f8d97;
  --teal-line: #2a5c63;
  --danger: #ff7b8a;
  --felt: #8a2f45;
  --rubber: #e0a84a;
  --radius: 10px;
  --gutter: 16px;
  --drawer-w: 380px;
  --font-body: "Chakra Petch", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Rajdhani", "Chakra Petch", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
}

body.sim-on {
  padding-bottom: calc(var(--simh, 60px) + 8px + env(safe-area-inset-bottom));
}

h1,
h2,
h3,
p {
  margin: 0;
}

h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  line-height: 1.15;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[tabindex="-1"]:focus {
  outline: none;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.center {
  text-align: center;
}
.ellipsis,
.one-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sp {
  flex: 1;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.row {
  display: flex;
}
.gap {
  gap: 10px;
}
.wrap-row {
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- buttons, chips, controls ---------- */

.btn,
.hbtn,
.gbtn,
.cta,
.opt,
.seg-btn,
.mic-chip,
.back-link,
.linkbtn {
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface2);
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn:hover,
.hbtn:hover,
.gbtn:hover {
  border-color: var(--muted);
}
.btn:active,
.cta:active {
  transform: translateY(1px);
}
.btn.primary,
.cta {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #0b0c10;
}
.btn.primary:hover,
.cta:hover {
  background: color-mix(in srgb, var(--accent) 85%, white);
}
.btn.ghost {
  background: transparent;
}
.btn.small {
  padding: 0 12px;
  font-size: 0.88rem;
}
.btn.danger,
.danger {
  color: var(--danger);
}
.btn[disabled],
.cta[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.cta {
  min-height: 52px;
  padding: 0 26px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.cta.wide {
  width: 100%;
}

.hbtn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  font-size: 0.9rem;
  white-space: nowrap;
}
.gbtn {
  flex: 1;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 0.82rem;
}
.gbtn.toggle[aria-pressed="true"] {
  border-color: var(--teal-line);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}
.linkbtn {
  background: none;
  border: none;
  padding: 0 2px;
  min-height: 44px;
  color: var(--accent);
  text-decoration: underline;
  font-size: inherit;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}
.back-link:hover {
  color: var(--accent);
}
.tune-bar .back-link {
  color: var(--fg);
  font-weight: 600;
  font-size: 0.95rem;
}

.control {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line2);
  background: var(--bg-deep);
  color: var(--fg);
  font: inherit;
  font-size: 16px; /* avoids iOS zoom on focus */
}
.control::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
.control:focus {
  border-color: var(--accent);
  outline: none;
}
.control.readout {
  display: flex;
  align-items: center;
  color: var(--muted);
}
select.control {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field-label,
.fld-l {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.fld-l {
  margin: 0;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text2);
}
.fld {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
  min-width: 0;
}
.fld.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

/* segmented control (radio group) */
.seg {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.seg-btn {
  flex: 1 1 auto;
  min-height: 44px;
  min-width: 56px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-deep);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}
.seg-btn small {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--muted);
}
.seg-btn.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-deep));
  color: var(--accent);
}
.seg-btn.on small {
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
}
.seg.pills .seg-btn {
  flex: 0 1 auto;
  flex-direction: row;
  gap: 6px;
  border-radius: 999px;
  padding: 0 16px;
  background: transparent;
}
.seg.tiles4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.seg.tiles4 .seg-btn {
  align-items: flex-start;
  text-align: left;
  min-height: 56px;
  min-width: 0;
  font-size: 13px;
}
.seg.stretch3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.seg.stretch3 .seg-btn {
  align-items: flex-start;
  text-align: left;
  gap: 2px;
  padding: 10px;
  border-radius: 12px;
  font-size: 14px;
  min-width: 0;
}
.seg.stretch3 svg {
  width: 100%;
  height: 40px;
  margin-bottom: 4px;
}

/* switch */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
  font-size: 0.92rem;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch-ui {
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: var(--line);
  position: relative;
  transition: background 0.15s;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fg);
  transition: transform 0.15s;
}
.switch input:checked + .switch-ui {
  background: var(--accent);
}
.switch input:checked + .switch-ui::after {
  transform: translateX(20px);
  background: #06181b;
}
.switch input:focus-visible + .switch-ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  min-width: 0;
}
.accent-card {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.notice {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent3) 60%, var(--line));
  background: color-mix(in srgb, var(--accent3) 10%, var(--surface));
  font-size: 0.92rem;
}
.notice.error {
  border-color: color-mix(in srgb, var(--accent2) 70%, var(--line));
  background: color-mix(in srgb, var(--accent2) 10%, var(--surface));
}
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0;
  background: var(--accent2);
  transition: width 0.25s;
}
.lead {
  font-size: 15px;
  color: var(--muted);
}
.cv {
  display: block;
  width: 100%;
  touch-action: manipulation;
}
kbd {
  font: inherit;
  font-size: 0.7rem;
  border: 1px solid #06181b66;
  border-radius: 4px;
  padding: 0 4px;
  opacity: 0.8;
}

/* ---------- screens and headers ---------- */

.screen {
  display: none;
}
.screen.active {
  display: block;
}

.sc-head {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 40px;
  border-bottom: 1px solid var(--line);
}
.sc-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
.sc-sub {
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

/* microphone chip + popover */
.mic-slot {
  display: inline-flex;
}
.mic-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  max-width: 260px;
}
.mic-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.mic-short {
  display: none;
}
.mic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.mic-chip.on .mic-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.mic-chip.err .mic-dot {
  background: var(--accent2);
}
.mic-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
  flex: none;
}
.mic-bars i {
  display: block;
  width: 3px;
  background: var(--line2);
}
.mic-bars i:nth-child(1) { height: 5px; }
.mic-bars i:nth-child(2) { height: 8px; }
.mic-bars i:nth-child(3) { height: 11px; }
.mic-bars i:nth-child(4) { height: 14px; }
.mic-bars i.lit {
  background: var(--accent);
}
.mic-chip.hot .mic-bars i.lit {
  background: var(--accent2);
}
.mic-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 60;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 84px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 6px 16px 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.mic-actions {
  display: flex;
  gap: 10px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.mic-panel .notice {
  margin: 8px 0;
}
.mic-prompt {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
}

/* ---------- pianos ---------- */

.pg {
  padding: 36px 40px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: calc(100dvh - 64px);
}
.pg-title {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.pg-title h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 5vw, 3.5rem);
  line-height: 0.9;
}
.pg-title .lead {
  margin-top: 8px;
}
.piano-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 18px;
}
.pcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.pcard.live {
  border-color: #5a3350;
}
.pc-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.pc-head > div {
  flex: 1;
  min-width: 0;
}
.pcard h2 {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.pc-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.pchip {
  flex: none;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pchip.pink {
  background: rgba(226, 100, 184, 0.15);
  border-color: transparent;
  color: #e88cc9;
}
.pchip.violet {
  background: rgba(157, 140, 255, 0.15);
  border-color: transparent;
  color: var(--accent3-soft);
}
.pcard svg.spark {
  width: 100%;
  height: 56px;
  display: block;
}
.pc-range {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.pc-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.pc-bar > div {
  height: 100%;
  background: var(--accent2);
}
.pc-bar.done > div {
  background: var(--teal);
}
.pc-foot {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pc-status {
  flex: 1;
  font-size: 13px;
  color: #c9ccd6;
  min-width: 0;
}
.pc-morebtn {
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 20px;
  line-height: 1;
}
.pc-morebtn[aria-expanded="true"] {
  color: var(--fg);
  border-color: var(--muted);
}
.pc-more-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.pc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pc-menu {
  flex-basis: 100%;
}
.add-card {
  border: 1.5px dashed var(--line2);
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}
.add-card:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.add-card .plus {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--accent);
}
.foot-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.empty h3 {
  font-size: 1.3rem;
}
.empty p {
  color: var(--muted);
}

/* ---------- setup ---------- */

.setup {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 64px);
}
.setup-body {
  flex: 1;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 32px;
  padding: 28px 40px 24px;
}
.steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 24px;
  align-self: start;
}
.steps a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 14px;
  color: var(--text2);
}
.steps a .num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1px solid var(--line2);
  color: var(--muted);
  flex: none;
}
.steps a[aria-current="step"] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.steps a[aria-current="step"] .num {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0c10;
  font-weight: 700;
}
.steps-note {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text2);
}
/* Setup is clicked through in 3 pages; each page fits a laptop or phone screen without scrolling. */
.setup-page {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-content: start;
  outline: none;
}
.setup-page[hidden] {
  display: none;
}
.steps a.done .num {
  border-color: var(--accent);
  color: var(--accent);
}
#setup-count {
  margin-right: 4px;
}
.foot-bar .cta.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line2);
}
.sec {
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 20px;
}
.sec.span2 {
  grid-column: 1 / -1;
}
.sec-h {
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  margin: 0;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.grid-tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}
.grid-tr:has(#root-wrap[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.temp-fig {
  margin: 0;
}
.temp-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  position: relative;
}
.temp-chart .tc {
  position: relative;
  height: 84px;
}
.temp-chart .tc::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 1px;
  background: var(--line2);
}
.temp-chart .tb {
  position: absolute;
  left: 20%;
  right: 20%;
  border-radius: 2px;
}
.temp-chart .tl {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.temp-fig figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 24px;
}
.strings-bar {
  display: flex;
  height: 26px;
  border-radius: 6px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  background: var(--line);
}
.strings-bar .sb {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.sb1 { background: var(--line2); }
.sb2 { background: #6a5cc4; }
.sb3 { background: var(--teal); color: #0b0c10; flex: 1; }
.guide-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
}
.mic-sec {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 18px;
}
.mic-sec .sec-h {
  width: 120px;
}
.mic-sec select {
  width: 260px;
  max-width: 100%;
}
.level-wrap {
  flex: 1 1 160px;
  min-width: 120px;
}
.level {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 18px;
}
.level i {
  flex: 1;
  display: block;
  border-radius: 2px;
  background: var(--line);
  height: 12px;
}
.level i.lit {
  background: var(--accent);
}
.level i.hot {
  background: var(--accent2);
}
.mic-note {
  font-size: 13px;
  color: var(--accent);
}
.foot-bar {
  position: sticky;
  bottom: var(--simh, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 40px calc(16px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.foot-bar .notice {
  margin: 0;
  flex: 1 1 280px;
}

/* ---------- measure ---------- */

.m-wrap {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 64px);
}
.m-wrap > .mic-prompt {
  margin: 16px 40px 0;
}
.m-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  padding: 24px 40px 20px;
}
.m-notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.m-notes .lead {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text2);
  margin-bottom: 4px;
}
.m-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mcard {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.mcard.active {
  background: rgba(226, 100, 184, 0.1);
  border: 1.5px solid var(--accent2);
}
.mcard .mn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  width: 52px;
  color: var(--muted);
}
.mcard.done .mn {
  color: var(--fg);
}
.mcard.active .mn {
  color: var(--accent2);
}
.mcard .mt {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mcard .mt b {
  font-size: 13px;
  font-weight: 600;
}
.mcard .mt span {
  font-size: 12px;
  color: var(--muted);
}
.mcard .mb {
  font-size: 16px;
  color: var(--accent);
}
.mcard.active .mb {
  color: var(--accent2);
}
.mcard.skipped {
  opacity: 0.55;
}
.m-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.m-listen {
  padding: 14px 18px;
  border-radius: 18px;
}
.ml-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.note-md {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  line-height: 0.9;
  color: var(--accent2);
}
.measure-status {
  flex: 1;
  font-size: 15px;
  min-width: 160px;
}
.rta-wrap {
  position: relative;
  height: 150px;
  margin: 8px 0;
}
.rta-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.m-actions {
  margin-top: 10px;
}
.m-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
}
.m-chart {
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.m-chart-h {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.m-chart-c {
  position: relative;
  height: 200px;
}
.m-chart-c canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.m-legend {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.m-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.m-legend i {
  display: block;
}
.lg-line { width: 14px; height: 2px; background: var(--accent); }
.lg-dash { width: 14px; height: 0; border-top: 2px dashed var(--muted); }
.lg-before { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--accent3); }
.lg-after { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.lg-tol { width: 14px; height: 8px; background: rgba(91, 217, 230, 0.18); }
.m-foot {
  padding-top: 16px;
}

/* ---------- tune: top bar ---------- */

.tune-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
}
.piano-id {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  flex: 0 1 300px;
}
.piano-id .pn {
  font-weight: 600;
  font-size: 15px;
}
.piano-id .ps {
  font-size: 12px;
  color: var(--muted);
}
.ps-phone {
  display: none;
}
.rail-nav {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  justify-content: center;
}
.rail {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 820px;
}
.rail li {
  flex: 1 1 0;
  min-width: 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: flex-grow 0.2s;
}
.rail li.cur {
  flex-grow: 1.7;
}
.rail .bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--rail-fill, var(--accent)) var(--p, 0%), var(--line) var(--p, 0%));
}
.rail li.full .bar {
  --rail-fill: #3a8c96;
}
.rail li.cur .bar {
  box-shadow: 0 0 0 1px var(--accent);
}
.rail .lbl {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail li.cur .lbl {
  color: var(--fg);
}
.bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.top-progress {
  display: none;
}

/* ---------- tune: hero ---------- */

body[data-screen="tune"] {
  overflow: hidden;
}
#screen-tune.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--drawer-w);
  grid-template-rows: 64px minmax(0, 1fr);
  height: calc(100dvh - var(--simh, 0px));
  position: relative;
}
.tune-bar {
  grid-column: 1 / -1;
  grid-row: 1;
}
.tune-mic-prompt {
  position: absolute;
  top: 74px;
  left: 24px;
  z-index: 8;
  background: var(--surface2);
  border-color: var(--accent);
  margin: 0;
}
.tune-mic-prompt p {
  font-size: 14px;
}
.t-main {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 24px;
}
.hero {
  --nav-w: clamp(92px, 9.2vw, 132px);
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--nav-w);
  align-items: center;
  gap: 16px;
}
.navbtn {
  height: clamp(96px, 15vh, 132px);
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, transform 0.05s;
}
.navbtn svg {
  flex: none;
}
.navbtn.prev svg {
  color: var(--muted);
}
.navbtn:hover:not([disabled]) {
  border-color: var(--muted);
}
.navbtn:active:not([disabled]) {
  transform: translateY(1px);
}
.navbtn.next {
  background: var(--accent);
  border: none;
  color: #0b0c10;
}
.navbtn.next:hover:not([disabled]) {
  background: color-mix(in srgb, var(--accent) 85%, white);
}
.navbtn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.nb-note {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nb-note.txt {
  font-size: 18px;
}
.nb-l {
  font-size: 12px;
  font-weight: 600;
}
.navbtn.prev .nb-l {
  color: var(--muted);
  font-weight: 400;
}

.hero-c {
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 0.7vh, 8px);
}
.note-row {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 18px;
  max-width: 100%;
  min-width: 0;
}
.note-big {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(44px, 8.2vh, 96px);
  line-height: 0.9;
  letter-spacing: 0.01em;
  color: var(--accent2);
  flex: none;
  white-space: nowrap;
}
.note-big.small {
  font-size: clamp(30px, 6vh, 56px);
  line-height: 1;
}
.note-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.step-instruction {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.step-detail {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}
.arc-wrap {
  flex: 1 1 0;
  min-height: 90px;
  max-height: 400px;
  width: 100%;
  max-width: 860px;
  position: relative;
}
.arc-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.arc-wrap.blank canvas {
  visibility: hidden;
}
.dir {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: clamp(44px, 6vh, 56px);
  min-width: min(440px, 100%);
  max-width: 100%;
  padding: 0 22px 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line2);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
.dir-ico {
  flex: none;
  width: 24px;
  text-align: center;
  font-size: 22px;
  line-height: 1;
}
.dir b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(18px, 3.1vh, 28px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.1;
}
.dir-sub {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  opacity: 0.9;
}
.dir[data-dir="flat"] {
  color: var(--accent3-soft);
  border-color: var(--accent3);
  background: rgba(157, 140, 255, 0.12);
}
.dir[data-dir="sharp"] {
  color: #f0a0d6;
  border-color: var(--accent2);
  background: rgba(226, 100, 184, 0.12);
}
.dir[data-dir="ok"] {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(91, 217, 230, 0.12);
}
.dir[data-hold="true"] .dir-ico,
.dir[data-hold="true"] b {
  opacity: 0.55;
}
.strobe {
  flex: none;
  width: 100%;
  max-width: 800px;
  height: clamp(12px, 2.2vh, 20px);
}
.caption-row {
  flex: none;
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  min-height: 16px;
}
.cap-r {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.autobar {
  flex: none;
  width: 100%;
  max-width: 800px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.autobar > div {
  height: 100%;
  width: 0;
  background: var(--accent);
}

/* ---------- tune: spectrum + keyboard cards ---------- */

/* The two cards sit in one wrapper. Wide: a one-column grid with equal-height rows, so the spectrum card is exactly as tall
   as the keyboard card (whose height comes from the true key proportions). Phones: the wrapper vanishes and the cards are
   ordered by the rules further down. */
.lower {
  display: contents;
}
.view-seg {
  display: inline-flex;
  align-items: center;
  margin: 0 0 0 10px;
  padding: 2px;
  gap: 2px;
  border-radius: 999px;
  background: var(--bg, #0b0c10);
  border: 1px solid var(--line);
}
.vs-btn {
  font: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 4px 10px;
  min-height: 22px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.vs-btn[aria-pressed="true"] {
  background: var(--surface2, var(--line));
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line2, var(--line));
}
.vs-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
@media (max-width: 899.98px) {
  .vs-btn {
    min-height: 28px;
    padding: 6px 12px;
  }
  .vs-key {
    display: none;
  }
}
.vs-key {
  margin: 0 5px 0 4px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 14px;
  color: var(--muted);
  border-color: var(--line2, var(--line));
  background: transparent;
}
/* Hover / target readout in the spectrum card's title row, between the view switch and the right-hand caption. */
.card-readout {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 8px;
  font-size: 11px;
  line-height: 18px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.card-readout[data-idle="true"] {
  color: var(--muted);
}
.card-h .card-note {
  flex: 0 1 auto;
  max-width: 44%;
}
body[data-spec-view="spectrogram"] #screen-tune:not([data-kind="unison"]) #beat-text {
  display: none; /* the readout gets the room; the caption only repeats the legend */
}
/* Spectrogram view, wide Tune: the keyboard card steps aside (hidden, but its grid cell keeps the .lower height) and the
   spectrogram takes both rows. The piano roll on the plot's left edge replaces the keyboard. */
@media (min-width: 900px) {
  body[data-spec-view="spectrogram"] .lower > .spec-card {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
  body[data-spec-view="spectrogram"] .lower > .kb-card {
    grid-column: 1;
    grid-row: 2;
    visibility: hidden;
    pointer-events: none;
  }
  body[data-spec-view="spectrogram"] #screen-free .free-spec {
    height: clamp(200px, 34vh, 340px);
  }
}
/* Phones: with the spectrogram on, it replaces the keyboard window and gets taller. */
@media (max-width: 899.98px) {
  .spec-card .card-h .eyebrow {
    display: none;
  }
  .spec-card .card-h .view-seg {
    margin-left: 0;
  }
  .card-readout {
    padding-left: 6px;
  }
  /* In the taller spectrogram card the readout gets its own line under the switch. */
  body[data-spec-view="spectrogram"] .spec-card .card-h {
    flex-wrap: wrap;
    row-gap: 3px;
  }
  body[data-spec-view="spectrogram"] .spec-card .card-readout {
    order: 3;
    flex: 1 1 100%;
    padding-left: 0;
  }
  body[data-spec-view="spectrogram"][data-spec="on"] #screen-tune .kb-card {
    display: none;
  }
  body[data-spec-view="spectrogram"][data-spec="on"] #screen-tune .spec-card {
    height: clamp(190px, 30vh, 280px);
  }
  body[data-spec-view="spectrogram"] #screen-free .free-spec {
    min-height: 170px;
  }
}
@media (min-width: 900px) {
  .lower {
    --card-cap: max(104px, calc((100dvh - var(--simh, 0px)) * 0.3 - 88px));
    --kb-chrome: 44px;
    flex: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: 1fr;
    gap: 12px;
  }
  .lower > .spec-card,
  .lower > .kb-card {
    height: auto;
    min-height: 0;
  }
  /* Keyboard: true proportions at full width, but never taller than the shared card cap; then it is letterboxed (centred, narrower). */
  .lower .cv-keys {
    width: min(100%, calc((var(--card-cap) - var(--kb-chrome)) * var(--kb-aspect, 8.15)));
    margin-inline: auto;
  }
}
@media (min-width: 900px) and (max-height: 820px) {
  .lower {
    --kb-chrome: 38px;
    gap: 10px;
  }
}

.spec-card,
.kb-card {
  flex: none;
  border-radius: 16px;
  padding: 10px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spec-card {
  height: clamp(112px, 14.5vh, 140px);
}
.kb-card {
  padding-bottom: 8px;
  gap: 6px;
}
.card-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 18px;
}
.card-note {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.spec-body {
  position: relative;
  flex: 1;
  min-height: 0;
}
.spec-body > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.beat-over {
  position: absolute;
  right: 6px;
  top: 14px;
  width: min(40%, 340px);
  height: 42px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.beat-over.on {
  opacity: 1;
}
.beat-over canvas {
  width: 100%;
  height: 100%;
}
.kb-hint {
  letter-spacing: 0;
  text-transform: none;
}
.key-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11px;
  color: var(--muted);
}
.key-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ksw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.ksw-cur { background: var(--accent2); }
.ksw-done { background: var(--accent); }
.ksw-off { background: var(--accent3); }
.ksw-todo { background: #d9dbe2; }
.kb-scroll {
  position: relative;
}
.cv-keys {
  width: 100%;
  height: auto;
  aspect-ratio: var(--kb-aspect, 8.15);
  cursor: pointer;
}
.kb-snap {
  position: absolute;
  top: 0;
  width: 1px;
  height: 1px;
  scroll-snap-align: start;
  pointer-events: none;
}

/* ---------- tune: drawer / bottom sheet ---------- */

.drawer {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--drawer);
}
.sheet-handle {
  display: none;
}
.drawer-tabs {
  display: flex;
  gap: 2px;
  padding: 14px 12px 0;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tab {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 6px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab[aria-selected="true"] {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  opacity: 0;
}
.tab-dot.pink {
  background: var(--accent2);
}
.tab-dot.cyan {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.tab-dot[data-on="true"] {
  opacity: 1;
}
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.tabpanel {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}
.tabpanel[hidden] {
  display: none;
}
.peek-only {
  display: none;
}
.sec-chip {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--teal-line);
  border-radius: 999px;
  padding: 3px 10px;
}
.g-title {
  font-family: var(--font-body);
  margin: 10px 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
}
.g-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text2);
}
.fig {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.g-fig:has(.g-mini:empty) {
  display: none;
}
.coach h3 {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.coach ol {
  margin: 0;
  padding: 0 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: #d4d7e0;
}
.coach li::marker {
  color: var(--accent);
  font-weight: 600;
}
.g-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 4px;
}
.accent-card h3 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}
.accent-card p {
  font-size: 14px;
  margin-bottom: 10px;
}
.mutes-next {
  margin-top: auto;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-width: 0;
}
.t-l {
  font-size: 11px;
  color: var(--muted);
}
.t-v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.15;
  white-space: nowrap;
}
.hist-h2 {
  margin-top: 4px;
}
.hist-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hrow {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface);
  flex: none;
}
.hrow .hn {
  width: 42px;
  font-weight: 600;
  font-size: 14px;
}
.hrow .hw {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
}
.hrow .hv {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.hrow .hv.warn {
  color: var(--accent3-soft);
}
.hist-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 2px;
}
.hist-last {
  margin-top: auto;
}
.tone-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 0 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.tone-btn .tb-t {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.tone-btn b {
  font-size: 20px;
}
.tone-btn small {
  font-size: 12px;
  opacity: 0.8;
}
.tone-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0c10;
}
.tone-btn[aria-pressed="true"] #tone-slash,
.tone-btn[aria-pressed="false"] #tone-waves {
  display: none;
}
.tone-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.tc-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.tc-top .note-md {
  font-size: 44px;
}
.tc-hz {
  font-size: 15px;
}
.tone-card p {
  margin-top: 6px;
}
.tone-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  font-size: 14px;
}
.opt b {
  font-weight: 600;
}
.opt small {
  font-size: 11px;
  color: var(--muted);
}
.opt[aria-pressed="true"] {
  border: 1.5px solid var(--accent);
  background: rgba(91, 217, 230, 0.08);
  padding: 9.5px 11.5px;
}
.tone-vol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}
.tone-vol input {
  width: 100%;
  accent-color: var(--accent);
  height: 32px;
}
.callout {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface2);
  font-size: 13px;
  line-height: 1.45;
  color: #c9ccd6;
}

/* ---------- summary ---------- */

.sum {
  padding: 26px 40px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(340px, 1fr);
  gap: 18px;
  min-height: calc(100dvh - 64px);
}
.stat-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  min-width: 0;
}
.stat .s-l {
  font-size: 12px;
  color: var(--muted);
}
.stat .s-v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 38px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .s-s {
  font-size: 12px;
  color: var(--muted);
}
.sum-chart {
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sum-canvas {
  position: relative;
  flex: 1;
  min-height: 240px;
}
.sum-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.sum-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.sum-side .card {
  border-radius: 18px;
  padding: 14px 16px;
}
.su-big {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
}
.su-v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  color: var(--accent);
}
.notes-field {
  flex: 1;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.notes-field textarea {
  flex: 1;
  resize: none;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line2);
  background: var(--bg-deep);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.45;
  min-height: 110px;
}
.notes-field textarea:focus {
  border-color: var(--accent);
  outline: none;
}
.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ---------- free tune ---------- */

body[data-screen="free"] {
  overflow: hidden;
}
#screen-free.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--drawer-w);
  grid-template-rows: 64px minmax(0, 1fr);
  height: calc(100dvh - var(--simh, 0px));
  position: relative;
}
#screen-free .sc-head {
  grid-column: 1 / -1;
  grid-row: 1;
}
.free-mic-prompt {
  position: absolute;
  top: 74px;
  left: 24px;
  z-index: 8;
  background: var(--surface2);
  border-color: var(--accent);
  margin: 0;
}
.free-mic-prompt p {
  font-size: 14px;
}
.free-main {
  display: contents;
}
.free-hero {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 0.9vh, 10px);
  padding: 14px 24px 0;
}
.free-note-row {
  flex: none;
  max-width: 100%;
}
.free-note-row .note-meta {
  max-width: 460px;
}
.free-arc {
  flex: 1 1 0;
  min-height: 90px;
}
.free-spec {
  grid-column: 1;
  grid-row: 3;
  margin: 10px 24px 14px;
}
#screen-free.active {
  grid-template-rows: 64px minmax(0, 1fr) auto;
}
.free-side {
  grid-column: 2;
  grid-row: 2 / span 2;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  border-left: 1px solid var(--line);
  background: var(--drawer);
}
.fs-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fs-block .eyebrow {
  margin: 0;
}
.pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pick-btn,
.pick-lock {
  flex: none;
  min-width: 48px;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pick-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.pick-btn:not(:disabled):hover,
.pick-lock:hover {
  border-color: var(--muted);
}
.pick-note {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  color: var(--accent2);
}
.pick-note[data-default="true"] {
  color: var(--muted);
}
.pick-lock {
  padding: 0 12px;
  font-size: 14px;
}
.pick-lock[aria-pressed="true"] {
  background: var(--accent3);
  border-color: var(--accent3);
  color: #0b0c10;
}
.free-kb {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 8px;
  scrollbar-width: none;
  scroll-snap-type: none;
}
.free-kb::-webkit-scrollbar {
  display: none;
}
.free-kb .cv-keys {
  display: block;
  max-width: none;
  height: auto;
}
.ft-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fs-tone .tone-btn {
  min-height: 72px;
}
.ft-waves {
  display: block;
}
.tone-btn[aria-pressed="true"] .ft-slash,
.tone-btn[aria-pressed="false"] .ft-waves {
  display: none;
}
.fs-tone .opt {
  min-height: 48px;
  justify-content: center;
}
.ft-read {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.ft-read .note-md {
  font-size: 34px;
}
.fs-tone .callout {
  margin-top: 0;
}
.fs-resp {
  margin-top: auto;
  display: flex;
  gap: 8px;
}
.fs-resp .gbtn {
  width: 100%;
}
.ft-vol input {
  height: 44px;
}
body.sim-on[data-screen="free"] {
  padding-bottom: 0;
}

/* ---------- sim bar, toast ---------- */

.sim-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--accent3);
  padding: 4px max(var(--gutter), env(safe-area-inset-left)) calc(4px + env(safe-area-inset-bottom));
}
.sim-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mini {
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.mini input[type="checkbox"] {
  width: 20px;
  height: 20px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 70;
  font-size: 0.9rem;
}
body.sim-on .toast {
  bottom: calc(80px + env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- laptops and landscape tablets: tighter columns ---------- */

@media (min-width: 900px) and (max-width: 1180px) {
  :root {
    --drawer-w: 320px;
  }
  .tabpanel {
    padding: 14px 16px;
  }
  .t-main {
    padding: 16px 18px;
    gap: 12px;
  }
  .tune-bar {
    padding: 0 16px;
    gap: 12px;
  }
  .piano-id {
    flex-basis: 190px;
  }
  .tab {
    font-size: 14px;
  }
  .mic-chip {
    max-width: 190px;
  }
  .sc-head,
  .pg,
  .m-grid,
  .sum,
  .foot-bar {
    padding-left: 24px;
    padding-right: 24px;
  }
  .setup-body {
    padding-left: 24px;
    padding-right: 24px;
    gap: 20px;
    grid-template-columns: 190px minmax(0, 1fr);
  }
}
@media (min-width: 900px) and (max-height: 760px) {
  .g-title {
    font-size: 19px;
    margin: 6px 0 2px;
  }
  .tabpanel {
    gap: 12px;
    padding-top: 12px;
  }
  .t-main {
    padding-top: 14px;
    padding-bottom: 14px;
    gap: 12px;
  }
  .hero {
    gap: 12px;
  }
  .step-detail {
    font-size: 12px;
  }
}

/* ---------- phones and narrow tablets ---------- */

@media (max-width: 899.98px) {
  .sc-head {
    padding: 0 16px;
    gap: 12px;
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .sc-brand {
    font-size: 20px;
    letter-spacing: 0.1em;
  }
  .sc-sub {
    display: none;
  }
  .pg {
    padding: 20px 16px 24px;
    min-height: 0;
  }
  .pg-title .cta {
    width: 100%;
  }
  .piano-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .add-card {
    min-height: 120px;
    flex-direction: row;
  }
  .setup {
    min-height: 0;
  }
  .setup-body {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 16px 20px;
    gap: 16px;
  }
  .steps {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .steps a {
    flex: none;
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 999px;
  }
  .steps-note {
    display: none;
  }
  .setup-page {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .sec {
    padding: 16px;
  }
  .seg.tiles4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .seg.stretch3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .seg.stretch3 svg {
    height: 32px;
  }
  .mic-sec .sec-h {
    width: 100%;
  }
  .foot-bar {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }
  .foot-bar .cta {
    flex: 1 1 auto;
  }
  .m-wrap {
    min-height: 0;
  }
  .m-wrap > .mic-prompt {
    margin: 12px 16px 0;
  }
  .m-grid {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 16px 12px;
  }
  .m-cards {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .mcard {
    flex: none;
    min-width: 168px;
  }
  .m-lower {
    grid-template-columns: minmax(0, 1fr);
  }
  .rta-wrap {
    height: 120px;
  }
  .sum {
    padding: 16px 16px 24px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    min-height: 0;
  }
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat .s-v {
    font-size: 30px;
  }
  .sum-canvas {
    min-height: 220px;
  }
  .mic-panel {
    top: 60px;
    right: 12px;
  }
  .free-wrap {
    padding: 14px 16px 24px;
  }
  .free-arc {
    height: 200px;
  }
  .hbtn {
    padding: 0 12px;
    font-size: 0.82rem;
  }
  .mic-name,
  .mic-bars {
    display: none;
  }
  .mic-short {
    display: inline;
  }
  .mic-chip {
    padding: 0 12px;
  }

  /* tune on a phone: stacked, sheet at the bottom */
  body[data-screen="tune"] {
    overflow: auto;
  }
  #screen-tune.active {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    padding-bottom: calc(var(--sheet-h, 140px) + var(--simh, 0px) + 14px);
  }
  .tune-bar {
    height: auto;
    min-height: 64px;
    padding: 10px 16px;
    gap: 10px;
  }
  .tune-bar .back-link {
    width: 44px;
    height: 44px;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--fg);
    flex: none;
  }
  .bl-t {
    display: none;
  }
  .piano-id {
    flex: 1 1 0;
  }
  .ps-wide,
  #tune-piano-sub {
    display: none;
  }
  .ps-phone {
    display: block;
  }
  .rail-nav {
    display: none;
  }
  .bar-right {
    gap: 8px;
  }
  .top-progress {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 4px;
    background: var(--line);
  }
  .top-progress > div {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.25s;
  }
  .tune-mic-prompt {
    position: static;
    margin: 10px 16px 0;
  }
  .t-main {
    padding: 12px 16px 0;
    gap: 12px;
  }
  .hero {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-areas:
      "c c"
      "p n";
    gap: 10px;
    flex: none;
  }
  .hero-c {
    grid-area: c;
    align-items: stretch;
    gap: 6px;
  }
  .navbtn.prev {
    grid-area: p;
  }
  .navbtn.next {
    grid-area: n;
  }
  .navbtn {
    height: 56px;
    border-radius: 16px;
    flex-direction: row;
    gap: 8px;
  }
  .navbtn svg {
    width: 16px;
    height: 16px;
  }
  .navbtn.prev .nb-l {
    display: none;
  }
  .navbtn.next .nb-l {
    order: 1;
    font-size: 17px;
    font-weight: 700;
  }
  .navbtn.next .nb-l::after {
    content: " ·";
  }
  .navbtn.next .nb-note {
    order: 2;
    font-size: 17px;
    font-family: var(--font-body);
    font-weight: 700;
  }
  .navbtn.next svg {
    order: 3;
  }
  .nb-note {
    font-size: 20px;
  }
  .note-row {
    gap: 12px;
  }
  .note-big {
    font-size: clamp(52px, 17vw, 68px);
  }
  .note-big.small {
    font-size: clamp(30px, 9vw, 44px);
  }
  .step-instruction {
    font-size: 16px;
  }
  .arc-wrap {
    flex: none;
    max-width: none;
    max-height: none;
    height: auto;
    aspect-ratio: 2.05 / 1;
    min-height: 0;
  }
  .dir {
    height: 52px;
    min-width: 0;
    width: 100%;
    border-radius: 16px;
    padding: 0 14px;
    gap: 10px;
  }
  .dir b {
    font-size: 21px;
    letter-spacing: 0.05em;
  }
  .dir-sub {
    display: none;
  }
  .dir[data-dir="idle"] .dir-sub:not(:empty) {
    display: block;
    font-size: 12px;
  }
  .strobe {
    max-width: none;
    height: 16px;
    margin-top: 4px;
  }
  .caption-row,
  .autobar {
    max-width: none;
  }
  .cap-l {
    display: none;
  }
  .cap-r {
    text-align: left;
    white-space: normal;
  }
  .spec-card {
    height: 110px;
  }
  .kb-card {
    order: 1;
  }
  .spec-card {
    order: 2;
  }
  #screen-tune[data-kind="unison"] .spec-card {
    order: 0;
  }
  .kb-hint,
  .key-legend {
    display: none;
  }
  .kb-card {
    padding: 10px 14px;
  }
  .kb-scroll {
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .kb-scroll::-webkit-scrollbar {
    display: none;
  }
  .cv-keys {
    width: max(100%, calc(var(--kb-whites, 52) * ((100vw - 60px) / 21)));
  }

  .drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--simh, 0px);
    z-index: 40;
    grid-column: auto;
    grid-row: auto;
    max-height: calc(100dvh - 76px - var(--simh, 0px));
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.45);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 100%;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    cursor: grab;
    touch-action: none;
  }
  .sheet-handle span {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--line2);
  }
  .drawer-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 0 16px 8px;
    border-bottom: none;
  }
  .tab {
    height: 40px;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
    color: var(--fg);
  }
  .tab[aria-selected="true"] {
    border-color: var(--teal-line);
    background: rgba(91, 217, 230, 0.1);
    color: var(--accent);
  }
  .drawer-body {
    padding: 0 16px;
    overflow: hidden;
    flex: none;
  }
  .drawer[data-sheet="open"] .drawer-body {
    flex: 1;
    max-height: min(62dvh, 560px);
    overflow-y: auto;
  }
  .tabpanel {
    padding: 2px 0 12px;
    gap: 12px;
    min-height: 0;
  }
  .drawer[data-sheet="peek"] .tabpanel > :not(.peek-keep):not(.peek-only) {
    display: none;
  }
  .drawer[data-sheet="peek"] .peek-only {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    color: #d4d7e0;
  }
  .drawer[data-sheet="peek"] .tone-btn {
    min-height: 48px;
    border-radius: 14px;
    padding: 0 18px;
  }
  .drawer[data-sheet="peek"] .tone-btn small,
  .drawer[data-sheet="peek"] .tone-btn svg {
    display: none;
  }
  .drawer[data-sheet="peek"] .tone-btn b {
    font-size: 16px;
  }
  .toast {
    bottom: calc(var(--sheet-h, 140px) + var(--simh, 0px) + 16px);
  }
  body.sim-on .toast {
    bottom: calc(var(--sheet-h, 140px) + var(--simh, 0px) + 16px);
  }
  .g-title {
    font-size: 20px;
  }
  .mutes-diagram .md-wrap {
    height: 180px;
  }
}

@media (max-width: 380px) {
  .grid2,
  .grid3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .sc-brand {
    font-size: 18px;
  }
}

@media (min-width: 900px) {
  body.sim-on {
    padding-bottom: 0;
  }
  body.sim-on[data-screen="pianos"],
  body.sim-on[data-screen="setup"],
  body.sim-on[data-screen="summary"] {
    padding-bottom: 0;
  }
}

/* ---------- mute diagram sizing inside the drawer ---------- */

.mutes-diagram {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mutes-diagram .md-wrap {
  height: 200px;
  min-height: 0;
  flex: none;
}
.md-compact .md-wrap {
  height: 92px;
  min-height: 0;
}
#panel-mutes .md-legend {
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}
#panel-mutes .md-caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
#panel-mutes .md-sw {
  width: 18px;
}

/* ---------- small state rules ---------- */

.dir-ico:empty {
  display: none;
}
.m-listen[data-done="true"] .rta-wrap,
.m-listen[data-done="true"] .progress,
.m-listen[data-done="true"] .m-actions {
  display: none;
}
.drawer[data-offer="true"] .g-step,
.drawer[data-offer="true"] .g-fig {
  display: none;
}

.g-actions .gbtn {
  font-size: 12.5px;
  padding: 0 4px;
}
.g-actions .gbtn.toggle {
  white-space: nowrap;
}

/* short laptops (about 720 px tall): shrink the hero's furniture so the dial keeps its size */
@media (min-width: 900px) and (max-height: 820px) {
  .note-big {
    font-size: clamp(44px, 8.4vh, 90px);
  }
  .note-big.small {
    font-size: clamp(28px, 5vh, 44px);
  }
  .note-meta .step-instruction {
    font-size: 16px;
  }
  .hero-c {
    gap: 4px;
  }
  .cap-l {
    display: none;
  }
  .caption-row {
    justify-content: center;
    min-height: 14px;
  }
  .cap-r {
    text-align: center;
  }
  .spec-card {
    height: clamp(86px, 12vh, 106px);
    padding-top: 6px;
  }
  .kb-card {
    padding: 6px 12px 8px;
    gap: 4px;
  }
  .t-main {
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

.drawer[data-offer="true"] .peek-only {
  display: none !important;
}
@media (max-width: 899.98px) {
  .m-foot {
    position: static;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .m-foot .sp {
    display: none;
  }
  .m-foot #measure-count {
    order: -1;
    flex: 1 0 100%;
  }
  .m-foot .btn,
  .m-foot .cta {
    flex: 1 1 100%;
  }
}

/* phone: tighter hero so note, dial, pill, Prev/Next and the keyboard fit above the sheet's peek */
@media (max-width: 899.98px) {
  .tune-bar { min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
  .t-main { padding-top: 8px; gap: 8px; }
  .hero-c { gap: 4px; }
  .hero { gap: 8px; }
  .note-big { font-size: clamp(46px, 14vw, 58px); }
  .arc-wrap { aspect-ratio: 2.3 / 1; }
  .strobe { height: 12px; margin-top: 0; }
  .dir { height: 46px; }
  .dir b { font-size: 19px; }
  .navbtn { height: 52px; }
  .caption-row { min-height: 0; }
  .kb-card { padding-top: 8px; padding-bottom: 10px; gap: 6px; }
  .sim-bar kbd, #sim-dev { display: none; }
  .sim-row { flex-wrap: nowrap; gap: 4px; }
  .sim-bar .btn { padding: 0 10px; }
  .mini { font-size: 0.72rem; gap: 3px; }
}

/* Setup on phones: each of the 3 pages fits the screen without scrolling. */
@media (max-width: 899.98px) {
  #screen-setup .sc-head,
  #screen-setup .steps-note {
    display: none;
  }
  /* compact step row: numbers, with the current step's name */
  #screen-setup .steps {
    flex-direction: row;
    gap: 6px;
    overflow: visible;
    padding: 0;
  }
  #screen-setup .steps a {
    font-size: 0;
    gap: 0;
    min-height: 36px;
    padding: 0 6px;
    border: none;
    background: none;
    box-shadow: none;
  }
  #screen-setup .steps a .num {
    font-size: 12px;
    width: 26px;
    height: 26px;
  }
  #screen-setup .steps a[aria-current="step"] {
    font-size: 14px;
    gap: 8px;
    color: var(--fg);
  }
  /* once Back is offered, Cancel lives behind it (and the header's Pianos link) */
  #screen-setup .foot-bar:has(#setup-prev:not([hidden])) #setup-cancel {
    display: none;
  }
  #screen-setup .foot-bar .cta.cta {
    flex: 2 1 0;
    white-space: nowrap;
    padding: 0 10px;
    font-size: 15px;
  }
  #screen-setup .setup-body {
    padding: 12px 16px 8px;
  }
  #screen-setup .sec {
    padding: 12px 14px;
    gap: 8px;
    border-radius: 14px;
  }
  #screen-setup .sec-h {
    margin: 0;
  }
  #screen-setup .fld {
    gap: 4px;
  }
  #screen-setup .grid2,
  #screen-setup .grid3 {
    gap: 8px;
  }
  #screen-setup .seg.tiles4 .seg-btn {
    min-height: 44px;
    padding: 6px 10px;
  }
  #screen-setup .seg.tiles4 .seg-btn small,
  #screen-setup .seg.stretch3 .seg-btn small {
    display: none;
  }
  #screen-setup .seg.pills {
    gap: 6px;
  }
  #screen-setup .seg.pills .seg-btn {
    padding: 0 11px;
    font-size: 14px;
  }
  #screen-setup .seg.stretch3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #screen-setup .seg.stretch3 .seg-btn {
    padding: 8px;
  }
  #screen-setup .seg.stretch3 svg {
    height: 26px;
  }
  #screen-setup .temp-chart .tc {
    height: 54px;
  }
  #screen-setup .temp-fig figcaption,
  #screen-setup #sec-stretch p,
  #screen-setup #sec-strings p,
  #screen-setup .mic-note {
    display: none;
  }
  #screen-setup .foot-bar {
    flex-wrap: nowrap;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }
  #screen-setup #setup-count {
    display: none;
  }
  #screen-setup .foot-bar .btn,
  #screen-setup .foot-bar .cta {
    flex: 1 1 0;
    min-width: 0;
  }
  #screen-setup .foot-bar .notice {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 100%;
    margin-bottom: 6px;
  }
}

/* ---------- free tune on phones: header, note + dial, pill, strobe, picker, tone row, spectrum ---------- */
@media (max-width: 899.98px) {
  body[data-screen="free"] {
    overflow: hidden;
  }
  #screen-free.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--simh, 0px));
    min-height: 0;
  }
  #screen-free .sc-head {
    flex: none;
    min-height: 56px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .free-mic-prompt {
    top: 62px;
    left: 16px;
    right: 16px;
  }
  .free-main {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 16px 8px;
  }
  .free-hero {
    flex: none;
    padding: 0;
    gap: 4px;
  }
  .free-hero .note-big {
    font-size: clamp(46px, 14vw, 58px);
  }
  .free-note-row {
    gap: 12px;
  }
  .free-note-row .step-instruction {
    font-size: 15px;
  }
  .free-note-row .step-detail {
    font-size: 11.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .free-arc {
    flex: none;
    aspect-ratio: 2.3 / 1;
    min-height: 0;
  }
  .free-hero .dir {
    height: 46px;
  }
  .free-hero .dir b {
    font-size: 19px;
  }
  .free-hero .strobe {
    height: 12px;
  }
  .free-hero .caption-row {
    display: none;
  }
  .free-side {
    flex: none;
    overflow: visible;
    padding: 0;
    border: 0;
    background: none;
    gap: 8px;
  }
  .fs-block {
    gap: 6px;
  }
  .fs-block > .eyebrow,
  .fs-tone .callout {
    display: none;
  }
  .pick-btn,
  .pick-lock {
    min-height: 44px;
  }
  .pick-note {
    font-size: 28px;
  }
  .free-kb .cv-keys {
    height: auto;
  }
  .fs-tone {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 8px;
  }
  .ft-row {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 8px;
  }
  .fs-tone .tone-btn {
    flex: 1.15 1 0;
    min-width: 0;
    min-height: 56px;
    padding: 0 12px;
    gap: 10px;
  }
  .fs-tone .tone-btn b {
    font-size: 18px;
  }
  .fs-tone .tone-modes {
    flex: 1 1 0;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
  .fs-tone .opt {
    min-height: 44px;
    padding: 0 10px;
  }
  .fs-tone .opt.opt[aria-pressed="true"] {
    padding: 0 9.5px;
  }
  .ft-read .note-md {
    font-size: 24px;
  }
  .ft-read .tc-hz {
    font-size: 12.5px;
  }
  .ft-vol {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .ft-vol input {
    flex: 1 1 0;
    min-width: 0;
  }
  .fs-resp {
    margin-top: 0;
  }
  #screen-free .sc-head {
    flex-wrap: nowrap;
    gap: 8px;
  }
  #screen-free .sc-head .sp {
    flex: 1 1 0;
    min-width: 0;
  }
  #screen-free .sc-brand {
    font-size: 17px;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }
  #screen-free .sc-head .hbtn {
    flex: none;
    white-space: nowrap;
    padding: 0 12px;
  }
  #free-back {
    font-size: 0;
    gap: 0;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }
  .free-note-row .step-detail {
    -webkit-line-clamp: 1;
  }
  .free-spec {
    flex: 1 1 0;
    min-height: 64px;
    height: auto;
    margin: 0;
    padding-top: 6px;
  }
}

@media (min-width: 900px) and (max-height: 820px) {
  .fs-tone .callout {
    display: none;
  }
  .free-side {
    gap: 10px;
    padding: 12px 18px;
  }
}

/* Spectrum on phones is a setting (off by default); unison steps keep it for the beat meter. */
.mobile-only {
  display: none;
}
@media (max-width: 899.98px) {
  .gbtn.mobile-only {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #screen-free .fs-resp {
    flex-direction: row;
  }
  #screen-free .fs-resp .gbtn {
    width: auto;
    flex: 1 1 0;
  }
  body:not([data-spec="on"]) #screen-tune:not([data-kind="unison"]) .spec-card,
  body:not([data-spec="on"]) #screen-free .free-spec {
    display: none;
  }
}
