/* Music Theory
   Studio at night: tolex-black walls, a rosewood neck, ivory keys, and an
   amber lamp on whatever is the tonic. */

/* Fonts are served from this site (fonts/), so the page needs no other host.
   Latin subsets of Barlow, Barlow Semi Condensed and Young Serif, all under
   the SIL Open Font License: see fonts/OFL-Barlow.txt and fonts/OFL-Young-Serif.txt. */
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/barlow-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/barlow-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/barlow-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/barlow-semi-condensed-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/barlow-semi-condensed-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Young Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/young-serif-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;

  --bg: #15110e;
  --surface: #1f1915;
  --raised: #2b231d;
  --line: #3b3027;
  --line-strong: #7a6857;  /* control outlines: 3:1 against the background */
  --text: #efe6d6;
  --muted: #ab9c8c;
  --ink: #17120e;          /* text on light and coloured surfaces */
  --amber: #f2b441;
  --focus: #fff3d0;

  /* One colour per scale degree, shared by every instrument. */
  --deg-1: #f2b441;
  --deg-2: #f0876a;
  --deg-3: #e88bb5;
  --deg-4: #b79cf0;
  --deg-5: #74b3ee;
  --deg-6: #57c7b6;
  --deg-7: #a3cf62;

  --wood: #2d1e17;
  --fret: #9c8f78;
  --bone: #e9dfc9;
  --ivory: #f3ebdb;
  --ivory-dim: #c9c0af;
  --ebony: #1a1512;

  --display: 'Young Serif', Georgia, 'Times New Roman', serif;
  --ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tight: 'Barlow Semi Condensed', 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --gutter: clamp(16px, 3.2vw, 44px);
  --radius: 7px;
}

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

/* Keep anything scrolled into view (focus, links) clear of the sticky bar. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h, 60px) + 20px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, [aria-disabled='true'] { cursor: default; }
a { color: inherit; text-underline-offset: 0.18em; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  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;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -80px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--text);
  color: var(--ink);
  border-radius: var(--radius);
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* Sharp and flat signs inside display type: the serif has no glyphs for them. */
.acc { font-family: var(--tight); font-weight: 500; font-size: 0.8em; }

/* Each degree class hands its colour to whatever is inside it. */
.deg-1 { --deg: var(--deg-1); }
.deg-2 { --deg: var(--deg-2); }
.deg-3 { --deg: var(--deg-3); }
.deg-4 { --deg: var(--deg-4); }
.deg-5 { --deg: var(--deg-5); }
.deg-6 { --deg: var(--deg-6); }
.deg-7 { --deg: var(--deg-7); }

/* ------------------------------------------------------------------ bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 9px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  font: 400 21px/1 var(--display);
  text-decoration: none;
  white-space: nowrap;
  margin-right: 4px;
}
.brand:hover { color: var(--amber); }

.bar .field { flex-direction: row; align-items: center; gap: 10px; }
/* "Key" and "Root" take turns here; a fixed width keeps the notes from shifting. */
.bar .field-label { min-width: 2.4em; font-size: 14.5px; }
.bar .bar-notes { flex: 1 1 420px; min-width: 0; max-width: 680px; }
.bar .bar-labels { margin-left: auto; }
.bar .bar-labels .field-label { min-width: 0; }

/* One labels switch on screen at a time: in the bar when wide, in the sidebar when narrow. */
@media (max-width: 959px) { .bar .bar-labels { display: none; } }
@media (min-width: 960px) { .sidebar .side-labels { display: none; } }

/* ------------------------------------------------------------- controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  margin-bottom: 16px;
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 13.5px; line-height: 1.2; color: var(--muted); white-space: nowrap; }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  max-width: 100%;
}
.seg-item {
  appearance: none;
  min-height: 36px;
  padding: 5px 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-weight: 500;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}
.seg-item:hover { background: var(--raised); }
.seg-item[aria-checked='true'] { background: var(--text); color: var(--ink); }
/* Twelve note buttons share the row equally so they always fit, even at 375px. */
.field-notes { width: 100%; max-width: 560px; }
.seg-notes { display: flex; width: 100%; }
.seg-notes .seg-item { flex: 1 1 0; min-width: 0; padding-inline: 0; font: 600 16px/1.2 var(--tight); }
.seg-tonic .seg-item[aria-checked='true'] { background: var(--amber); }
.seg-positions .seg-item { min-width: 38px; padding-inline: 8px; }

