/* app.css: layouts and components. Every colour, font, size, radius, shadow and
   timing comes from tokens.css. The only literals are small component geometry
   (icon sizes) and #000 inside mask-image, which is an alpha mask, not a colour.
   A reskin never touches this file. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
a:active, button:active { opacity: 0.65; }
button { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--color-text-3); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--color-surface-2); padding: 1px 6px; border-radius: var(--radius-sm); }

/* ================================================================ chrome */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) max(var(--space-2), var(--safe-right)) 0 max(var(--space-2), var(--safe-left));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: var(--color-bar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: var(--border-width) solid var(--color-border);
}
.topbar__side { display: flex; align-items: center; }
.topbar__side--end { justify-content: flex-end; }
.topbar__title {
  font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-md);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw;
  opacity: 0; transition: opacity var(--dur-med) var(--ease);
}
.is-scrolled .topbar__title { opacity: 1; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: var(--radius-pill);
  cursor: pointer; color: var(--color-text); padding: 0;
}
.icon-btn svg { width: 23px; height: 23px; }
.icon-btn[aria-pressed="true"] { color: var(--color-accent); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.icon-btn--soft { background: var(--color-accent-soft); color: var(--color-accent); }
.icon-btn--soft svg { width: 16px; height: 16px; fill: currentColor; }

.view { padding-top: calc(var(--topbar-h) + var(--safe-top)); }
.page { max-width: var(--content-width); margin: 0 auto; padding: 0 max(var(--space-5), var(--safe-left)); }
.page:last-child { padding-bottom: var(--space-8); }

/* ---------------------------------------------------------------- Tabs layout */
[data-layout="tabs"] .view { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--color-bar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-top: var(--border-width) solid var(--color-border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--text-2xs); color: var(--color-text-3); }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.is-on { color: var(--color-accent); }
.groupbar {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-top)); z-index: 20;
  background: var(--color-bar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  padding: var(--space-2) max(var(--space-5), var(--safe-left)) var(--space-3);
  margin-bottom: var(--space-5);
}
.groupbar__seg { display: flex; max-width: calc(var(--content-width) - 2 * var(--space-5)); margin: 0 auto; padding: 3px; gap: 2px; background: var(--color-surface-2); border-radius: var(--radius-md); }
.groupbar__seg button { flex: 1; border: 0; background: transparent; height: 36px; border-radius: calc(var(--radius-md) - 3px); font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text-2); cursor: pointer; }
.groupbar__seg button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }


/* ---------------------------------------------------------------- Cards layout */
.deck { position: fixed; inset: 0; overflow: hidden; background: var(--color-surface-3); }
.deck-card {
  position: absolute; left: 0; right: 0; bottom: 0;
  top: calc(var(--safe-top) + var(--card-top, 0px));
  background: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-2);
  transform: scale(calc(1 - var(--card-depth, 0) * 0.035));
  transform-origin: top center;
  transition: transform var(--dur-med) var(--ease), top var(--dur-med) var(--ease);
  overflow: hidden;
}
.deck-card:first-child { border-radius: 0; top: 0; padding-top: var(--safe-top); }
.deck-card:first-child .deck-card__body { top: calc(var(--topbar-h) + var(--safe-top)); }
.deck-card.is-entering, .deck-card.is-leaving { transform: translateY(100%); }
.deck-card.is-hidden { display: none; }
.deck-card.is-under::after { content: ""; position: absolute; inset: 0; background: var(--color-text); opacity: 0.04; pointer-events: none; }
.deck-card.is-under .deck-card__body { pointer-events: none; }
.deck-card__head {
  position: relative; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-1);
  padding: 0 var(--space-2);
  border-bottom: var(--border-width) solid var(--color-border);
  cursor: pointer;
}
.deck-card__grab { position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--color-surface-3); }
.deck-card__title { flex: 1; min-width: 0; padding-left: var(--space-2); font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-card.is-under .deck-card__head { align-items: flex-start; padding-top: 6px; }
.deck-card.is-under .deck-card__head .icon-btn { visibility: hidden; }
.deck-card__body {
  position: absolute; left: 0; right: 0; bottom: 0; top: var(--topbar-h);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding-bottom: var(--safe-bottom);
}

/* ================================================================ page parts */
.hero { padding: var(--space-6) 0 var(--space-5); }
.hero--compact { padding-bottom: var(--space-3); }
.eyebrow {
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: var(--color-text-3);
}
.eyebrow a { color: var(--color-accent); }
h1 {
  font-family: var(--font-display); font-weight: var(--weight-display);
  font-size: var(--h1-size); line-height: 1.08; letter-spacing: var(--tracking-tight);
  margin: var(--space-2) 0 var(--space-2);
}
.hero__sub { color: var(--color-text-2); margin: 0; }
.hero__sub a { color: var(--color-text); }
.hero__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-4); }

