/* ==========================================================================
   ChordIA-CM — Academic Hybrid Theme
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
  --bg-primary:    #faf8f5;
  --bg-secondary:  #f0ede8;
  --bg-card:       #ffffff;
  --bg-table-alt:  #f7f5f2;
  --text-primary:  #2c2c2c;
  --text-secondary:#5a5a5a;
  --text-muted:    #8a8a8a;
  --border-light:  #e0dcd7;
  --border-medium: #c8c4be;
  --shadow-soft:   0 2px 8px rgba(0,0,0,0.07);
  --shadow-medium: 0 4px 16px rgba(0,0,0,0.10);

  /* Harmonic function colors */
  --color-tonic:      #1a5276;
  --color-dominant:   #c0392b;
  --color-subdominant:#27ae60;
  --color-secondary:  #d35400;
  --color-neapolitan: #6c3483;
  --color-aug6:       #b03a2e;
  --color-mixture:    #117a65;
  --color-cadence:    #b7770d;
  --color-ornament:   #2471a3;
  --color-neutral:    #7f8c8d;

  /* Cadence colors */
  --color-pac:        #1a7a34;
  --color-hc:         #1a5276;
  --color-plagal:     #6c8a2c;
  --color-deceptive:  #922b21;
  --color-iac:        #148a74;

  /* Fonts */
  --font-serif: 'Crimson Text', Georgia, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-tonic); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-soft);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  font-size: 2rem;
  color: var(--color-tonic);
  line-height: 1;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
}

.nav-link.active, .nav-link:hover {
  color: var(--color-tonic);
  text-decoration: none;
}

.nav-sep { color: var(--border-medium); }
.nav-info { font-size: 0.78rem; color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: 0.5rem 2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.breadcrumb-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.breadcrumb a { color: var(--color-tonic); }
.breadcrumb .bc-sep { color: var(--border-medium); }
.breadcrumb .bc-current { color: var(--text-secondary); font-weight: 500; }

/* --------------------------------------------------------------------------
   Main layout
   -------------------------------------------------------------------------- */
.site-main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  padding: 0.8rem 2rem;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.footer-sep { color: var(--border-medium); }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.5rem;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.card-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   Section headers
   -------------------------------------------------------------------------- */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Index page — corpus overview
   -------------------------------------------------------------------------- */
.corpus-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.corpus-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.corpus-charts-wide {
  margin-bottom: 2rem;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.5rem;
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* --------------------------------------------------------------------------
   Opera table
   -------------------------------------------------------------------------- */
.opera-group {
  margin-bottom: 2rem;
}

.opera-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 0;
}

.opera-name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-primary);
}

.opera-year {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.opera-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

.aria-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.aria-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.aria-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.aria-table tr:last-child td { border-bottom: none; }

.aria-table tbody tr:hover td { background: var(--bg-secondary); cursor: pointer; }

.aria-table tr.status-error td { color: var(--text-muted); font-style: italic; }

.aria-title-link {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--color-tonic);
}

.aria-title-link:hover { text-decoration: underline; }

.aria-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  white-space: nowrap;
}

.badge-tonal {
  background: rgba(26,82,118,0.1);
  color: var(--color-tonic);
  border: 1px solid rgba(26,82,118,0.2);
}

.badge-tonal.major { background: rgba(192,57,43,0.1); color: var(--color-dominant); border-color: rgba(192,57,43,0.2); }

.badge-cadence { background: rgba(183,119,13,0.12); color: var(--color-cadence); border: 1px solid rgba(183,119,13,0.25); }
.badge-secondary { background: rgba(211,84,0,0.1); color: var(--color-secondary); border: 1px solid rgba(211,84,0,0.2); }
.badge-neapolitan { background: rgba(108,52,131,0.1); color: var(--color-neapolitan); border: 1px solid rgba(108,52,131,0.2); }
.badge-mixture { background: rgba(17,122,101,0.1); color: var(--color-mixture); border: 1px solid rgba(17,122,101,0.2); }
.badge-aug6 { background: rgba(176,58,46,0.1); color: var(--color-aug6); border: 1px solid rgba(176,58,46,0.2); }
.badge-ok { background: rgba(39,174,96,0.1); color: #27ae60; border: 1px solid rgba(39,174,96,0.2); }
.badge-error { background: rgba(192,57,43,0.1); color: var(--color-dominant); border: 1px solid rgba(192,57,43,0.2); }
.badge-pdf { background: rgba(127,140,141,0.1); color: var(--color-neutral); border: 1px solid rgba(127,140,141,0.2); }
.badge-xml { background: rgba(26,82,118,0.1); color: var(--color-tonic); border: 1px solid rgba(26,82,118,0.2); }

/* --------------------------------------------------------------------------
   Aria page layout
   -------------------------------------------------------------------------- */

/* Zone A: Score viewer */
.score-zone {
  margin-bottom: 1.5rem;
}

.score-viewer-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
}

.score-viewer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.score-tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.score-tab-btn.active {
  color: var(--color-tonic);
  border-bottom-color: var(--color-tonic);
  background: var(--bg-card);
}