.select {
  appearance: none;
  min-height: 42px;
  max-width: 100%;
  padding: 7px 34px 7px 11px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23ab9c8c' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 11px center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 15px;
}
.select:hover { background-color: var(--raised); }

.btn {
  appearance: none;
  min-height: 42px;
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.2;
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:disabled { opacity: 0.42; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 0.18em; padding-inline: 6px; }
.btn-quiet:hover:not(:disabled) { background: transparent; color: var(--text); }
.btn-step { width: 38px; min-height: 38px; padding: 0; font-size: 19px; }
.btn-respell { min-height: 34px; padding: 4px 11px; font-size: 14px; }

/* ----------------------------------------------------------------- main */

.layout { max-width: 1640px; margin: 0 auto; }
.content { min-width: 0; }
main { padding: 0 var(--gutter); container: main / inline-size; }

.panel { padding-block: 30px 34px; border-top: 1px solid var(--line); container-type: inline-size; }
.panel-title { margin: 0 0 18px; font: 400 27px/1.15 var(--display); }
.sub-title { margin: 22px 0 10px; font: 600 15px/1.3 var(--ui); color: var(--text); }
.sub-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 22px 0 10px; }
.sub-head .sub-title { margin: 0; }
.panel-note { margin: 10px 0 0; max-width: 68ch; font-size: 14.5px; color: var(--muted); }
.notice { padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); }

.columns { display: flex; flex-direction: column; }
.column { display: contents; }
#chords { order: 1; }
#circle { order: 2; }
#piano { order: 3; }
#progression { order: 4; }

@container main (min-width: 900px) {
  .columns { flex-direction: row; gap: clamp(32px, 4cqi, 64px); border-top: 1px solid var(--line); }
  .column { display: block; flex: 1 1 0; min-width: 0; }
  .column > .panel:first-child { border-top: 0; }
}

/* -------------------------------------------------------------- sidebar */

.sidebar { padding: 16px var(--gutter) 6px; border-bottom: 1px solid var(--line); }

.field-modes { width: 100%; }
.seg-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 3px; padding: 3px; }
.seg-modes .seg-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 66px;
  padding: 9px 2px 8px;
  font: 600 15px/1.1 var(--ui);
}
.mode-icon { display: block; }
.mode-icon circle { fill: currentColor; }

.field-labels { margin-top: 16px; }
.field-labels .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.field-labels .seg-item { padding-inline: 4px; }

.side-title { margin: 20px 0 4px; font: 600 15px/1.3 var(--ui); }

.search-wrap { margin: 2px 0 6px; }
.search {
  appearance: none;
  width: 100%;
  min-height: 38px;
  padding: 7px 10px 7px 33px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='6.8' cy='6.8' r='4.8' fill='none' stroke='%23ab9c8c' stroke-width='1.7'/%3E%3Cpath d='M10.4 10.4 14 14' stroke='%23ab9c8c' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 11px center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: 500 15px/1.2 var(--ui);
}
.search::placeholder { color: var(--muted); opacity: 1; }
.search:hover { background-color: var(--raised); }
.search::-webkit-search-cancel-button { cursor: pointer; }
.search-status { margin: 4px 10px 8px; font-size: 14px; color: var(--muted); }

/* The part of an option that matches the filter. */
.choice-match { background: none; color: var(--amber); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; }
.choice[aria-checked='true'] .choice-match { color: var(--ink); }

