:root {
  /* Core surfaces */
  --page-background: #f2efe8;
  --header-background: #fdfbf7;
  --sidebar-background: #eee9df;
  --surface: #f7f4ee;
  --surface-raised: #fdfbf7;
  --inner-background: #ede8de;
  --input-background: #f5f1e9;
  --control-background: #e9e4da;
  --notation-background: #faf7f0;
  --library-module-surface: rgb(74 65 53 / 4%);

  /* Typography */
  --text: #302c27;
  --strong-text: #211e1a;
  --muted: #665f56;
  --muted-text: #756e64;
  --notation-ink: #332f2a;

  /* Dividers */
  --line: #cec6ba;
  --line-soft: #e2dbd0;
  --pattern-outline: #176f9f;

  /* Primary studio blue */
  --blue: #156f9e;
  --blue-dark: #0c5278;
  --accent: #156f9e;
  --active-soft: #dcebf0;

  /* Secondary amber and statuses */
  --orange: #a9570b;
  --success: #16735b;
  --success-soft: #e4f1eb;
  --danger: #b42318;
  --danger-soft: #f8e9e5;

  /* Compatibility and library states */
  --compatibility-background: #e4eff0;
  --compatibility-hover-background: #d6e7e9;
  --compatibility-shadow: rgb(21 111 158 / 18%);
  --omni-named-background: #e7f0ed;
  --omni-named-border: #5b9088;
  --omni-exotic-background: #eee9e1;
  --omni-exotic-text: #5b554c;
  --omni-group-accent: var(--blue);

  /* Musical note roles */
  --root-note: #b95012;
  --root-note-ink: #fffaf2;
  --bass-note: #087985;
  --bass-note-ink: #fffaf2;
  --pitch-color: var(--line);
  --scale-category-accent: var(--blue);

  /* Notation action */
  --notation-accent: #156f9e;
  --notation-accent-end: #168ba4;

  /* Studio control layer */
  --studio-panel: #f6f2eb;
  --studio-panel-raised: #fdfbf7;
  --studio-recessed: #ebe5da;
  --studio-control: #e5ded2;
  --studio-control-hover: #d8d0c3;
  --studio-divider: #c9c0b3;
  --studio-focus: #147bad;
  --studio-ink: #302c27;
  --studio-muted: #6b645b;
  --studio-faint: #fffaf2;
  --studio-accent: #156f9e;
  --studio-accent-soft: #d9e9ed;
  --studio-accent-strong: #0d5b84;

  /* Overlays and shadows */
  --command-shadow: rgb(59 52 43 / 14%);
  --identifier-overlay: rgb(38 33 27 / 74%);
  --identifier-panel-shadow: 0 28px 80px rgb(59 52 43 / 20%);

  /* Match rendering */
  --match-hue: 204;
  --match-scale: 1;
  --identifier-match-card-lightness: 94%;
  --identifier-match-border-lightness: 42%;

  /* Safe structural defaults */
  --identifier-nav-height: 56px;
  --identifier-toolbar-height: 60px;
  --scale-sticky-top: calc(
    var(--identifier-nav-height) + var(--identifier-toolbar-height) + 12px
  );
  --chord-sticky-top: calc(
    var(--identifier-nav-height) + var(--identifier-toolbar-height) + 12px
  );
  --identifier-instrument-scale: 1;
  --identifier-scaled-height: auto;
  --engine-slider-index: 0;
  --select-content-width: 14ch;
  --staff-render-width: 392px;
  --staff-render-height: 220px;
  --ascii-fit-font-size: 11px;
  --ascii-lines: 6;
  --string-thickness: 1px;
}

:root[data-theme="dark"] {
  /* Core surfaces */
  --page-background: #0b0e12;
  --header-background: #0d1116;
  --sidebar-background: #0f141a;
  --surface: #12171d;
  --surface-raised: #171d24;
  --inner-background: #0e1318;
  --input-background: #10161c;
  --control-background: #181f27;
  --notation-background: #0d1319;
  --library-module-surface: rgb(255 255 255 / 3%);

  /* Typography */
  --text: #f3f6f9;
  --strong-text: #ffffff;
  --muted: #aeb9c6;
  --muted-text: #9aa7b6;
  --notation-ink: #eaf0f6;

  /* Dividers */
  --line: #343e49;
  --line-soft: #242c35;
  --pattern-outline: #4da3cc;

  /* Primary studio blue */
  --blue: #267fae;
  --blue-dark: #185f84;
  --accent: #328bb8;
  --active-soft: #18384a;

  /* Secondary amber and statuses */
  --orange: #e08a2e;
  --success: #4bbd96;
  --success-soft: #163128;
  --danger: #ff7070;
  --danger-soft: #32191d;

  /* Compatibility and library states */
  --compatibility-background: #132b38;
  --compatibility-hover-background: #193a4b;
  --compatibility-shadow: rgb(50 139 184 / 20%);
  --omni-named-background: #142d31;
  --omni-named-border: #3b8991;
  --omni-exotic-background: #171d24;
  --omni-exotic-text: #c5ced8;

  /* Musical note roles */
  --root-note: #d47718;
  --root-note-ink: #190d03;
  --bass-note: #2fa1ac;
  --bass-note-ink: #04181a;

  /* Notation action */
  --notation-accent: #267fae;
  --notation-accent-end: #278f9f;

  /* Studio control layer */
  --studio-panel: #12171d;
  --studio-panel-raised: #171d24;
  --studio-recessed: #0d1217;
  --studio-control: #1e2630;
  --studio-control-hover: #28333f;
  --studio-divider: #333e4a;
  --studio-focus: #56acd5;
  --studio-ink: #f4f7fa;
  --studio-muted: #a4afbd;
  --studio-faint: #e3e9ef;
  --studio-accent: #267fae;
  --studio-accent-soft: #18394b;
  --studio-accent-strong: #4ca4cf;

  /* Overlays and shadows */
  --command-shadow: rgb(0 0 0 / 45%);
  --identifier-overlay: rgb(2 5 8 / 84%);
  --identifier-panel-shadow: 0 30px 90px rgb(0 0 0 / 58%);

  /* Match rendering */
  --identifier-match-card-lightness: 22%;
  --identifier-match-border-lightness: 47%;
}

/* Chord Identifier ------------------------------------------------------- */

.identifier-results-layout,
.identifier-weak-content {
  display: grid;
  gap: 20px;
}

.identifier-tier-group {
  min-width: 0;
}

