:root {
  --bg:         #1a1a2e;
  --bg-card:    #16213e;
  --bg-input:   #0f3460;
  --text:       #e0e0e0;
  --text-muted: #6a7080;
  --accent:     #e94560;
  --accent2:    #f5a623;
  --border:     #2a2a4a;
  --radius:     10px;

  /* Note color hierarchy — used in SVG staffs and note chips */
  --note-tonic:  #ff3355;
  --note-chord:  #e94560;
  --note-scale:  #e07888;
  --note-muted:  #444464;

  /* Visual profile font scale — JS overrides this per profile */
  --font-scale: 1;

  /* Note chip text color — overridden per profile (dark bg → white, light pastel bg → dark) */
  --chip-text: #fff;

  /* Tonic column highlight color in range staff */
  --tonic-col-bg: rgba(70,160,90,0.20);

  /* Logo variables (default dark values) */
  --logo-clef:   #b09878;
  --logo-staff:  #7878a0;
  --logo-tonic:  #a8b4e0;
  --logo-chord:  #e0a8b4;
  --logo-accent: #88a888;
}

/* Scales all rem-based text sizes when profile changes --font-scale */
html { font-size: calc(16px * var(--font-scale)); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Header ─── */
header {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

header h1 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  overflow: hidden;
  min-width: 0;
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: normal;
}

.logo {
  height: 34px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

/* ─── Breadcrumb navigation ─── */
.bc-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.bc-logo:hover { opacity: 0.75; }

.bc-link {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 2;
}
.bc-link:hover { color: var(--accent); text-decoration: underline; }

.bc-sep {
  color: var(--text-muted);
  opacity: 0.4;
  flex-shrink: 0;
  font-size: 0.8rem;
  user-select: none;
}

.bc-current {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}

.nav-current {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}

/* ─── Title row: heading + range link side by side ─── */
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

/* ─── Range page link inside scale boxes ─── */
.range-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.range-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ─── Saxophone-alto page back-link ─── */
.back-link {
  text-decoration: none;
  color: var(--accent);
  font-size: 0.85rem;
}
.back-link:hover { text-decoration: underline; }

/* ─── Type sub-nav (minor variants on saxophone-alto page) ─── */
.type-nav {
  display: inline-flex;
  align-items: stretch;
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.87rem;
}
.type-nav a,
.type-nav strong {
  padding: 0.35rem 1rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.type-nav strong {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.type-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.type-nav a:hover {
  background: var(--bg-card);
  color: var(--text);
}
.type-nav-sep {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── Main layout — mobile portrait (default) ─── */
main {
  width: 100%;
  max-width: 760px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ─── Range page: full-width layout ─── */
.range-main {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

/* ─── Filter bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.8rem;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 0.1rem;
}

/* ─── Filter chips (toggle buttons) ─── */
.filter-chip {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.28rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-input);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-chip:hover:not(.active) {
  border-color: var(--accent);
  color: var(--text);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Scale select (combo) ─── */
.scale-select-group {
  flex: 1;
  min-width: 140px;
  flex-wrap: nowrap;
}

/* ─── Scale select ─── */
.scale-select-group select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.38rem 0.7rem;
  font-size: 0.95rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.scale-select-group select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Profile selector (inline in header) ─── */
.profile-select {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.22rem 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
  max-width: 9rem;
  flex-shrink: 0;
}
.profile-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Cards ─── */
.scale-section,
.range-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.scale-section h2,
.range-section h2 { font-size: 1.2rem; }

.circle-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

.title-info {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.chord-inline {
  font-size: 0.82rem;
  font-weight: normal;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Minor variant sub-sections ─── */
.minor-variant {
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
  margin-top: 0.8rem;
}

.minor-variant:first-of-type { border-top: none; padding-top: 0; margin-top: 0.5rem; }

.minor-variant h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.minor-variant .title-row > h3 {
  flex: 1;
  min-width: 0;
}

.variant-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.variant-changes-inline {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.variant-changes {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0.6rem;
}

/* ─── Note chips ─── */
.note-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.note-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background 0.15s;
}

.note-chip.chord {
  background: var(--note-chord-label-bg);
  border-color: var(--note-chord-label-bg);
  color: var(--note-chord-label);
}

.note-chip.tonic {
  background: var(--note-tonic-label-bg);
  border-color: var(--note-tonic-label-bg);
  color: var(--note-tonic-label);
}

/* ─── Staff containers ─── */
.staff-container {
  color: var(--text);
  overflow-x: auto;
}

.range-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 1rem; margin-bottom: 0.6rem; }

.range-dir-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent2);
  margin-bottom: 0.3rem;
}

/* ─── Range staff note tooltip ─── */
.note-tooltip {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}

/* ─── Minor range variants ─── */
.range-variant {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  margin-top: 1.1rem;
}

.range-variant:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0.2rem;
}

.range-variant h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent2);
  margin-bottom: 0.3rem;
}

/* ─── Desktop: wider max-width (≥ 900 px) ─── */
@media (min-width: 900px) {
  main { max-width: 900px; }
  .bc-current { font-size: 1.4rem; }
  .bc-link { font-size: 1.0rem; }
}

/* ─── Landscape mobile: compact header + tighter layout ─── */
@media (orientation: landscape) and (max-height: 560px) {
  header { padding: 0.25rem 0.8rem; }
  .logo { height: 26px; }
  .bc-current { font-size: 0.95rem; }
  .bc-link { font-size: 0.78rem; }
  .profile-select { font-size: 0.7rem; padding: 0.15rem 0.3rem; }

  main { gap: 0.7rem; padding: 0.6rem 1rem; }

  .filter-bar { padding: 0.5rem 0.8rem; }

  .scale-section,
  .range-section { padding: 0.6rem 0.8rem; }

  .scale-section h2 { font-size: 1rem; margin-bottom: 0.2rem; }
  .range-section h2 { font-size: 1rem; margin-bottom: 0.2rem; }

  .chord-label  { margin-bottom: 0.4rem; }
  .note-row     { margin-bottom: 0.5rem; }
  .minor-variant { margin-top: 0.5rem; padding-top: 0.5rem; }
}

/* ─── App footer ─── */
.app-footer {
  width: 100%;
  text-align: center;
  padding: 0.6rem 1rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: auto;
  flex-shrink: 0;
}
.app-footer a { color: inherit; text-decoration: none; }
.app-footer a:hover { opacity: 0.7; }

/* ─── Small portrait phones (< 380 px) ─── */
@media (max-width: 380px) {
  .logo { height: 30px; }
  .bc-current { font-size: 1.1rem; }
  .note-chip { font-size: 0.8rem; min-width: 2rem; padding: 0.25rem 0.4rem; }
  .scale-section h2 { font-size: 1rem; }
  .filter-chip { font-size: 0.75rem; padding: 0.22rem 0.55rem; }
}
