:root {
  color-scheme: dark;
  --forest: #102e29;
  --canvas: #f4f0df;
  --landscape: url("./assets/forest-valley.webp");
  --forest-mid: #20453c;
  --mint: #bbd1bd;
  --brass: #e3ca90;
  --paper: #faf8f2;
  --paper-low: #efeee6;
  --ink: #21382e;
  --muted: #5e6c60;
  --rule: #d9ded3;
  --green: #235241;
  --display: 'Baskervville', Georgia, 'AppleMyungjo', 'Batang', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --hairline: #d9dcd1;
  --ink-soft: #55695c;
  --key-surface: #13233d;
  --keys: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--forest); }
body { color: var(--paper); font: 15px/1.5 var(--sans); }
button, select, input { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { border: 0; padding: 0; background: transparent; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
button, a { -webkit-user-select: none; user-select: none; }
a { color: inherit; }
:where(a, input, select, summary):focus-visible { outline: 2px solid var(--focus, #ffda83); outline-offset: -2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.control-icon, .song-emblem svg, .score-expand svg {
  width: 20px; height: 20px; display: block; flex: none; pointer-events: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.icon-button, .song-play, .full-play {
  display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px;
  border-radius: 8px; text-decoration: none; font: 18px/1 var(--sans);
}
.icon-button .control-icon { width: 19px; height: 19px; }
.icon-button { border-radius: 50%; }

/* The stage uses the logical viewport, including a portrait-locked phone held sideways. */
.play-app { height: 100vh; height: 100dvh; overflow: hidden; }
.play-surface {
  --gutter: clamp(18px, 3.5vw, 60px);
  --header-height: calc(72px + env(safe-area-inset-top));
  position: fixed; top: 50%; left: 50%; width: var(--play-width, 100vw); height: var(--play-height, 100dvh);
  transform: translate(-50%, -50%) rotate(var(--play-angle, 0deg)); container: stage / size;
  background: var(--forest); overflow: hidden;
}
.play-header {
  position: absolute; inset: 0 0 auto; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: max(4px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 4px max(var(--gutter), env(safe-area-inset-left));
  height: var(--header-height); background: var(--forest); border-bottom: 1px solid #395449;
}
.brand-lockup { display: flex; align-items: center; gap: 16px; min-width: 0; margin-right: auto; }
.brand { display: block; width: 76px; height: 60px; object-fit: contain; }
.wordmark { white-space: nowrap; border-left: 1px solid #4e6657; padding-left: 16px; font: italic 24px/1.2 var(--display); letter-spacing: -.035em; color: #f0e6cc; }
.play-header .icon-button { color: var(--mint); }
#menu-button {
  display: inline-flex; justify-content: center; gap: 7px; width: auto;
  min-width: 44px; padding: 0 5px 0 10px; color: #eee9d8; font-size: 14px; font-weight: 500;
}
#menu-button .control-icon { width: 19px; height: 19px; }
.performance, .instrument-stage, .instrument-mount, .simple-scene { position: absolute; inset: 0; }
.performance {
  --score-width: min(34cqw, 470px);
  --split: calc(var(--score-width) + 2 * var(--gutter));
  --dock-space: 0px;
  --shift-left: max(14px, env(safe-area-inset-left));
  --shift-bottom: max(18px, calc(env(safe-area-inset-bottom) + 6px));
  --shift-width: min(172px, calc(50cqw - var(--shift-left) - 4px));
  isolation: isolate; overflow: hidden; touch-action: none;
}
body[data-mode='merch'] .performance, body[data-mode='simple'] .performance { --dock-space: max(64px, 12cqh); }
.instrument-stage { z-index: 2; pointer-events: none; }
.instrument-mount { user-select: none; -webkit-user-select: none; }
.performance::before {
  content: ''; position: absolute; inset: var(--header-height) 0 0; pointer-events: none;
  background:
    radial-gradient(ellipse 270px 135px at var(--shift-left) calc(100% - var(--shift-bottom)), #f4f0df 5%, rgb(244 240 223 / 92%) 50%, transparent),
    var(--canvas) var(--landscape) center bottom / cover no-repeat;
}
.ocarina-scene, .decor-ocarina {
  position: absolute; aspect-ratio: 3 / 2;
  width: min(calc((100cqw - var(--split)) * .94), calc((100cqh - var(--header-height) - var(--dock-space)) * 1.43));
  left: calc((100cqw + var(--split)) / 2); top: calc((100cqh + var(--header-height) - var(--dock-space)) / 2);
  transform: translate(-50%, -50%);
}
.two-touch-scene { container-type: inline-size; }
.ocarina-body { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Leave the entire button playable. Only the inset disc marks the finger position. */
.hole {
  --key-inset: 10%;
  --key-fill: var(--key-surface);
  position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center;
  isolation: isolate; width: 47px; height: 47px; border-radius: 50%;
  color: #f4f1e5; font: 500 16px/1 var(--sans); touch-action: none; pointer-events: auto;
}
.hole::before {
  content: ''; position: absolute; z-index: -1; inset: var(--key-inset);
  border-radius: inherit; background: var(--key-fill); pointer-events: none;
}
.hole.small { width: 33px; height: 33px; }
.hole.closed, .hole.sounding {
  --key-fill: var(--brass); color: var(--forest);
}
.hole.held::before { transform: scale(.91); }
.hole.controller-hole {
  /* The closest finger positions are 13.7% of the instrument width apart. */
  --key-size: min(13.2cqw, 84px);
  --key-inset: 0;
  width: var(--key-size); height: var(--key-size);
  font-size: clamp(17px, 5cqw, 26px); font-weight: 600;
}
.instrument-dock { position: absolute; inset: auto 0 max(12px, env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; gap: 20px; }
.instrument-dock:not(.touch-dock), .simple-scene .quick-notes { left: var(--split); }
.thumb-row, .quick-notes { display: flex; align-items: center; justify-content: center; gap: 8px; }
.thumb-row .hole { position: relative; transform: none; width: 44px; height: 44px; }
.note-key, .custom-keys button {
  position: relative; isolation: isolate; display: grid; place-items: center;
  width: 48px; height: 46px; color: var(--forest); border-radius: 50%; touch-action: none; pointer-events: auto;
}
.note-key::before, .custom-keys button::before {
  content: ''; position: absolute; z-index: -1; inset: 4px; border-radius: inherit;
  background: #e0e5d8;
}
.note-key strong, .custom-keys button { font: 550 15px/1 var(--sans); }
.note-key.sounding, .custom-keys button:active { color: var(--paper); }
.note-key.sounding::before, .custom-keys button:active::before { background: var(--green); }
.simple-scene .quick-notes { position: absolute; inset: auto 0 max(12px, env(safe-area-inset-bottom)) var(--split); }
.shift-rail, .touch-dock { left: var(--shift-left); width: var(--shift-width); }
.shift-rail {
  --scale-line: #788773;
  --scale-ink: #374d40;
  --scale-active: var(--forest);
  position: absolute; bottom: var(--shift-bottom);
  display: flex; pointer-events: auto; touch-action: none;
}
.shift-rail::before {
  content: ''; position: absolute; top: 10px; inset-inline: calc(100% / 14);
  height: 1px; background: var(--scale-line); pointer-events: none;
}
.shift-label {
  position: absolute; bottom: calc(100% + 3px); left: 0;
  font-size: 12px; font-weight: 550; color: var(--scale-ink);
}
.shift-rail button {
  position: relative; flex: 1; height: 44px; min-width: 0; padding-top: 16px; border-radius: 6px;
  color: var(--scale-ink); font: 500 13px/1 var(--keys); touch-action: none;
}
.shift-rail button::before {
  content: ''; position: absolute; top: 7px; left: 50%; width: 1px; height: 7px;
  transform: translateX(-50%); background: var(--scale-line);
}
.shift-rail button.active { color: var(--scale-active); font-weight: 700; }
.shift-rail button.active::before {
  top: 6.5px; width: 8px; height: 8px; border-radius: 50%; background: var(--scale-active);
}
.touch-dock { right: auto; bottom: calc(var(--shift-bottom) + 47px); justify-content: flex-end; }
#live-pitch { color: var(--green); font: 600 12px/1.5 var(--sans); }
#live-pitch:empty { visibility: hidden; }

.selected-score {
  position: absolute; z-index: 1; top: max(17cqh, calc(var(--header-height) + 14px));
  left: max(var(--gutter), env(safe-area-inset-left)); width: var(--score-width);
  display: grid; gap: 18px;
}
.selected-score::before {
  content: ''; position: absolute; z-index: -1; inset: -14px -18px;
  border-radius: 10px; background: var(--forest); pointer-events: none;
}
.performance[data-free='true'] .selected-score { display: none; }
.selected-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.selected-heading h1, .modal-header h2 { margin: 0; font: 600 clamp(23px, 2.35cqw, 38px)/1.24 var(--display); letter-spacing: -.045em; overflow-wrap: anywhere; }
.selected-heading .icon-button { color: #b8c7b9; }
.selected-heading .icon-button .control-icon { width: 17px; height: 17px; }
.score-link { position: relative; order: 1; width: 100%; overflow: hidden; border-radius: 6px; background: #eee9d8; }
.score-viewer { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; width: 100%; aspect-ratio: 1912 / 874; }
.score-viewer img { display: block; min-height: 0; min-width: 0; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; filter: grayscale(1) contrast(1.08); }
.score-expand { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: var(--paper); color: var(--ink); }
.score-expand svg { width: 15px; height: 15px; }
.score-error { color: var(--muted); font-size: 13px; padding: 8px; }
.score-controls { order: 2; display: grid; gap: 16px; }
.selected-actions { border-top: 1px solid #466053; padding-top: 12px; }
.selected-score .practice-sequence { column-gap: 5px; }
.selected-score .practice-sequence::before { content: attr(aria-label); margin-right: 6px; font-size: 12px; color: var(--mint); }
.selected-actions, .practice-tools { display: flex; align-items: center; gap: 4px; }
#practice-play, #practice-full, .song-actions button {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; width: auto; padding: 0 12px; border-radius: 30px; white-space: nowrap;
  font: 550 13px/1 var(--sans);
}
#practice-play { color: #25372b; padding-inline: 15px; }
#practice-play::before, #practice-full::before, .song-actions button::before {
  content: ''; position: absolute; z-index: -1; inset: 5px 0; border-radius: inherit;
}
#practice-play::before { background: var(--brass); }
#practice-full { color: #ede4ca; }
#practice-full.is-playing::before { background: var(--forest-mid); }
#practice-play .control-icon, .song-play .control-icon { width: 13px; height: 13px; }
#practice-full .control-icon, .full-play .control-icon { width: 17px; height: 17px; }
#practice-reset { margin-left: auto; color: var(--mint); }

.practice-sequence, .mini-notes { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.practice-step { display: grid; justify-items: center; gap: 4px; }
.practice-step small { color: var(--muted); font-size: 10px; }
.selected-score .practice-step small { display: none; }
.mini-note {
  position: relative; display: inline-grid; place-items: center; min-width: 19px; height: 24px;
  border-radius: 50%; color: var(--ink-soft); font: 500 13px/1 var(--keys);
}
.mini-notes > .mini-note + .mini-note::before,
.practice-step + .practice-step .mini-note::before {
  content: ''; position: absolute; left: -3px; top: calc(50% - 1px); width: 2px; height: 2px;
  border-radius: 50%; background: currentColor; opacity: .35;
}
.mini-note.high { color: #835d29; }
.selected-score .mini-note {
  min-width: clamp(23px, 2.2cqw, 31px); height: clamp(23px, 2.2cqw, 31px); color: #e3e8db;
}
.selected-score .mini-note.high { color: var(--brass); }
.practice-step.done .mini-note { color: #dbe9cd; background: #365745; }
.practice-step.current .mini-note, .mini-note.current { color: var(--forest); background: var(--brass); }
.song-card .mini-note.current { color: white; background: var(--green); }

@container stage (orientation: portrait) {
  .play-header { --header-height: calc(60px + env(safe-area-inset-top)); gap: 2px; }
  .brand-lockup { gap: 10px; }
  .brand { width: 52px; height: 46px; }
  .wordmark { font-size: 20px; padding-left: 10px; }
  #menu-button { padding: 0 11px; }
  .performance {
    top: calc(60px + env(safe-area-inset-top)); container-type: size;
    --header-height: 0px; --instrument-top: 148px;
  }
  .selected-score {
    top: 9px; left: 50%; transform: translateX(-50%); width: min(calc(100cqw - 2 * var(--gutter)), 540px);
    gap: 5px 14px; grid-template-columns: minmax(0,1fr) minmax(90px, 34%);
  }
  .selected-score::before { inset: -9px calc(50% - 50cqw) -12px; border-radius: 0; }
  .selected-heading { grid-column: 1 / -1; }
  .score-controls { grid-column: 1; grid-row: 2; }
  .score-link { grid-column: 2; grid-row: 2; align-self: center; }
  .selected-actions { border: none; padding: 0; }
  #practice-play, #practice-full { padding-inline: 9px; }
  .selected-score .practice-sequence { gap: 3px; }
  .selected-score .practice-sequence::before { display: none; }
  .selected-actions .icon-button { height: 44px; }
  #practice-reset { margin-left: 0; }
  .score-expand { width: 20px; height: 20px; top: 3px; right: 3px; }
  .score-expand svg { width: 12px; height: 12px; }
  .instrument-mount { --dock-space: max(96px, calc(env(safe-area-inset-bottom) + 72px)); }
  .instrument-dock:not(.touch-dock), .simple-scene .quick-notes { left: 0; }
  .selected-heading h1 { font-size: 25px; }
  .score-viewer { height: auto; }
  .score-controls { gap: 8px; }
  .ocarina-scene, .decor-ocarina {
    width: min(96cqw, calc((100cqh - var(--instrument-top) - var(--dock-space)) * 1.5)); height: auto;
    inset: calc((100cqh + var(--instrument-top) - var(--dock-space)) / 2) auto auto 50%;
  }
  .hole { width: 38px; height: 38px; }
  .hole.small { width: 28px; height: 28px; }
  .instrument-dock:not(.touch-dock) { flex-wrap: wrap; gap: 6px 12px; }
  .thumb-row { width: 100%; }
}
@container stage (orientation: portrait) and (max-width: 440px) {
  .selected-score { grid-template-columns: minmax(0,1fr) 31%; }
  .selected-score .mini-note { min-width: 22px; height: 22px; }
}
@container stage (orientation: portrait) and (min-height: 740px) {
  .performance { --instrument-top: calc(min(19cqh, 247px) + 144px); }
  .selected-score { grid-template-columns: 1fr; gap: 8px; }
  .score-link { grid-area: auto; }
  .score-viewer { max-height: 19cqh; }
  .score-controls { grid-area: auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
}
@container stage (max-width: 360px) {
  .brand-lockup { gap: 6px; }
  .wordmark { font-size: 17px; padding-left: 7px; }
  .brand { width: 40px; }
  .selected-score .mini-note { min-width: 20px; height: 20px; }
}
@container stage (orientation: landscape) and (max-height: 550px) {
  .play-header, .performance { --header-height: max(48px, calc(40px + env(safe-area-inset-top))); }
  .performance { --score-width: min(36cqw, 460px); --shift-bottom: max(5px, env(safe-area-inset-bottom)); }
  .brand { width: 44px; height: 40px; }
  .brand-lockup { gap: 10px; }
  .wordmark { font-size: 18px; padding-left: 10px; }
  .selected-score { top: max(52px, calc(46px + env(safe-area-inset-top))); gap: 5px; }
  .selected-score::before { inset: -4px calc(-1 * var(--gutter)) -4px; border-radius: 0 0 10px 0; }
  .selected-heading h1 { font-size: 22px; }
  .score-viewer { height: min(25cqh, 112px); aspect-ratio: auto; }
  .score-controls { gap: 3px; }
  .selected-actions { padding: 0; border: 0; }
  .selected-score .practice-sequence::before { display: none; }
  .selected-score .mini-note { min-width: 21px; height: 21px; font-size: 12px; }
  .selected-actions { gap: 4px; }
  .selected-actions .icon-button { width: 38px; height: 36px; }
  .instrument-dock:not(.touch-dock), .simple-scene .quick-notes { bottom: max(4px, env(safe-area-inset-bottom)); }
}

/* The songbook stays upright relative to the same logical canvas as the instrument. */
dialog {
  --focus: #846129;
  color-scheme: light; position: fixed; inset: auto; left: 50%; top: 50%; margin: 0; padding: 0;
  transform: translate(-50%, -50%) rotate(var(--play-angle, 0deg)); max-width: calc(var(--play-width, 100vw) - 20px);
  max-height: calc(var(--play-height, 100dvh) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  color: var(--ink); background: var(--paper); border: 0; border-radius: 14px;
  overscroll-behavior: contain;
}
dialog::backdrop { background: rgb(5 21 17 / 77%); }
.menu-dialog {
  --inset: 24px;
  width: min(660px, calc(var(--play-width) - 20px)); height: min(780px, calc(var(--play-height) - 40px));
  container: songbook / size; overflow: hidden;
}
.menu-dialog[open] { display: grid; grid-template: auto auto minmax(0, 1fr) / minmax(0, 1fr); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px 12px 22px; }
.modal-header h2 { font-size: 24px; }
.modal-header .icon-button { font-size: 15px; }
.close-dialog { color: var(--forest); }
.close-dialog .control-icon { width: 22px; height: 22px; stroke-width: 1.8; }
.modal-header h2:focus { outline: none; }
.menu-heading {
  position: relative; isolation: isolate; overflow: hidden; min-height: 84px; padding: 12px var(--inset);
  color: var(--forest); background: var(--canvas); border-bottom: 1px solid var(--hairline);
}
.menu-heading::before {
  content: ''; position: absolute; z-index: -1; inset: 0 0 0 34%;
  background: var(--landscape) right 79% / cover no-repeat;
  mask-image: linear-gradient(to right, transparent, black 23%, black calc(100% - 64px), transparent calc(100% - 12px)); opacity: .72;
}
.menu-heading-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-heading-title .control-icon { width: 36px; height: 36px; stroke-width: 1.4; color: var(--green); }
.menu-heading h2 { font-size: 32px; line-height: 1.2; }
.menu-tabs {
  flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 var(--inset); border-bottom: 1px solid var(--rule);
}
.menu-tabs button {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 51px; color: var(--muted); font-size: 13px; font-weight: 500;
}
.menu-tabs button[aria-pressed='true'] { color: var(--green); font-weight: 650; }
.menu-tabs button[aria-pressed='true']::after { content: ''; position: absolute; inset: auto 30% -1px; height: 2px; background: var(--green); }
.menu-tabs .control-icon { width: 17px; height: 17px; }
.menu-panel { flex: 1; min-height: 0; padding: 20px var(--inset) 24px; overflow: auto; overscroll-behavior: contain; scrollbar-color: #b4c0af transparent; scrollbar-width: thin; }
.library-search, .library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.search-wrap { position: relative; flex: 1; min-width: 0; }
.search-wrap .control-icon { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); width: 18px; height: 18px; pointer-events: none; color: var(--muted); }
.search-wrap input {
  width: 100%; min-height: 44px; padding: 8px 14px 8px 39px;
  border: 1px solid transparent; border-radius: 24px; color: var(--ink); background: var(--paper-low);
  font-size: 16px;
}
.search-wrap input:focus-visible { border-color: #6c8574; outline: 1px solid #6c8574; outline-offset: -1px; }
.search-wrap input::placeholder { color: #647064; opacity: 1; }
.text-button {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  padding: 0 4px 0 8px; border-radius: 6px; color: var(--green); font-size: 13px; font-weight: 550;
}
.text-button .control-icon { width: 17px; height: 17px; }
.library-toolbar { margin: 8px 0 0; }
.filters { display: flex; align-items: center; gap: 12px; }
.filters button {
  position: relative; min-height: 44px; min-width: 44px; padding-inline: 2px;
  font-size: 14px; font-weight: 450; color: var(--muted);
}
.filters button[aria-pressed='true'] { color: var(--green); font-weight: 650; }
.filters button[aria-pressed='true']::after {
  content: ''; position: absolute; inset: auto 6px -1px; height: 2px; background: currentColor;
}
.song-count { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.song-list { border-top: 1px solid var(--hairline); }
.song-card {
  --symbol-size: 27px;
  --song-gap: 12px;
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 0 6px; padding: 16px 0 8px;
}
.song-card::after {
  content: ''; position: absolute; inset: auto 0 0 calc(var(--symbol-size) + var(--song-gap));
  height: 1px; background: var(--hairline); pointer-events: none;
}
.song-open {
  grid-column: 1 / -1; display: grid; grid-template-columns: var(--symbol-size) minmax(0, 1fr);
  align-items: start; gap: var(--song-gap); text-align: start;
}
.song-open::after { content: ''; position: absolute; inset: 0; }
.song-emblem {
  display: grid; place-items: center; width: var(--symbol-size); height: 28px;
  color: color-mix(in srgb, var(--song-color) 43%, #2a332c);
}
.song-emblem svg { width: 23px; height: 23px; stroke-width: 1.45; }
.song-info { display: block; min-width: 0; }
.song-name { display: block; font: 600 20px/1.35 var(--display); letter-spacing: -.035em; }
.song-name .control-icon { display: inline-block; width: 15px; height: 15px; margin-inline-start: 7px; color: var(--green); stroke-width: 2; vertical-align: middle; }
.song-effect { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
:lang(ko) .song-effect, :lang(ko) .guide-intro, :lang(ko) .install-steps { word-break: keep-all; }
.song-card > .mini-notes { pointer-events: none; margin-inline-start: calc(var(--symbol-size) + var(--song-gap)); gap: 4px; }
.song-actions { position: relative; z-index: 1; display: flex; align-items: center; }
.song-actions button + button::after {
  content: ''; position: absolute; left: 0; top: calc(50% - 6px); height: 12px; width: 1px; background: var(--hairline); pointer-events: none;
}
.song-actions button { min-width: 58px; padding-inline: 8px; height: 44px; color: var(--green); font-size: 13px; }
.song-actions button.is-playing { color: #fff; }
.song-actions button.is-playing::before { background: var(--green); }
.song-card.is-playing .song-name { color: var(--green); }
.scarecrow-card {
  width: 100%; min-height: 55px; display: flex; align-items: center; gap: 12px; margin-top: 10px;
  padding: 8px 0; color: var(--green); text-align: start;
}
.scarecrow-card strong { flex: 1; font: 600 18px var(--display); }
.scarecrow-card > .control-icon:last-child { width: 17px; margin-inline-end: 8px; }
.empty-results { margin: 18px 0; padding: 20px 10px; color: var(--muted); text-align: center; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px; margin: 0 0 18px; }
.setting-row > span { color: var(--ink-soft); font-size: 13px; font-weight: 550; }
.setting-row select, .setting-row input { grid-column: 1 / -1; }
.setting-row select {
  width: 100%; min-height: 44px; appearance: none; padding: 6px 28px 6px 0;
  border: 0; border-bottom: 1px solid #bbc5b9; border-radius: 0; color: var(--ink);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2355695c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 6 4.5 4.5L12.5 6'/%3E%3C/svg%3E") right 6px center / 16px no-repeat;
  font-size: 16px;
}
.setting-row input[type='range'] { width: 100%; height: 44px; appearance: none; margin: 0; background: transparent; cursor: pointer; accent-color: var(--green); }
.setting-row input[type='range']::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--green) var(--range-fill), #c5cfc2 var(--range-fill)); }
.setting-row input[type='range']::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--green); }
.setting-row input[type='range']::-moz-range-track { height: 3px; border-radius: 2px; background: #c5cfc2; }
.setting-row input[type='range']::-webkit-slider-thumb { width: 17px; height: 17px; margin-top: -7px; appearance: none; border-radius: 50%; background: var(--green); }
.setting-row input[type='range']::-moz-range-thumb { width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--green); }
.setting-row output { color: var(--green); font: 500 13px var(--keys); }
.input-hint, .touch-capability { color: var(--muted); font-size: 13px; margin: 4px 0; }
.touch-capability { margin-bottom: 20px; }
.checkbox-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; cursor: pointer; }
.checkbox-row input {
  position: relative; order: 1; appearance: none; width: 36px; height: 22px; margin: 0;
  border-radius: 22px; background: #aab5aa; cursor: pointer;
}
.checkbox-row input::before { content: ''; position: absolute; inset: 3px auto 3px 3px; width: 16px; border-radius: 50%; background: white; }
.checkbox-row input:checked { background: var(--green); }
.checkbox-row input:checked::before { transform: translateX(14px); }
.guide-panel h3 { font-size: 18px; margin: 0 0 8px; }
.guide-intro, .guide-legend, .source-copy { color: var(--muted); font-size: 14px; line-height: 1.7; }
.guide-intro, .source-copy p { margin: 0 0 14px; }
.guide-legend { color: var(--green); font-size: 12px; }
.scale-scroll { overflow-x: auto; }
.scale-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.scale-table th, .scale-table td { padding: 6px; text-align: start; border-bottom: 1px solid var(--rule); }
.scale-table thead { background: var(--paper-low); }
.scale-table b { color: var(--green); }
.scale-table .icon-button, .setting-row .icon-button, .practice-tools .icon-button { color: var(--green); }
.scale-table .icon-button .control-icon, #custom-play .control-icon { width: 15px; height: 15px; }
.scale-table .icon-button { font-size: 13px; }
.fingering-diagram { display: block; width: 96px; height: 57px; }
.extra-scale { margin-top: 16px; }
.extra-scale summary { padding: 10px 0; color: var(--green); cursor: pointer; font-weight: 600; }
.source-copy a { display: block; padding: 10px 0; border-top: 1px solid var(--rule); color: var(--green); font-weight: 600; text-decoration: none; }
.small-dialog { width: 440px; padding: 0 20px 20px; }
.small-dialog .modal-header { padding: 12px 0; margin-bottom: 14px; border-bottom: 1px solid var(--rule); }
.install-steps { margin: 0; padding-inline-start: 21px; color: var(--muted); line-height: 1.7; }
.install-steps li { padding-inline-start: 3px; }
.install-steps li + li { margin-top: 8px; }
.install-steps li::marker { color: var(--green); font-weight: 700; }
.small-dialog .practice-sequence { justify-content: center; flex-wrap: nowrap; gap: 5px; }
.small-dialog .mini-note { min-width: 24px; height: 30px; }
.custom-keys, .practice-tools { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
#custom-sequence .mini-note { border-bottom: 1px solid #b7c5b6; border-radius: 0; }
#custom-sequence .mini-note::before { display: none; }
.score-dialog { width: min(1200px, calc(var(--play-width) - 20px)); }
.score-dialog h2 { margin-right: auto; }
.expanded-score { padding: 0 14px 14px; overflow: auto; }
.expanded-score img { display: block; width: 100%; height: auto; }
.toast { position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 20; width: max-content; max-width: calc(100% - 24px); padding: 10px 16px; border-radius: 7px; background: var(--brass); color: var(--forest); font-size: 13px; text-align: center; visibility: hidden; pointer-events: none; }
.toast.visible { visibility: visible; }
body[data-rotated='true'] .toast { max-width: calc(var(--play-width) - 30px); top: 50%; bottom: auto; transform: translate(-50%, -50%) rotate(var(--play-angle)); }

@container (max-width: 490px) {
  .menu-heading, .menu-panel { --inset: 16px; }
  .menu-heading { min-height: 66px; padding-block: 10px; }
  .menu-heading h2 { font-size: 24px; }
  .menu-heading-title .control-icon { width: 30px; height: 30px; }
  .menu-tabs { padding: 0 6px; }
  .menu-tabs button { gap: 5px; font-size: 12px; }
  .menu-panel { padding-top: 15px; }
  .song-card { --symbol-size: 25px; --song-gap: 10px; padding: 14px 0 6px; }
  .song-name { font-size: 19px; }
  .song-card > .mini-notes { gap: 3px; }
  .song-card .mini-note { min-width: 17px; height: 22px; }
  .song-actions button { min-width: 48px; padding-inline: 4px; gap: 4px; }
}
@container (max-width: 340px) {
  .menu-panel { --inset: 14px; }
  .menu-tabs button { flex-direction: column; gap: 1px; }
  .song-card { --symbol-size: 21px; --song-gap: 7px; }
  .song-card > .mini-notes { margin-inline-start: 0; }
}
@media (max-width: 600px) {
  body[data-layout='portrait'] .menu-dialog {
    --inset: 20px; top: auto; bottom: 0; transform: translateX(-50%);
    width: 100%; max-width: 100%; height: min(860px, calc(100dvh - max(18px, env(safe-area-inset-top))));
    max-height: none; border-radius: 18px 18px 0 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  body[data-layout='portrait'] .menu-dialog .menu-panel { grid-area: 2 / 1; }
  body[data-layout='portrait'] .menu-tabs { grid-area: 3 / 1; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--rule); border-bottom: 0; background: var(--paper); }
  body[data-layout='portrait'] .menu-tabs button { flex-direction: column; gap: 4px; min-height: 58px; font-size: 12px; }
  body[data-layout='portrait'] .menu-tabs .control-icon { width: 20px; height: 20px; }
  body[data-layout='portrait'] .menu-tabs button[aria-pressed='true']::after { display: none; }
  body[data-layout='portrait'] .menu-tabs button[aria-pressed='true'] .control-icon { stroke-width: 2; }
  body[data-layout='portrait'] .menu-tabs button[aria-pressed='true'] span { position: relative; }
  body[data-layout='portrait'] .menu-tabs button[aria-pressed='true'] span::before { content: ''; position: absolute; top: calc(50% - 2px); left: -8px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
}
/* A short landscape phone has space for navigation and search on two lines. */
@container songbook (max-height: 450px) and (min-width: 480px) {
  .menu-heading, .menu-tabs { grid-area: 1 / 1; }
  .menu-heading { min-height: 52px; padding: 4px 12px; background: var(--forest); }
  .menu-heading::before { display: none; }
  .menu-heading-title { padding-left: 3px; }
  .menu-heading-title .control-icon { width: 28px; height: 28px; color: var(--brass); }
  .menu-heading .close-dialog { color: var(--paper); }
  .menu-heading h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .menu-tabs { z-index: 1; margin: 0 64px; padding: 0; border: 0; }
  .menu-tabs button { color: #c6d7c8; min-height: 44px; }
  .menu-tabs button[aria-pressed='true'] { color: white; }
  .menu-tabs button[aria-pressed='true']::after { background: var(--brass); bottom: 0; }
  .menu-panel { grid-area: 2 / 1 / 4; padding: 10px 16px; }
  .menu-panel[data-panel='songs'] {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px;
    align-content: start; align-items: center;
  }
  .library-search, .library-toolbar { display: contents; }
  .search-wrap { grid-area: 1 / 1; }
  .filters { grid-area: 1 / 2; gap: 0; }
  .filters button { padding-inline: 6px; }
  .song-count { grid-area: 1 / 3; }
  #free-play { grid-area: 1 / 4; }
  .song-list, .empty-results, .scarecrow-card { grid-column: 1 / -1; }
  .song-card { padding-block: 10px; }
}
@media (hover: hover) {
  #menu-button:hover, .play-header .icon-button:hover, #practice-reset:hover { color: white; }
  #practice-play:hover::before { background: #f1dca8; }
  #practice-full:hover::before { background: var(--forest-mid); }
  .song-open:hover .song-name { color: var(--green); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
  .song-actions button:not(.is-playing):hover::before, dialog .icon-button:not(.close-dialog):hover { background: #e7ece0; }
  .filters button:hover, .text-button:hover, .source-copy a:hover, .scarecrow-card:hover { text-decoration: underline; text-underline-offset: 4px; }
}
:where(.text-button, .close-dialog, .song-actions button, .selected-actions button, .menu-tabs button, #menu-button):active { opacity: .72; }
button:focus-visible {
  outline: none; background-color: #c9decf; color: var(--forest);
}
.hole:focus-visible::before, .note-key:focus-visible::before, .custom-keys button:focus-visible::before,
#practice-play:focus-visible::before, #practice-full:focus-visible::before,
.score-link:focus-visible .score-expand { background: #c9decf; color: var(--forest); }
.hole:focus-visible, .selected-score .icon-button:focus-visible, #practice-full:focus-visible,
#practice-reset:focus-visible, .play-header .icon-button:focus-visible, #menu-button:focus-visible,
.menu-tabs button:focus-visible, .menu-heading .close-dialog:focus-visible { color: var(--forest); }
@media (forced-colors: active) {
  button:focus-visible { outline: 2px solid Highlight; outline-offset: -2px; }
  .shift-rail button.active, .mini-note.current, .checkbox-row input:checked { outline: 2px solid Highlight; }
  .checkbox-row input { appearance: auto; }
  .checkbox-row input::before { display: none; }
  .setting-row input[type='range'] { appearance: auto; }
}