.identifier-tier-heading {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identifier-tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.identifier-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.identifier-card:hover {
  border-color: var(--blue);
  box-shadow: 0 7px 20px rgb(0 0 0 / 10%);
  transform: translateY(-1px);
}

.identifier-card:focus-visible,
.identifier-card-action:focus-visible,
.identifier-weak-matches summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.identifier-card-featured {
  grid-column: span 2;
}

.identifier-card.tier-1-match {
  border-color: color-mix(in srgb, var(--success) 58%, var(--line));
  background: color-mix(in srgb, var(--success-soft) 58%, var(--surface));
}

.identifier-card.tier-2-match {
  border-color: color-mix(in srgb, var(--blue) 42%, var(--line));
  background: color-mix(in srgb, var(--blue) 6%, var(--surface));
}

.identifier-card.tier-3-match {
  opacity: 0.84;
}

.identifier-card.tier-4-match {
  opacity: 0.68;
}

.identifier-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.identifier-card-heading {
  min-width: 0;
}

.identifier-card-title {
  margin: 0;
  overflow: hidden;
  color: var(--strong-text);
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identifier-card-metadata {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.identifier-match-score {
  color: var(--success);
  font-weight: 740;
}

.identifier-card-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
}

.identifier-card-action {
  display: inline-grid;
  width: 27px;
  height: 27px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.identifier-card-action:hover {
  background: var(--surface-raised);
  color: var(--blue);
}

.identifier-formula-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 13px;
}

.identifier-formula-badge {
  min-width: 29px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 720;
  line-height: 1.3;
  text-align: center;
}

.identifier-formula-badge.is-matched {
  background: var(--blue);
  color: #fff;
}

.identifier-formula-badge.is-missing {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  opacity: 0.62;
}

.identifier-formula-badge.is-extra {
  border-color: color-mix(in srgb, var(--danger) 52%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}

.identifier-weak-matches {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.identifier-weak-matches summary {
  width: fit-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
}

.identifier-weak-content {
  margin-top: 14px;
}

.identifier-empty-message {
  margin: 0;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 620px) {
  .identifier-tier-grid {
    grid-template-columns: 1fr;
  }

  .identifier-card-featured {
    grid-column: span 1;
  }
}

/* Chord Anthropology dashboard ------------------------------------------ */

.chord-analysis-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.chord-anthropology-column,
.chord-mini-data-card {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--surface);
}

.chord-anthropology-column {
  padding: 18px;
}

.rootless-warning-badge {
  width: fit-content;
  margin-bottom: 12px;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 58%, var(--line));
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.02em;
}

.chord-anthropology-title,
.chord-mini-data-title {
  margin: 0;
  color: var(--strong-text);
}

.chord-anthropology-title {
  font-size: 18px;
}

.chord-anthropology-layers {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.anthropology-layer {
  display: grid;
  min-height: 62px;
  grid-template-columns: minmax(130px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-raised);
}

.anthropology-layer-title {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.anthropology-layer-tones {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.anthropology-tone {
  display: grid;
  min-width: 58px;
  gap: 1px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.anthropology-interval-name {
  font-size: 9px;
  font-weight: 760;
}

.anthropology-note-name {
  font-size: 13px;
  line-height: 1.1;
}

.anthropology-tone.is-matched {
  border-color: color-mix(in srgb, var(--success) 48%, var(--line));
  background: var(--success-soft);
  color: var(--success);
}

.anthropology-tone.is-missing {
  border-color: var(--line);
  border-style: dashed;
  background: transparent;
  color: var(--muted);
  opacity: 0.62;
}

.anthropology-tone.is-extra {
  border-color: color-mix(in srgb, var(--danger) 52%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
}

.anthropology-layer-empty {
  color: var(--muted);
  font-size: 11px;
  opacity: 0.65;
}

.chord-mini-data-card {
  align-self: start;
  padding: 18px;
  box-shadow: 0 12px 30px rgb(0 0 0 / 9%);
}

.chord-mini-data-eyebrow {
  color: var(--blue);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chord-mini-data-title {
  margin-top: 5px;
  font-size: 21px;
  line-height: 1.2;
}

.chord-mini-data-list {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
  gap: 0;
  margin: 16px 0 0;
  border-top: 1px solid var(--line-soft);
}

.chord-mini-data-list dt,
.chord-mini-data-list dd {
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
}

.chord-mini-data-list dt {
  color: var(--muted);
}

.chord-mini-data-list dd {
  overflow-wrap: anywhere;
  color: var(--strong-text);
  font-weight: 680;
  text-align: right;
}

.chord-mini-formula {
  font-variant-numeric: tabular-nums;
}

.chord-mini-binary {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* Unified top-navigation dropdowns -------------------------------------- */

.omni-library-tabs .nav-dropdown {
  position: relative;
  align-self: stretch;
}

.omni-library-tabs .nav-dropdown > summary {
  display: flex;
  min-height: 100%;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 730;
  list-style: none;
}

.omni-library-tabs .nav-dropdown > summary::-webkit-details-marker {
  display: none;
}

.omni-library-tabs .nav-dropdown > summary::after {
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  content: "";
  transform: translateY(-1px) rotate(45deg);
  transition: transform 140ms ease;
}

.omni-library-tabs .nav-dropdown[open] > summary::after {
  transform: translateY(2px) rotate(225deg);
}

.omni-library-tabs .nav-dropdown > summary:hover,
.omni-library-tabs .nav-dropdown[open] > summary,
.omni-library-tabs .nav-dropdown:has(a[aria-current="page"]) > summary {
  color: var(--text);
}

.omni-library-tabs .nav-dropdown:has(a[aria-current="page"]) > summary {
  border-bottom-color: var(--blue);
}

.omni-library-tabs .nav-dropdown > summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.omni-library-tabs .nav-dropdown:not([open]) > .nav-dropdown-menu {
  display: none;
}

.omni-library-tabs .nav-dropdown > .nav-dropdown-menu {
  z-index: 40;
  top: calc(100% + 6px);
  width: max-content;
  min-width: 168px;
  max-width: calc(100vw - 24px);
  border-radius: 8px;
}

.omni-library-tabs .nav-dropdown > .nav-dropdown-menu a {
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  font-size: 11px;
  white-space: nowrap;
}

@media (max-width: 800px) {
  .chord-analysis-dashboard {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .anthropology-layer {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .omni-library-tabs .nav-dropdown > summary {
    padding: 5px;
    font-size: 9px;
  }

  .omni-library-tabs .nav-dropdown > .nav-dropdown-menu {
    left: -7px;
  }
}

/* Article catalog ------------------------------------------------------- */

.article-catalog-main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(52px, 8vw, 96px) 0 clamp(72px, 10vw, 120px);
}

.article-catalog-hero {
  max-width: 820px;
  padding-bottom: clamp(36px, 6vw, 60px);
  border-bottom: 1px solid var(--line);
}

.article-catalog-eyebrow {
  margin: 0 0 16px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.article-catalog-hero h1 {
  max-width: 780px;
  margin: 0;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 7vw, 70px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.02;
  text-wrap: balance;
}

.article-catalog-intro {
  max-width: 660px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.65;
}

.article-catalog-section {
  padding-top: clamp(34px, 5vw, 54px);
}

.article-catalog-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.article-catalog-section-heading h2 {
  margin: 0;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.2;
}

.article-catalog-section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 24px);
}

.article-catalog-card {
  display: flex;
  min-width: 0;
  min-height: 310px;
  flex-direction: column;
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.article-catalog-card:hover {
  border-color: var(--line-soft);
  box-shadow: 0 14px 30px var(--compatibility-shadow);
  transform: translateY(-4px);
}

.article-catalog-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.article-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.article-card-category {
  color: var(--blue);
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.article-catalog-card h2 {
  margin: 0 0 16px;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(23px, 2.4vw, 30px);
  font-weight: 700;
  letter-spacing: -.018em;
  line-height: 1.16;
  text-wrap: balance;
}

.article-catalog-card p {
  margin: 0 0 28px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}

.article-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  color: var(--blue);
  font-size: 13px;
  font-weight: 780;
}

.article-card-cta span {
  transition: transform 180ms ease;
}

.article-catalog-card:hover .article-card-cta span {
  transform: translateX(4px);
}

.article-catalog-status,
.article-catalog-noscript {
  grid-column: 1 / -1;
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.article-catalog-status[data-state="error"],
.article-catalog-noscript h1 {
  color: var(--danger);
}

.article-catalog-noscript {
  width: min(720px, calc(100% - 32px));
  margin: 40px auto;
}

@media (max-width: 900px) {
  .article-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .article-catalog-main {
    width: min(100% - 24px, 1120px);
    padding-top: 40px;
  }

  .article-catalog-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .article-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-catalog-card {
    min-height: 280px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .article-catalog-card,
  .article-card-cta span {
    transition: none;
  }

  .article-catalog-card:hover {
    transform: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--page-background);
  color: var(--text);
}

.app-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--header-background);
}

.app-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 680;
  letter-spacing: 0;
}

.selection-summary {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.selection-summary strong {
  color: var(--text);
  font-size: 17px;
  letter-spacing: 0;
}

.selection-mode {
  color: var(--orange);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.control-shell {
  border-bottom: 1px solid var(--line-soft);
  background: var(--control-background);
}

.control-toolbar {
  display: flex;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 40px);
}

.control-panel-toggle {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 9px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.control-panel-toggle::after {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  content: "";
  transform: rotate(225deg);
  transition: transform 180ms ease;
}

.control-panel-toggle[aria-expanded="false"]::after {
  transform: rotate(45deg);
}

.control-panel-toggle:hover {
  color: var(--blue);
}

.control-panel-toggle:focus-visible,
.control-field select:focus-visible,
.segmented-control input:focus-visible + label {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.control-panel {
  max-height: 150px;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition:
    max-height 220ms ease,
    opacity 160ms ease,
    visibility 0s linear;
}

.control-panel.is-collapsed {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    max-height 220ms ease,
    opacity 140ms ease,
    visibility 0s linear 220ms;
}

.control-panel-inner {
  display: grid;
  width: 100%;
  max-width: 1600px;
  grid-template-columns: minmax(140px, 0.7fr) minmax(210px, 0.9fr) minmax(
      220px,
      1.4fr
    );
  gap: 18px;
  margin: 0 auto;
  padding: 2px clamp(16px, 3vw, 40px) 18px;
}

.control-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}

.control-field > span,
.control-field legend {
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.control-field select {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.segmented-control {
  display: grid;
  height: 38px;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.segmented-control label {
  display: grid;
  min-width: 0;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.segmented-control label + input + label {
  border-left: 1px solid var(--line);
}

.segmented-control input:checked + label {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--blue);
}

#selection-notes {
  overflow: hidden;
  max-width: 36vw;
  text-overflow: ellipsis;
  font-size: 13px;
}

.instrument-workspace {
  width: 100%;
}

.instrument-section {
  width: 100%;
  padding: 24px clamp(16px, 3vw, 40px) 30px;
  border-bottom: 1px solid var(--line-soft);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.instrument-viewport {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--inner-background);
  scrollbar-color: #4a5158 #171a1d;
  scrollbar-width: thin;
}

.notation-layout {
  display: grid;
  width: 100%;
  max-width: 1600px;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 0.8fr);
  gap: 24px;
  margin: 0 auto;
}

.staff-container {
  width: 100%;
  min-height: 210px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--notation-background);
  scrollbar-color: #737b83 #d8dce0;
  scrollbar-width: thin;
}

.staff-container svg {
  display: block;
}

.notation-fallback {
  display: grid;
  min-height: 210px;
  place-items: center;
  padding: 24px;
  color: var(--notation-ink);
  font-size: 13px;
}

.analysis-container {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 18px 0;
}

.analysis-group {
  display: grid;
  gap: 9px;
}

.analysis-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.analysis-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.analysis-value {
  min-width: 36px;
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.acoustic-data-panel {
  display: grid;
  width: 100%;
  max-width: 1600px;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 28px;
  margin: 20px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.acoustic-section {
  min-width: 0;
}

.acoustic-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.acoustic-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.acoustic-table th,
.acoustic-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.acoustic-table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.acoustic-table td {
  color: var(--text);
}

.acoustic-table th:nth-child(2),
.acoustic-table td:nth-child(2) {
  width: 76px;
  text-align: center;
}

.harmonic-grid {
  display: grid;
  gap: 12px;
}

.harmonic-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.harmonic-label {
  padding-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.harmonic-values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.harmonic-value {
  min-width: 34px;
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.fretboard-viewport {
  padding-bottom: 2px;
}

.guitar-analysis-panel {
  width: 100%;
  max-width: 1600px;
  margin: 14px auto 0;
}

.guitar-analysis-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.guitar-analysis-heading h3,
.caged-indicator > span {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.caged-indicator {
  display: flex;
  align-items: center;
  gap: 9px;
}

#caged-badge {
  min-width: 74px;
  padding: 5px 8px;
  border: 1px solid var(--omni-named-border);
  border-radius: 4px;
  background: var(--compatibility-background);
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  text-align: center;
}

#caged-badge[data-available="false"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

#ascii-tab-container {
  width: 100%;
  margin: 0;
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c0e10;
  color: #dce5ed;
  font-family: monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
  scrollbar-color: #4a5158 #171a1d;
  scrollbar-width: thin;
  white-space: pre;
}

.geometry-panel {
  width: 100%;
  max-width: 1600px;
  margin: 22px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.geometry-panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.geometry-panel-heading h3,
.geometry-map h4 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

.geometry-panel-heading span {
  color: var(--muted);
  font-size: 11px;
}

.geometry-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(440px, 1.15fr);
  align-items: start;
  gap: 22px;
}

.geometry-map {
  min-width: 0;
}

.geometry-map h4 {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.geometry-container {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--inner-background);
}

.geometry-container svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.geometry-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
}

.geometry-grid-edge {
  stroke: var(--line-soft);
  stroke-width: 1.35;
  vector-effect: non-scaling-stroke;
}

.geometry-active-edge {
  stroke: #ff9d5c;
  stroke-linecap: round;
  stroke-width: 3.2;
  filter: drop-shadow(0 0 4px rgb(255 145 77 / 48%));
}

.geometry-active-polygon {
  fill: rgb(85 169 255 / 10%);
  stroke: #ff9d5c;
  stroke-linejoin: round;
  stroke-width: 3.2;
  filter: drop-shadow(0 0 4px rgb(255 145 77 / 42%));
  vector-effect: non-scaling-stroke;
}

.geometry-node-shape {
  fill: var(--surface-raised);
  stroke: var(--line);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.geometry-node-label {
  fill: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  pointer-events: none;
}

.geometry-node.is-active .geometry-node-shape {
  fill: var(--compatibility-background);
  stroke: var(--blue);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 5px var(--compatibility-shadow));
}

.geometry-node.is-active .geometry-node-label {
  fill: var(--strong-text);
}

.circle-map .geometry-container {
  max-width: 560px;
  margin: 0 auto;
}

.tonnetz-map .geometry-container {
  margin-top: clamp(0px, 5vw, 76px);
}

.visual-data-panel {
  width: 100%;
  max-width: 1600px;
  margin: 22px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.visual-data-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.visual-data-heading h3,
.visual-data-map h4 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

.visual-data-heading span {
  color: var(--muted);
  font-size: 11px;
}

.visual-data-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(440px, 1.2fr);
  align-items: start;
  gap: 22px;
}

.visual-data-map {
  min-width: 0;
}

.visual-data-map h4 {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.color-wheel-container,
.semitone-matrix-container {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--inner-background);
}

.color-wheel-container {
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
}

.color-wheel-container svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.color-wheel-segment {
  fill: var(--surface-raised);
  stroke: var(--line);
  stroke-width: 1.5;
  transition:
    fill 160ms ease,
    opacity 160ms ease;
  vector-effect: non-scaling-stroke;
}

.color-wheel-segment.is-active {
  filter: drop-shadow(0 0 7px currentColor);
  stroke-width: 2.4;
}

.color-wheel-label {
  fill: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
  pointer-events: none;
}

.color-wheel-label.is-active {
  fill: var(--strong-text);
}

.palette-segment {
  opacity: 0.92;
  stroke: var(--inner-background);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.palette-center {
  fill: var(--inner-background);
  stroke: var(--line);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.semitone-matrix-container {
  overflow: auto;
  scrollbar-color: var(--line) var(--surface);
  scrollbar-width: thin;
}

.semitone-matrix {
  width: 100%;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.semitone-matrix th,
.semitone-matrix td {
  min-width: 48px;
  height: 42px;
  padding: 7px 9px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  text-align: center;
}

.semitone-matrix th {
  background: var(--surface-raised);
  color: var(--strong-text);
  font-size: 11px;
  font-weight: 750;
  box-shadow: inset 0 2px 0 var(--pitch-color, var(--line));
}

.semitone-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.semitone-matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
}

.semitone-matrix .matrix-corner {
  left: 0;
  z-index: 3;
  min-width: 82px;
  color: var(--muted);
  box-shadow: none;
}

.semitone-matrix td {
  background: var(--inner-background);
  color: var(--muted);
}

.semitone-matrix td[data-distance="0"] {
  background: var(--compatibility-background);
  color: var(--blue);
  font-weight: 800;
}

.fretboard-grid {
  display: grid;
  width: max-content;
  min-width: 100%;
  align-items: stretch;
}

.fret-label,
.string-label {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: #14171a;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.fret-label {
  height: 27px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line);
}

.fret-corner,
.string-label {
  position: sticky;
  left: 0;
  z-index: 4;
  border-right: 1px solid var(--line);
}

.string-label {
  height: 46px;
  color: #cbd0d5;
  font-size: 11px;
  font-weight: 700;
}

.fret-cell {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border-right: 1px solid #454b51;
  background: var(--surface);
}

.fret-cell::before {
  position: absolute;
  z-index: 0;
  width: 100%;
  height: var(--string-thickness, 1px);
  background: #a5abb1;
  content: "";
  box-shadow: 0 1px 0 rgb(0 0 0 / 40%);
}

.fret-cell.landmark-fret::after {
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #626a72;
  content: "";
}

.fret-cell.open-position,
.fret-cell.capo-position {
  background: var(--surface-raised);
}

.fret-cell.capo-position {
  border-left: 3px solid var(--orange);
}

.fret-note-label {
  position: relative;
  z-index: 2;
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid #89c5ff;
  border-radius: 50%;
  background: var(--blue-dark);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 0 0 2px rgb(12 14 16 / 72%);
}

.fret-cell.active-note {
  background: #1a252f;
}

.piano-viewport {
  padding: 14px;
}

.piano-keyboard {
  position: relative;
  height: 184px;
  min-width: max-content;
}

.piano-key {
  position: absolute;
  top: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  user-select: none;
}

.white-key {
  z-index: 1;
  width: 42px;
  height: 180px;
  border: 1px solid #777d83;
  border-top: 0;
  background: #e7e9eb;
  color: #14171a;
}

.black-key {
  z-index: 2;
  width: 26px;
  height: 112px;
  border: 1px solid #050607;
  background: #1a1d20;
  color: #ffffff;
  box-shadow: 0 4px 5px rgb(0 0 0 / 55%);
}

.white-key.active-note {
  border-color: #8dcbff;
  background: var(--blue);
  color: #07121b;
}

.black-key.active-note {
  border-color: #ffb27f;
  background: var(--orange);
  color: #241005;
}

.piano-note-label {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  background: rgb(255 255 255 / 88%);
  color: #111418;
  font-size: 10px;
  font-weight: 800;
}

.black-key .piano-note-label {
  background: rgb(22 12 6 / 82%);
  color: #ffffff;
}

@media (max-width: 700px) {
  .app-header {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .selection-summary {
    width: 100%;
    justify-content: flex-start;
    gap: 9px;
  }

  #selection-notes {
    max-width: none;
  }

  .control-panel {
    max-height: 320px;
  }

  .control-panel.is-collapsed {
    max-height: 0;
  }

  .control-panel-inner {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .instrument-section {
    padding-top: 20px;
  }

  .notation-layout {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .analysis-container {
    padding-bottom: 4px;
  }

  .acoustic-data-panel {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .guitar-analysis-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  #ascii-tab-container {
    font-size: 11px;
  }

  .geometry-panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .geometry-layout {
    grid-template-columns: 1fr;
  }

  .tonnetz-map .geometry-container {
    margin-top: 0;
  }

  .visual-data-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .visual-data-layout {
    grid-template-columns: 1fr;
  }
}

/* Stage 18.1 measured masonry and consolidated Omni workspace */
.omni-command-shell {
  box-shadow: none;
}

.omni-command-toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  padding: 7px 58px 7px clamp(12px, 2vw, 28px);
}

.omni-brand-group {
  width: 100%;
  justify-content: flex-start;
}

.omni-library-tabs a {
  padding: 6px 8px;
  font-size: 10px;
}

.omni-panel-shell {
  position: relative;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--control-background);
}

.omni-panel-shell .omni-collapse-button {
  position: absolute;
  z-index: 3;
  top: 2px;
  right: clamp(12px, 2vw, 28px);
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  font-size: 9px;
}

.omni-command-panel {
  max-height: 1800px;
  overflow: hidden;
  border-top: 0;
  transition:
    max-height 260ms ease,
    opacity 160ms ease,
    visibility 0s linear;
}

.omni-command-panel.is-collapsed {
  max-height: 0;
  overflow: hidden;
}

.omni-command-mount .omni-library-panel {
  padding: 8px clamp(12px, 2vw, 28px) 14px;
}

.omni-command-mount .omni-library-panel > .omni-library-heading {
  display: grid;
}

.omni-library-heading {
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding: 0 112px 9px 0;
}

.omni-library-title {
  display: grid;
  gap: 2px;
}

.omni-library-title h2 {
  font-size: 12px;
}

.omni-library-title span,
.omni-root-control > span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.omni-root-control {
  display: grid;
  grid-template-columns: auto 60px;
  align-items: center;
  gap: 6px;
}

.omni-root-control select {
  width: 60px;
  height: 28px;
  padding: 0 20px 0 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 10px;
  font-weight: 720;
}

.omni-selection-summary {
  min-width: 0;
  justify-content: flex-end;
  gap: 7px;
}

.omni-selection-summary strong {
  font-size: 12px;
}

.omni-selection-summary > span:last-child {
  max-width: 34ch;
  overflow: hidden;
  font-size: 9px;
  text-overflow: ellipsis;
}

.omni-command-mount .omni-library-layout {
  grid-template-columns: minmax(220px, 250px) minmax(0, 1fr);
  gap: 12px;
}

.omni-command-mount .omni-filter-panel details,
.omni-command-mount .omni-results,
.omni-filter-panel,
.omni-results-shell {
  max-height: none;
  overflow: visible;
}

.omni-filter-content {
  gap: 9px;
}

.omni-command-mount .omni-results {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 165px), 1fr));
  gap: 4px;
}

.omni-command-mount .omni-set-badge {
  min-height: 34px;
  gap: 2px;
  padding: 4px 7px;
}

.omni-command-mount .omni-set-badge strong {
  font-size: 9px;
}

.omni-command-mount .omni-set-badge span {
  font-size: 7px;
}

.omni-command-mount .omni-results-heading {
  min-height: 24px;
}

.omni-command-mount .omni-pagination {
  min-height: 30px;
  padding-top: 5px;
}

.omni-command-mount .omni-pagination button {
  min-height: 24px;
  padding: 3px 8px;
}

.omni-command-mount .omni-results-shell {
  gap: 7px;
}

.omni-command-mount .omni-results-heading,
.omni-command-mount .omni-pagination {
  min-height: 28px;
}

.floating-audio-dock {
  position: fixed;
  z-index: 60;
  top: 8px;
  right: 12px;
}

.audio-dock-toggle {
  position: relative;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--blue) 70%, var(--line));
  border-radius: 50%;
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 5px 18px rgb(0 0 0 / 28%);
}

.audio-dock-toggle::before {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
  content: "";
}

.audio-dock-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.compact-playback-bar.audio-dock-popover {
  position: absolute;
  top: 42px;
  right: 0;
  display: grid;
  width: 294px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 16px 34px rgb(0 0 0 / 32%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-7px);
  pointer-events: none;
  transition:
    opacity 140ms ease,
    transform 160ms ease,
    visibility 0s linear 160ms;
}

.floating-audio-dock:hover .audio-dock-popover,
.floating-audio-dock:focus-within .audio-dock-popover,
.floating-audio-dock.is-open .audio-dock-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition-delay: 0s;
}

.audio-dock-popover .playback-field {
  display: grid;
  width: auto;
}

.audio-dock-popover .playback-field > span,
.audio-dock-popover .preview-switch > span:last-child,
.audio-dock-popover .audio-status-badge {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
}

.audio-dock-popover .playback-field select {
  height: 32px;
  font-size: 10px;
}

.audio-dock-popover .preview-switch,
.audio-dock-popover .audio-theme-switch {
  min-height: 30px;
}

.audio-dock-popover .audio-status-badge {
  grid-column: 1 / -1;
  min-height: 28px;
}

.audio-dock-popover .audio-play-button {
  position: absolute;
  right: 12px;
  bottom: 11px;
}

.feature-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  grid-auto-rows: 4px;
  align-items: start;
  gap: 10px;
  padding: 12px clamp(10px, 1.4vw, 18px) 24px;
}

.feature-panel,
.feature-panel-wide {
  grid-column: span 4;
  align-self: start;
  height: max-content;
  padding: 11px;
}

.feature-panel-heading {
  min-height: 20px;
  margin-bottom: 8px;
  padding-bottom: 7px;
}

[data-feature-panel="fretboard"],
[data-feature-panel="piano"] {
  grid-column: span 12;
}

body[data-library-mode="chord"] .feature-grid > [data-feature-panel="grandStaff"],
body[data-library-mode="scale"] .feature-grid > [data-feature-panel="grandStaff"] {
  grid-column: span 8;
}

body[data-library-mode="chord"] .feature-grid > [data-feature-panel="asciiTab"],
body[data-library-mode="scale"] .feature-grid > [data-feature-panel="asciiTab"],
.feature-grid > [data-feature-panel="caged"] {
  grid-column: span 4;
}

body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout {
  grid-template-columns: minmax(300px, 392px) minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
}

body .staff-container[data-mode="chord"],
body .staff-container[data-mode="scale"] {
  min-height: 0;
  height: var(--staff-render-height);
  max-width: 100%;
  overflow: hidden;
}

body .staff-container svg {
  max-width: 100%;
}

.staff-container svg {
  max-height: var(--staff-render-height);
}

body[data-library-mode="chord"] .analysis-container {
  align-content: center;
  align-self: stretch;
  gap: 7px 12px;
  padding: 0;
}

body[data-library-mode="chord"] .analysis-value {
  min-width: 30px;
  padding: 3px 5px;
  font-size: 10px;
}

.caged-result {
  display: grid;
  min-height: 0;
  justify-items: center;
  gap: 7px;
  padding: 8px;
}

.chord-diagram-container {
  width: min(100%, 228px);
  margin: 0 auto;
  justify-self: center;
}

.chord-diagram-stage {
  width: min(100%, 210px);
  margin: 0 auto;
}

.chord-diagram-container svg {
  width: 210px;
  max-width: 100%;
  margin: 0 auto;
}

.chord-diagram-navigation,
.caged-shape-row {
  width: min(100%, 228px);
}

#ascii-tab-container[data-mode="chord"] {
  overflow: hidden;
  scrollbar-width: none;
}

#ascii-tab-container[data-mode="chord"]::-webkit-scrollbar {
  display: none;
}

#ascii-tab-container[data-mode="scale"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.fret-cell.pattern-note {
  box-shadow: none;
}

.fret-cell.active-note,
.fret-cell.active-note.root-note {
  background: var(--surface);
}

.fret-cell.active-note.open-position,
.fret-cell.active-note.capo-position {
  background: var(--surface-raised);
}

.fret-cell.pattern-note .fret-note-label {
  box-shadow:
    0 0 0 2px var(--pattern-outline),
    0 0 0 4px color-mix(in srgb, var(--surface) 85%, transparent);
}

.harmonic-metric,
.neo-riemannian-item,
.advanced-theory-status,
.braille-output,
.figured-bass-item,
.schenkerian-sequence {
  min-height: 0;
}

.harmonic-metric,
.neo-riemannian-item,
.figured-bass-item {
  padding: 9px;
}

@media (max-width: 1180px) {
  body[data-library-mode="chord"] .feature-grid > [data-feature-panel="grandStaff"],
  body[data-library-mode="scale"] .feature-grid > [data-feature-panel="grandStaff"],
  body[data-library-mode="chord"] .feature-grid > [data-feature-panel="asciiTab"],
  body[data-library-mode="scale"] .feature-grid > [data-feature-panel="asciiTab"],
  .feature-grid > [data-feature-panel="caged"] {
    grid-column: span 12;
  }
}

@media (max-width: 900px) {
  .omni-library-heading {
    grid-template-columns: auto auto;
    padding-right: 0;
  }

  .omni-selection-summary {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .omni-command-mount .omni-library-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .omni-command-toolbar {
    padding-right: 52px;
  }

  .omni-brand-group {
    gap: 7px;
  }

  .omni-library-tabs {
    gap: 0;
    padding-left: 6px;
  }

  .omni-library-tabs a {
    padding: 5px;
    font-size: 9px;
  }

  .omni-library-heading {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .omni-library-title > span,
  .omni-selection-summary > span:last-child {
    display: none;
  }

  .compact-playback-bar.audio-dock-popover {
    width: min(294px, calc(100vw - 24px));
  }

  .feature-panel,
  .feature-panel-wide,
  [data-feature-panel="fretboard"],
  [data-feature-panel="piano"] {
    grid-column: span 12;
  }
}

/* Final horizontal Omni layout and dense module ordering */
@media (min-width: 901px) {
  .omni-command-mount .omni-library-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .omni-command-mount .omni-filter-panel {
    padding: 0 0 9px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .omni-command-mount .omni-filter-content {
    display: grid;
    grid-template-columns: 175px 150px minmax(180px, 1fr) 138px auto;
    align-items: start;
    gap: 8px 12px;
  }

  .omni-command-mount .omni-filter-content > .omni-switch {
    grid-column: 1;
  }

  .omni-command-mount .omni-filter-field[for="omni-category-select"] {
    grid-column: 2;
  }

  .omni-command-mount .omni-filter-field[for="omni-search-input"] {
    grid-column: 3;
  }

  .omni-command-mount .omni-cardinality-group {
    grid-column: 4;
  }

  .omni-command-mount .omni-reset-button {
    grid-column: 5;
    align-self: end;
  }

  .omni-command-mount .omni-required-group {
    grid-column: 1 / span 3;
    grid-row: 2;
  }

  .omni-command-mount .omni-property-filters {
    grid-column: 4 / span 2;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .omni-command-mount .omni-interval-filters {
    grid-template-columns: repeat(11, minmax(28px, 1fr));
  }
}

.feature-grid > [data-feature-panel="fretboard"],
.feature-grid > [data-feature-panel="piano"] {
  order: -20;
}

@media (max-width: 900px) {
  .omni-command-mount .omni-filter-content {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-filter-content > *,
  .omni-command-mount .omni-filter-content > .omni-switch,
  .omni-command-mount .omni-filter-field[for="omni-category-select"],
  .omni-command-mount .omni-filter-field[for="omni-search-input"],
  .omni-command-mount .omni-cardinality-group,
  .omni-command-mount .omni-reset-button,
  .omni-command-mount .omni-required-group,
  .omni-command-mount .omni-property-filters {
    grid-column: 1;
    grid-row: auto;
  }

  .omni-command-mount .omni-property-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-interval-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Horizontal Omni filters and deterministic primary-module order */
.omni-command-mount .omni-library-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}

.omni-command-mount .omni-filter-panel {
  padding: 0 0 9px;
  border-right: 0;
  border-bottom: 1px solid var(--line-soft);
}

.omni-command-mount .omni-filter-content {
  display: grid;
  grid-template-columns: 175px 150px minmax(180px, 1fr) 138px auto;
  align-items: start;
  gap: 8px 12px;
}

.omni-command-mount .omni-filter-content > .omni-switch {
  grid-column: 1;
}

.omni-command-mount .omni-filter-field[for="omni-category-select"] {
  grid-column: 2;
}

.omni-command-mount .omni-filter-field[for="omni-search-input"] {
  grid-column: 3;
}

.omni-command-mount .omni-cardinality-group {
  grid-column: 4;
}

.omni-command-mount .omni-reset-button {
  grid-column: 5;
  align-self: end;
}

.omni-command-mount .omni-required-group {
  grid-column: 1 / span 3;
  grid-row: 2;
}

.omni-command-mount .omni-property-filters {
  grid-column: 4 / span 2;
  grid-row: 2;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.omni-command-mount .omni-interval-filters {
  grid-template-columns: repeat(11, minmax(28px, 1fr));
}

.feature-grid > [data-feature-panel="fretboard"],
.feature-grid > [data-feature-panel="piano"] {
  order: -20;
}

@media (max-width: 900px) {
  .omni-command-mount .omni-filter-content {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-filter-content > *,
  .omni-command-mount .omni-filter-content > .omni-switch,
  .omni-command-mount .omni-filter-field[for="omni-category-select"],
  .omni-command-mount .omni-filter-field[for="omni-search-input"],
  .omni-command-mount .omni-cardinality-group,
  .omni-command-mount .omni-reset-button,
  .omni-command-mount .omni-required-group,
  .omni-command-mount .omni-property-filters {
    grid-column: 1;
    grid-row: auto;
  }

  .omni-command-mount .omni-property-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-interval-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

/* Stage 12 dashboard and independently rendered feature panels */
[hidden],
.is-feature-hidden {
  display: none !important;
}

.dashboard-layout {
  display: grid;
  width: 100%;
  grid-template-columns: 248px minmax(0, 1fr);
  align-items: start;
  transition: grid-template-columns 220ms ease;
}

.master-dashboard {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 20px 16px 24px;
  border-right: 1px solid var(--line-soft);
  background: var(--sidebar-background);
  scrollbar-color: #4a5158 #171a1d;
  scrollbar-width: thin;
}

.dashboard-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--line);
}

.dashboard-heading h2,
.feature-panel-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.dashboard-heading span,
.feature-panel-heading span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.feature-categories {
  display: grid;
}

.feature-category {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 15px 4px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
}

.feature-category legend {
  width: 100%;
  margin-bottom: 3px;
  padding: 0;
  color: var(--text);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}

.feature-switch {
  display: grid;
  min-width: 0;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
}

.feature-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 30px;
  height: 16px;
  border: 1px solid #495057;
  border-radius: 8px;
  background: var(--surface-raised);
  transition:
    border-color 150ms ease,
    background-color 150ms ease;
}

.switch-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8d959d;
  content: "";
  transition:
    transform 150ms ease,
    background-color 150ms ease;
}

.feature-switch input:checked + .switch-track {
  border-color: #4b8fc8;
  background: #17334a;
}

.feature-switch input:checked + .switch-track::after {
  background: var(--blue);
  transform: translateX(14px);
}

.feature-switch input:checked ~ span:last-child {
  color: var(--text);
}

.feature-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.feature-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr));
  grid-auto-flow: dense;
  align-items: start;
  gap: 16px;
  padding: 20px clamp(14px, 2vw, 28px) 34px;
}

.feature-panel {
  min-width: 0;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.feature-panel-wide {
  grid-column: 1 / -1;
}

.compatibility-panel {
  overflow: visible;
}

.compatibility-results {
  min-width: 0;
}

.compatibility-tags {
  display: flex;
  max-height: 290px;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  overflow-y: auto;
  padding: 2px 6px 5px 2px;
  scrollbar-color: var(--line) transparent;
}

.compatibility-badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--compatibility-background);
  color: var(--text);
  font-size: 11px;
  font-weight: 680;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: none;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease,
    color 150ms ease;
}

.compatibility-badge:hover {
  border-color: var(--blue);
  background: var(--compatibility-hover-background);
  box-shadow: 0 0 14px var(--compatibility-shadow);
  color: var(--blue);
}

.compatibility-badge:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.compatibility-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.compatibility-show-all {
  margin-top: 10px;
  align-self: flex-start;
}

.omni-library-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.omni-filter-panel {
  min-width: 0;
  border-right: 1px solid var(--line-soft);
  padding-right: 18px;
}

.omni-filter-panel details {
  min-width: 0;
}

.omni-filter-panel summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  list-style: none;
}

.omni-filter-panel summary::-webkit-details-marker {
  display: none;
}

.omni-filter-panel summary::after {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  content: "";
  transform: rotate(225deg);
  transition: transform 160ms ease;
}

.omni-filter-panel details:not([open]) summary::after {
  transform: rotate(45deg);
}

.omni-filter-panel summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.omni-filter-content {
  display: grid;
  gap: 14px;
  padding-top: 12px;
}

.omni-switch {
  min-height: 26px;
}

.omni-filter-field {
  display: grid;
  gap: 6px;
}

.omni-filter-field > span,
.omni-cardinality-fields span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
}

.omni-filter-field input,
.omni-filter-field select,
.omni-cardinality-fields input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 11px;
}

.omni-filter-field input,
.omni-cardinality-fields input {
  padding: 6px 9px;
}

.omni-filter-field select {
  padding: 6px 28px 6px 9px;
}

.omni-filter-field input:focus-visible,
.omni-filter-field select:focus-visible,
.omni-cardinality-fields input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.omni-filter-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.omni-filter-group legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
}