.score-tab-content { display: none; }
.score-tab-content.active { display: flex; flex-direction: column; }

/* OSMD tab is the scroll container so the playback bar can be sticky */
#tab-osmd {
  max-height: 700px;
  overflow-y: auto;
  overflow-x: hidden;
}

#score-pdf-container {
  height: 600px;
  background: #525659;
}

#score-pdf-container embed,
#score-pdf-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

#score-osmd-container {
  padding: 1rem;
  min-height: 400px;
  overflow-x: auto;
  flex-shrink: 0;  /* don't compress — let #tab-osmd scroll instead */
}

.osmd-playback-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--bg-secondary, #f5f5f5);
  border-bottom: 1px solid var(--border-color, #ddd);
  position: sticky;
  top: 0;
  z-index: 20;
}

.osmd-pb-btn {
  border: 1px solid var(--border-color, #ccc);
  background: var(--bg-primary, #fff);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

.osmd-pb-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.osmd-pb-btn:not(:disabled):hover {
  background: var(--accent-light, #e8e8e8);
}

.osmd-pb-status {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  margin-left: 0.5rem;
}

.osmd-pb-sep {
  width: 1px;
  height: 1.2rem;
  background: var(--border-color, #ccc);
  margin: 0 0.25rem;
}

.osmd-pb-section {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.osmd-pb-tempo {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.analysis-pb-bar {
  position: static;
  border-radius: 6px 6px 0 0;
  border: 1px solid var(--border-light);
  border-bottom: none;
  margin-bottom: 0;
}

/* Cursor element — transitions handled by JS interpolation during playback */

.score-no-file {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* Measure navigator strip */
.measure-navigator {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  overflow-x: auto;
}

.measure-nav-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.measure-nav-strip {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.measure-cell {
  width: 22px;
  height: 18px;
  border-radius: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
  position: relative;
}

.measure-cell:hover { transform: scaleY(1.15); z-index: 1; }
.measure-cell.active { border-width: 2px; }

.measure-cell.cadence { background: rgba(183,119,13,0.3); border-color: var(--color-cadence); }
.measure-cell.secondary { background: rgba(211,84,0,0.2); border-color: var(--color-secondary); }
.measure-cell.neapolitan, .measure-cell.aug6 { background: rgba(108,52,131,0.2); border-color: var(--color-neapolitan); }
.measure-cell.mixture { background: rgba(17,122,101,0.15); border-color: var(--color-mixture); }
.measure-cell.highlight { outline: 2px solid var(--color-tonic); outline-offset: 1px; }
.measure-cell.playing { box-shadow: inset 0 0 0 2px rgba(39,174,96,0.6); background-color: rgba(39,174,96,0.25) !important; }

/* Measure navigator rich tooltip */
.mnav-tooltip {
  position: fixed;
  transform: translate(-50%, -100%);
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  padding: 0.5rem 0.75rem;
  pointer-events: none;
  max-width: 260px;
  font-size: 0.82rem;
  line-height: 1.4;
}
.mnav-tooltip strong {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
/* Column header tooltip (data-col-tip) */
.col-tip {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  box-shadow: var(--shadow-medium);
  padding: 0.45rem 0.7rem;
  pointer-events: none;
  max-width: 260px;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  line-height: 1.45;
  color: var(--text-primary);
  display: none;
}
.col-tip-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

th[data-col-tip] {
  cursor: help;
  border-bottom: 1px dashed rgba(255,255,255,0.4);
}

.mnav-tip-chords {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0.15rem 0;
}
.mnav-tip-degrees {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-tonic);
}
.mnav-tip-events {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-cadence);
}

/* Zone B: Analysis */
.analysis-zone {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

/* Slice table */
.slice-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.slice-panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slice-panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.slice-filter-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.filter-btn {
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  border-radius: 3px;
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-btn.active { background: var(--color-tonic); color: white; border-color: var(--color-tonic); }

.slice-autoscroll-btn {
  margin-left: auto;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid var(--border-medium);
  border-radius: 3px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.03em;
}
.slice-autoscroll-btn.active {
  background: rgba(39,174,96,0.12);
  color: #27ae60;
  border-color: rgba(39,174,96,0.4);
}

.slice-table-wrapper {
  overflow-y: auto;
  max-height: 480px;
}

.slice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.slice-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 0.45rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  z-index: 1;
  white-space: nowrap;
}

.slice-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--bg-table-alt);
  vertical-align: middle;
  white-space: nowrap;
}

.slice-table tr:hover td { background: var(--bg-secondary); cursor: pointer; }
.slice-table tr.selected td { background: rgba(26,82,118,0.07); }
.slice-table tr.strong-beat td { font-weight: 500; }
.slice-table tr.has-cadence td { background: rgba(183,119,13,0.06); }
.slice-table tr.playing-row td { background: rgba(39,174,96,0.10); }
.slice-table tr.playing-row td:first-child { box-shadow: inset 3px 0 0 rgba(39,174,96,0.7); }

.slice-measure { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.slice-beat { font-size: 0.78rem; color: var(--text-muted); }
.slice-chord {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
}
.slice-degree {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.9rem;
}
.slice-motion { font-size: 0.75rem; }
.slice-special { display: flex; gap: 3px; flex-wrap: wrap; }
.slice-ornaments { font-size: 0.75rem; color: var(--color-ornament); }

/* Motion icons */
.motion-contrary { color: var(--color-tonic); }
.motion-parallel { color: var(--color-dominant); font-weight: 600; }
.motion-similar  { color: var(--text-secondary); }
.motion-oblique  { color: var(--color-mixture); }
.motion-static   { color: var(--text-muted); }

/* Degree colors */
.deg-i, .deg-I   { color: var(--color-tonic); }
.deg-V            { color: var(--color-dominant); }
.deg-iv, .deg-IV  { color: var(--color-subdominant); }
.deg-ii, .deg-II  { color: #7d3c98; }
.deg-III          { color: #2e86c1; }
.deg-VI, .deg-vi  { color: #d4ac0d; }
.deg-VII, .deg-vii{ color: #a04000; }
.deg-N, .deg-N6   { color: var(--color-neapolitan); }
.deg-other        { color: var(--text-secondary); }

/* Detail panel */
.detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  position: sticky;
  top: 80px;
}

.detail-panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.detail-panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.detail-panel-body {
  padding: 1rem;
  font-size: 0.85rem;
}

.detail-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bg-table-alt);
}

.detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.detail-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.detail-chord-big {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-style: italic;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.detail-chord-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.15rem 0;
  font-size: 0.83rem;
}

.detail-row-label { color: var(--text-muted); }
.detail-row-value { font-weight: 500; color: var(--text-primary); }

.note-list { display: flex; flex-direction: column; gap: 2px; }

.note-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 3px;
  font-size: 0.8rem;
}

.note-name { font-family: var(--font-serif); font-size: 0.9rem; }
.note-staff { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }
.note-type { font-size: 0.72rem; padding: 0.1rem 0.3rem; border-radius: 2px; }
.note-chord-tone { background: rgba(26,82,118,0.1); color: var(--color-tonic); }
.note-ornament { background: rgba(36,113,163,0.1); color: var(--color-ornament); }

.detail-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem;
}

/* Confidence bar */
.confidence-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.confidence-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-tonic);
  transition: width 0.3s;
}

.confidence-value { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }

/* Zone C: Charts */
.charts-zone {
  margin-bottom: 1.5rem;
}

.charts-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-canvas-wrap {
  position: relative;
  height: 260px;
}

/* Cadence timeline */
.cadence-timeline {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.timeline-canvas-wrap {
  position: relative;
  height: 80px;
}

/* Aria info header */
.aria-info-header {
  margin-bottom: 1.5rem;
}

.aria-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.aria-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  text-align: center;
}

.aria-stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.aria-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   Loading / Spinner
   -------------------------------------------------------------------------- */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  gap: 0.75rem;
  font-size: 0.9rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--color-tonic);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-serif { font-family: var(--font-serif); font-style: italic; }
.text-mono  { font-family: var(--font-mono); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .analysis-zone { grid-template-columns: 1fr; }
  .charts-grid-2, .charts-grid-3 { grid-template-columns: 1fr; }
  .corpus-charts-row { grid-template-columns: 1fr; }
  .site-main { padding: 1rem; }
  .detail-panel { position: static; }
}

/* ==========================================================================
   Voice control panel (metronome + per-voice Audio/Vista toggles)
   ========================================================================== */

.voice-panel {
  position: absolute;
  z-index: 9000;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: var(--shadow-medium);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
}

.vp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0;
  gap: 0.5rem;
}

.vp-metro { font-weight: 600; }
.vp-label { flex: 1; }

.vp-sep {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 0.4rem 0;
}

.vp-part-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.vp-controls {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-shrink: 0;
}

.vp-mini-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--text-muted);
  cursor: pointer;
}

.vp-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0.2rem 0 0;
}

/* iOS-style toggle switch */
.vp-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.vp-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.vp-slider {
  position: absolute;
  inset: 0;
  background: #c8c4be;
  border-radius: 20px;
  transition: background 0.2s;
}
.vp-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.vp-switch input:checked + .vp-slider { background: var(--color-tonic, #1a5276); }
.vp-switch input:checked + .vp-slider::before { transform: translateX(16px); }

/* Small variant used inside vp-controls */
.vp-small { width: 30px; height: 16px; }
.vp-small .vp-slider::before { width: 10px; height: 10px; left: 3px; bottom: 3px; }
.vp-small input:checked + .vp-slider::before { transform: translateX(14px); }

/* Gear button in playback bar */
.osmd-voices-btn { font-size: 1rem; padding: 0 0.45rem; opacity: 0.7; }
.osmd-voices-btn:hover { opacity: 1; }

/* Export HTML button */
.btn-export {
  display: inline-block;
  margin-left: auto;
  padding: 0.4rem 0.9rem;
  background: var(--color-tonic, #1a5276);
  color: #fff;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-export:hover { opacity: 0.85; }