.choices { display: flex; flex-direction: column; gap: 1px; }
.choices-heading { margin: 12px 10px 3px; font: 500 13px/1.25 var(--ui); color: var(--muted); }
.choices-heading:first-child { margin-top: 2px; }
.choice {
  appearance: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  font-weight: 500;
  font-size: 15px;
  line-height: 1.25;
}
.choice:hover { background: var(--surface); }
.choice[aria-checked='true'] { background: var(--text); color: var(--ink); }
.choice-label { white-space: nowrap; }
.choice-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.choice[aria-checked='true'] .choice-note { color: #4d4137; }

/* Wide screens: the sidebar sits on the left and stays in view while the page scrolls. */
@media (min-width: 960px) {
  .layout { display: grid; grid-template-columns: 276px minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: var(--bar-h, 60px);
    align-self: start;
    max-height: calc(100vh - var(--bar-h, 60px));
    max-height: calc(100dvh - var(--bar-h, 60px));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--line-strong) transparent;
    padding: 20px 14px 24px var(--gutter);
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
}

/* Narrow screens: the list becomes one row that scrolls sideways inside its own strip. */
@media (max-width: 959px) {
  .side-title { margin: 16px 0 8px; }
  .choices {
    flex-direction: row;
    gap: 6px;
    margin-inline: calc(-1 * var(--gutter));
    padding: 0 var(--gutter) 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
  .choices-heading { display: none; }
  .choice {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 1px;
    width: auto;
    min-height: 46px;
    justify-content: center;
    border: 1px solid var(--line);
  }
  .choice-note { font-size: 12.5px; }
}

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

.summary { padding-block: clamp(22px, 4cqi, 44px) 30px; }
.key-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 40px; }
.key-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 20px; min-width: 0; }
.key-name {
  margin: 0;
  font: 400 clamp(46px, 10cqi, 112px)/0.95 var(--display);
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.key-facts { margin: 0; max-width: 50ch; font-size: 15px; color: var(--muted); }

.degrees {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 5px;
  margin-top: 26px;
}
.degree {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 62px;
  padding: 6px 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.degree:not(:disabled):hover { border-color: var(--line-strong); color: var(--text); }
.degree:disabled { cursor: default; }
.degree-note { font: 600 19px/1.1 var(--tight); }
.degree-token { font: 500 13px/1.1 var(--tight); }
.degree-on { background: var(--deg); border-color: var(--deg); color: var(--ink); }
.degree-on:not(:disabled):hover { color: var(--ink); filter: brightness(1.08); }
.degree-root { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--deg); }
.degrees-hint { margin-top: 12px; }

/* ------------------------------------------------------------ fretboard */

.fb-scroll, .kb-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-color: var(--line-strong) transparent;
  border-radius: 4px;
}
.fb-scroll { padding: 2px 0 6px; }
.fb-svg { display: block; }