.omni-cardinality-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.omni-cardinality-fields label {
  display: grid;
  gap: 5px;
}

.omni-interval-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.omni-interval-filters label {
  display: flex;
  min-width: 0;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--inner-background);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.omni-interval-filters label:has(input:checked) {
  border-color: var(--blue);
  background: var(--compatibility-background);
  color: var(--blue);
}

.omni-interval-filters input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--blue);
}

.omni-filter-panel .omni-hierarchy-filter {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
}

.omni-filter-panel .omni-hierarchy-filter > summary {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 9px;
  text-transform: uppercase;
}

.omni-filter-panel .omni-hierarchy-filter > summary small {
  font-size: 8px;
  text-transform: none;
}

.omni-hierarchy-options {
  display: grid;
  gap: 4px;
  padding: 0 7px 7px;
}

.omni-hierarchy-options label {
  display: grid;
  min-width: 0;
  min-height: 26px;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--inner-background);
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.omni-hierarchy-options label:has(input:checked) {
  border-color: var(--blue);
  background: var(--compatibility-background);
  color: var(--blue);
}

.omni-hierarchy-options input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--blue);
}

.omni-property-filters {
  display: grid;
  gap: 7px;
}

.omni-reset-button {
  justify-self: start;
}

.omni-results-shell {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.omni-results-heading {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.omni-results-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.omni-results-heading span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.omni-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 8px;
}

.omni-set-badge {
  display: grid;
  min-width: 0;
  min-height: 62px;
  align-content: center;
  gap: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease;
}

.omni-set-badge strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.3;
}

.omni-set-badge span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 8px;
  line-height: 1.35;
}

.omni-set-badge.is-named {
  border-color: var(--omni-named-border);
  background: var(--omni-named-background);
}

.omni-set-badge.is-named:hover {
  border-color: var(--blue);
  box-shadow: 0 0 14px var(--compatibility-shadow);
}

.omni-set-badge.is-exotic {
  border-color: var(--line-soft);
  background: var(--omni-exotic-background);
  color: var(--omni-exotic-text);
}

.omni-set-badge.is-exotic:hover {
  border-color: var(--muted);
  color: var(--text);
}

.omni-set-badge.is-selected {
  border-color: var(--orange);
  box-shadow: inset 3px 0 0 var(--orange);
}

.omni-set-badge:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.omni-empty-message {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
  font-size: 12px;
}