/* Inline links in running text get a taller invisible hit area: finger-sized
   without changing the line spacing. */
.hero__sub a, .note-line a, .row__meta a, .prose a {
  padding: 10px 0; margin: -10px 0;
  text-decoration: underline; text-decoration-color: var(--color-border); text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.row__meta a { text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--tap); padding: 0 var(--space-5);
  border-radius: var(--radius-pill); border: var(--border-width) solid var(--color-border);
  background: transparent; color: var(--color-text);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer; transition: transform var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); border-color: var(--btn-primary-bg); }
.btn svg { width: 15px; height: 15px; fill: currentColor; }

.switcher {
  display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none;
  margin: var(--space-5) calc(-1 * var(--space-5)) 0; padding: 2px var(--space-5);
}
.switcher::-webkit-scrollbar { display: none; }
.switcher a {
  flex: none; min-width: var(--tap); height: var(--tap); padding: 0 var(--space-2);
  display: inline-grid; place-items: center;
  border-radius: var(--radius-pill); font-size: var(--text-sm);
  color: var(--color-text-2);
}
.switcher a.is-current { background: var(--color-text); color: var(--color-bg); font-weight: var(--weight-medium); }

/* sections: boxed cards or hairline rules, chosen by the skin */
.card {
  background: var(--card-bg);
  border: var(--card-border-width) solid var(--card-border-color);
  border-top: var(--card-rule);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: calc(var(--card-pad) + var(--card-rule-pad)) var(--card-pad) var(--card-pad);
  margin: 0 0 var(--card-gap);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
h2 {
  font-family: var(--font-display); font-weight: var(--weight-display);
  font-size: var(--h2-size); letter-spacing: var(--tracking-tight); line-height: 1.2; margin: 0;
}
h3 {
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
  color: var(--color-text-3); margin: var(--space-5) 0 var(--space-2);
}
h3:first-child { margin-top: 0; }
.note-line { color: var(--color-text-2); font-size: var(--text-sm); margin: 0 0 var(--space-4); }
.note-line a, .prose a { color: var(--color-text); }
.count { font-family: var(--font-sans); font-size: var(--text-xs); color: var(--color-text-3); font-weight: var(--weight-regular); }
/* Sections off screen skip layout and paint until scrolled to: most of a long page is
   below the fold, and laying it all out was the bulk of each tap on a phone. */
.card { content-visibility: auto; contain-intrinsic-size: auto 480px; }
details.card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--tap); }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: ""; width: 9px; height: 9px; flex: none;
  border-right: 2px solid var(--color-text-3); border-bottom: 2px solid var(--color-text-3);
  transform: rotate(45deg) translateY(-3px); transition: transform var(--dur-med) var(--ease);
}
details.card[open] > summary::after { transform: rotate(225deg) translate(-2px, 0); }
details.card[open] > summary { margin-bottom: var(--space-4); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: var(--chip-height); padding: 0 var(--space-4);
  border-radius: var(--chip-radius);
  background: var(--chip-bg); color: var(--color-text);
  border: var(--border-width) solid var(--chip-border);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease);
}
.chip:active { transform: scale(0.96); }
.chip--root { background: var(--color-root); border-color: var(--color-root); color: var(--color-root-text); }
.chip--char { background: var(--color-char); border-color: var(--color-char); color: var(--color-char-text); }
.chip--ghost { background: transparent; border-color: var(--color-border); color: var(--color-text-2); }
.chip--rare { color: var(--color-text-2); }
.chip small { font-weight: var(--weight-regular); opacity: 0.7; font-size: var(--text-2xs); }

