@layer components {
  /* The Theory Map (docs/product/theory-map-redesign-decisions.md): key, instrument and
     tuning as drop-downs in one row, the neck, then the controls used while playing. */
  .av-theory-helper {
    position: relative;
    display: grid;
    gap: 14px;
    background: #ffffff;
    border: none;
    border-radius: 0.5rem;
    padding: 20px 22px;
    box-shadow: none;
  }

  /* Still used by the "Set key" dialogs on the practice screens. */
  .av-theory-group-title {
    font-weight: 700;
    color: #1f3148;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
  }

  /* ---- The top row reads as a sentence: "C major on guitar in standard tuning
     (E A D G B E)". Each changeable word is a quiet outlined button (av-theory-word);
     the key and instrument open our own pop-ups, the tuning a real drop-down. ---- */
  .av-theory-sentence {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    text-align: left;
    font-size: 1.05rem;
    color: rgba(15, 23, 42, 0.72);
  }

  .av-theory-bar [hidden] {
    display: none !important;
  }

  /* "on guitar", "in standard tuning": each phrase wraps as one piece. */
  .av-theory-phrase {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .av-theory-anchor {
    position: relative;
    display: inline-flex;
  }

  /* A word you can change: white, a 1px outline, the button radius, an arrow. No shadow,
     so the neck leads. The global `button` rule in button.css is unlayered and adds a
     shadow and a hover lift, hence !important on those two. */
  .av-theory-word {
    box-shadow: none !important;
    transform: none !important;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 10px 0 12px;
    font: inherit;
    font-weight: 700;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.28);
    border-radius: var(--av-btn-radius, 4px);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease, border-color 120ms ease;
  }

  .av-theory-word:hover,
  .av-theory-word--select:focus-within {
    background: rgba(53, 171, 178, 0.08);
    border-color: rgba(15, 23, 42, 0.45);
  }

  .av-theory-word[aria-expanded="true"] {
    background: rgba(53, 171, 178, 0.1);
    border-color: #176269;
  }

  .av-theory-word:focus-visible,
  .av-theory-word--select:focus-within {
    outline: 3px solid rgba(53, 171, 178, 0.6);
    outline-offset: 2px;
  }

  /* The key leads the sentence. */
  .av-theory-word--key {
    min-height: 44px;
    padding: 0 12px 0 14px;
    font-size: 1.45rem;
  }

  .av-theory-word--key.is-unset {
    color: #176269;
  }

  .av-theory-word__caret {
    flex: none;
    width: 12px;
    height: 12px;
    fill: none;
    stroke: #176269;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .av-theory-word--key .av-theory-word__caret {
    width: 14px;
    height: 14px;
  }

  .av-theory-word__extra {
    font-weight: 400;
    color: rgba(15, 23, 42, 0.62);
  }

  /* The real drop-down sits over its button, unseen, so a click or tap opens the
     browser's own list (the phone's picker on phones). 16px stops iOS zooming in. */
  .av-theory-word__select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    font-size: 16px;
    cursor: pointer;
  }

  /* ---- Pop-ups: the key picker and the instrument menu ---- */
  .av-theory-picker {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 400px;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    padding: 12px 14px 14px;
    background: #ffffff;
    border: 2px solid rgba(15, 23, 42, 0.32);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    font-size: 0.95rem;
    font-weight: 400;
    color: #0f172a;
  }

  .av-theory-picker[hidden],
  .av-theory-picker-backdrop[hidden] {
    display: none !important;
  }

  .av-theory-picker-backdrop {
    display: none;
  }

  .av-theory-picker--menu {
    width: 250px;
    gap: 4px;
    padding: 8px;
  }

  .av-theory-picker__head {
    display: flex;
    align-items: center;
  }

  .av-theory-picker__title {
    flex-grow: 1;
    font-weight: 700;
    padding-left: 2px;
  }

  .av-theory-picker__note {
    margin: 0;
    color: rgba(15, 23, 42, 0.68);
  }

  .av-theory-picker__label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.6);
  }

  .av-theory-picker__roots {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  /* Wide enough for "Mixolydian" on one line. */
  .av-theory-picker__modes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 4px;
  }

  .av-theory-picker__option {
    box-shadow: none !important;
    transform: none !important;
    min-height: 36px;
    padding: 0 6px;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: var(--av-btn-radius, 4px);
    background: #ffffff;
    font-size: 0.92rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
  }

  .av-theory-picker__option:hover {
    background: rgba(53, 171, 178, 0.1);
  }

  .av-theory-picker__option.is-active {
    background: #222434;
    border-color: #222434;
    color: #ffffff;
  }

  .av-theory-picker__done {
    align-self: flex-end;
  }

  .av-theory-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .av-theory-menu__row {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .av-theory-menu__item,
  .av-theory-menu__star {
    box-shadow: none !important;
    transform: none !important;
    min-height: 38px;
    border: 0;
    border-radius: var(--av-btn-radius, 4px);
    background: transparent;
    cursor: pointer;
  }

  .av-theory-menu__item {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    text-align: left;
    font-size: 0.98rem;
    color: #0f172a;
  }

  .av-theory-menu__item.is-active {
    font-weight: 700;
    background: rgba(53, 171, 178, 0.12);
  }

  .av-theory-menu__item:hover,
  .av-theory-menu__star:hover {
    background: rgba(53, 171, 178, 0.12);
  }

  /* The star: quiet until it's on. */
  .av-theory-menu__star {
    flex: none;
    width: 38px;
    color: rgba(15, 23, 42, 0.35);
  }

  .av-theory-menu__star.is-on {
    color: #d79a2b;
  }

  .av-theory-menu__item:focus-visible,
  .av-theory-menu__star:focus-visible,
  .av-theory-picker__option:focus-visible {
    outline: 3px solid rgba(53, 171, 178, 0.6);
    outline-offset: 1px;
  }

  /* Bootstrap's own hr and p margins are unlayered, so these need !important. */
  .av-theory-menu__rule {
    margin: 4px 6px !important;
    border: 0;
    border-top: 1px solid rgba(17, 24, 39, 0.12);
  }

  .av-theory-menu__family {
    margin: 8px 10px 2px !important;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.55);
  }

  .av-theory-sentence .av-theory-rel-toggle {
    margin-left: 2px;
  }

  /* ---- Box: Off / C A G E D, Draw a box, "Your box: frets 5–8", Clear ---- */
  .av-theory-box-status {
    font-weight: 700;
    color: #176269;
  }

  .av-theory-box-move {
    display: none;
  }

  .av-theory-tools [hidden] {
    display: none !important;
  }

  .av-theory-key-hint {
    flex: 1 1 100%;
    margin: 0;
    font-size: 0.88rem;
    color: rgba(15, 23, 42, 0.68);
  }

  /* ---- Quiet buttons (the ghost tier) ----
     No fill or shadow at rest, a light tint on hover. The global `button` rule in
     button.css is unlayered and adds a shadow and a hover lift, which beat anything in
     this layer, hence !important on those two. */
  .av-theory-ghost {
    box-shadow: none !important;
    transform: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--av-btn-radius, 4px);
    background: transparent;
    color: #176269;
    font-size: 0.92rem;
    cursor: pointer;
  }

  .av-theory-ghost:hover,
  .av-theory-ghost[aria-expanded="true"] {
    background: rgba(53, 171, 178, 0.12);
  }

  .av-theory-ghost:focus-visible,
  .av-theory-seg > button:focus-visible,
  .av-theory-summary-cell:focus-visible {
    outline: 3px solid rgba(53, 171, 178, 0.6);
    outline-offset: 2px;
  }

  /* ---- Segmented toggles: Notes/Degrees, Show ----
     One outlined group, no shadows, so the neck and Change lead. */
  .av-theory-seg {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid rgba(15, 23, 42, 0.22);
    border-radius: var(--av-btn-radius, 4px);
    overflow: hidden;
    background: #ffffff;
  }

  .av-theory-seg > button,
  .av-theory-chip {
    box-shadow: none !important;
    transform: none !important;
    min-height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #0f172a;
    font-size: 0.92rem;
    cursor: pointer;
  }

  .av-theory-seg > button:not([hidden]) ~ button:not([hidden]) {
    border-left: 1px solid rgba(15, 23, 42, 0.14);
  }

  .av-theory-seg > button:hover {
    background: rgba(53, 171, 178, 0.1);
  }

  .av-theory-seg > button.is-active {
    background: #222434;
    color: #ffffff;
  }

  /* Your instruments: only the musician's own show. A hidden button must stay hidden
     whatever its display. */
  .av-theory-chip[hidden] {
    display: none;
  }

  .av-theory-tools__label {
    margin: 0 !important;
    font-size: 0.85rem;
    color: rgba(15, 23, 42, 0.68);
  }

  .av-theory-rel-toggle.is-hidden {
    display: none;
  }

  /* Drop-downs on the map: solid white with a clear outline, so they read as the
     controls they are, sized to their choices. Bootstrap's unlayered .form-select is
     width: 100% with its own border, which beat this layer, hence !important. */
  .av-theory-select {
    width: auto !important;
    min-height: 38px;
    padding-left: 12px;
    font-weight: 600;
    color: #0f172a;
    background-color: #ffffff !important;
    border: 2px solid rgba(15, 23, 42, 0.3) !important;
    border-radius: 6px !important;
  }

  .av-theory-select:hover {
    border-color: rgba(15, 23, 42, 0.5) !important;
  }

  .av-theory-select:focus {
    border-color: #35abb2 !important;
    box-shadow: 0 0 0 0.25rem rgba(138, 195, 198, 0.3) !important;
  }

  .av-theory-key-root-select {
    min-width: 96px;
  }

  .av-theory-tuning-select {
    min-width: 210px;
    max-width: 100%;
  }

  .av-theory-modal-row .form-group {
    display: grid;
    gap: 6px;
  }

  .av-theory-modal-field {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .av-theory-hint {
    font-size: 0.85rem;
  }

  /* ---- Under the neck: what only this instrument has (Box, the violin's positions note,
     the piano's keys), then Notes or Degrees at the right ---- */
  .av-theory-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(17, 24, 39, 0.08);
  }

  .av-theory-label-toggle {
    margin-left: auto;
  }

  /* The second row under the neck (Box, or the violin's positions note): no rule above. */
  .av-theory-tools--box {
    padding-top: 0;
    border-top: 0;
  }

  .av-theory-tools--box[hidden],
  .av-theory-tools--box:empty {
    display: none;
  }

  /* Piano: the starting C, with a step either side. */
  .av-theory-piano-start {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 700;
  }

  .av-theory-piano-start [data-role="piano-start"] {
    min-width: 28px;
    text-align: center;
  }

  .av-theory-piano-start .av-theory-ghost:disabled {
    opacity: 0.35;
    cursor: default;
  }

  .av-theory-tools__item {
    position: relative;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
  }

  .av-theory-tools__item.av-theory-hidden {
    display: none;
  }


  .av-theory-box-hint {
    font-size: 0.85rem;
    color: rgba(15, 23, 42, 0.62);
  }

  /* The violin's positions note, opened from "How positions work". */
  .av-theory-popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 30;
    width: min(520px, calc(100vw - 32px));
    padding: 14px 16px;
    background: #ffffff;
    border: 2px solid rgba(15, 23, 42, 0.32);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .av-theory-popover[hidden] {
    display: none;
  }

  .av-theory-popover p {
    margin: 0 0 6px;
  }

  .av-theory-popover p:last-child {
    margin-bottom: 0;
  }

  /* ---- The scale tones (each a toggle, and the legend), then Show ---- */
  .av-theory-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
  }

  .av-theory-tones {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .av-theory-show {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
  }

  /* Quiet toggles with the button radius: a filled dot when the note shows, a dashed
     outline when it is hidden. */
  .av-theory-summary-cell {
    box-shadow: none !important;
    transform: none !important;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    min-width: 58px;
    padding: 0 10px 0 6px;
    border: 1px solid rgba(15, 23, 42, 0.22);
    border-radius: var(--av-btn-radius, 4px);
    background: #ffffff;
    color: #0f172a;
    font-size: 0.92rem;
    cursor: pointer;
  }

  .av-theory-summary-cell:hover {
    background: rgba(53, 171, 178, 0.1);
  }

  .av-theory-summary-interval {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: #eef1f3;
    color: #0f172a;
  }

  .av-theory-summary-cell.is-root .av-theory-summary-interval {
    background: #76bc79;
  }

  .av-theory-summary-cell.is-third .av-theory-summary-interval {
    background: #eeb259;
  }

  .av-theory-summary-cell.is-fifth .av-theory-summary-interval {
    background: #8ac3c6;
  }

  .av-theory-summary-cell.is-seventh .av-theory-summary-interval {
    background: #c9b3dd;
  }

  .av-theory-summary-cell.is-disabled {
    background: #f3f5f6;
    border-style: dashed;
    color: rgba(15, 23, 42, 0.55);
  }

  .av-theory-summary-cell.is-disabled .av-theory-summary-interval {
    background: transparent;
    border: 1px dashed rgba(15, 23, 42, 0.3);
    color: rgba(15, 23, 42, 0.55);
  }

  .av-theory-summary-note {
    font-weight: 600;
  }

  .av-theory-display {
    background: transparent;
    border-radius: var(--av-card-radius);
    padding: 0;
    border: none;
  }

  .av-theory-fretboard {
    display: grid;
    gap: 8px;
    position: relative;
    --av-fret-gap: 6px;
    --av-fretboard-padding: 16px;
    --av-fret-min-width: 24px;
    --av-fret-grid: repeat(var(--av-fret-columns, 23), minmax(var(--av-fret-min-width), 1fr));
    padding: var(--av-fretboard-padding);
    user-select: none;
    background: rgba(255, 255, 255, 0.75);
    border-radius: var(--av-card-radius);
    border: none;
  }

  .av-theory-string {
    display: grid;
    grid-template-columns: var(--av-fret-grid);
    gap: var(--av-fret-gap);
    align-items: center;
    position: relative;
  }

  /* The string itself, through the middle of its row; the notes sit on it. */
  .av-theory-string::before {
    content: "";
    position: absolute;
    /* The banjo's short 5th string starts at its peg (set by TheoryHelper.view.js). */
    left: var(--av-string-start, 0);
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(15, 23, 42, 0.28);
    z-index: 1;
    pointer-events: none;
  }

  .av-theory-open-string {
    font-weight: 700;
    color: rgba(15, 23, 42, 0.7);
    text-align: right;
    padding-right: 6px;
  }


  /* Notes on the neck, in the original style (1 Dec 2026, the user preferred it to the
     round marks): every note in the key is an outlined box, so the plain ones read as
     clearly as the coloured root, 3rd and 5th. */
  .av-theory-note {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    font-size: 0.82rem;
    border-radius: 8px;
    background: rgba(34, 36, 52, 0.05);
    border: 1px solid transparent;
    position: relative;
    z-index: 2;
    width: 70%;
    justify-self: center;
    max-width: 52px;
    transition: transform 120ms ease, box-shadow 140ms ease;
    user-select: none;
  }

  .av-theory-note.is-open {
    width: 24px;
    min-height: 22px;
    height: 22px;
    border-radius: 8px;
    font-size: 0.75rem;
    place-self: center;
  }

  /* Solid fills and text throughout (nothing see-through), so every note reads at a
     glance whatever is behind it. */
  .av-theory-note.is-in-key {
    background: #ffffff;
    border-color: #c4c9d1;
    color: #1f2937;
    font-weight: 600;
  }

  .av-theory-note.is-root {
    background: #c3e1c5;
    border-color: #8fc792;
    color: #0f1a12;
    width: 82%;
    min-height: 30px;
    font-size: 0.9rem;
    box-shadow:
      0 0 0 2px #5d6470,
      0 0 0 6px #e3f1e4,
      0 6px 12px rgba(17, 24, 39, 0.12);
  }

  .av-theory-note.is-third {
    background: #f3e6ca;
    border-color: #ddb96b;
    border-width: 2px;
    color: #221c10;
  }

  .av-theory-note.is-fifth {
    background: #d1ecee;
    border-color: #6cc1c6;
    border-width: 2px;
    color: #0c2a2c;
  }

  /* The chord's 7th, only when picked out (Chord + 7). */
  .av-theory-note.is-seventh {
    background: #e9e1f1;
    border-color: #a68bc4;
    border-width: 2px;
    color: #2c1742;
  }

  .av-theory-note.is-other {
    background: #ffffff;
    border-color: #c4c9d1;
    border-width: 2px;
    color: #374151;
  }

  /* A tune with no key: every note, alike and a little quieter than a key's notes, so
     the neck reads as a map of where notes are rather than a scale. */
  .av-theory-note.is-chromatic {
    border-color: #d5d9df;
    color: #4b5563;
    font-weight: 500;
  }

  .av-theory-note.is-hidden {
    background: transparent;
    color: transparent;
  }

  .av-theory-keyboard {
    position: relative;
    display: flex;
    height: 160px;
    gap: 2px;
    padding: 12px 8px 8px;
    border: none;
  }

  .av-theory-markers {
    display: grid;
    grid-template-columns: var(--av-fret-grid);
    gap: var(--av-fret-gap);
    align-items: center;
    margin-top: 2px;
    position: relative;
    z-index: 1;
  }

  .av-theory-marker {
    position: relative;
    min-height: 12px;
  }

  .av-theory-marker.is-active::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(34, 36, 52, 0.25);
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.2);
  }

  .av-theory-marker.is-double.is-active::before,
  .av-theory-marker.is-double.is-active::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(34, 36, 52, 0.25);
    position: absolute;
    top: 50%;
    left: 50%;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.2);
  }

  .av-theory-marker.is-double.is-active::before {
    transform: translate(-110%, -50%);
  }

  .av-theory-marker.is-double.is-active::after {
    transform: translate(10%, -50%);
  }

  .av-theory-fret-numbers {
    display: grid;
    grid-template-columns: var(--av-fret-grid);
    gap: var(--av-fret-gap);
    align-items: center;
    margin-bottom: 6px;
    color: rgba(15, 23, 42, 0.6);
    font-weight: 600;
    font-size: 0.75rem;
    position: relative;
    z-index: 1;
  }

  .av-theory-fret-number {
    text-align: center;
  }

  .av-theory-fret-lines {
    position: absolute;
    inset: var(--av-fretboard-padding);
    display: grid;
    grid-template-columns: var(--av-fret-grid);
    gap: var(--av-fret-gap);
    z-index: 1;
    pointer-events: none;
  }

  .av-theory-box-overlay {
    position: absolute;
    inset: var(--av-fretboard-padding);
    display: grid;
    grid-template-columns: var(--av-fret-grid);
    gap: var(--av-fret-gap);
    z-index: 1;
    pointer-events: none;
  }

  .av-theory-box {
    grid-column: var(--av-box-start-line, 1) / var(--av-box-end-line, 1);
    border: 2px solid #176269;
    background: rgba(53, 171, 178, 0.1);
    border-radius: 8px;
    position: relative;
    height: 100%;
    pointer-events: auto;
    cursor: grab;
  }

  .av-theory-box:active {
    cursor: grabbing;
  }

  .av-theory-box-handle {
    position: absolute;
    top: 8px;
    bottom: 8px;
    width: 6px;
    border-radius: 999px;
    background: #176269;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
    cursor: ew-resize;
    z-index: 3;
  }

  .av-theory-box-handle.is-start {
    left: -4px;
  }

  .av-theory-box-handle.is-end {
    right: -4px;
  }

  /* Outside a box: greyed but solid, never see-through. */
  .av-theory-note.is-in-key.is-outside-box {
    background: #f1f3f5;
    border-color: #dde1e6;
    color: #9aa3af;
    box-shadow: none;
  }

  .av-theory-fret-number.is-outside-box,
  .av-theory-marker.is-outside-box {
    opacity: 0.25;
  }

  .av-theory-fret-line {
    width: 100%;
    height: 100%;
    position: relative;
    justify-self: start;
    background: transparent;
  }

  .av-theory-fret-line::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(34, 36, 52, 0.16);
  }

  .av-theory-fret-line.is-nut::after {
    background: rgba(34, 36, 52, 0.26);
    width: 2px;
  }

  .av-theory-fret-line.is-hidden {
    background: transparent;
  }

  .av-theory-fret-line.is-octave::after {
    background: rgba(34, 36, 52, 0.24);
    width: 2px;
  }

  /* A neck that stops at the 12th fret (phones) ends on the octave wire: draw it on
     the last column's right edge. */
  .av-theory-fret-line.is-octave-end {
    /* Not a pseudo-element: fret 12's ::before holds its marker dots. */
    box-shadow: inset -2px 0 0 rgba(34, 36, 52, 0.24);
  }

  /* Position labels are landmarks, not a count, so only the named ones show. */
  .av-theory-fret-numbers.is-positions {
    font-size: 0.7rem;
    letter-spacing: -0.01em;
  }

  .av-theory-fret-numbers.is-positions .av-theory-fret-number.is-position {
    color: rgba(15, 23, 42, 0.85);
  }

  /* A violin has no frets, so the lines read as note positions, not stops. */
  .av-theory-fretboard.is-fretless .av-theory-fret-line:not(.is-nut)::after {
    background: repeating-linear-gradient(
      to bottom,
      rgba(34, 36, 52, 0.2) 0 4px,
      transparent 4px 9px
    );
  }

  .av-theory-fret-line.is-hidden::after {
    display: none;
  }


  .av-theory-key {
    position: relative;
    flex: 1;
    background: #ffffff;
    border: 2px solid #3a3f4d;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-size: 0.8rem;
    color: rgba(15, 23, 42, 0.7);
    box-shadow: inset 0 -6px 0 rgba(15, 23, 42, 0.04);
    overflow: hidden;
  }

  .av-theory-key.is-out-of-key {
    background: #ffffff;
    border-color: #9aa0aa;
    color: rgba(15, 23, 42, 0.25);
    box-shadow: none;
  }

  .av-theory-key.is-in-key {
    background: #ffffff;
    border-color: #9aa0aa;
    box-shadow: inset 0 -6px 0 rgba(15, 23, 42, 0.1);
    z-index: 1;
  }

  .av-theory-key.is-black {
    position: absolute;
    width: 4.8%;
    height: 78px;
    background: #000000;
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(34, 36, 52, 0.6);
    border-radius: 0 0 8px 8px;
    z-index: 2;
    box-shadow: inset 0 -6px 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
  }

  .av-theory-key.is-black.is-out-of-key {
    background: #000000;
    color: rgba(255, 255, 255, 0.35);
    border-color: rgba(34, 36, 52, 0.45);
    box-shadow: none;
  }

  .av-theory-key.is-black.is-in-key {
    background: #000000;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 -6px 0 rgba(255, 255, 255, 0.12);
    z-index: 3;
  }

  .av-theory-keyboard .av-theory-key.is-in-key {
    color: #1f3148;
    font-weight: 600;
  }

  .av-theory-keyboard .av-theory-key.is-black.is-in-key {
    color: #ffffff;
    font-weight: 600;
  }

  .av-theory-keyboard .av-theory-key.is-root {
    border-color: #76bc79;
    border-width: 3px;
    font-weight: 800;
  }

  .av-theory-keyboard .av-theory-key.is-black.is-root {
    border-color: #76bc79;
    border-width: 3px;
    font-weight: 800;
  }

  .av-theory-keyboard .av-theory-key.is-root::before {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: inherit;
    background: repeating-linear-gradient(
      135deg,
      rgba(118, 188, 121, 0.25),
      rgba(118, 188, 121, 0.25) 4px,
      rgba(118, 188, 121, 0.08) 4px,
      rgba(118, 188, 121, 0.08) 8px
    );
    pointer-events: none;
    z-index: 0;
  }

  .av-theory-keyboard .av-theory-key.is-black.is-root::before {
    inset: 1px;
    background: repeating-linear-gradient(
      135deg,
      rgba(118, 188, 121, 0.35),
      rgba(118, 188, 121, 0.35) 4px,
      rgba(34, 36, 52, 0.85) 4px,
      rgba(34, 36, 52, 0.85) 8px
    );
  }

  .av-theory-keyboard .av-theory-key.is-out-of-key {
    background: #ffffff;
    border-color: #c7cbd4;
  }

  .av-theory-keyboard .av-theory-key.is-black.is-out-of-key {
    background: #000000;
    border-color: #2b303d;
  }

  .av-theory-keyboard .av-theory-key-label {
    position: relative;
    z-index: 1;
  }

  .av-theory-key-label {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    line-height: 1;
    margin-bottom: 4px;
  }

  .av-theory-key-label-text {
    font-size: 0.85rem;
  }

  .av-theory-key.is-black .av-theory-key-label-text {
    font-size: 0.78rem;
  }

  .av-theory-key-bubble {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    display: inline-block;
  }

  .av-theory-key-bubble.is-root {
    background: #76bc79;
    border-color: #437457;
  }

  .av-theory-key-bubble.is-third {
    background: #d7ac4f;
    border-color: #8a7b47;
  }

  .av-theory-key-bubble.is-fifth {
    background: #35abb2;
    border-color: #2f9398;
  }

  .av-theory-key-bubble.is-other {
    background: #ffffff;
    border-color: #9aa0aa;
  }


  /* Each C on the keyboard carries its octave; middle C (C4) is marked in teal. */
  .av-theory-key-octave {
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(15, 23, 42, 0.45);
  }

  .av-theory-key.is-middle-c {
    box-shadow: inset 0 -5px 0 #35abb2;
  }

  .av-theory-key.is-middle-c .av-theory-key-octave {
    color: #176269;
  }

  .av-theory-hidden {
    display: none;
  }