.omni-pagination {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.omni-pagination button {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
}

.omni-pagination button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.omni-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.omni-pagination button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.omni-pagination span {
  min-width: 78px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

@media (max-width: 900px) {
  .omni-library-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-filter-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding-right: 0;
    padding-bottom: 14px;
  }
}

@media (max-width: 480px) {
  .omni-interval-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .omni-results-heading,
  .omni-pagination {
    align-items: flex-start;
  }

  .omni-results-heading {
    flex-direction: column;
    gap: 4px;
  }

  .omni-pagination {
    justify-content: space-between;
  }
}

.feature-panel-heading {
  display: flex;
  min-height: 24px;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.feature-panel .notation-layout,
.feature-panel .instrument-viewport {
  max-width: none;
  margin: 0;
}

.data-table-container {
  width: 100%;
  overflow-x: auto;
}

.data-table-container .acoustic-table {
  min-width: 280px;
}

.caged-result {
  display: flex;
  min-height: 116px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border: 1px solid var(--line-soft);
  background: var(--inner-background);
}

.caged-result > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.harmonic-analysis-container {
  display: grid;
  gap: 18px;
}

.harmonic-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
}

.harmonic-metric {
  display: flex;
  min-width: 0;
  min-height: 68px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  background: var(--inner-background);
}

.harmonic-metric span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.harmonic-metric strong {
  overflow-wrap: anywhere;
  color: var(--strong-text);
  font-size: 13px;
  font-weight: 680;
}

.harmonic-metric.is-prominent strong {
  color: var(--orange);
  font-size: 18px;
}

.harmonic-analysis-container .harmonic-grid {
  padding: 12px;
  border: 1px solid var(--line-soft);
  background: var(--inner-background);
}

@media (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .master-dashboard {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .feature-categories {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0 20px;
  }

  .feature-grid {
    padding-top: 16px;
  }
}

@media (max-width: 560px) {
  .harmonic-summary {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .feature-panel {
    padding: 12px;
  }

  .feature-panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

/* Stage 13 inversion, voicing, and Neo-Riemannian panels */
.voicings-container {
  display: grid;
  gap: 22px;
}

.voicing-group + .voicing-group {
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.voicing-group-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}

.voicing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
}

.voicing-item {
  min-width: 0;
  padding: 14px;
  background: #111417;
}

.voicing-item-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.voicing-item-heading h4 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 720;
}

.voicing-item-heading span {
  color: var(--muted);
  font-size: 10px;
}

.voicing-sequence {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px;
}

.voicing-note {
  display: flex;
  min-width: 72px;
  flex: 1 1 72px;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  border-bottom: 2px solid #3d6f98;
  background: #182028;
}

.voicing-note strong {
  color: #dceeff;
  font-size: 14px;
}

.voicing-note span {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.neo-riemannian-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
  gap: 1px;
}

.neo-riemannian-item {
  display: grid;
  min-width: 0;
  min-height: 112px;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #111417;
}

.neo-riemannian-item > strong {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #4b8fc8;
  border-radius: 50%;
  color: var(--blue);
  font-size: 15px;
}

.neo-riemannian-item > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.neo-riemannian-item span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.neo-riemannian-item b {
  overflow-wrap: anywhere;
  color: var(--orange);
  font-size: 14px;
  font-weight: 720;
}

.advanced-theory-status {
  display: grid;
  min-height: 112px;
  margin: 0;
  place-items: center;
  padding: 18px;
  border: 1px solid var(--line-soft);
  background: #111417;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 620px) {
  .neo-riemannian-grid {
    grid-template-columns: 1fr;
  }

  .voicing-item-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

/* Stage 14 academic, historical, and accessibility notation */
.braille-container,
.figured-bass-container,
.schenkerian-container {
  min-width: 0;
}

.braille-output {
  display: flex;
  min-height: 122px;
  align-items: center;
  justify-content: center;
  overflow-wrap: anywhere;
  padding: 20px;
  border: 1px solid var(--line-soft);
  background: #111417;
  color: #dceeff;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.5;
  text-align: center;
}

.niche-notation-caption {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.figured-bass-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
  gap: 1px;
}

.figured-bass-grid[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.figured-bass-grid[data-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.figured-bass-item {
  display: flex;
  min-width: 0;
  min-height: 130px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: #111417;
}

.figured-bass-item > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  text-align: center;
}

.figured-bass-symbol {
  display: flex;
  min-width: 42px;
  min-height: 58px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  color: var(--orange);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-variant-numeric: lining-nums;
  font-weight: 700;
  line-height: 0.82;
}

.figured-bass-symbol span {
  display: block;
}

.schenkerian-sequence {
  display: flex;
  min-height: 122px;
  align-items: stretch;
  flex-wrap: wrap;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
  gap: 1px;
}

.schenkerian-degree {
  position: relative;
  display: grid;
  min-width: 78px;
  flex: 1 1 78px;
  grid-template-rows: 18px 44px 18px;
  place-items: center;
  padding: 12px 8px 10px;
  background: #111417;
}

.schenkerian-caret {
  align-self: end;
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 0.7;
}

.schenkerian-degree strong {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
}

.schenkerian-degree small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

@media (max-width: 560px) {
  .braille-output {
    justify-content: flex-start;
    overflow-x: auto;
    font-size: 30px;
    white-space: nowrap;
  }

  .figured-bass-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .figured-bass-grid[data-count="3"] {
    grid-template-columns: 1fr;
  }
}

/* Stage 15 local SoundFont playback controls */
.audio-status-badge,
.audio-play-button,
.playback-field select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}

.audio-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  background: var(--input-background);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 730;
  white-space: nowrap;
}

.audio-status-badge::before {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.audio-status-badge[data-status="loading"]::before {
  background: var(--orange);
}

.audio-status-badge[data-status="ready"] {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.audio-status-badge[data-status="ready"]::before {
  background: var(--success);
  box-shadow: 0 0 7px color-mix(in srgb, var(--success) 55%, transparent);
}

.audio-status-badge[data-status="error"] {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.audio-status-badge[data-status="error"]::before {
  background: var(--danger);
}

.audio-play-button {
  min-width: 84px;
  padding: 0 18px;
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.audio-play-button:hover:not(:disabled) {
  background: var(--blue-dark);
}

.audio-play-button:disabled,
.audio-status-badge:disabled,
.playback-field select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.audio-status-badge:focus-visible,
.audio-play-button:focus-visible,
.playback-field select:focus-visible,
.preview-playable:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.preview-playable {
  cursor: pointer;
}

/* Stage 16 navigation, routing, themes, and responsive workspace */
.top-nav {
  position: relative;
  z-index: 20;
  display: grid;
  min-height: 52px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 8px clamp(14px, 2.5vw, 32px);
  border-bottom: 1px solid var(--line);
  background: var(--header-background);
}

.top-nav-leading,
.primary-links,
.theme-switch {
  display: flex;
  align-items: center;
}

.top-nav-leading {
  gap: 11px;
}

.brand-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
  line-height: 0;
  text-decoration: none;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  width: auto;
  height: 40px;
  object-fit: contain;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-content: center;
  gap: 4px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
}

.sidebar-toggle > span {
  width: 14px;
  height: 1px;
  background: currentColor;
}

.primary-links {
  min-width: 0;
  gap: 4px;
}

.primary-links > a,
.nav-dropdown summary {
  min-height: 32px;
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
  list-style: none;
  text-decoration: none;
}

.nav-dropdown summary::-webkit-details-marker {
  display: none;
}

.primary-links > a:hover,
.nav-dropdown summary:hover,
.primary-links a[aria-current="page"] {
  color: var(--text);
}

.primary-links a[aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--blue);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  display: grid;
  min-width: 148px;
  overflow: hidden;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgb(0 0 0 / 18%);
}

.nav-dropdown-menu a {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a[aria-current="page"] {
  background: var(--surface-raised);
  color: var(--text);
}

.theme-switch {
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.theme-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.theme-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.app-header {
  min-height: 62px;
  padding: 10px clamp(14px, 2.5vw, 32px);
}

.selection-summary {
  justify-content: flex-start;
}

.compact-playback-bar {
  display: flex;
  min-width: 0;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.playback-field {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
}

.playback-field:first-child {
  width: min(190px, 24vw);
}

.playback-field select {
  width: 100%;
  padding: 0 28px 0 9px;
  background: var(--input-background);
  color: var(--text);
  font-size: 11px;
}

.preview-switch {
  min-height: 34px;
  grid-template-columns: 32px auto;
  padding: 0 5px;
}

.dashboard-layout.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.master-dashboard {
  transform: translateX(0);
  transition:
    transform 220ms ease,
    opacity 160ms ease,
    visibility 0s linear;
}

.dashboard-layout.sidebar-collapsed .master-dashboard {
  overflow: hidden;
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-100%);
  pointer-events: none;
  transition:
    transform 220ms ease,
    opacity 140ms ease,
    visibility 0s linear 220ms;
}

.feature-switch:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.45;
}

#ascii-tab-container,
.geometry-container,
.color-wheel-container,
.semitone-matrix-container,
.voicing-item,
.neo-riemannian-item,
.advanced-theory-status,
.braille-output,
.figured-bass-item,
.schenkerian-degree {
  background: var(--inner-background);
  color: var(--text);
}

.semitone-matrix th,
.fret-label,
.string-label {
  background: var(--surface-raised);
  color: var(--muted);
}

.semitone-matrix td {
  background: var(--input-background);
  color: var(--muted);
}

.voicing-note {
  background: var(--surface-raised);
}

.voicing-note strong,
.braille-output {
  color: var(--strong-text);
}

.staff-container svg {
  max-height: 210px;
}

@media (max-width: 1000px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .compact-playback-bar {
    display: grid;
    grid-template-columns: minmax(150px, 1.3fr) auto auto minmax(120px, 0.8fr) auto;
  }

  .playback-field:first-child {
    width: auto;
  }
}

@media (max-width: 900px) {
  .dashboard-layout,
  .dashboard-layout.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .master-dashboard {
    max-height: 820px;
    transition:
      max-height 220ms ease,
      opacity 160ms ease,
      visibility 0s linear;
  }

  .dashboard-layout.sidebar-collapsed .master-dashboard {
    max-height: 0;
    transform: none;
  }
}

@media (max-width: 720px) {
  .top-nav {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .primary-links {
    grid-column: 1 / -1;
    overflow-x: auto;
    border-top: 1px solid var(--line-soft);
    padding-top: 5px;
  }

  .compact-playback-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audio-status-badge,
  .audio-play-button {
    width: 100%;
  }

  .notation-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .analysis-container {
    padding: 4px 0;
  }
}

@media (max-width: 480px) {
  .feature-categories,
  .compact-playback-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand-link {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .preview-switch {
    min-height: 30px;
  }
}

/* Fixed library pages, compact notation, and interactive guitar controls */
.control-panel-inner {
  grid-template-columns: max-content max-content;
  justify-content: start;
  gap: 14px;
}

.control-field select {
  width: var(--select-content-width, 14ch);
  max-width: calc(100vw - 32px);
}

#root-note-select {
  min-width: 68px;
}

.primary-links > a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--blue);
}

body[data-library-mode="scale"] .feature-switch:has([data-mode-only="chord"]) {
  display: none;
}

body[data-library-mode="scale"] [data-library-only="chord"] {
  display: none !important;
}

.tuning-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  background: var(--inner-background);
}

.tuning-editor-heading {
  display: grid;
  gap: 3px;
  align-self: center;
}

.tuning-editor-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
}

.tuning-editor-heading span,
.tuning-string-control span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.tuning-controls {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.tuning-string-control {
  display: grid;
  gap: 4px;
}

.tuning-string-control select {
  width: 72px;
  height: 32px;
  padding: 0 23px 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 11px;
}

.secondary-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 720;
}

.secondary-button:hover {
  border-color: var(--blue);
}

.secondary-button:focus-visible,
.tuning-string-control select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

body[data-library-mode="chord"] [data-feature-panel="grandStaff"],
body[data-library-mode="chord"] [data-feature-panel="asciiTab"] {
  grid-column: auto;
}

body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.staff-container[data-mode="chord"] {
  width: min(100%, var(--staff-render-width));
  min-height: var(--staff-render-height);
}

.staff-container[data-mode="scale"] {
  min-height: var(--staff-render-height);
}

.staff-container svg {
  max-height: none;
}

body[data-library-mode="chord"] .analysis-container {
  flex-flow: row wrap;
  justify-content: flex-start;
  gap: 10px 18px;
  padding: 4px 0;
}

body[data-library-mode="chord"] .analysis-group {
  align-content: start;
}

#ascii-tab-container[data-mode="chord"] {
  width: max-content;
  max-width: 100%;
  padding: 10px 12px;
  line-height: 1.45;
}

.caged-result {
  display: grid;
  min-height: 0;
  justify-items: center;
  gap: 10px;
  padding: 12px;
}

.chord-diagram-container {
  display: grid;
  width: min(100%, 250px);
  place-items: center;
}

.chord-diagram-container svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chord-diagram-fret,
.chord-diagram-string {
  stroke: var(--muted);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.chord-diagram-nut {
  stroke: var(--text);
  stroke-width: 7;
  vector-effect: non-scaling-stroke;
}

.chord-diagram-open {
  fill: none;
  stroke: var(--text);
  stroke-width: 2;
}

.chord-diagram-mute,
.chord-diagram-fret-number {
  fill: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 750;
}

.chord-diagram-note {
  fill: var(--strong-text);
  stroke: var(--surface);
  stroke-width: 2;
}

.chord-diagram-root {
  fill: var(--orange);
}

.chord-diagram-barre {
  stroke: var(--strong-text);
  stroke-width: 14;
  stroke-linecap: round;
}

.caged-shape-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
}

.caged-shape-row > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
}