/* notes, drawn by the skin: canvas makes them noteheads */
.notes { display: grid; grid-template-columns: repeat(var(--n, 7), minmax(0, 56px)); gap: var(--space-1); }
.note-cell { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.note-cell .chip.note {
  width: 100%; max-width: var(--note-size); height: auto; aspect-ratio: 1; min-height: 0; padding: 0;
  border-radius: var(--note-radius);
  background: var(--color-tone); color: var(--color-tone-text);
  border: var(--note-line-width) solid var(--color-tone-line);
  font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-display);
}
.note-cell .chip.note.chip--root { background: var(--color-root); color: var(--color-root-text); border-color: var(--color-root); }
.note-cell .chip.note.chip--char { background: var(--color-char); color: var(--color-char-text); border-color: var(--color-char); }
.note-cell .deg {
  min-height: 36px; width: 100%; display: grid; place-items: center;
  font-size: var(--text-xs); color: var(--color-text-2); font-variant-numeric: tabular-nums;
}
.steps { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; align-items: center; }
.step { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-text-2); padding: 2px var(--space-2); border-radius: var(--radius-sm); background: var(--color-surface-2); }
.step--h { color: var(--color-accent); }
.legend { font-size: var(--text-2xs); color: var(--color-text-3); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--color-surface-2); border-radius: var(--radius-pill); }
.seg button {
  border: 0; background: transparent; cursor: pointer;
  height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text-2);
}
.seg button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
[data-seg-pane] { display: none; }
[data-seg-pane].is-shown { display: block; }

/* ---------------------------------------------------------------- instruments */
.inst-tools { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.inst-scroll { overflow-x: auto; scrollbar-width: thin; }
.inst-scroll svg { display: block; width: 100%; height: auto; }
.inst-scroll svg.kb { max-width: 560px; margin: 0 auto; }
.neck-h svg { min-width: 600px; }
.neck-v { display: none; }
.neck-v svg.neck { display: block; width: 100%; max-width: 340px; margin: 0 auto; }
@media (max-width: 600px) and (orientation: portrait) {
  .neck-h { display: none; }
  .neck-v { display: block; }
}
.kb-white { fill: var(--color-key-white); stroke: var(--color-key-line); stroke-width: 1; }
.kb-black { fill: var(--color-key-black); }
.kb-key { cursor: pointer; }
.kb-dot { fill: var(--color-tone); stroke: var(--color-tone-line); stroke-width: var(--note-line-width); }
.kb-dot.is-root { fill: var(--color-root); stroke: var(--color-root); }
.kb-dot.is-char { fill: var(--color-char); stroke: var(--color-char); }
.kb-label { font: var(--weight-bold) 12px var(--font-sans); fill: var(--color-tone-text); text-anchor: middle; pointer-events: none; }
.kb-label.is-root { fill: var(--color-root-text); }
.kb-label.is-char { fill: var(--color-char-text); }
.kb-key.is-playing .kb-white, .kb-key.is-playing .kb-black { fill: var(--color-accent-soft); }
.fb-board { fill: var(--color-fret-board); }
.fb-nut { fill: var(--color-text-2); }
.fb-fret { stroke: var(--color-fret-wire); stroke-width: 2; }
.fb-string { stroke: var(--color-string); }
.fb-inlay { fill: var(--color-inlay); }
.fb-num { font: 11px var(--font-sans); fill: var(--color-text-3); text-anchor: middle; }
.fb-dot { fill: var(--color-tone); stroke: var(--color-tone-line); stroke-width: var(--note-line-width); cursor: pointer; }
.fb-dot.is-root { fill: var(--color-root); stroke: var(--color-root); }
.fb-dot.is-char { fill: var(--color-char); stroke: var(--color-char); }
.fb-label { font: var(--weight-bold) 10.5px var(--font-sans); fill: var(--color-tone-text); text-anchor: middle; pointer-events: none; }
.fb-label.is-root { fill: var(--color-root-text); }
.fb-label.is-char { fill: var(--color-char-text); }
.fb-spot { cursor: pointer; }
.fb-spot.is-playing .fb-dot { stroke: var(--color-accent); stroke-width: 3; }
.inst-legend { display: flex; gap: var(--space-4); margin-top: var(--space-3); font-size: var(--text-xs); color: var(--color-text-2); flex-wrap: wrap; }
.inst-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: var(--space-1); vertical-align: -1px; }
.inst-legend .l-root { background: var(--color-root); }
.inst-legend .l-tone { background: var(--color-tone); box-shadow: inset 0 0 0 var(--note-line-width) var(--color-tone-line); }
.inst-legend .l-char { background: var(--color-char); }