@media (max-width: 768px) {
    .av-theory-fretboard {
      --av-fretboard-padding: 12px;
      --av-fret-gap: 4px;
      --av-fret-min-width: 18px;
      --av-fret-grid: repeat(var(--av-fret-columns, 13), minmax(var(--av-fret-min-width), 1fr));
    }

    .av-theory-helper {
      padding: 16px;
    }

    /* Phones: the sentence wraps by phrase; each word is a 44px target, and the
       tuning drops its strings (they head the neck). */
    .av-theory-word {
      min-height: 44px;
    }

    .av-theory-word--key {
      font-size: 1.3rem;
    }

    .av-theory-word__extra {
      display: none;
    }

    /* The key picker and the instrument menu become bottom sheets. */
    .av-theory-picker-backdrop {
      display: block;
      position: fixed;
      inset: 0;
      z-index: 1040;
      background: rgba(15, 23, 42, 0.45);
    }

    .av-theory-picker,
    .av-theory-picker--menu {
      position: fixed;
      top: auto;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 1041;
      width: auto;
      max-width: none;
      max-height: 85vh;
      overflow-y: auto;
      padding: 10px 16px 24px;
      border: 0;
      border-radius: 20px 20px 0 0;
      box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.18);
    }

    .av-theory-picker::before {
      content: "";
      align-self: center;
      flex: none;
      width: 40px;
      height: 5px;
      border-radius: 999px;
      background: rgba(15, 23, 42, 0.2);
    }

    .av-theory-picker__roots {
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 6px;
    }

    .av-theory-picker__modes {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
    }

    .av-theory-picker__option,
    .av-theory-menu__item,
    .av-theory-menu__star {
      min-height: 44px;
    }

    .av-theory-menu__star {
      width: 44px;
    }

    .av-theory-picker__done {
      align-self: stretch;
      min-height: 48px;
    }

    /* Dragging needs a mouse, so a drawn box can be moved with buttons. */
    .av-theory-box-move {
      display: inline-flex;
      flex-wrap: wrap;
    }

    .av-theory-box-move[hidden] {
      display: none !important;
    }

    /* Phones: 44px targets. */
    .av-theory-ghost,
    .av-theory-seg > button,
    .av-theory-chip {
      min-height: 44px;
    }

    .av-theory-seg {
      display: flex;
    }

    .av-theory-seg > button {
      flex: 1 1 auto;
      padding: 0 8px;
      white-space: nowrap;
    }

    .av-theory-tools__item[data-role="box-group"] {
      flex: 1 1 auto;
    }

    /* Phones offer one or two octaves (Range offers to fret 12 the same way). */
    .av-theory-wide-only {
      display: none !important;
    }

    .av-theory-box-select {
      width: auto !important;
      flex: 1 1 auto;
    }

    .av-theory-label-toggle {
      margin-left: 0;
      flex: 1 1 100%;
    }

    /* The seven tones in one row: the degree over the note name. */
    .av-theory-tones {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      gap: 5px;
      width: 100%;
    }

    .av-theory-summary-cell {
      flex-direction: column;
      justify-content: center;
      gap: 3px;
      min-width: 0;
      min-height: 56px;
      padding: 4px 0;
    }

    .av-theory-show {
      margin-left: 0;
      width: 100%;
    }

    .av-theory-show .av-theory-quick-filters {
      flex: 1 1 auto;
    }

    .av-theory-keyboard {
      padding: 12px;
      height: 120px;
    }

    .av-theory-key.is-black {
      height: 68px;
    }

    .av-theory-key-label-text {
      font-size: 0.78rem;
    }

    .av-theory-key.is-black .av-theory-key-label-text {
      font-size: 0.7rem;
    }

    .av-theory-string {
      grid-template-columns: var(--av-fret-grid);
      gap: var(--av-fret-gap);
    }

    .av-theory-note {
      min-height: 22px;
      font-size: 0.72rem;
    }

    .av-theory-markers,
    .av-theory-fret-numbers {
      grid-template-columns: var(--av-fret-grid);
      gap: var(--av-fret-gap);
    }

    .av-theory-fret-lines,
    .av-theory-box-overlay {
      grid-template-columns: var(--av-fret-grid);
      gap: var(--av-fret-gap);
      inset: var(--av-fretboard-padding);
    }
  }
}