@media (max-width: 700px) {
  .control-panel-inner {
    grid-template-columns: max-content max-content;
    overflow-x: auto;
  }

  .tuning-editor {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .tuning-controls {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 420px) {
  .control-panel-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .control-field select {
    width: min(100%, var(--select-content-width, 14ch));
  }

  .tuning-editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .tuning-controls,
  .secondary-button {
    grid-column: 1;
  }

  .tuning-string-control {
    flex: 1 1 70px;
  }

  .tuning-string-control select {
    width: 100%;
  }
}

/* Stage 18 compact Omni command surface and geometric workspace */
:root {
  --root-note: #d8641d;
  --root-note-ink: #ffffff;
  --bass-note: #087f73;
  --bass-note-ink: #ffffff;
  --pattern-outline: #0e7898;
  --command-shadow: rgb(24 39 52 / 10%);
}

:root[data-theme="dark"] {
  --root-note: #ff914d;
  --root-note-ink: #1a0c03;
  --bass-note: #2dd4bf;
  --bass-note-ink: #062a26;
  --pattern-outline: #55c7e8;
  --command-shadow: rgb(0 0 0 / 32%);
}

.fret-cell.active-note.bass-note .fret-note-label,
.piano-key.active-note.bass-note,
.voicing-note.bass-note {
  border-color: color-mix(in srgb, var(--bass-note) 72%, white);
  background: var(--bass-note);
  color: var(--bass-note-ink);
}

.fret-cell.active-note.root-note.bass-note .fret-note-label,
.piano-key.active-note.root-note.bass-note {
  border-color: color-mix(in srgb, var(--root-note) 72%, white);
  background: var(--root-note);
  color: var(--root-note-ink);
}

.omni-command-shell {
  position: relative;
  z-index: 15;
  border-bottom: 1px solid var(--line);
  background: var(--header-background);
  box-shadow: 0 8px 24px var(--command-shadow);
}

.omni-command-toolbar {
  display: grid;
  min-height: 54px;
  grid-template-columns: auto minmax(170px, 1fr) auto auto auto;
  align-items: center;
  gap: 14px;
  padding: 8px clamp(12px, 2vw, 28px);
}

.omni-brand-group,
.omni-library-tabs,
.omni-command-toolbar .theme-switch {
  display: flex;
  align-items: center;
}

.omni-brand-group {
  gap: 14px;
}

.omni-library-tabs {
  gap: 2px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.omni-library-tabs a {
  padding: 7px 9px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 730;
  text-decoration: none;
}

.omni-library-tabs a:hover,
.omni-library-tabs a[aria-current="page"] {
  color: var(--text);
}

.omni-library-tabs a[aria-current="page"] {
  border-bottom-color: var(--blue);
}

.omni-command-toolbar .selection-summary {
  justify-content: flex-start;
  gap: 8px;
}

.omni-command-toolbar .selection-summary strong {
  font-size: 14px;
}

.omni-command-toolbar .selection-summary > span:last-child {
  max-width: 28ch;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
}

.omni-command-toolbar .compact-playback-bar {
  align-items: center;
  gap: 6px;
}

.omni-command-toolbar .playback-field {
  display: block;
}

.omni-command-toolbar .playback-field > span,
.omni-command-toolbar .preview-switch > span:last-child,
.omni-command-toolbar .audio-status-badge {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.omni-command-toolbar .playback-field:first-child {
  width: 132px;
}

.omni-command-toolbar .playback-field:nth-child(2) {
  width: 108px;
}

.omni-command-toolbar .playback-field select {
  min-height: 30px;
  height: 30px;
  padding-left: 8px;
  font-size: 10px;
}

.omni-command-toolbar .preview-switch {
  min-height: 30px;
  grid-template-columns: 30px;
  padding: 0 2px;
}

.audio-play-icon {
  position: relative;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.audio-play-icon::after {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
  content: "";
}

.omni-collapse-button {
  min-height: 30px;
  padding: 0 4px;
  white-space: nowrap;
}

.omni-command-panel {
  max-height: min(60vh, 340px);
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  background: var(--control-background);
  scrollbar-color: var(--line) transparent;
}

.omni-command-panel.is-collapsed {
  max-height: 0;
  overflow: hidden;
}

.omni-primary-controls {
  display: flex;
  max-width: none;
  align-items: end;
  gap: 10px;
  padding: 10px clamp(12px, 2vw, 28px) 8px;
}

.omni-primary-controls .control-field {
  flex: 0 0 auto;
  gap: 4px;
}

.omni-primary-controls .control-field > span {
  font-size: 9px;
}

.omni-primary-controls select {
  min-height: 30px;
  height: 30px;
  padding: 0 26px 0 8px;
  font-size: 11px;
}

.omni-command-mount .omni-library-panel {
  margin: 0;
  padding: 0 clamp(12px, 2vw, 28px) 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.omni-command-mount .omni-library-panel > .feature-panel-heading {
  display: none;
}

.omni-command-mount .omni-library-layout {
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 12px;
}

.omni-command-mount .omni-filter-panel details {
  max-height: 172px;
  overflow: auto;
}

.omni-command-mount .omni-results {
  max-height: 126px;
  overflow-y: auto;
}

.dashboard-layout {
  grid-template-columns: 238px minmax(0, 1fr);
}

.master-dashboard {
  top: 0;
  max-height: 100vh;
  padding: 14px 12px 22px;
}

.dashboard-heading {
  align-items: center;
  padding: 0 2px 10px;
}

.dashboard-heading > div {
  display: grid;
  gap: 2px;
}

.sidebar-panel-toggle {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--muted);
  cursor: pointer;
}

.sidebar-panel-toggle::after,
.diagram-arrow::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  content: "";
  transform: translate(-35%, -50%) rotate(45deg);
}

.dashboard-layout.sidebar-collapsed {
  grid-template-columns: 38px minmax(0, 1fr);
}

.dashboard-layout.sidebar-collapsed .master-dashboard {
  width: 38px;
  overflow: hidden;
  padding: 10px 4px;
  border-right: 1px solid var(--line-soft);
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.dashboard-layout.sidebar-collapsed .master-dashboard > :not(.dashboard-heading),
.dashboard-layout.sidebar-collapsed .dashboard-heading > div {
  display: none;
}

.dashboard-layout.sidebar-collapsed .dashboard-heading {
  padding: 0;
  border: 0;
}

.dashboard-layout.sidebar-collapsed .sidebar-panel-toggle::after {
  transform: translate(-65%, -50%) rotate(225deg);
}

.sidebar-compatibility {
  margin-top: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar-compatibility > summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 3px;
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
  list-style: none;
}

.sidebar-compatibility > summary::-webkit-details-marker {
  display: none;
}

.sidebar-compatibility > summary::after {
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  content: "";
  transform: rotate(45deg);
}

.sidebar-compatibility[open] > summary::after {
  transform: rotate(225deg);
}

.sidebar-compatibility > summary > span:nth-child(2) {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.sidebar-compatibility-content {
  padding: 2px 0 12px;
}

.sidebar-compatibility .compatibility-tags {
  max-height: 210px;
  gap: 5px;
}

.sidebar-compatibility .compatibility-badge {
  min-height: 25px;
  padding: 4px 6px;
  font-size: 9px;
}

.feature-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  grid-auto-rows: min-content;
  gap: 12px;
  padding: 14px clamp(10px, 1.6vw, 22px) 30px;
}

.feature-panel,
.feature-panel-wide {
  grid-column: span 4;
  align-self: start;
  padding: 13px;
}

[data-feature-panel="fretboard"],
[data-feature-panel="piano"] {
  grid-column: span 12;
}

[data-feature-panel="grandStaff"],
[data-feature-panel="asciiTab"] {
  grid-column: span 6;
}

body[data-library-mode="chord"] .feature-grid > [data-feature-panel="grandStaff"],
body[data-library-mode="chord"] .feature-grid > [data-feature-panel="asciiTab"] {
  grid-column: span 6;
}

body[data-library-mode="scale"] [data-feature-panel="grandStaff"],
body[data-library-mode="scale"] [data-feature-panel="asciiTab"] {
  grid-column: span 8;
}

.fretboard-viewport {
  width: 100%;
  overflow-x: auto;
}

.fretboard-grid {
  width: 100%;
  min-width: 1136px;
}

.fret-corner {
  display: flex;
  height: 32px;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 5px;
}

.fretboard-capo-control {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 7px;
  margin: 3px 6px;
  padding: 2px 4px 2px 9px;
  color: var(--muted-text);
  border-left: 1px solid var(--line-soft);
  background: var(--surface-raised);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fretboard-capo-select {
  width: 72px;
  height: 25px;
  padding: 0 20px 0 7px;
}

.inline-tuning-reset {
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font: inherit;
  font-size: 8px;
  font-weight: 750;
}

.fret-label {
  height: 32px;
}

.string-label {
  display: grid;
  height: 44px;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 3px;
  padding: 4px;
}

.string-number {
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.inline-tuning-select {
  width: 60px;
  min-width: 0;
  height: 27px;
  padding: 0 18px 0 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 9px;
  font-weight: 720;
}

.inline-tuning-select:focus-visible,
.inline-tuning-reset:focus-visible,
.sidebar-panel-toggle:focus-visible,
.diagram-arrow:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.fret-cell {
  width: auto;
  min-width: 42px;
  height: 44px;
}

.fret-cell.pattern-note {
  box-shadow: inset 0 0 0 1px var(--pattern-outline);
}

.fret-cell.root-note {
  background: color-mix(in srgb, var(--root-note) 19%, var(--surface));
}

.fret-cell.root-note .fret-note-label {
  border-color: color-mix(in srgb, var(--root-note) 72%, white);
  background: var(--root-note);
  color: var(--root-note-ink);
}

.instrument-degree-marker {
  position: absolute;
  z-index: 3;
  top: 2px;
  right: 3px;
  display: grid;
  min-width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid var(--pattern-outline);
  border-radius: 50%;
  background: var(--surface);
  color: var(--pattern-outline);
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
}

.piano-key.pattern-note {
  box-shadow: inset 0 0 0 2px var(--pattern-outline);
}

.piano-key.root-note,
.white-key.active-note.root-note,
.black-key.active-note.root-note {
  border-color: var(--root-note);
  background: var(--root-note);
  color: var(--root-note-ink);
}

.piano-key .instrument-degree-marker {
  top: auto;
  right: 50%;
  bottom: 42px;
  transform: translateX(50%);
}

.black-key .instrument-degree-marker {
  bottom: 39px;
}

.staff-container[data-mode="chord"] {
  width: min(100%, var(--staff-render-width));
  max-width: 100%;
  min-height: var(--staff-render-height);
  overflow: hidden;
}

.staff-container[data-mode="scale"] {
  width: 100%;
  overflow-x: auto;
}

#ascii-tab-container {
  min-height: 0;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.35;
}

.chord-diagram-container {
  width: min(100%, 268px);
}

.chord-diagram-stage {
  display: grid;
  width: min(100%, 240px);
  place-items: center;
}

.chord-diagram-navigation {
  display: grid;
  width: 100%;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
}

.diagram-arrow {
  position: relative;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
}

.diagram-arrow-next::after {
  transform: translate(-65%, -50%) rotate(225deg);
}

.diagram-arrow:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.diagram-voicing-counter {
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
  text-align: center;
}

.chord-diagram-root {
  fill: var(--root-note);
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--root-note) 55%, transparent));
}

@media (max-width: 1180px) {
  .omni-command-toolbar {
    grid-template-columns: auto minmax(160px, 1fr) auto auto;
  }

  .omni-command-toolbar .compact-playback-bar {
    grid-column: 1 / -1;
    justify-content: flex-end;
    border-top: 1px solid var(--line-soft);
    padding-top: 7px;
  }

  .feature-panel,
  .feature-panel-wide {
    grid-column: span 6;
  }

  [data-feature-panel="fretboard"],
  [data-feature-panel="piano"],
  [data-feature-panel="grandStaff"],
  [data-feature-panel="asciiTab"] {
    grid-column: span 12;
  }

  body[data-library-mode="chord"] .feature-grid > [data-feature-panel="grandStaff"],
  body[data-library-mode="chord"] .feature-grid > [data-feature-panel="asciiTab"] {
    grid-column: span 12;
  }

  body[data-library-mode="scale"] .feature-grid > [data-feature-panel="grandStaff"],
  body[data-library-mode="scale"] .feature-grid > [data-feature-panel="asciiTab"] {
    grid-column: span 12;
  }
}

@media (max-width: 900px) {
  .omni-command-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .omni-brand-group,
  .omni-command-toolbar .selection-summary {
    grid-column: 1 / -1;
  }

  .dashboard-layout,
  .dashboard-layout.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .master-dashboard {
    position: relative;
    max-height: none;
  }

  .dashboard-layout.sidebar-collapsed .master-dashboard {
    width: 100%;
    height: 38px;
    max-height: 38px;
    padding: 5px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .dashboard-layout.sidebar-collapsed .dashboard-heading {
    justify-content: flex-end;
  }

  .omni-command-mount .omni-library-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .omni-command-toolbar {
    gap: 8px;
  }

  .omni-brand-group {
    min-width: 0;
    justify-content: space-between;
  }

  .omni-brand-group .brand-link {
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .omni-command-toolbar .selection-summary > span:last-child {
    display: none;
  }

  .omni-command-toolbar .compact-playback-bar {
    display: flex;
    flex-wrap: wrap;
  }

  .omni-primary-controls {
    display: flex;
    overflow-x: auto;
  }

  .feature-panel,
  .feature-panel-wide {
    grid-column: span 12;
  }
}

/* Final Stage 18.1 precedence layer */
/* Stage 18.2 command row, full portraits, and chord-position navigation */
.top-theme-switch {
  position: fixed;
  z-index: 40;
  top: 9px;
  right: 10px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
}

body .floating-audio-dock {
  position: fixed;
  z-index: 39;
  top: 8px;
  right: 118px;
}

body .audio-dock-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

body .audio-dock-toggle.is-loading {
  opacity: 0.7;
}

body .omni-panel-shell .omni-collapse-button {
  top: 24px;
  right: clamp(12px, 2vw, 28px);
}

body .omni-command-mount .omni-library-panel > .omni-library-heading {
  grid-template-columns: auto auto minmax(140px, 210px) minmax(190px, 1fr) minmax(360px, auto);
  gap: 10px;
  padding-right: 116px;
}

.omni-formula-control {
  display: grid;
  min-width: 0;
  gap: 3px;
  color: var(--muted-text);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.omni-formula-control select {
  width: min(100%, var(--select-content-width, 22ch));
  min-height: 28px;
  padding: 4px 24px 4px 7px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 10px;
  text-transform: none;
}

body .omni-selection-summary {
  min-width: 0;
  justify-content: flex-start;
  overflow: hidden;
  white-space: nowrap;
}

body .omni-playback-controls {
  position: static;
  display: flex;
  width: auto;
  min-width: 0;
  grid-template-columns: none;
  align-items: end;
  justify-self: end;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.omni-playback-controls .playback-field {
  display: grid;
  width: auto;
  gap: 2px;
}

.omni-playback-controls .playback-field > span,
.omni-playback-controls .preview-switch > span:last-child {
  font-size: 7px;
}

.omni-playback-controls select {
  width: auto;
  min-width: 104px;
  max-width: 150px;
  min-height: 28px;
  padding: 4px 22px 4px 6px;
  font-size: 9px;
}

.omni-playback-controls .preview-switch {
  min-height: 28px;
  padding-bottom: 4px;
}

.omni-playback-controls .audio-status-badge {
  min-height: 28px;
  padding: 4px 7px;
  font-size: 8px;
}

body [data-feature-panel="grandStaff"] .notation-layout {
  align-items: stretch;
}

body .staff-container[data-mode="chord"],
body .staff-container[data-mode="scale"] {
  width: 100%;
  height: var(--staff-render-height);
}

body .staff-container svg {
  width: 100%;
  height: 100%;
}

body #ascii-tab-container {
  width: 100%;
  max-width: none;
  min-height: calc(var(--ascii-lines, 6) * 1.45em + 18px);
  padding: 10px 12px;
  overflow: hidden;
}

body .chord-diagram-container {
  width: min(100%, 310px);
}

body .chord-diagram-stage,
body .chord-diagram-container svg {
  width: min(100%, 288px);
}

body .chord-diagram-navigation,
body .caged-shape-row {
  width: min(100%, 310px);
}

.diagram-voicing-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.diagram-voicing-counter input {
  width: 54px;
  min-height: 28px;
  padding: 3px 5px;
  color: var(--strong-text);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  text-align: center;
  font: inherit;
}

.fretboard-control-bar {
  position: relative;
  display: grid;
  min-height: 34px;
  margin: 0 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface-raised);
}

.piano-control-bar {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: flex-end;
  margin: 0 0 8px;
  padding: 0 10px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface-raised);
}

/* Holds the scaled keyboard; its height is set from the applied scale so the
   panel never keeps blank space under a shrunken keyboard. */
.piano-scale-frame {
  width: 100%;
  min-width: 0;
  scrollbar-width: thin;
}

.fretboard-control-bar > .fretboard-voicing-browser,
.fretboard-control-bar > .fretboard-capo-control {
  grid-area: 1 / 1;
}

.fretboard-control-bar > .fretboard-capo-control {
  z-index: 2;
  align-self: start;
  justify-self: end;
}

.fretboard-voicing-browser {
  min-width: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.fretboard-voicing-browser > summary {
  min-height: 30px;
  padding: 7px 140px 7px 10px;
  color: var(--strong-text);
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.fretboard-voicing-strip {
  display: flex;
  gap: 4px;
  padding: 7px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.fretboard-voicing-button {
  flex: 0 0 auto;
  min-width: 28px;
  min-height: 26px;
  padding: 3px 6px;
  color: var(--muted-text);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font-size: 9px;
  cursor: pointer;
}

.fretboard-voicing-button:hover,
.fretboard-voicing-button.is-selected {
  color: var(--strong-text);
  border-color: var(--accent);
  background: var(--active-soft);
}

body .fretboard-grid .instrument-degree-marker {
  display: none;
}

@media (max-width: 1280px) {
  body .omni-command-mount .omni-library-panel > .omni-library-heading {
    grid-template-columns: auto auto minmax(140px, 190px) minmax(180px, 1fr);
  }

  body .omni-playback-controls {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 700px) {
  .top-theme-switch {
    right: 8px;
  }

  .top-theme-switch #theme-label {
    display: none;
  }

  body .floating-audio-dock {
    right: 64px;
  }

  body .omni-command-mount .omni-library-panel > .omni-library-heading {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-right: 0;
  }

  .omni-formula-control,
  body .omni-selection-summary,
  body .omni-playback-controls {
    grid-column: 1 / -1;
  }

  body .omni-playback-controls {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.omni-command-toolbar {
  display: flex;
  min-height: 48px;
  grid-template-columns: none;
  align-items: center;
  gap: 0;
  padding: 7px 58px 7px clamp(12px, 2vw, 28px);
}

.omni-brand-group {
  width: 100%;
  justify-content: flex-start;
}

.omni-panel-shell {
  position: relative;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--control-background);
}

.omni-panel-shell .omni-collapse-button {
  position: absolute;
  z-index: 4;
  top: 2px;
  right: clamp(12px, 2vw, 28px);
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  font-size: 9px;
}

.omni-command-panel {
  max-height: 3000px;
  overflow: hidden;
  border-top: 0;
}

.omni-command-panel.is-collapsed {
  max-height: 0;
  overflow: hidden;
}

.omni-command-mount .omni-library-panel {
  padding: 8px clamp(12px, 2vw, 28px) 14px;
  border: 0;
  background: transparent;
}

.omni-command-mount .omni-library-panel > .omni-library-heading {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding: 0 112px 9px 0;
}

.omni-command-mount .omni-library-layout {
  grid-template-columns: minmax(300px, 330px) minmax(0, 1fr);
  gap: 12px;
}

.omni-command-mount .omni-filter-panel {
  padding: 0 12px 0 0;
  border-right: 1px solid var(--line-soft);
  border-bottom: 0;
}

.omni-command-mount .omni-filter-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 7px 9px;
}

.omni-command-mount .omni-filter-content > .omni-switch {
  grid-column: 1 / -1;
}

.omni-command-mount .omni-filter-field[for="omni-category-select"] {
  grid-column: 1;
}

.omni-command-mount .omni-filter-field[for="omni-search-input"] {
  grid-column: 2;
}

.omni-command-mount .omni-cardinality-group {
  grid-column: 1 / -1;
}

.omni-command-mount .omni-hierarchy-filter {
  grid-column: 1 / -1;
}

.omni-command-mount .omni-hierarchy-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.omni-command-mount .omni-reset-button {
  grid-column: 1 / -1;
}

.omni-command-mount .omni-required-group {
  grid-column: 1 / -1;
  grid-row: auto;
}

.omni-command-mount .omni-property-filters {
  grid-column: 1 / -1;
  grid-row: auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.omni-command-mount .omni-interval-filters {
  grid-template-columns: repeat(6, minmax(28px, 1fr));
}

.omni-command-mount .omni-filter-panel details,
.omni-command-mount .omni-results,
.omni-command-mount .omni-results-shell,
.omni-command-mount .omni-filter-panel {
  max-height: none;
  overflow: visible;
}

.omni-command-mount .omni-results {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 165px), 1fr));
  gap: 4px;
}

.omni-command-mount .omni-set-badge {
  min-height: 34px;
  gap: 2px;
  padding: 4px 7px;
}

.omni-command-mount .omni-set-badge strong {
  font-size: 9px;
}

.omni-command-mount .omni-set-badge span {
  font-size: 7px;
}

.omni-command-mount .omni-results-heading {
  min-height: 24px;
}

.omni-command-mount .omni-pagination {
  min-height: 30px;
  padding-top: 5px;
}

.omni-command-mount .omni-pagination button {
  min-height: 24px;
  padding: 3px 8px;
}

.compact-playback-bar.audio-dock-popover {
  position: absolute;
  top: 42px;
  right: 0;
  display: grid;
  width: 294px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-7px);
  pointer-events: none;
}

.floating-audio-dock:hover .audio-dock-popover,
.floating-audio-dock:focus-within .audio-dock-popover,
.floating-audio-dock.is-open .audio-dock-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.feature-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  grid-auto-rows: 4px;
  align-items: start;
  gap: 10px;
  padding: 12px clamp(10px, 1.4vw, 18px) 24px;
}

.feature-panel,
.feature-panel-wide {
  grid-column: span 4;
  align-self: start;
  height: max-content;
  padding: 11px;
}

[data-feature-panel="fretboard"],
[data-feature-panel="piano"] {
  grid-column: span 12;
  order: -20;
}

body[data-library-mode="chord"] .feature-grid > [data-feature-panel="grandStaff"],
body[data-library-mode="scale"] .feature-grid > [data-feature-panel="grandStaff"] {
  grid-column: span 8;
}

body[data-library-mode="chord"] .feature-grid > [data-feature-panel="asciiTab"],
body[data-library-mode="scale"] .feature-grid > [data-feature-panel="asciiTab"],
.feature-grid > [data-feature-panel="caged"] {
  grid-column: span 4;
}

body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout {
  grid-template-columns: minmax(300px, 392px) minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
}

.staff-container[data-mode="chord"],
.staff-container[data-mode="scale"] {
  min-height: 0;
  height: var(--staff-render-height);
}

.caged-result {
  display: grid;
  min-height: 0;
  justify-items: center;
  gap: 7px;
  padding: 8px;
}

.chord-diagram-container {
  width: min(100%, 228px);
  margin: 0 auto;
  justify-self: center;
}

.chord-diagram-stage,
.chord-diagram-container svg {
  width: min(100%, 210px);
  margin: 0 auto;
}

.chord-diagram-navigation,
.caged-shape-row {
  width: min(100%, 228px);
}

#ascii-tab-container[data-mode="chord"] {
  overflow: hidden;
  scrollbar-width: none;
}

.fret-cell.pattern-note {
  box-shadow: none;
}

.fret-cell.active-note,
.fret-cell.active-note.root-note {
  background: var(--surface);
}

.fret-cell.active-note.open-position,
.fret-cell.active-note.capo-position {
  background: var(--surface-raised);
}

.fret-cell.pattern-note .fret-note-label {
  box-shadow:
    0 0 0 2px var(--pattern-outline),
    0 0 0 4px color-mix(in srgb, var(--surface) 85%, transparent);
}

@media (max-width: 1180px) {
  body[data-library-mode="chord"] .feature-grid > [data-feature-panel="grandStaff"],
  body[data-library-mode="scale"] .feature-grid > [data-feature-panel="grandStaff"],
  body[data-library-mode="chord"] .feature-grid > [data-feature-panel="asciiTab"],
  body[data-library-mode="scale"] .feature-grid > [data-feature-panel="asciiTab"],
  .feature-grid > [data-feature-panel="caged"] {
    grid-column: span 12;
  }
}

@media (max-width: 900px) {
  .omni-command-mount .omni-library-panel > .omni-library-heading {
    grid-template-columns: auto auto;
    padding-right: 0;
  }

  .omni-selection-summary {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .omni-command-mount .omni-library-layout,
  body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-filter-content {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-filter-content > *,
  .omni-command-mount .omni-filter-content > .omni-switch,
  .omni-command-mount .omni-filter-field[for="omni-category-select"],
  .omni-command-mount .omni-filter-field[for="omni-search-input"],
  .omni-command-mount .omni-cardinality-group,
  .omni-command-mount .omni-reset-button,
  .omni-command-mount .omni-required-group,
  .omni-command-mount .omni-property-filters {
    grid-column: 1;
    grid-row: auto;
  }

  .omni-command-mount .omni-property-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .omni-command-mount .omni-interval-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .omni-command-toolbar {
    padding-right: 52px;
  }

  .omni-command-mount .omni-library-panel > .omni-library-heading {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .omni-library-title > span,
  .omni-selection-summary > span:last-child {
    display: none;
  }

  .feature-panel,
  .feature-panel-wide,
  [data-feature-panel="fretboard"],
  [data-feature-panel="piano"] {
    grid-column: span 12;
  }
}

/* Stage 18.3 final sizing and interaction precedence */
body .caged-result {
  display: grid;
  min-height: 0;
  justify-content: center;
  justify-items: center;
  gap: 8px;
  padding: 10px;
}

body .chord-diagram-container {
  display: grid;
  width: 360px;
  max-width: 100%;
  margin: 0;
  place-items: center;
  justify-self: center;
}

body .chord-diagram-stage,
body .chord-diagram-container svg {
  width: 330px;
  max-width: 100%;
  margin: 0 auto;
}

body .chord-diagram-navigation,
body .caged-shape-row {
  width: 360px;
  max-width: 100%;
}

/* Stage 19 settings, enharmonic controls, and position navigation */
.omni-command-toolbar {
  padding-right: 104px;
}

.settings-menu {
  position: fixed;
  z-index: 70;
  top: 8px;
  right: 10px;
}

.settings-menu-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 5px 18px rgb(0 0 0 / 22%);
}

.settings-menu-toggle:hover,
.settings-menu-toggle[aria-expanded="true"] {
  border-color: var(--blue);
  color: var(--blue);
}

.settings-menu-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.settings-glyph {
  display: grid;
  width: 16px;
  gap: 3px;
}

.settings-glyph i {
  position: relative;
  display: block;
  height: 1px;
  background: currentColor;
}

.settings-glyph i::after {
  position: absolute;
  top: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.settings-glyph i:nth-child(1)::after,
.settings-glyph i:nth-child(3)::after {
  left: 3px;
}

.settings-glyph i:nth-child(2)::after {
  right: 3px;
}

.settings-menu-popover {
  position: absolute;
  top: 42px;
  right: 0;
  display: grid;
  width: 224px;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: 0 14px 34px rgb(0 0 0 / 30%);
}

.settings-menu-popover[hidden] {
  display: none;
}

.settings-menu-heading {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--strong-text);
  font-size: 10px;
  font-weight: 760;
}

.settings-switch-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  color: var(--muted-text);
  cursor: pointer;
  font-size: 10px;
  font-weight: 680;
}

.settings-switch-row + .settings-switch-row {
  border-top: 1px solid var(--line-soft);
}

.settings-switch-control {
  display: inline-flex;
  min-width: 82px;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  color: var(--text);
}

.settings-switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.settings-switch-control input:checked + .switch-track {
  border-color: var(--blue);
  background: var(--active-soft);
}

.settings-switch-control input:checked + .switch-track::after {
  background: var(--blue);
  transform: translateX(14px);
}

.settings-switch-control input:focus-visible + .switch-track {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

body .floating-audio-dock {
  right: 54px;
}

.omni-panel-shell {
  padding-top: 0;
}

body .omni-command-panel,
body .omni-command-panel.is-collapsed {
  max-height: 3000px;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body .omni-command-mount .omni-library-panel > .omni-library-heading {
  grid-template-columns: 190px 150px 150px minmax(220px, 1fr) 220px auto;
  align-items: end;
  gap: 12px;
  padding: 8px 0 10px;
}

body .omni-library-title {
  position: relative;
  display: grid;
  align-self: stretch;
  align-content: center;
  gap: 3px;
  padding: 3px 24px 3px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

body .omni-library-title::after {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted-text);
  border-bottom: 1.5px solid var(--muted-text);
  content: "";
  transform: translateY(-65%) rotate(45deg);
  transition: transform 180ms ease;
}

body .omni-library-title[aria-expanded="false"]::after {
  transform: translateY(-30%) rotate(225deg);
}

body .omni-library-title:hover .omni-library-title-heading,
body .omni-library-title:focus-visible .omni-library-title-heading {
  color: var(--blue);
}

body .omni-library-title:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.omni-library-title-heading {
  color: var(--strong-text);
  font-size: 13px;
  font-weight: 780;
}

.omni-library-subtitle {
  color: var(--muted-text);
  font-size: 8px;
  font-weight: 680;
}

body .omni-root-control,
body .omni-formula-control,
body .omni-quick-search-control {
  display: grid;
  width: 150px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 4px;
  color: var(--muted-text);
  font-size: 8px;
  font-weight: 720;
  text-transform: uppercase;
}

body .omni-root-control > span,
body .omni-formula-control > span,
body .omni-quick-search-control > span {
  display: block;
  color: var(--muted-text);
  font-size: 8px;
}

body .omni-root-control select,
body .omni-formula-control select,
body .omni-quick-search-control input {
  width: 150px;
  min-width: 150px;
  height: 32px;
  min-height: 32px;
  padding: 4px 26px 4px 9px;
  font-size: 11px;
  text-transform: none;
}

body .omni-quick-search-control {
  width: 220px;
}

body .omni-quick-search-control input {
  width: 220px;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
  color: var(--text);
  font-family: inherit;
}

body .omni-quick-search-control input:focus-visible {
  border-color: var(--blue);
  outline: 2px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset: 1px;
}

body .omni-selection-summary {
  min-width: 0;
  justify-content: flex-start;
  gap: 9px;
  padding: 0 8px 6px 18px;
  overflow: visible;
}

body .omni-selection-summary .selection-mode {
  font-size: 9px;
}

body .omni-selection-summary strong {
  flex: 0 0 auto;
  font-size: 14px;
}

body .omni-selection-summary > span:last-child {
  max-width: none;
  overflow: visible;
  color: var(--muted-text);
  font-size: 11px;
  text-overflow: clip;
}

.omni-library-panel .omni-library-layout {
  max-height: 3000px;
  opacity: 1;
  visibility: visible;
  transition:
    max-height 260ms ease,
    opacity 160ms ease,
    visibility 0s linear;
}

.omni-library-panel.is-collapsed .omni-library-layout {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition:
    max-height 240ms ease,
    opacity 130ms ease,
    visibility 0s linear 240ms;
}

.omni-library-panel.is-collapsed .omni-library-heading {
  grid-template-columns: 190px;
  margin-bottom: 0;
  border-bottom: 0;
}

.omni-library-panel.is-collapsed .omni-root-control,
.omni-library-panel.is-collapsed .omni-formula-control,
.omni-library-panel.is-collapsed .omni-quick-search-control,
.omni-library-panel.is-collapsed .omni-selection-summary,
.omni-library-panel.is-collapsed .omni-playback-controls {
  display: none;
}

body .piano-key .instrument-degree-marker {
  display: none;
}

body #ascii-tab-container,
body #ascii-tab-container[data-mode="chord"],
body #ascii-tab-container[data-mode="scale"] {
  width: 100%;
  max-width: none;
  overflow: hidden;
  font-size: var(--ascii-fit-font-size, 11px);
  letter-spacing: 0;
  white-space: pre;
}

@media (max-width: 1280px) {
  body .omni-command-mount .omni-library-panel > .omni-library-heading {
    grid-template-columns: 170px 150px 150px minmax(260px, 1fr);
  }

  body .omni-quick-search-control {
    grid-column: 1 / 3;
  }

  body .omni-playback-controls {
    grid-column: 3 / -1;
  }
}

@media (max-width: 700px) {
  .omni-command-toolbar {
    padding-right: 96px;
  }

  body .floating-audio-dock {
    right: 54px;
  }

  body .omni-command-mount .omni-library-panel > .omni-library-heading {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  body .omni-library-title,
  body .omni-selection-summary,
  body .omni-quick-search-control,
  body .omni-playback-controls {
    grid-column: 1 / -1;
  }

  body .omni-root-control,
  body .omni-formula-control,
  body .omni-quick-search-control,
  body .omni-root-control select,
  body .omni-formula-control select,
  body .omni-quick-search-control input {
    width: 100%;
    min-width: 0;
  }

  body .omni-selection-summary {
    padding-left: 0;
  }

  .settings-menu-popover {
    width: min(224px, calc(100vw - 20px));
  }

  .omni-library-panel.is-collapsed .omni-library-heading {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Stage 19.7: fixed musical-library density and compact staff geometry. */
body .omni-command-mount .omni-results {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

body .omni-command-mount .omni-set-badge {
  min-height: 44px;
}

body .staff-container[data-mode="scale"] {
  height: var(--staff-render-height);
  min-height: var(--staff-render-height);
  overflow: hidden;
}

@media (max-width: 1200px) {
  body .omni-command-mount .omni-results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  body .omni-command-mount .omni-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  body .omni-command-mount .omni-results {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Stage 20: categorized Omni Library and full-use notation geometry. */
body .omni-command-mount .omni-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 8px;
}

.omni-category-block {
  --omni-group-accent: #4ba9dc;
  display: grid;
  min-width: 0;
  gap: 5px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--omni-group-accent) 42%, var(--line));
  border-left: 3px solid var(--omni-group-accent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--omni-group-accent) 5%, var(--surface));
}

.omni-category-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--omni-group-accent) 30%, var(--line-soft));
}

.omni-category-heading h4 {
  margin: 0;
  color: var(--omni-group-accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.omni-category-heading span {
  color: var(--muted-text);
  font-size: 8px;
  font-weight: 650;
}

.omni-category-cards {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

body .omni-category-block .omni-set-badge {
  min-width: 0;
  min-height: 44px;
  border-color: color-mix(in srgb, var(--omni-group-accent) 58%, var(--line));
  background: color-mix(in srgb, var(--omni-group-accent) 10%, var(--surface-raised));
}

body .omni-category-block .omni-set-badge:hover {
  border-color: var(--omni-group-accent);
  background: color-mix(in srgb, var(--omni-group-accent) 16%, var(--surface-raised));
}

body .omni-category-block .omni-set-badge.is-selected {
  border-color: var(--orange);
  box-shadow: inset 3px 0 0 var(--orange);
}

.omni-group-standard { --omni-group-accent: #4da6dc; }
.omni-group-standard-inversions { --omni-group-accent: #35c8bf; }
.omni-group-complex-inversions { --omni-group-accent: #9574f2; }
.omni-group-polychords { --omni-group-accent: #b47cf0; }
.omni-group-quartal-quintal { --omni-group-accent: #8fcf62; }
.omni-group-clusters { --omni-group-accent: #91a3b7; }
.omni-group-major-modes { --omni-group-accent: #42a9d5; }
.omni-group-minor-modes { --omni-group-accent: #8f83e8; }
.omni-group-pentatonic-blues { --omni-group-accent: #3dbb84; }
.omni-group-symmetrical-synthetic { --omni-group-accent: #c078db; }
.omni-group-world-ethnic { --omni-group-accent: #d7874e; }
.omni-group-exotic { --omni-group-accent: #7f8a96; }

.omni-page-jump {
  display: inline-grid;
  grid-template-columns: auto 48px auto;
  align-items: center;
  gap: 6px;
  color: var(--muted-text);
  font-size: 10px;
  font-weight: 650;
}

.omni-page-jump input {
  width: 48px;
  height: 26px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  text-align: center;
}

.omni-page-jump input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.omni-page-jump strong {
  color: var(--text);
}

body .omni-results-shell {
  align-content: start;
}

body .omni-selection-summary {
  display: grid;
  min-height: 44px;
  grid-template-columns: max-content max-content minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 4px 12px 4px 18px;
}

body .omni-selection-summary .selection-mode {
  font-size: 10px;
}

body .omni-selection-summary strong {
  font-size: 17px;
  line-height: 1.15;
}

body .omni-selection-summary > span:last-child {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 620;
  line-height: 1.25;
}

body [data-feature-panel="grandStaff"] .notation-layout {
  align-items: stretch;
}

body[data-library-mode="scale"] [data-feature-panel="grandStaff"] .notation-layout {
  height: 220px;
  max-height: 220px;
  min-height: 220px;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.75fr);
}

body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout {
  height: 140px;
  max-height: 140px;
  grid-template-columns: minmax(300px, 1.35fr) minmax(250px, 0.9fr);
}

body [data-feature-panel="grandStaff"] .analysis-container {
  display: grid;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-content: stretch;
  justify-content: stretch;
  justify-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  overflow: hidden;
}

body [data-feature-panel="grandStaff"] .analysis-group {
  display: grid;
  width: 100%;
  min-height: 0;
  align-content: center;
  gap: 7px;
}

body [data-feature-panel="grandStaff"] .analysis-label {
  font-size: 10px;
}

body [data-feature-panel="grandStaff"] .analysis-sequence {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
  gap: 6px;
}

.feature-grid > [data-feature-panel].is-layout-solo {
  grid-column: span 12 !important;
}

body [data-feature-panel="grandStaff"] .analysis-value,
body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .analysis-value {
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--surface-raised);
  font-size: 12px;
  line-height: 1;
  text-align: center;
}

@media (max-width: 1200px) {
  .omni-category-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .omni-category-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body .omni-selection-summary {
    grid-template-columns: max-content minmax(0, 1fr);
  }

  body .omni-selection-summary > span:last-child {
    grid-column: 1 / -1;
  }

  body[data-library-mode="chord"] [data-feature-panel="grandStaff"] .notation-layout,
  body[data-library-mode="scale"] [data-feature-panel="grandStaff"] .notation-layout {
    height: auto;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 480px) {
  .omni-category-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Stage 21: dynamic-chord hierarchy and optional jazz-symbol presentation. */
body .floating-audio-dock {
  display: flex;
  width: auto;
  align-items: center;
  gap: 8px;
}

.jazz-notation-switch {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  color: var(--muted-text);
  cursor: pointer;
  box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
  font-size: 9px;
  font-weight: 720;
  white-space: nowrap;
}

.jazz-notation-switch:hover {
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  color: var(--text);
}

.jazz-notation-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.jazz-notation-switch .switch-track {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  flex: 0 0 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input-background);
  transition: border-color 150ms ease, background 150ms ease;
}

.jazz-notation-switch .switch-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted-text);
  content: "";
  transition: background 150ms ease, transform 150ms ease;
}

.jazz-notation-switch input:checked + .switch-track {
  border-color: #9a7bff;
  background: color-mix(in srgb, #6d4bd2 34%, var(--input-background));
}

.jazz-notation-switch input:checked + .switch-track::after {
  background: #bba7ff;
  transform: translateX(12px);
}

.jazz-notation-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.omni-group-core { --omni-group-accent: #42b9a0; }
.omni-group-standard-extended { --omni-group-accent: #4da6dc; }
.omni-group-complex-custom { --omni-group-accent: #9574f2; }

.omni-category-block.omni-group-complex-custom,
.omni-category-block.omni-group-complex-inversions {
  border-color: color-mix(in srgb, #7454d4 62%, var(--line));
  background: color-mix(in srgb, #2c1f62 28%, var(--surface));
  box-shadow: inset 0 0 22px rgb(111 76 210 / 8%);
}

body .omni-category-block .omni-set-badge.omni-group-complex-custom,
body .omni-category-block .omni-set-badge.omni-group-complex-inversions {
  border-color: color-mix(in srgb, #9c7cff 64%, var(--line));
  background: color-mix(in srgb, #302064 34%, var(--surface-raised));
}

body .omni-category-block .omni-set-badge.omni-group-complex-custom:hover,
body .omni-category-block .omni-set-badge.omni-group-complex-inversions:hover {
  border-color: #b29bff;
  background: color-mix(in srgb, #4a328f 42%, var(--surface-raised));
}

@media (max-width: 700px) {
  .jazz-notation-switch {
    padding-inline: 6px;
  }

  .jazz-notation-label {
    display: none;
  }
}

/* Uniform Omni cards and a stable page-navigation anchor. */
body .omni-command-mount .omni-library-layout {
  align-items: stretch;
}

body .omni-command-mount .omni-results-shell {
  height: clamp(420px, calc(100dvh - 242px), 478px);
  max-height: clamp(420px, calc(100dvh - 242px), 478px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  overflow: hidden;
}

body .omni-command-mount .omni-results {
  min-height: 0;
  align-content: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

body .omni-command-mount .omni-category-block {
  grid-template-rows: auto minmax(0, 1fr);
}

body .omni-command-mount .omni-category-cards {
  height: 100%;
  align-content: space-between;
}

body .omni-command-mount .omni-set-badge {
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  grid-template-rows: minmax(0, auto) minmax(0, auto);
  gap: 2px;
  padding-block: 5px;
  overflow: hidden;
}

body .omni-command-mount .omni-category-cards {
  grid-auto-rows: 44px;
}

body .omni-command-mount .omni-set-badge strong,
body .omni-command-mount .omni-set-badge span {
  display: block;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .omni-command-mount .omni-set-badge strong {
  font-size: 13px;
  font-weight: 820;
  line-height: 1.05;
}

body .omni-command-mount .omni-set-badge span {
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.05;
}

body .omni-command-mount .omni-pagination {
  position: sticky;
  z-index: 4;
  bottom: 0;
  margin-top: 0;
  background: var(--control-background);
}

/* Markdown article reader ------------------------------------------------ */

.article-site-header {
  position: sticky;
  z-index: 90;
  top: 0;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--header-background);
}

.article-site-header-inner {
  display: flex;
  width: min(1200px, 100%);
  min-height: 56px;
  align-items: center;
  gap: 18px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 36px);
}

.omni-library-tabs > .article-nav-link {
  display: flex;
  min-height: 100%;
  align-items: center;
}

.article-wrapper {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(44px, 7vw, 88px) 0 clamp(72px, 10vw, 120px);
}

.article-content {
  color: var(--text);
  font-size: clamp(16px, 1.35vw, 18px);
  line-height: 1.78;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  color: var(--strong-text);
  line-height: 1.2;
  text-wrap: balance;
}

.article-content h1 {
  margin: 0 0 28px;
  font-size: clamp(36px, 6vw, 58px);
  font-weight: 790;
  letter-spacing: -.035em;
}

.article-content h2 {
  margin: 58px 0 18px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: clamp(25px, 3.8vw, 34px);
  font-weight: 760;
  letter-spacing: -.025em;
}

.article-content h3 {
  margin: 38px 0 14px;
  font-size: clamp(20px, 2.8vw, 25px);
  font-weight: 750;
}

.article-content h4 {
  margin: 30px 0 12px;
  font-size: 18px;
  font-weight: 750;
}

.article-content p {
  margin: 0 0 1.35em;
  color: var(--text);
}

.article-content strong {
  color: var(--strong-text);
  font-weight: 780;
}

.article-content a {
  color: var(--blue);
  font-weight: 690;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article-content a:hover {
  color: var(--strong-text);
  text-decoration-color: var(--blue);
}

.article-content blockquote {
  margin: 32px 0;
  padding: 18px 22px;
  border-left: 3px solid var(--blue);
  background: var(--surface-raised);
  color: var(--muted);
}

.article-content blockquote p {
  margin: 0;
  color: var(--muted);
}

.article-content ul,
.article-content ol {
  margin: 0 0 1.5em;
  padding-left: 1.4em;
  color: var(--text);
}

.article-content li {
  margin: .48em 0;
  padding-left: .28em;
}

.article-content li::marker {
  color: var(--blue);
}

.article-content code {
  padding: .16em .38em;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface);
  color: var(--strong-text);
  font: 650 .88em/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.article-content pre {
  max-width: 100%;
  margin: 28px 0;
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.article-content pre code {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  line-height: 1.65;
}

.article-content hr {
  margin: 48px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.article-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 32px auto;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
}

.article-loading {
  color: var(--muted);
  text-align: center;
}

.article-content.has-error {
  min-height: 52vh;
  display: grid;
  place-items: center;
}

.article-error {
  width: 100%;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  text-align: center;
}

.article-error h1 {
  margin: 0 0 10px;
  color: var(--danger);
  font-size: clamp(27px, 4vw, 38px);
}

.article-error p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 560px) {
  .article-site-header-inner {
    gap: 10px;
    padding-inline: 12px;
  }

  .article-wrapper {
    width: min(100% - 24px, 720px);
    padding-top: 34px;
  }

  .article-content blockquote,
  .article-content pre {
    padding: 15px 16px;
  }
}

/* ============================================================ Authentication
   Header cluster and sign-in modal. Loaded on every page, so this lives in
   style.css rather than the identifier-only sheet.

   All colour comes from tokens already defined in :root, which is what keeps
   the panel correct in both themes without a single dark-mode override here.
   ========================================================================== */

.auth-cluster {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 8px;
}

.support-control {
  position: relative;
  display: flex;
  align-items: center;
}

.support-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid var(--orange);
  border-radius: 7px;
  background: color-mix(in srgb, var(--orange) 86%, var(--surface-raised));
  color: var(--root-note-ink);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--orange) 28%, transparent),
    0 0 18px color-mix(in srgb, var(--orange) 35%, transparent);
  font-size: 12.5px;
  font-weight: 780;
  letter-spacing: .015em;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.support-button:hover {
  background: var(--orange);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--orange) 38%, transparent),
    0 0 24px color-mix(in srgb, var(--orange) 48%, transparent);
  transform: translateY(-1px);
}

.support-button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

.support-message {
  position: absolute;
  z-index: 280;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  width: min(330px, calc(100vw - 24px));
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--muted);
  box-shadow: var(--identifier-panel-shadow);
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 0s linear 140ms;
  visibility: hidden;
}

.support-message strong {
  color: var(--strong-text);
  font-size: 14px;
  line-height: 1.35;
}

.support-message span {
  font-size: 12.5px;
  line-height: 1.5;
}

.support-control:hover .support-message,
.support-control:focus-within .support-message {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
  visibility: visible;
}

/* The two faces of the cluster are mutually exclusive; the session state on the
   wrapper decides which one exists, so neither can flash the other. */
.auth-cluster[data-auth-state="out"] .auth-library-link,
.auth-cluster[data-auth-state="out"] .auth-account,
.auth-cluster[data-auth-state="in"] .auth-signin-button {
  display: none;
}

.auth-signin-button {
  padding: 8px 16px;
  border: 1px solid var(--blue);
  border-radius: 999px;
  background-color: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 680;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.auth-signin-button:hover {
  border-color: var(--blue-dark);
  background-color: var(--blue-dark);
}

.auth-signin-button:focus-visible,
.auth-account-toggle:focus-visible,
.auth-library-link:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.auth-library-link {
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
}

.auth-library-link:hover {
  background-color: var(--control-background);
}

.auth-account {
  position: relative;
}

.auth-account-toggle {
  display: flex;
  align-items: center;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 620;
  gap: 8px;
  cursor: pointer;
}

.auth-account-toggle:hover {
  border-color: var(--blue);
}

.auth-avatar {
  display: grid;
  width: 24px;
  height: 24px;
  place-content: center;
  border-radius: 50%;
  background-color: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.auth-account-email {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-account-menu {
  position: absolute;
  z-index: 260;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--surface-raised);
  box-shadow: var(--identifier-panel-shadow);
  gap: 2px;
}

.auth-account-menu[hidden] {
  display: none;
}

.auth-account-menu-label {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.auth-account-menu a,
.auth-account-menu button {
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.auth-account-menu a:hover,
.auth-account-menu button:hover {
  background-color: var(--control-background);
}

/* ------------------------------------------------------------------- modal */

.auth-modal-mount[hidden] {
  display: none;
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-overlay {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  padding: 16px;
  backdrop-filter: blur(8px);
  background-color: var(--identifier-overlay);
  place-items: center;
}

.auth-dialog {
  position: relative;
  display: grid;
  width: min(880px, 100%);
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background-color: var(--surface);
  box-shadow: var(--identifier-panel-shadow);
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.auth-dialog-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.auth-dialog-close:hover {
  background-color: var(--control-background);
  color: var(--text);
}

/* ------------------------------------------------------------------- perks */

.auth-perks {
  display: flex;
  flex-direction: column;
  padding: 36px 32px;
  border-right: 1px solid var(--line);
  background-color: var(--inner-background);
  gap: 6px;
}

.auth-perks-eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.auth-perks-title {
  margin: 2px 0 22px;
  color: var(--strong-text);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-perks-list {
  display: grid;
  padding: 0;
  margin: 0;
  gap: 16px;
  list-style: none;
}

.auth-perk {
  display: grid;
  align-items: start;
  color: var(--text);
  font-size: 14px;
  gap: 12px;
  grid-template-columns: 20px 1fr;
  line-height: 1.5;
}

.auth-perk-check {
  display: grid;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  place-content: center;
  border-radius: 50%;
  /* Tinted from the same blue rather than a new colour, so the checkmarks read
     as part of the studio palette instead of a generic success green. */
  background-color: color-mix(in srgb, var(--blue) 14%, transparent);
  color: var(--blue);
}

/* -------------------------------------------------------------------- form */

.auth-form-panel {
  display: flex;
  flex-direction: column;
  padding: 36px 32px;
  overflow-y: auto;
}

.auth-form-title {
  margin: 0;
  color: var(--strong-text);
  font-size: 20px;
  font-weight: 700;
}

.auth-form-subtitle {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.auth-google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--surface-raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 620;
  gap: 10px;
  cursor: pointer;
  transition: border-color 140ms ease;
}

.auth-google-button:hover {
  border-color: var(--blue);
}

.auth-google-mark {
  display: grid;
  width: 20px;
  height: 20px;
  place-content: center;
  border-radius: 50%;
  background-color: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.auth-divider {
  display: grid;
  align-items: center;
  margin: 18px 0;
  color: var(--muted);
  font-size: 11px;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  border-top: 1px solid var(--line-soft);
  content: "";
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 640;
}

.auth-field input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.auth-field input:focus-visible {
  border-color: var(--blue);
  outline: 2px solid color-mix(in srgb, var(--blue) 35%, transparent);
  outline-offset: 1px;
}

.auth-form-error {
  margin: 0;
  color: var(--danger);
  font-size: 12.5px;
}

.auth-form-error[hidden] {
  display: none;
}

.auth-submit-button {
  padding: 12px 16px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  background-color: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 680;
  cursor: pointer;
  transition: background 140ms ease;
}

.auth-submit-button:hover {
  background-color: var(--blue-dark);
}

.auth-form-footnote {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

/* The perks column is the first thing to yield: on a phone the form is the
   task and the pitch is context, so it stacks underneath rather than pushing
   the inputs below the fold. */
@media (max-width: 760px) {
  .auth-dialog {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .auth-perks {
    padding: 26px 22px 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    order: 2;
  }

  .auth-perks-title {
    margin-bottom: 16px;
    font-size: 19px;
  }

  .auth-form-panel {
    padding: 30px 22px 22px;
    order: 1;
  }

  .auth-account-email {
    display: none;
  }
}

/* ================================================================= Freemium
   Ad slots, the profile premium panel, and the upgrade CTA. Loaded on every
   page. Colour comes only from :root tokens, so both themes are covered with
   no per-theme override.
   ========================================================================== */

/* Manual ad-slot styling used to live here. It is gone with the move to Auto
   Ads: Google now decides placement and sizing from the AdSense dashboard, so
   the site no longer authors containers of its own to style. */

/* ----------------------------------------------------------- premium in menu */

.auth-premium {
  display: grid;
  padding: 8px 4px 10px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
  gap: 10px;
}

.auth-premium-status {
  display: flex;
  align-items: center;
}

.auth-premium-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--control-background);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: 0.01em;
}

.auth-premium-badge[data-state="premium"] {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  color: var(--blue);
}

.auth-premium-field {
  display: grid;
  gap: 5px;
}

.auth-premium-field-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 640;
}

.auth-premium-key {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-background);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.auth-premium-key:focus-visible {
  border-color: var(--blue);
  outline: 2px solid color-mix(in srgb, var(--blue) 32%, transparent);
  outline-offset: 1px;
}

.auth-premium-activate {
  padding: 9px 12px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 12.5px;
  font-weight: 680;
  cursor: pointer;
  transition: background 140ms ease;
}

.auth-premium-activate:hover:not(:disabled) {
  background: var(--blue-dark);
}

.auth-premium-activate:disabled {
  opacity: 0.6;
  cursor: progress;
}

.auth-premium-feedback {
  min-height: 1em;
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.auth-premium-feedback[data-tone="error"] {
  color: var(--danger);
}

.auth-premium-feedback[data-tone="ok"] {
  color: var(--success);
}

/* Once premium, the badge alone tells the story — retire the key form so the
   panel confirms the purchase instead of re-soliciting it. */
:root[data-premium-state="premium"] .auth-premium-upgrade {
  display: none;
}

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

.app-footer {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.app-footer-inner {
  display: grid;
  width: min(1200px, calc(100% - 32px));
  align-items: center;
  gap: 24px 40px;
  margin: 0 auto;
  padding: 30px 0;
  grid-template-columns: minmax(240px, 1fr) auto auto;
}

.app-footer-identity {
  display: grid;
  gap: 5px;
}

.app-footer-brand {
  width: fit-content;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
}

.app-footer-identity p,
.app-footer-copyright {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.app-footer-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-footer-links a {
  padding: 7px 9px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  text-decoration: none;
}

.app-footer-links a:hover,
.app-footer-links a:focus-visible {
  background: var(--control-background);
  color: var(--strong-text);
}

.app-footer-links a:focus-visible,
.app-footer-brand:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (max-width: 820px) {
  .app-footer-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .app-footer-copyright {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .auth-cluster {
    gap: 6px;
  }

  .support-button {
    min-height: 32px;
    padding-inline: 10px;
    font-size: 11.5px;
  }

  .app-footer-inner {
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
  }

  .app-footer-links {
    flex-wrap: wrap;
  }

  .app-footer-copyright {
    grid-column: auto;
  }
}

/* ------------------------------------------------ auth: sign-in / sign-up mode */

.auth-mode-switch {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.auth-mode-toggle {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 12.5px;
  font-weight: 680;
  cursor: pointer;
}

.auth-mode-toggle:hover {
  text-decoration: underline;
}

.auth-mode-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* The error surface doubles as a neutral notice for "check your email"; the
   info tone keeps that message from reading as a failure. */
.auth-form-error[data-tone="info"] {
  color: var(--success);
}

/* =================================================================== Library
   Favorite hearts and the My Library side-panel. Loaded on every page; colour
   comes only from :root tokens so both themes are covered with no override.
   ========================================================================== */

/* ------------------------------------------------------------ favorite heart */

.favorite-toggle {
  display: inline-grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-content: center;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, opacity 120ms ease;
}

.favorite-toggle:hover {
  color: var(--blue);
}

.favorite-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* Saved: the same heart, filled in the studio blue. */
.favorite-toggle.is-saved {
  color: var(--blue);
}

.favorite-toggle.is-saved .favorite-icon path {
  fill: currentColor;
}

/* On the dense omni grid the badge is a <button>, so the heart is a sibling in
   a wrapper cell, floated over the corner and revealed on hover — or kept
   visible once the item is saved. */
.omni-set-cell {
  position: relative;
  display: grid;
  min-width: 0;
}

.omni-set-cell > .omni-set-badge {
  width: 100%;
}

.omni-set-cell > .favorite-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  opacity: 0;
}

.omni-set-cell:hover > .favorite-toggle,
.omni-set-cell > .favorite-toggle:focus-visible,
.omni-set-cell > .favorite-toggle.is-saved {
  opacity: 1;
}

/* ------------------------------------------------------------- library panel */

.library-panel-mount[hidden] {
  display: none;
}

body.library-panel-open {
  overflow: hidden;
}

.library-overlay {
  position: fixed;
  z-index: 320;
  inset: 0;
  backdrop-filter: blur(4px);
  background: var(--identifier-overlay);
}

.library-panel {
  position: fixed;
  z-index: 321;
  top: 0;
  right: 0;
  display: flex;
  width: min(420px, 100%);
  height: 100dvh;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--identifier-panel-shadow);
  animation: library-slide-in 180ms ease;
}

@keyframes library-slide-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}

.library-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.library-panel-header h2 {
  margin: 0;
  color: var(--strong-text);
  font-size: 18px;
  font-weight: 700;
}

.library-panel-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.library-panel-close:hover {
  background: var(--control-background);
  color: var(--text);
}

.library-panel-body {
  display: grid;
  flex: 1;
  padding: 18px 20px;
  gap: 24px;
  overflow-y: auto;
  align-content: start;
}

.library-section-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-list {
  display: grid;
  gap: 8px;
}

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  gap: 12px;
}

.library-item-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-remove {
  flex-shrink: 0;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--danger);
  font: inherit;
  font-size: 12.5px;
  font-weight: 640;
  cursor: pointer;
}

.library-item-remove:hover {
  text-decoration: underline;
}

.library-item-remove:disabled {
  opacity: 0.5;
  cursor: default;
  text-decoration: none;
}

.library-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ================================================================= Downloads
   Premium chord export menu. Sits in the chord heading beside the selection
   summary. Colour comes only from :root tokens, so both themes are covered.
   ========================================================================== */

.download-group {
  position: relative;
  display: inline-flex;
  margin-left: auto;
}

.download-trigger {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 640;
  gap: 7px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.download-trigger:hover {
  border-color: var(--blue);
  background: var(--control-background);
}

.download-trigger:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.download-menu {
  position: absolute;
  z-index: 260;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 226px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--identifier-panel-shadow);
  gap: 2px;
}

.download-menu[hidden] {
  display: none;
}

.download-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.download-option:hover {
  background: var(--control-background);
}

.download-option:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

/* Locked: dimmed label and a visible padlock. Still clickable on purpose —
   the click is what opens the upgrade prompt. */
.download-option.is-locked {
  color: var(--muted);
}

.download-option.is-locked:hover {
  background: color-mix(in srgb, var(--blue) 8%, transparent);
  color: var(--text);
}

.download-lock {
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1;
  opacity: 0.85;
}

.download-lock[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .download-group {
    margin-left: 0;
  }

  .download-menu {
    right: auto;
    left: 0;
  }
}

/* ------------------------------------- downloads: flashy trigger + toast ---
   Overrides the plain trigger defined earlier in this sheet. */

.download-trigger {
  position: relative;
  border: 0;
  background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow: hidden;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--blue) 38%, transparent);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.download-trigger:hover {
  background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
  filter: brightness(1.08);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--blue) 52%, transparent);
  transform: translateY(-1px);
}

.download-trigger:active {
  transform: translateY(0);
}

/* A slow highlight sweep so the control reads as the premium action. */
.download-trigger-shine {
  position: absolute;
  top: 0;
  left: -60%;
  width: 45%;
  height: 100%;
  background: linear-gradient(
    100deg, transparent, rgb(255 255 255 / 42%), transparent
  );
  animation: download-shine 3.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes download-shine {
  0%, 62% { left: -60%; }
  100% { left: 130%; }
}

@media (prefers-reduced-motion: reduce) {
  .download-trigger-shine { animation: none; }
  .download-trigger:hover { transform: none; }
}

/* --------------------------------------------------------------- the toast */

.download-toast {
  position: fixed;
  z-index: 400;
  right: 20px;
  bottom: 22px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--identifier-panel-shadow);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.download-toast.is-visible {
  opacity: 1;
  transform: none;
}

.download-toast[data-tone="warn"] {
  border-left-color: #f97316;
}

/* ------------------------------------ downloads: traditional trigger -------
   Replaces the earlier gradient/shine treatment. Solid studio blue, matching
   the primary buttons already used across the app. */

.download-trigger {
  position: relative;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 660;
  letter-spacing: 0;
  overflow: visible;
  box-shadow: none;
  transition: background 140ms ease, border-color 140ms ease;
}

.download-trigger:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  filter: none;
  transform: none;
  box-shadow: none;
}

.download-trigger:active {
  transform: none;
}

/* The sweep element is no longer rendered; neutralise it if any cached markup
   still carries it. */
.download-trigger-shine {
  display: none;
}

/* Landing page ---------------------------------------------------------- */

:root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .home-hero-logo {
  filter: grayscale(1) brightness(0) invert(1);
}

:root[data-app-view="home"] .omni-panel-shell,
:root[data-app-view="home"] .dashboard-layout {
  position: absolute;
  inset-inline: 0;
  width: 100%;
  height: 1px;
  max-height: 1px;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

:root[data-app-view="home"] .floating-audio-dock {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

:root[data-app-view="home"]
  .omni-library-tabs
  .nav-dropdown:has(a[aria-current="page"])
  > summary {
  border-bottom-color: transparent;
  color: var(--muted);
}

:root[data-app-view="library"] .home-container,
.home-container[hidden] {
  display: none;
}

:root[data-app-view="library"] .omni-panel-shell,
:root[data-app-view="library"] .dashboard-layout {
  animation: app-view-enter 360ms ease-out both;
}

.home-container {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 54px);
  overflow: hidden;
  padding: clamp(52px, 7vw, 100px) clamp(18px, 4vw, 64px)
    clamp(72px, 9vw, 126px);
  background:
    radial-gradient(
      circle at 50% 4%,
      color-mix(in srgb, var(--blue) 24%, transparent),
      transparent 36%
    ),
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--header-background) 72%, transparent),
      transparent 52%
    );
}

.home-container::before,
.home-container::after {
  position: absolute;
  z-index: -1;
  width: clamp(300px, 42vw, 620px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--blue) 20%, transparent);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.home-container::before {
  top: -280px;
  left: -220px;
}

.home-container::after {
  right: -300px;
  bottom: -330px;
}

.home-hero,
.home-categories {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin-inline: auto;
}

.home-hero {
  display: grid;
  justify-items: center;
  text-align: center;
}

.home-eyebrow,
.home-section-heading > p,
.home-card-kicker {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.home-hero-logo-frame {
  display: grid;
  width: min(560px, 92vw);
  aspect-ratio: 5 / 4;
  margin-block: 10px 4px;
  overflow: hidden;
  place-items: start center;
}

.home-hero-logo {
  display: block;
  width: 100%;
  height: auto;
  transform: translateY(-6%);
  transform-origin: top center;
}

.home-hero h1 {
  max-width: 860px;
  margin: 0;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5.4vw, 68px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.02;
}

.home-introduction {
  max-width: 720px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: clamp(16px, 1.8vw, 20px);
  line-height: 1.7;
}

.home-categories {
  margin-top: clamp(72px, 10vw, 126px);
}

.home-section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
  text-align: center;
}

.home-section-heading h2 {
  margin: 0;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.home-category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 24px);
}

.home-category-card {
  position: relative;
  display: flex;
  min-height: 350px;
  flex-direction: column;
  align-items: flex-start;
  padding: clamp(24px, 3vw, 34px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 88%, var(--blue));
  border-radius: 18px;
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--surface-raised) 96%, var(--blue) 4%),
      var(--surface)
    );
  box-shadow: 0 18px 42px color-mix(in srgb, var(--command-shadow) 78%, transparent);
  transition:
    transform 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}

.home-category-card::before {
  position: absolute;
  top: 0;
  right: 18%;
  left: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  content: "";
  opacity: 0.72;
}

.home-category-card:hover,
.home-category-card:focus-within {
  border-color: color-mix(in srgb, var(--blue) 62%, var(--line));
  box-shadow:
    0 24px 56px color-mix(in srgb, var(--command-shadow) 88%, transparent),
    0 0 32px color-mix(in srgb, var(--blue) 12%, transparent);
  transform: translateY(-6px);
}

.home-card-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 26px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--blue) 44%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--blue) 12%, var(--surface-raised));
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 600;
}

.home-card-kicker {
  margin-bottom: 8px;
  letter-spacing: 0.14em;
}

.home-category-card h3 {
  margin: 0;
  color: var(--strong-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 600;
}

.home-card-description {
  flex: 1;
  margin: 16px 0 30px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.home-cta {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  background: var(--blue);
  color: var(--root-note-ink);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--blue) 28%, transparent);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.home-cta:hover,
.home-cta:focus-visible {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  box-shadow: 0 16px 34px color-mix(in srgb, var(--blue) 36%, transparent);
  transform: translateY(-2px);
}

.home-cta:focus-visible {
  outline: 2px solid var(--studio-focus);
  outline-offset: 3px;
}

.home-cta-arrow {
  font-size: 22px;
  font-weight: 400;
  transition: transform 160ms ease;
}

.home-cta:hover .home-cta-arrow,
.home-cta:focus-visible .home-cta-arrow {
  transform: translateX(4px);
}

@keyframes app-view-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 860px) {
  .home-category-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-category-card {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .home-container {
    min-height: calc(100vh - 58px);
    padding-top: 42px;
  }

  .home-hero-logo-frame {
    width: min(390px, 100vw);
  }

  .home-introduction {
    line-height: 1.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-app-view="library"] .omni-panel-shell,
  :root[data-app-view="library"] .dashboard-layout {
    animation: none;
  }

  .home-category-card,
  .home-cta,
  .home-cta-arrow {
    transition: none;
  }

  .home-category-card:hover,
  .home-category-card:focus-within,
  .home-cta:hover,
  .home-cta:focus-visible,
  .home-cta:hover .home-cta-arrow,
  .home-cta:focus-visible .home-cta-arrow {
    transform: none;
  }
}

/* ===================================================== Reported UI fixes ===
   Each rule below answers a specific defect; the comment says which.
   ========================================================================== */

/* 1. Download label was unreadable in light mode.
      The button sets color:#fff, but its inner <span> was being caught by a
      generic span rule and resolved to a dark muted brown — dark text on a
      solid blue pill. The label now simply inherits the button's colour. */
.download-trigger span,
.download-trigger svg {
  color: inherit;
}

/* 2. The chord/scale summary overflowed once the omni panel collapsed.
      It was `white-space: nowrap` with no min-width, so a long name such as
      "C Lydian Augmented Sharp 2" pushed straight out of its box instead of
      being allowed to shrink. */
.selection-summary {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.selection-summary #selection-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-summary #selection-notes {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 3. "Force as Root" was a 15px-tall strip with 1px padding — the label was
      physically too small to read. It now has room for its text. */
.identifier-page .identifier-root-lock,
.scale-identifier-page .identifier-root-lock,
.chord-identifier-page .identifier-root-lock {
  min-height: 22px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

/* 4. Forcing a root barely changed the note.
      `--studio-accent-strong` is *lighter* than `--studio-accent` in dark mode,
      so "forced" read as a paler shade of "selected". The forced root now uses
      the same orange this app already means "root" with, on the fretboard, the
      piano and in every PDF export — one colour, one meaning. */
.identifier-page .identifier-note-button.is-implicit-root,
.identifier-page .identifier-note-choice.has-locked-root .identifier-note-button,
.scale-identifier-page .identifier-note-choice.has-locked-root .identifier-note-button,
.chord-identifier-page .identifier-note-choice.has-locked-root .identifier-note-button {
  background: #f97316 !important;
  color: #fff !important;
  box-shadow:
    inset 0 0 0 2px rgb(255 255 255 / 55%),
    0 0 0 2px color-mix(in srgb, #f97316 55%, transparent) !important;
  font-weight: 800;
}

.identifier-page .identifier-note-choice.has-locked-root .identifier-root-lock,
.scale-identifier-page .identifier-note-choice.has-locked-root .identifier-root-lock,
.chord-identifier-page .identifier-note-choice.has-locked-root .identifier-root-lock {
  background: #9a3412;
  color: #fff;
}

/* 5. The violet library groups sat at almost the same lightness as the light
      page background, so their cards and headings stopped reading as distinct.
      Darkened for light mode only; dark mode keeps the original hues. */
:root[data-theme="light"] .omni-group-complex-inversions { --omni-group-accent: #6d3fd4; }
:root[data-theme="light"] .omni-group-polychords { --omni-group-accent: #8b3fd0; }
:root[data-theme="light"] .omni-group-minor-modes { --omni-group-accent: #5a4bcf; }
:root[data-theme="light"] .omni-group-symmetrical-synthetic { --omni-group-accent: #9333b8; }

/* 6. My Library entries are now cards that recall the saved item when clicked. */
.library-item {
  position: relative;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.library-item:hover {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 7%, var(--surface-raised));
  transform: translateY(-1px);
}

.library-item:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.library-item-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.library-item-open {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* 7. Password recovery states inside the auth dialog. */
.auth-forgot-link {
  display: inline-block;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.auth-forgot-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.auth-forgot-link:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* In reset and recovery modes the dialog hides the fields that do not apply,
   so the form always asks for exactly one thing. */
:root[data-auth-mode="reset"] .auth-field-password,
:root[data-auth-mode="reset"] .auth-google-button,
:root[data-auth-mode="reset"] .auth-divider,
:root[data-auth-mode="reset"] .auth-mode-switch,
:root[data-auth-mode="recovery"] .auth-field-email,
:root[data-auth-mode="recovery"] .auth-google-button,
:root[data-auth-mode="recovery"] .auth-divider,
:root[data-auth-mode="recovery"] .auth-mode-switch,
:root[data-auth-mode="recovery"] .auth-forgot-link,
:root[data-auth-mode="reset"] .auth-forgot-link {
  display: none;
}

/* ========================================================= Mobile (≤768px) ==
   The site's first responsive layer. Everything here is additive: the desktop
   layout is untouched above the breakpoint, and the dark premium palette is
   inherited rather than redefined — no colour is restated below.
   ========================================================================== */

/* iOS zooms the whole page when a focused input renders below 16px. Setting the
   floor globally is the only reliable cure; it must apply to every control, not
   just the auth form, or the zoom returns on the first search box a user taps.
   Declared outside the media query so desktop keeps it too — 16px inputs are
   not a mobile-only virtue. */
input,
select,
textarea {
  font-size: max(16px, 1em);
}

@media (max-width: 768px) {
  /* ------------------------------------------------------------ navigation */

  .omni-command-toolbar,
  .identifier-site-nav-inner,
  .article-site-header-inner {
    flex-wrap: wrap;
    padding-inline: 12px;
    gap: 8px;
    row-gap: 10px;
  }

  /* The logo is authored at 500x200. Constraining width alone would stretch it,
     so the intrinsic ratio is preserved explicitly. */
  .brand-logo {
    width: auto;
    max-width: 158px;
    height: auto;
    aspect-ratio: 500 / 200;
  }

  /* Rather than hide the sections behind a hamburger — which costs a tap and
     hides the app's whole structure — the tab row stays visible and scrolls.
     Every destination remains one thumb-swipe away. */
  .omni-library-tabs {
    max-width: 100%;
    flex: 1 1 100%;
    order: 3;
    gap: 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .omni-library-tabs::-webkit-scrollbar {
    display: none;
  }

  .omni-library-tabs > * {
    flex: 0 0 auto;
  }

  .omni-library-tabs summary,
  .omni-library-tabs .article-nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding-inline: 12px;
    white-space: nowrap;
  }

  /* Dropdown panels become full-width sheets instead of narrow desktop menus. */
  .nav-dropdown-menu {
    position: fixed;
    left: 8px;
    right: 8px;
    width: auto;
    min-width: 0;
  }

  .nav-dropdown-menu a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .auth-cluster {
    margin-left: auto;
    gap: 6px;
  }

  .auth-cluster .auth-account-email {
    display: none;
  }

  .support-button,
  .auth-signin-button,
  .auth-library-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding-inline: 12px;
    font-size: 12.5px;
  }

  /* ------------------------------------------------------------- home view */

  .home-container,
  .home-categories {
    width: 100%;
    padding-inline: 16px;
  }

  /* Three columns collapse to one; cards read as a vertical stack. */
  .home-category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .home-category-card {
    width: 100%;
  }

  /* Full-bleed call to action: the whole row is the tap target. */
  .home-category-card a,
  .home-category-card button,
  .home-cta,
  .home-hero a[class*="cta"],
  .home-hero button {
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .home-hero-logo {
    width: auto;
    max-width: min(320px, 78vw);
    height: auto;
  }

  .home-categories {
    margin-top: 44px;
  }

  /* ------------------------------------------------- instruments and grids */

  /* Wide instruments swipe horizontally rather than forcing the page to. The
     page itself must never scroll sideways — that is what makes a layout feel
     broken — so the scroll is contained to the instrument. */
  .instrument-viewport,
  .fretboard-viewport,
  .identifier-scaled-instrument-frame,
  .piano-viewport,
  #fretboard-container,
  #piano-container,
  .chord-diagram-container {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  body {
    overflow-x: hidden;
  }

  /* Twelve 44px columns need 528px, which overflows every phone. Six columns
     keep the 44px target intact and fit a 360px viewport. */
  .identifier-note-grid {
    grid-template-columns: repeat(6, minmax(44px, 1fr));
  }

  .identifier-note-button {
    min-height: 44px;
  }

  /* Fret cells are the densest touch surface on the site. */
  .fret-cell,
  .piano-key,
  .omni-set-badge,
  .identifier-card,
  .feature-switch,
  .library-item {
    min-height: 44px;
  }

  .identifier-root-lock {
    min-height: 26px;
  }

  /* Library results go single-column so each row is a comfortable target. */
  .omni-category-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-panel,
  .feature-panel-wide {
    padding-inline: 12px;
  }

  /* --------------------------------------------------------------- reading */

  .article-wrapper,
  .article-content {
    max-width: 100%;
    padding-inline: 18px;
  }

  .article-content {
    font-size: 17px;
    line-height: 1.72;
  }

  .article-content h1 { font-size: 27px; line-height: 1.22; }
  .article-content h2 { font-size: 22px; line-height: 1.28; }
  .article-content h3 { font-size: 19px; }

  .article-content p,
  .article-content li {
    font-size: 17px;
  }

  /* Code and tables are the usual culprits for sideways page scroll. */
  .article-content pre,
  .article-content table {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ------------------------------------------------------ modals and menus */

  .auth-overlay,
  .library-overlay {
    padding: 0;
  }

  .auth-dialog {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .auth-form-panel,
  .auth-perks {
    padding: 22px 18px;
  }

  .library-panel {
    width: 100%;
  }

  /* 16px is the iOS zoom threshold; the shared rule above sets the floor and
     this keeps the fields comfortable to hit as well as to read. */
  .auth-field input,
  .auth-premium-key {
    min-height: 46px;
  }

  .auth-submit-button,
  .auth-google-button,
  .auth-premium-activate,
  .library-item-remove {
    min-height: 46px;
  }

  .auth-mode-toggle,
  .auth-forgot-link {
    min-height: 32px;
  }

  /* The download menu is anchored to a button near the right edge; on a phone
     it becomes a sheet so it can never open off-screen. */
  .download-group {
    position: static;
  }

  .download-menu {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    min-width: 0;
  }

  .download-option,
  .download-trigger {
    min-height: 46px;
  }

  .download-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

/* Very small phones: two more columns come out of the note grid so the 44px
   target survives down to 320px. */
@media (max-width: 400px) {
  .identifier-note-grid {
    grid-template-columns: repeat(4, minmax(44px, 1fr));
  }

  .omni-category-cards {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    max-width: 132px;
  }
}

/* Desktop navigation sizing -------------------------------------------- */

@media (min-width: 769px) {
  .omni-library-tabs {
    gap: 6px;
  }

  .omni-library-tabs .nav-dropdown > summary,
  .omni-library-tabs > .article-nav-link {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.2;
  }

  .omni-library-tabs .nav-dropdown > summary::after {
    width: 6px;
    height: 6px;
    margin-left: 2px;
  }

  .omni-library-tabs .nav-dropdown > .nav-dropdown-menu {
    top: calc(100% + 8px);
    min-width: 210px;
    padding: 7px;
  }

  .omni-library-tabs .nav-dropdown > .nav-dropdown-menu a {
    display: flex;
    min-height: 42px;
    align-items: center;
    padding: 11px 13px;
    font-size: 13px;
    font-weight: 700;
  }
}