/* ---------------------------------------------------------------- chords by degree */
.degrees { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: var(--space-2); }
@media (min-width: 640px) { .degrees { grid-template-columns: repeat(7, 1fr); } }
.degree {
  display: flex; flex-direction: column; align-items: stretch;
  padding: var(--space-3) var(--space-1) var(--space-1);
  border-radius: var(--radius-md); background: var(--color-surface); border: var(--border-width) solid var(--color-border); text-align: center;
}
.degree__num { font-family: var(--font-display); font-size: var(--text-sm); font-weight: var(--weight-display); color: var(--color-accent); }
.degree__chord { font-size: var(--text-md); font-weight: var(--weight-medium); min-height: var(--tap); display: grid; place-items: center; }
.degree__chord.is-home { color: var(--color-accent); }
.play-mini {
  align-self: center; width: var(--tap); height: 36px; border-radius: var(--radius-pill);
  border: 0; background: transparent; cursor: pointer; color: var(--color-text-3);
  display: grid; place-items: center;
}
.play-mini svg { width: 13px; height: 13px; fill: currentColor; }

/* ---------------------------------------------------------------- rows & lists */
.rows { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-3) 0; border-top: var(--border-width) solid var(--color-border);
}
.row:first-child { border-top: 0; padding-top: 0; }
.row--link:first-child { padding-top: var(--space-2); }
.row__main { min-width: 0; }
.row__title { font-weight: var(--weight-medium); }
.row__meta { font-size: var(--text-sm); color: var(--color-text-2); margin-top: 2px; }
.row__meta a { color: var(--color-text); }
.row.is-current .row__title, .row.is-current .row__title a { color: var(--color-accent); }
.row__end { display: flex; align-items: center; gap: var(--space-2); }
.degree__fn { font-size: var(--text-2xs); color: var(--color-text-3); letter-spacing: 0.02em; margin-top: -4px; }
.btn[aria-pressed="true"] { background: var(--color-accent-soft); border-color: var(--color-accent); color: var(--color-accent); }
.chev { color: var(--color-text-3); font-size: var(--text-xl); line-height: 1; }
.change {
  font-family: var(--font-mono); font-size: var(--text-xs);
  padding: 4px var(--space-2); border-radius: var(--radius-sm);
  background: var(--color-accent-soft); color: var(--color-accent);
  white-space: nowrap;
}
.change a { color: inherit; }
.bright { width: 72px; height: 4px; border-radius: var(--radius-pill); background: var(--color-surface-2); overflow: hidden; }
.bright i { display: block; height: 100%; background: var(--color-accent); border-radius: inherit; }