.fb-wood { fill: var(--wood); }
.fb-fret { stroke: var(--fret); stroke-width: 2; }
.fb-nut { stroke: var(--bone); stroke-width: 5; stroke-linecap: round; }
.fb-string { stroke: #cfc5ae; opacity: 0.7; }
.fb-inlay { fill: #49382d; }
.fb-number { fill: #8d7f70; font: 500 12px var(--tight); text-anchor: middle; }
.fb-number-marked { fill: var(--text); }
.fb-string-name { fill: var(--muted); font: 600 14px var(--tight); text-anchor: middle; }
.fb-band { fill: rgb(242 180 65 / 0.09); stroke: rgb(242 180 65 / 0.6); stroke-width: 1.5; }
.fb-band-tag { fill: var(--amber); font: 600 13px var(--tight); text-anchor: middle; }
.fb-muted { fill: var(--muted); font: 500 17px var(--ui); text-anchor: middle; }

/* Note markers (fretboard, piano, chord diagrams). */
.dot-disc { fill: var(--deg); stroke: rgb(0 0 0 / 0.4); stroke-width: 1; }
.dot-ring { fill: none; stroke: var(--deg); stroke-width: 2; }
.dot-label { fill: var(--ink); font-family: var(--tight); font-weight: 600; text-anchor: middle; pointer-events: none; }
.dot-off .dot-disc { opacity: 0.24; stroke: none; }
.dot-ghost circle { fill: #8b7b6b; }

.tuning-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 24px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
}
.steppers { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.stepper { display: grid; grid-template-columns: auto 3.4em auto; align-items: center; gap: 4px; }
.stepper-name { grid-column: 1 / -1; font-size: 13.5px; color: var(--muted); }
.stepper-value { text-align: center; font: 600 17px var(--tight); }

/* ---------------------------------------------------------------- piano */

.kb-scroll { padding-bottom: 4px; }
.kb-svg { display: block; width: 100%; height: auto; }
.key { stroke: var(--bg); stroke-width: 1; }
.key-white { fill: var(--ivory-dim); }
.key-white.key-on { fill: var(--ivory); }
.key-black { fill: var(--ebony); }
.key-black.key-on { fill: #3d3028; }
.key-octave { fill: #8d7f70; font: 500 11px var(--tight); text-anchor: middle; }
/* Pale markers on pale keys need a dark edge to stand out. */
.kb-svg .dot-disc { stroke: var(--ink); stroke-width: 1.5; }
.kb-svg .dot-on-white.dot-ghost circle { fill: #5a4c40; }

/* --------------------------------------------------------------- circle */

.circle-layout { display: grid; gap: 8px 36px; }
.circle-figure { min-width: 0; }
.circle-svg { display: block; width: 100%; max-width: 460px; height: auto; margin-inline: auto; }
@container (min-width: 700px) {
  .circle-layout { grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); align-items: start; }
  .circle-side .sub-head:first-child { margin-top: 4px; }
}

.sector { cursor: pointer; outline: none; }
.sector path { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.sector text { text-anchor: middle; pointer-events: none; }
.sector-name { fill: var(--muted); }
.sector-major .sector-name { font: 400 20px var(--display); }
.sector-minor .sector-name { font: 500 14.5px var(--tight); }
.sector-numeral { fill: var(--amber); font: 600 11.5px var(--tight); }
.sector:hover path { stroke: var(--text); }
.sector-in-key path { fill: #3a2e25; stroke: var(--line-strong); }
.sector-in-key .sector-name { fill: var(--text); }
.sector-current path { fill: var(--amber); stroke: var(--amber); }
.sector-current .sector-name, .sector-current .sector-numeral { fill: var(--ink); }
.sector:focus-visible path { stroke: var(--focus); stroke-width: 3; }

.degree-arc path { fill: var(--surface); }
.degree-arc-on path { fill: var(--deg); }
.degree-arc-root path { stroke: var(--text); stroke-width: 2; }
.degree-arc-label { fill: var(--ink); font: 600 11.5px var(--tight); text-anchor: middle; }
.signature { fill: #8d7f70; font: 500 11.5px var(--tight); text-anchor: middle; }
.signature-current { fill: var(--amber); font-weight: 600; }
.center-tonic { fill: var(--text); font: 400 34px var(--display); text-anchor: middle; }
.center-scale { fill: var(--muted); font: 500 12px var(--tight); text-anchor: middle; }

/* ---------------------------------------------------------------- chips */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 62px;
  min-height: 46px;
  padding: 6px 12px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}
.chip:hover:not(:disabled) { border-color: var(--line-strong); background: var(--raised); }
.chip:disabled { opacity: 0.42; }
.chip[aria-pressed='true'] { border-color: var(--amber); background: #33270f; }
.chip-roman { font: 500 13px/1.25 var(--tight); color: var(--muted); }
.chip[aria-pressed='true'] .chip-roman { color: var(--amber); }
.chip-symbol { font: 600 17px/1.2 var(--tight); }
.chip-key .chip-symbol { font-size: 15.5px; }
.chip-preset { justify-content: center; font: 600 15.5px/1.2 var(--tight); }

/* --------------------------------------------------------------- chords */

.chord-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-bottom: 14px; }
.chord-name { margin: 0; font: 400 clamp(36px, 8cqi, 52px)/1 var(--display); }
.chord-facts { margin: 0; font-size: 15px; color: var(--muted); }

.shapes { display: flex; flex-wrap: wrap; gap: 10px; }
.shape {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 8px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.shape:hover { border-color: var(--line-strong); background: var(--raised); }
.shape[aria-pressed='true'] { border-color: var(--amber); background: #33270f; }
.shape-frets { font: 600 14px/1.3 var(--tight); letter-spacing: 0.05em; }
.shape-source { font-size: 12.5px; line-height: 1.3; color: var(--muted); }

.diagram { display: block; }
.diagram-line { stroke: #6f5f50; stroke-width: 1; }
.diagram-nut { stroke: var(--bone); stroke-width: 3.5; stroke-linecap: square; }
.diagram-fret { fill: var(--muted); font: 500 11px var(--tight); text-anchor: end; }
.diagram-mute { fill: var(--muted); font: 500 13px var(--ui); text-anchor: middle; }
.diagram-open { fill: none; stroke: var(--deg); stroke-width: 2; }
.diagram-barre { fill: #cfc5ae; opacity: 0.32; }


/* ---------------------------------------------------------- progression */

.steps {
  counter-reset: bar;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}
.steps-twelve { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.steps li { counter-increment: bar; min-width: 0; }
.steps-empty { grid-column: 1 / -1; padding: 18px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.step {
  appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 68px;
  padding: 9px 12px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}
.step::after {
  content: counter(bar);
  position: absolute;
  top: 7px;
  right: 9px;
  font: 500 12px/1 var(--tight);
  color: #8d7f70;
}
.step:hover { border-color: var(--line-strong); background: var(--raised); }
.step[aria-pressed='true'] { border-color: var(--amber); background: #33270f; }
.step-roman { font: 500 14px/1.3 var(--tight); color: var(--amber); }
.step-symbol { font: 400 23px/1.2 var(--display); }

/* --------------------------------------------------------------- footer */

.footer {
  padding: 26px var(--gutter) 48px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  color: var(--muted);
}
.footer p { margin: 0 0 8px; max-width: 78ch; }
.footer-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-left: -6px; }

/* --------------------------------------------------------------- dialog */

.dialog {
  width: min(500px, calc(100vw - 32px));
  padding: 26px 26px 22px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}
.dialog::backdrop { background: rgb(8 6 4 / 0.72); }
.dialog-title { margin: 0 0 16px; font: 400 25px/1.2 var(--display); }
.dialog-note { margin: 14px 0 18px; font-size: 14.5px; color: var(--muted); }
.keys { display: grid; gap: 9px; margin: 0; }
.keys div { display: grid; grid-template-columns: 7.2em 1fr; align-items: baseline; gap: 12px; }
.keys dd { margin: 0; }
kbd {
  display: inline-block;
  min-width: 1.75em;
  padding: 1px 6px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 600 14px/1.5 var(--tight);
  text-align: center;
}

/* --------------------------------------------------------------- narrow */

@media (max-width: 760px) {
  .brand { display: none; }
  .bar { padding-block: 7px; }
  .bar .field { gap: 6px; }
  .bar .field-label { min-width: 2.2em; font-size: 13px; }
  .bar .bar-notes { flex-basis: 100%; max-width: none; }
  .seg-notes .seg-item { font-size: 15px; }
  .seg-item { min-height: 40px; }
  .seg-modes .seg-item { min-height: 58px; }
  .panel { padding-block: 24px 28px; }
  .panel-title { font-size: 24px; margin-bottom: 14px; }
  .degrees { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .degree { min-height: 56px; }
}

@media (prefers-reduced-motion: no-preference) {
  .seg-item, .btn, .chip, .step, .shape, .degree { transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
}

@media (forced-colors: active) {
  .seg-item[aria-checked='true'], .chip[aria-pressed='true'],
  .step[aria-pressed='true'], .shape[aria-pressed='true'], .degree-on { outline: 2px solid Highlight; outline-offset: -2px; }
}