.homes { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.home {
  display: flex; align-items: center; gap: var(--space-2); min-height: 48px;
  padding: 0 var(--space-3); border-radius: var(--radius-md);
  background: var(--color-surface); border: var(--border-width) solid var(--color-border); font-size: var(--text-sm);
}
.home b { font-family: var(--font-display); font-weight: var(--weight-display); color: var(--color-accent); min-width: 2.4em; }

.grid-links { display: grid; gap: 0 var(--space-4); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-links > * { min-height: var(--tap); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); border-bottom: var(--border-width) solid var(--color-border); }

/* ---------------------------------------------------------------- home & search */
.brand { padding: var(--space-6) 0 var(--space-2); }
.brand h1 { margin: var(--space-1) 0 var(--space-2); }
.brand p { color: var(--color-text-2); margin: 0; max-width: 30em; }
.search-box {
  display: flex; align-items: center; gap: var(--space-3);
  height: 52px; padding: 0 var(--space-4);
  background: var(--color-surface); border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  margin: var(--space-5) 0 var(--space-6);
}
.search-box:focus-within { box-shadow: var(--focus-ring); }
.search-box svg { width: 20px; height: 20px; color: var(--color-text-3); flex: none; display: block; }
.search-box--link span { color: var(--color-text-3); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: var(--text-md); color: var(--color-text); }
.search-box input:focus-visible { box-shadow: none; }
.search-box input::placeholder { color: var(--color-text-3); }
.results { display: flex; flex-direction: column; margin: calc(-1 * var(--space-4)) 0 var(--space-6); }
.results:empty { display: none; }
.result {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 52px; padding: 0 var(--space-2); border-bottom: var(--border-width) solid var(--color-border);
}
.result.is-active { background: var(--color-surface-2); }
.result b { font-weight: var(--weight-medium); }
.result span { font-size: var(--text-xs); color: var(--color-text-3); text-align: right; }

.circle { display: block; width: 100%; max-width: 400px; margin: 0 auto; height: auto; }
.circle .c-ring { fill: none; stroke: var(--color-border); }
.circle .c-major { font: var(--weight-display) 17px var(--font-display); fill: var(--color-text); text-anchor: middle; dominant-baseline: central; }
.circle .c-minor { font: var(--weight-medium) 12.5px var(--font-sans); fill: var(--color-text-2); text-anchor: middle; dominant-baseline: central; }
.circle .c-sig { font: 10px var(--font-sans); fill: var(--color-text-3); text-anchor: middle; dominant-baseline: central; }
.circle .c-hit { fill: transparent; }
.circle a:active .c-hit { fill: var(--color-accent-soft); }

/* ---------------------------------------------------------------- settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); min-height: 60px; border-top: var(--border-width) solid var(--color-border); }
.setting:first-child { border-top: 0; }
.setting__label { font-weight: var(--weight-medium); }
.setting__hint { font-size: var(--text-xs); color: var(--color-text-3); }
.layouts { display: grid; gap: var(--space-2); }
.layout-btn {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border); background: var(--color-surface);
}
.layout-btn b { display: block; font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-lg); }
.layout-btn span { font-size: var(--text-xs); color: var(--color-text-2); }
.layout-btn[aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); box-shadow: inset 0 0 0 1px var(--color-accent); }
/* look picker: each button previews its own look + palette (data-look on .look-demo) */
.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.look-btn { display: flex; flex-direction: column; gap: var(--space-1); padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.look-demo {
  display: flex; flex-direction: column; justify-content: space-between; height: 78px; padding: var(--space-2) var(--space-3);
  background: var(--color-bg); color: var(--color-text);
  border: var(--card-border-width) solid var(--card-border-color); border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--color-border);
}
.look-demo b { font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-xl); letter-spacing: var(--tracking-tight); line-height: 1; }
.look-demo__notes { display: flex; gap: 4px; }
.nh { width: 14px; height: 14px; border-radius: var(--note-radius); background: var(--color-tone); box-shadow: inset 0 0 0 var(--note-line-width) var(--color-tone-line); }
.nh--root { background: var(--color-root); box-shadow: none; }
.nh--char { background: var(--color-char); box-shadow: none; }
.look-btn__name, .pal-btn__name { font-size: var(--text-xs); color: var(--color-text-2); padding-left: 2px; }
.look-btn[aria-pressed="true"] .look-demo, .pal-btn[aria-pressed="true"] .pal-demo { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.look-btn[aria-pressed="true"] .look-btn__name, .pal-btn[aria-pressed="true"] .pal-btn__name { color: var(--color-text); font-weight: var(--weight-medium); }

/* palette picker: six up top, the rest behind "More colours" in the bottom-right corner */
.palettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3) var(--space-2); }
.pal-btn { display: flex; flex-direction: column; gap: var(--space-1); padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.pal-demo {
  position: relative; display: flex; align-items: flex-end; gap: 4px; height: 52px; padding: var(--space-2);
  border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.pal-demo b { position: absolute; top: 6px; left: 9px; font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-md); }
.pal-demo i { width: 16px; height: 16px; border-radius: 50%; margin-left: auto; }
.pal-demo i + i { margin-left: 0; }
.palette-card__foot { display: flex; justify-content: flex-end; margin-top: var(--space-4); }
.more-btn {
  height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--color-border); background: var(--color-surface);
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text); cursor: pointer;
}
.palette-card h3 { margin-top: var(--space-5); }

.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-2); }
.skin-btn {
  border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); padding: var(--space-2); cursor: pointer; text-align: left;
  font-size: var(--text-xs); min-height: var(--tap);
}
.skin-btn[aria-pressed="true"] { border-color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.skin-btn .sw { display: flex; height: 22px; border-radius: 5px; overflow: hidden; margin-bottom: var(--space-1); }
.skin-btn .sw i { flex: 1; }

.footer { text-align: center; color: var(--color-text-3); font-size: var(--text-xs); padding: var(--space-4) 0 var(--space-6); }
.footer a { color: var(--color-text-2); display: inline-block; padding: 12px 4px; }
.empty { text-align: center; padding: var(--space-8) 0; color: var(--color-text-2); }
.empty a { color: var(--color-accent); }

@media (prefers-reduced-motion: reduce) {
  .deck-card, .topbar__title { transition: none; }
}

/* layout toolbox (R23): content pages end with a link to their layout (#/layout/<kind>) */
.page-foot { display: flex; justify-content: center; padding: var(--space-4) 0 var(--space-6); }
.page-foot a { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); color: var(--color-text-2); font-size: var(--text-sm); text-decoration: none; }
.page-foot svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.sec-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) 0; border-top: var(--border-width) solid var(--color-border);
}
.sec-row__title { font-weight: var(--weight-medium); }
.sec-row.is-hidden .sec-row__title { color: var(--color-text-2); text-decoration: line-through; }
.sec-row .seg { flex: none; }

/* toolbox (R27): tuner, metronome and tap, in a sheet from the top-right button */
.metro-running .tools-btn { color: var(--color-accent); }
.tools { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.tools[hidden] { display: none; }
.tools__scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--color-text) 28%, transparent); }
.tools__sheet {
  position: relative; width: 100%; max-width: 560px;
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + var(--safe-bottom));
  background: var(--color-surface); color: var(--color-text);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-2);
}
.tools__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-5); }
.tools__pane { text-align: center; }
.tools__pane[hidden] { display: none; }
.tools .btn { min-width: var(--tap); justify-content: center; }

.tuner__note { font-family: var(--font-display); font-weight: var(--weight-display); line-height: 1; min-height: 88px; }
.tuner__note b { font-size: 80px; }
.tuner__note sub { font-size: var(--text-xl); color: var(--color-text-2); margin-left: 2px; }
.tuner__meter { position: relative; height: 44px; margin: var(--space-4) var(--space-2) var(--space-1); border-radius: var(--radius-pill); background: var(--color-surface-2); }
.tuner__zone { position: absolute; top: 0; bottom: 0; left: 45%; width: 10%; background: var(--color-accent-soft); }
.tuner__mid { position: absolute; top: 6px; bottom: 6px; left: 50%; width: 2px; margin-left: -1px; background: var(--color-text-3); }
.tuner__needle { position: absolute; top: -4px; bottom: -4px; left: 50%; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--color-text-2); transition: left 90ms linear; opacity: 0.35; }
.tools.is-heard .tuner__needle { opacity: 1; background: var(--color-char); }
.tools.is-in-tune .tuner__needle { background: var(--color-accent); }
.tools.is-in-tune .tuner__note b { color: var(--color-accent); }
.tuner__scale { display: flex; justify-content: space-between; font-size: var(--text-2xs); color: var(--color-text-3); margin: 0 var(--space-2); }
.tuner__read { font-size: var(--text-sm); color: var(--color-text-2); margin: var(--space-3) 0 0; font-variant-numeric: tabular-nums; }
.tuner__status { font-weight: var(--weight-medium); margin: var(--space-2) 0 var(--space-4); }
.tuner__ref { display: flex; align-items: center; justify-content: center; gap: var(--space-2); color: var(--color-text-2); }

.metro__bpm { display: flex; align-items: center; justify-content: center; gap: var(--space-5); }
.metro__bpm b { display: block; font-family: var(--font-display); font-weight: var(--weight-display); font-size: 72px; line-height: 1; font-variant-numeric: tabular-nums; min-width: 3ch; }
.metro__bpm span { font-size: var(--text-xs); color: var(--color-text-2); letter-spacing: 0.08em; }
.metro__range { width: 100%; margin: var(--space-4) 0; accent-color: var(--color-accent); }
.metro__dots { display: flex; justify-content: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.metro__dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--color-surface-2); }
.metro__dots i.is-first { box-shadow: inset 0 0 0 2px var(--color-accent); }
.metro__dots i.is-on { background: var(--color-accent); }
.metro__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.metro__row .note-line { margin: 0; }
.metro__actions { display: grid; }
.metro__actions .btn { height: 56px; font-size: var(--text-lg); }
.tap__bpm b { display: block; font-family: var(--font-display); font-weight: var(--weight-display); font-size: 72px; line-height: 1; font-variant-numeric: tabular-nums; }
.tap__bpm span { font-size: var(--text-xs); color: var(--color-text-2); letter-spacing: 0.08em; }
.tap__pad {
  display: block; width: 180px; height: 180px; margin: var(--space-5) auto var(--space-4);
  border-radius: 50%; border: var(--border-width) solid var(--color-border);
  background: var(--color-accent-soft); color: var(--color-text);
  font-family: inherit; font-weight: var(--weight-medium); font-size: var(--text-xl);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.tap__pad.is-hit { animation: tap-hit 180ms var(--ease); }
@keyframes tap-hit { from { background: var(--color-accent); color: var(--color-on-accent); transform: scale(0.96); } }
.tools [data-tools="use-tap"] { width: 100%; }

