/* =========================================================
   Persian Music Scales — Audio Analyzer Extension
   Drop-in companion stylesheet for index.html
   ========================================================= */

:root {
  --analyzer-ink: #18202b;
  --analyzer-muted: #687386;
  --analyzer-panel: rgba(255, 255, 255, 0.96);
  --analyzer-border: rgba(24, 32, 43, 0.14);
  --analyzer-accent: #774953;
  --analyzer-accent-2: #1a3b66;
  --analyzer-good: #1f7a5a;
  --analyzer-warn: #a66a00;
  --analyzer-danger: #a23a3a;
  --analyzer-shadow: 0 24px 70px rgba(13, 22, 35, 0.28);
}

/* Floating entry point below the existing scale player. */
.analyzer-launch-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  z-index: 20;
}

.analyzer-launch-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: linear-gradient(135deg, #1a3b66, #774953);
  color: #fff;
  padding: 10px 17px;
  font: 700 0.88rem/1 Arial, sans-serif;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(26, 59, 102, 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.analyzer-launch-button:hover,
.analyzer-launch-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(26, 59, 102, 0.32);
  filter: saturate(1.08);
  outline: none;
}

.analysis-mini-badge {
  display: none;
  align-items: center;
  gap: 7px;
  max-width: min(62vw, 420px);
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--analyzer-ink);
  padding: 7px 12px;
  font-size: 0.78rem;
  box-shadow: 0 7px 18px rgba(13, 22, 35, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.analysis-mini-badge.visible {
  display: inline-flex;
}

.analysis-mini-badge strong {
  color: var(--analyzer-accent-2);
}

/* Drawer and backdrop. */
.audio-analyzer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1590;
  background: rgba(8, 14, 24, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.audio-analyzer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.audio-analyzer-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1600;
  width: min(500px, 96vw);
  display: flex;
  flex-direction: column;
  color: var(--analyzer-ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(247, 231, 198, 0.65), transparent 35%),
    var(--analyzer-panel);
  border-left: 1px solid var(--analyzer-border);
  box-shadow: var(--analyzer-shadow);
  transform: translateX(103%);
  transition: transform 260ms cubic-bezier(0.22, 0.82, 0.24, 1);
  overflow: hidden;
}

.audio-analyzer-drawer.open {
  transform: translateX(0);
}

.analyzer-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 13px;
  border-bottom: 1px solid var(--analyzer-border);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.analyzer-title-wrap h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

.analyzer-title-wrap p {
  margin: 5px 0 0;
  color: var(--analyzer-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.analyzer-icon-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--analyzer-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: var(--analyzer-ink);
  font-size: 1.3rem;
  cursor: pointer;
}

.analyzer-icon-button:hover,
.analyzer-icon-button:focus-visible {
  background: #fff;
  outline: 2px solid rgba(26, 59, 102, 0.25);
}

.analyzer-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 88px;
}

.analyzer-card {
  margin-bottom: 13px;
  padding: 14px;
  border: 1px solid var(--analyzer-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 7px 24px rgba(13, 22, 35, 0.06);
}

.analyzer-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.analyzer-card-heading h3 {
  margin: 0;
  font-size: 0.92rem;
}

.analyzer-card-heading span {
  color: var(--analyzer-muted);
  font-size: 0.72rem;
}

.audio-drop-zone {
  display: grid;
  place-items: center;
  min-height: 118px;
  border: 1.5px dashed rgba(26, 59, 102, 0.38);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(26, 59, 102, 0.055), rgba(119, 73, 83, 0.055));
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.audio-drop-zone:hover,
.audio-drop-zone:focus-visible,
.audio-drop-zone.dragover {
  border-color: var(--analyzer-accent-2);
  background: linear-gradient(145deg, rgba(26, 59, 102, 0.1), rgba(119, 73, 83, 0.1));
  transform: translateY(-1px);
  outline: none;
}

.audio-drop-zone .drop-icon {
  display: block;
  margin-bottom: 6px;
  font-size: 1.65rem;
}

.audio-drop-zone strong {
  display: block;
  font-size: 0.86rem;
}

.audio-drop-zone small {
  display: block;
  margin-top: 5px;
  color: var(--analyzer-muted);
  font-size: 0.72rem;
}

.track-summary {
  display: none;
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 11px;
  background: rgba(26, 59, 102, 0.06);
}

.track-summary.visible {
  display: block;
}

.track-summary strong,
.track-summary span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-summary strong {
  font-size: 0.8rem;
}

.track-summary span {
  margin-top: 3px;
  color: var(--analyzer-muted);
  font-size: 0.7rem;
}

.analyzer-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.analyzer-field label {
  display: block;
  margin-bottom: 5px;
  color: var(--analyzer-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.analyzer-field select,
.analyzer-field input[type="number"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--analyzer-border);
  border-radius: 9px;
  background: #fff;
  color: var(--analyzer-ink);
  padding: 7px 9px;
  font-size: 0.78rem;
}

.analyzer-help {
  margin: 8px 0 0;
  color: var(--analyzer-muted);
  font-size: 0.69rem;
  line-height: 1.45;
}

.analyzer-actions {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr;
  gap: 8px;
  margin-top: 12px;
}

.analyzer-button {
  min-height: 39px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font: 700 0.75rem/1 Arial, sans-serif;
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease, opacity 130ms ease;
}

.analyzer-button:hover:not(:disabled),
.analyzer-button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  outline: none;
}

.analyzer-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.analyzer-button.primary {
  background: var(--analyzer-accent-2);
  color: #fff;
}

.analyzer-button.secondary {
  background: var(--analyzer-accent);
  color: #fff;
}

.analyzer-button.ghost {
  border-color: var(--analyzer-border);
  background: #fff;
  color: var(--analyzer-ink);
}

.analyzer-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  color: var(--analyzer-muted);
  font-size: 0.7rem;
}

.analyzer-progress-track {
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(24, 32, 43, 0.1);
}

.analyzer-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--analyzer-accent-2), var(--analyzer-accent));
  transition: width 120ms linear;
}

.analyzer-canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(24, 32, 43, 0.09);
  border-radius: 11px;
  background: #f5f7fa;
}

.analyzer-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 94px;
}

.analyzer-seek {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--analyzer-accent-2);
}

.analyzer-time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--analyzer-muted);
  font-size: 0.67rem;
  font-variant-numeric: tabular-nums;
}

.analysis-result-placeholder {
  color: var(--analyzer-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.best-match {
  display: none;
}

.best-match.visible {
  display: block;
}

.best-match-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.best-match-name {
  margin: 0;
  font-size: 1.18rem;
  color: var(--analyzer-accent-2);
}

.best-match-subtitle {
  margin-top: 4px;
  color: var(--analyzer-muted);
  font-size: 0.72rem;
}

.confidence-ring {
  --confidence-angle: 0deg;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: conic-gradient(var(--analyzer-good) var(--confidence-angle), rgba(24, 32, 43, 0.1) 0);
  position: relative;
}

.confidence-ring::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #fff;
}

.confidence-ring span {
  position: relative;
  z-index: 1;
  font-size: 0.78rem;
  font-weight: 800;
}

.candidate-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.candidate-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border-radius: 9px;
  background: rgba(24, 32, 43, 0.045);
  font-size: 0.72rem;
}

.candidate-item strong {
  font-size: 0.74rem;
}

.candidate-item span {
  color: var(--analyzer-muted);
  font-variant-numeric: tabular-nums;
}

.now-playing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.now-playing-cell {
  min-width: 0;
  padding: 9px;
  border-radius: 10px;
  background: rgba(26, 59, 102, 0.06);
}

.now-playing-cell small,
.now-playing-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-playing-cell small {
  margin-bottom: 4px;
  color: var(--analyzer-muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.now-playing-cell strong {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.analyzer-disclaimer {
  margin: 0;
  padding: 10px 11px;
  border-left: 3px solid var(--analyzer-warn);
  border-radius: 7px;
  background: rgba(166, 106, 0, 0.07);
  color: #634511;
  font-size: 0.68rem;
  line-height: 1.45;
}

/* Active note animation on existing outer labels. */
.dynamic-label.analysis-active {
  z-index: 40;
  color: #fff !important;
  background: linear-gradient(135deg, #1a3b66, #774953) !important;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.76),
    0 0 0 9px rgba(119, 73, 83, 0.2),
    0 0 25px rgba(26, 59, 102, 0.72);
  animation: analyzerNotePulse 440ms ease-in-out infinite alternate;
}

.dynamic-label.analysis-near {
  z-index: 39;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.68),
    0 0 18px rgba(166, 106, 0, 0.6);
  animation: analyzerNearPulse 620ms ease-in-out infinite alternate;
}

.dynamic-label.analysis-outside {
  z-index: 39;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.68),
    0 0 0 8px rgba(162, 58, 58, 0.2),
    0 0 18px rgba(162, 58, 58, 0.64);
}

@keyframes analyzerNotePulse {
  from {
    transform: translate(-50%, -50%) scale(1.02) rotate(-1deg);
  }
  to {
    transform: translate(-50%, -50%) scale(1.22) rotate(1deg);
  }
}

@keyframes analyzerNearPulse {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.1); }
}

body.analyzer-lock-scroll {
  overflow: hidden;
}

.rtl .audio-analyzer-drawer {
  right: auto;
  left: 0;
  border-left: 0;
  border-right: 1px solid var(--analyzer-border);
  transform: translateX(-103%);
}

.rtl .audio-analyzer-drawer.open {
  transform: translateX(0);
}

.rtl .analyzer-disclaimer {
  border-left: 0;
  border-right: 3px solid var(--analyzer-warn);
}

@media (prefers-reduced-motion: reduce) {
  .audio-analyzer-drawer,
  .audio-analyzer-backdrop,
  .analyzer-launch-button,
  .dynamic-label.analysis-active,
  .dynamic-label.analysis-near {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 620px) {
  .audio-analyzer-drawer {
    width: 100vw;
  }

  .analyzer-scroll {
    padding-inline: 12px;
  }

  .analyzer-field-grid,
  .now-playing-grid {
    grid-template-columns: 1fr;
  }

  .analyzer-actions {
    grid-template-columns: 1fr 1fr;
  }

  .analyzer-actions .ghost {
    grid-column: 1 / -1;
  }

  .analysis-mini-badge {
    max-width: 76vw;
  }
}

/* =========================================================
   Predominant-melody controls and v2 playback
   ========================================================= */

.analyzer-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 11px;
  padding: 10px;
  border: 1px solid rgba(26, 59, 102, 0.14);
  border-radius: 11px;
  background: rgba(26, 59, 102, 0.045);
  cursor: pointer;
}

.analyzer-toggle input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--analyzer-accent-2);
}

.analyzer-toggle span,
.analyzer-toggle strong,
.analyzer-toggle small {
  display: block;
}

.analyzer-toggle strong {
  color: var(--analyzer-ink);
  font-size: 0.75rem;
  line-height: 1.3;
}

.analyzer-toggle small {
  margin-top: 3px;
  color: var(--analyzer-muted);
  font-size: 0.66rem;
  line-height: 1.4;
}

.analyzer-range-label,
.analyzer-range-ends {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.analyzer-range-label output {
  color: var(--analyzer-accent-2);
  font-size: 0.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.analyzer-range {
  width: 100%;
  margin: 2px 0 0;
  accent-color: var(--analyzer-accent-2);
}

.analyzer-range-ends {
  margin-top: 1px;
  color: var(--analyzer-muted);
  font-size: 0.61rem;
}

.analyzer-actions-playback {
  grid-template-columns: 1.18fr 1fr 1.22fr 0.72fr;
}

.analyzer-button.melody {
  border-color: rgba(31, 122, 90, 0.24);
  background: rgba(31, 122, 90, 0.12);
  color: #155d44;
}

.analyzer-button.playing {
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.17);
  filter: saturate(1.12);
}

#noteTimelineCanvas {
  height: 110px;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  margin-top: 7px;
  color: var(--analyzer-muted);
  font-size: 0.62rem;
}

.timeline-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.timeline-key {
  display: inline-block;
  width: 15px;
  height: 6px;
  border-radius: 999px;
}

.timeline-key.raw {
  background: rgba(104, 115, 134, 0.35);
}

.timeline-key.structural {
  background: #1a3b66;
}

.timeline-key.ornament {
  background: #a66a00;
}

.now-playing-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dynamic-label.analysis-ornament {
  z-index: 40;
  color: #fff !important;
  background: linear-gradient(135deg, #a66a00, #774953) !important;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.74),
    0 0 0 8px rgba(166, 106, 0, 0.2),
    0 0 22px rgba(166, 106, 0, 0.68);
  animation: analyzerOrnamentPulse 220ms ease-in-out infinite alternate;
}

@keyframes analyzerOrnamentPulse {
  from { transform: translate(-50%, -50%) scale(1.01) rotate(-1.4deg); }
  to { transform: translate(-50%, -50%) scale(1.15) rotate(1.4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .dynamic-label.analysis-ornament {
    animation: none !important;
  }
}

@media (max-width: 620px) {
  .analyzer-actions-playback {
    grid-template-columns: 1fr 1fr;
  }

  .analyzer-actions-playback .primary,
  .analyzer-actions-playback .melody {
    grid-column: auto;
  }

  .analyzer-actions-playback .ghost {
    grid-column: auto;
  }

  .now-playing-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* =========================================================
   v3 — selectable interpretations, modal evidence and
   a true radial spectrum halo around the circle.
   ========================================================= */

.radial-spectrum-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(100% + clamp(88px, 15vw, 190px));
  height: calc(100% + clamp(88px, 15vw, 190px));
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 240ms ease;
  filter: drop-shadow(0 0 7px rgba(26, 59, 102, 0.22));
}

.radial-spectrum-canvas.visible {
  opacity: 1;
}

.visualizer-settings {
  margin: 12px 0 3px;
  border: 1px solid rgba(26, 59, 102, 0.12);
  border-radius: 12px;
  background: rgba(245, 247, 250, 0.74);
  overflow: hidden;
}

.visualizer-settings > summary,
.analysis-explanation > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  color: var(--analyzer-accent-2);
  font-size: 0.73rem;
  font-weight: 800;
  user-select: none;
}

.visualizer-settings > summary::-webkit-details-marker,
.analysis-explanation > summary::-webkit-details-marker {
  display: none;
}

.visualizer-settings > summary::after,
.analysis-explanation > summary::after {
  content: "＋";
  float: inline-end;
  opacity: 0.7;
}

.visualizer-settings[open] > summary::after,
.analysis-explanation[open] > summary::after {
  content: "−";
}

.visualizer-settings > :not(summary) {
  margin-inline: 11px;
}

.visualizer-settings > :last-child {
  margin-bottom: 11px;
}

.analyzer-toggle.compact {
  padding: 8px 9px;
  margin-bottom: 8px;
}

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

.ambiguity-notice {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(166, 106, 0, 0.28);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(255, 246, 218, 0.95), rgba(247, 231, 198, 0.75));
  color: #6a4600;
}

.ambiguity-notice.visible {
  display: block;
}

.ambiguity-notice.strong {
  border-color: rgba(31, 122, 90, 0.25);
  background: rgba(227, 248, 239, 0.88);
  color: #155d44;
}

.ambiguity-notice.low {
  border-color: rgba(162, 58, 58, 0.28);
  background: rgba(255, 235, 235, 0.9);
  color: #7d2525;
}

.ambiguity-notice strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.74rem;
}

.ambiguity-notice p {
  margin: 0;
  font-size: 0.67rem;
  line-height: 1.45;
}

.candidate-choice-list {
  display: grid;
  gap: 7px;
}

.candidate-choice-list .candidate-item {
  width: 100%;
  border: 1px solid rgba(26, 59, 102, 0.14);
  background: rgba(255, 255, 255, 0.84);
  cursor: pointer;
  text-align: start;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.candidate-choice-list .candidate-item:hover {
  transform: translateY(-1px);
  border-color: rgba(26, 59, 102, 0.35);
  box-shadow: 0 5px 15px rgba(21, 36, 56, 0.08);
}

.candidate-choice-list .candidate-item.selected {
  border-color: rgba(26, 59, 102, 0.72);
  background: linear-gradient(135deg, rgba(226, 237, 252, 0.95), rgba(245, 248, 253, 0.95));
  box-shadow: 0 0 0 3px rgba(26, 59, 102, 0.1);
}

.candidate-choice-list .candidate-item.close-candidate::after {
  content: "≈";
  margin-inline-start: 5px;
  color: #a66a00;
  font-weight: 900;
}

.candidate-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(26, 59, 102, 0.1);
  color: var(--analyzer-accent-2);
  font-size: 0.65rem;
  font-weight: 900;
}

.candidate-label {
  min-width: 0;
  flex: 1;
}

.candidate-label strong,
.candidate-label small {
  display: block;
}

.candidate-label small {
  margin-top: 2px;
  color: var(--analyzer-muted);
  font-size: 0.6rem;
}

.candidate-score {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.candidate-comparison {
  display: none;
  margin-top: 12px;
  border-top: 1px solid rgba(26, 59, 102, 0.1);
  padding-top: 10px;
}

.candidate-comparison.visible {
  display: block;
}

.candidate-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.candidate-metric {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 9px;
  background: rgba(245, 247, 250, 0.86);
}

.candidate-metric small,
.candidate-metric strong {
  display: block;
}

.candidate-metric small {
  color: var(--analyzer-muted);
  font-size: 0.58rem;
}

.candidate-metric strong {
  margin-top: 2px;
  color: var(--analyzer-text);
  font-size: 0.72rem;
}

.metric-bar {
  height: 4px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(26, 59, 102, 0.08);
}

.metric-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #48625f, #1a3b66);
}

.manual-override {
  margin-top: 13px;
  padding-top: 10px;
  border-top: 1px solid rgba(26, 59, 102, 0.1);
}

.manual-override-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.manual-override .analyzer-button {
  min-height: 38px;
  white-space: nowrap;
}

.analysis-explanation {
  margin-top: 12px;
  border: 1px solid rgba(26, 59, 102, 0.1);
  border-radius: 10px;
  background: rgba(245, 247, 250, 0.72);
}

.analysis-explanation p {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--analyzer-muted);
  font-size: 0.67rem;
  line-height: 1.52;
}

.dynamic-label.analysis-selected-scale {
  outline: 1px solid rgba(26, 59, 102, 0.22);
}

@media (max-width: 620px) {
  .visualizer-grid,
  .candidate-metrics,
  .manual-override-grid {
    grid-template-columns: 1fr;
  }

  .manual-override .analyzer-button {
    width: 100%;
  }

  .radial-spectrum-canvas {
    width: calc(100% + 74px);
    height: calc(100% + 74px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .radial-spectrum-canvas {
    transition: none;
    filter: none;
  }

  .candidate-choice-list .candidate-item {
    transition: none;
  }
}

.candidate-choice-list .candidate-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.candidate-choice-list .candidate-rank {
  color: var(--analyzer-accent-2);
}

.candidate-choice-list .candidate-score {
  color: var(--analyzer-accent-2);
  font-weight: 900;
}


/* v4: automatic-analysis workflow and default controls */
.analyzer-card-heading-actions {
  gap: 12px;
  align-items: center;
}

.analyzer-reset-button {
  border: 1px solid rgba(26, 59, 102, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #1a3b66;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.analyzer-reset-button:hover,
.analyzer-reset-button:focus-visible {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 5px 14px rgba(26, 59, 102, 0.13);
  outline: none;
}

.auto-analysis-hint {
  margin: 9px 1px 0;
  color: var(--analyzer-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.audio-analyzer-drawer.analysis-complete {
  box-shadow: -18px 0 54px rgba(26, 59, 102, 0.22);
}

.audio-analyzer-drawer.analysis-complete .analyzer-progress-bar {
  filter: saturate(1.2) brightness(1.06);
}

@media (max-width: 560px) {
  .analyzer-card-heading-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .analyzer-reset-button {
    align-self: flex-start;
  }
}




/* =========================================================
   Built-in example recording — v5.5
   ========================================================= */
.example-track-button {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  border: 1px solid rgba(26, 59, 102, 0.2);
  border-radius: 14px;
  padding: 11px 13px;
  background:
    radial-gradient(circle at 8% 10%, rgba(247, 231, 198, 0.68), transparent 38%),
    linear-gradient(135deg, rgba(26, 59, 102, 0.08), rgba(119, 73, 83, 0.07));
  color: var(--analyzer-ink);
  text-align: start;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.example-track-button:hover:not(:disabled),
.example-track-button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(26, 59, 102, 0.48);
  box-shadow: 0 8px 20px rgba(26, 59, 102, 0.12);
  outline: none;
}

.example-track-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.example-track-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1a3b66, #4b4e6d);
  color: #fff;
  box-shadow: 0 5px 14px rgba(26, 59, 102, 0.22);
  font-size: 0.85rem;
  padding-inline-start: 2px;
}

.example-track-copy {
  min-width: 0;
}

.example-track-copy strong,
.example-track-copy small {
  display: block;
}

.example-track-copy strong {
  font-size: 0.82rem;
}

.example-track-copy small {
  margin-top: 4px;
  color: var(--analyzer-muted);
  font-size: 0.68rem;
  line-height: 1.38;
}

.example-track-arrow {
  color: var(--analyzer-accent);
  font-size: 1.55rem;
  line-height: 1;
}

.analyzer-button.attention {
  animation: analyzer-play-attention 1.15s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(26, 59, 102, 0.34);
}

@keyframes analyzer-play-attention {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0 rgba(26, 59, 102, 0.28);
  }
  50% {
    transform: translateY(-1px);
    box-shadow: 0 0 0 7px rgba(26, 59, 102, 0);
  }
}

@media (max-width: 520px) {
  .example-track-button {
    grid-template-columns: 40px minmax(0, 1fr) 14px;
    gap: 9px;
    padding: 10px 11px;
  }

  .example-track-icon {
    width: 38px;
    height: 38px;
  }

  .example-track-copy small {
    font-size: 0.64rem;
  }
}

/* =========================================================
   Microphone hold-to-record input — v5.1
   ========================================================= */
.analyzer-input-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 10px;
  color: var(--analyzer-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.analyzer-input-divider::before,
.analyzer-input-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--analyzer-border));
}

.analyzer-input-divider::after {
  background: linear-gradient(90deg, var(--analyzer-border), transparent);
}

.microphone-recorder {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(119, 73, 83, 0.19);
  border-radius: 15px;
  padding: 12px;
  background:
    radial-gradient(circle at 12% 0%, rgba(247, 231, 198, 0.55), transparent 46%),
    linear-gradient(145deg, rgba(119, 73, 83, 0.055), rgba(26, 59, 102, 0.045));
}

.hold-record-button {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 13px;
  border: 0;
  border-radius: 13px;
  padding: 10px 12px;
  color: var(--analyzer-ink);
  background: rgba(255, 255, 255, 0.76);
  text-align: start;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 5px 18px rgba(13, 22, 35, 0.07);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.hold-record-button:hover:not(:disabled),
.hold-record-button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(13, 22, 35, 0.12);
  outline: 2px solid rgba(119, 73, 83, 0.2);
  outline-offset: 2px;
}

.hold-record-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.record-button-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(119, 73, 83, 0.12);
  box-shadow: inset 0 0 0 1px rgba(119, 73, 83, 0.16);
}

.record-button-core {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #9f5361, #6c3542);
  font-size: 1.05rem;
  box-shadow: 0 6px 14px rgba(119, 73, 83, 0.27);
  transform: scale(1);
  transition: transform 140ms ease, filter 140ms ease;
}

.record-button-copy strong,
.record-button-copy small {
  display: block;
}

.record-button-copy strong {
  font-size: 0.86rem;
}

.record-button-copy small {
  margin-top: 3px;
  color: var(--analyzer-muted);
  font-size: 0.69rem;
  line-height: 1.35;
}

.hold-record-button.arming .record-button-ring,
.hold-record-button.recording .record-button-ring {
  animation: recorder-ring-pulse 1.15s ease-in-out infinite;
}

.hold-record-button.recording {
  background: rgba(255, 242, 244, 0.96);
  box-shadow: 0 9px 25px rgba(119, 73, 83, 0.19);
}

.hold-record-button.recording .record-button-core {
  filter: saturate(1.3) brightness(1.05);
  transform: scale(1.08);
}

.hold-record-button.processing .record-button-core {
  animation: recorder-processing 0.9s linear infinite;
}

@keyframes recorder-ring-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(119, 73, 83, 0.16), 0 0 0 0 rgba(159, 83, 97, 0.27); }
  50% { box-shadow: inset 0 0 0 1px rgba(119, 73, 83, 0.22), 0 0 0 10px rgba(159, 83, 97, 0); }
}

@keyframes recorder-processing {
  to { transform: rotate(360deg); }
}

.recording-feedback {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  margin-top: 9px;
  color: var(--analyzer-muted);
  font-size: 0.7rem;
}

.recording-feedback strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recording-feedback time {
  min-width: 45px;
  color: var(--analyzer-ink);
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a95a5;
  box-shadow: 0 0 0 3px rgba(138, 149, 165, 0.12);
}

.recording-feedback[data-state="recording"] .recording-dot {
  background: #c33b4e;
  box-shadow: 0 0 0 3px rgba(195, 59, 78, 0.14);
  animation: recording-dot-pulse 0.9s ease-in-out infinite;
}

.recording-feedback[data-state="arming"] .recording-dot,
.recording-feedback[data-state="processing"] .recording-dot {
  background: #b77813;
  box-shadow: 0 0 0 3px rgba(183, 120, 19, 0.14);
}

.recording-feedback[data-state="error"] .recording-dot {
  background: var(--analyzer-danger);
}

@keyframes recording-dot-pulse {
  50% { opacity: 0.38; transform: scale(0.78); }
}

.microphone-level-track {
  height: 6px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(24, 32, 43, 0.09);
}

.microphone-level-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #48625f, #d39a34, #a23a3a);
  transition: width 65ms linear;
}

.microphone-level-fill.clipping {
  box-shadow: 0 0 9px rgba(162, 58, 58, 0.7);
}

.cancel-recording-button {
  margin-top: 9px;
  border: 1px solid rgba(162, 58, 58, 0.24);
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--analyzer-danger);
  background: rgba(255, 255, 255, 0.68);
  font: 700 0.68rem/1 Arial, sans-serif;
  cursor: pointer;
}

.cancel-recording-button[hidden] {
  display: none;
}

.microphone-privacy {
  margin: 8px 1px 0;
  color: var(--analyzer-muted);
  font-size: 0.65rem;
  line-height: 1.35;
}

[dir="rtl"] .hold-record-button {
  text-align: right;
}

@media (max-width: 520px) {
  .hold-record-button {
    grid-template-columns: 45px 1fr;
    gap: 10px;
    padding: 9px 10px;
  }

  .record-button-ring {
    width: 45px;
    height: 45px;
  }

  .record-button-core {
    width: 33px;
    height: 33px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hold-record-button.arming .record-button-ring,
  .hold-record-button.recording .record-button-ring,
  .recording-feedback[data-state="recording"] .recording-dot,
  .hold-record-button.processing .record-button-core {
    animation: none !important;
  }
}

/* =========================================================
   Direct floating microphone recorder — v5.4
   Matches the application's existing floating circular controls.
   The button itself is held to record; no choice menu opens.
   ========================================================= */
.quick-scale-finder {
  position: fixed;
  right: max(25px, env(safe-area-inset-right));
  left: auto;
  top: min(500px, calc(100vh - 210px));
  z-index: 1480;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  opacity: 0.78;
  transition: opacity 220ms ease;
}

.quick-scale-finder:hover,
.quick-scale-finder:focus-within,
.quick-scale-finder.status-open {
  opacity: 1;
}

.quick-scale-finder-button,
.quick-recording-popover {
  pointer-events: auto;
}

.quick-scale-finder-button,
.hold-record-button {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.quick-scale-finder-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 94px;
  border: 0;
  padding: 0;
  color: #333;
  background: transparent;
  text-align: center;
  cursor: pointer;
  touch-action: none;
  outline: none;
}

.quick-finder-icon-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.36);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.12);
  transition: background 0.3s ease, transform 0.22s ease, box-shadow 0.22s ease;
  animation: quick-recorder-float 2s ease-in-out infinite;
}

.quick-finder-icon-ring::after {
  content: "";
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(255, 215, 0, 0.34);
  border-radius: 50%;
  opacity: 0;
  animation: quick-recorder-intro-halo 1.9s ease-out 3;
}

.quick-finder-icon-core {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #a85a68, #6b3542);
  font-size: 1.28rem;
  line-height: 1;
  box-shadow: 0 4px 9px rgba(119, 73, 83, 0.28);
  transition: background 0.25s ease, transform 0.2s ease;
}

.quick-scale-finder-button:hover .quick-finder-icon-ring,
.quick-scale-finder-button:focus-visible .quick-finder-icon-ring {
  background: rgba(255, 215, 0, 0.58);
  transform: scale(1.055);
  box-shadow: 0 7px 13px rgba(0, 0, 0, 0.17);
}

.quick-scale-finder-button:focus-visible .quick-finder-icon-ring {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

.quick-scale-finder-button.arming .quick-finder-icon-ring,
.quick-scale-finder-button.recording .quick-finder-icon-ring {
  background: rgba(255, 215, 0, 0.76);
  animation: quick-recorder-active 0.92s ease-in-out infinite;
}

.quick-scale-finder-button.recording .quick-finder-icon-core {
  background: linear-gradient(145deg, #c44f63, #7d2638);
}

.quick-scale-finder-button.processing .quick-finder-icon-ring {
  animation: quick-recorder-processing 1s linear infinite;
}

.quick-scale-finder-button.has-result .quick-finder-icon-ring {
  box-shadow:
    0 4px 7px rgba(0, 0, 0, 0.13),
    0 0 0 4px rgba(31, 122, 90, 0.12);
}

.quick-scale-finder-button.has-result .quick-finder-icon-core {
  background: linear-gradient(145deg, #2b8c69, #185d48);
}

.quick-finder-copy {
  display: block;
  width: 116px;
  margin-top: 8px;
  text-align: center;
  pointer-events: none;
}

.quick-finder-copy strong,
.quick-finder-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-finder-copy strong {
  color: #333;
  font: 700 0.8rem/1.15 Arial, sans-serif;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.72);
}

.quick-finder-copy small {
  margin-top: 3px;
  color: rgba(45, 45, 45, 0.78);
  font: 600 0.61rem/1.2 Arial, sans-serif;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

.quick-recording-popover {
  position: absolute;
  right: 0;
  left: auto;
  bottom: calc(100% + 12px);
  width: min(295px, calc(100vw - 24px));
  border: 1px solid rgba(24, 32, 43, 0.14);
  border-radius: 15px;
  padding: 11px 12px;
  color: var(--analyzer-ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(247, 231, 198, 0.72), transparent 44%),
    rgba(255, 255, 255, 0.96);
  box-shadow: 0 17px 45px rgba(13, 22, 35, 0.25);
  backdrop-filter: blur(15px) saturate(1.08);
  -webkit-backdrop-filter: blur(15px) saturate(1.08);
  opacity: 0;
  transform: translateY(9px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms cubic-bezier(0.22, 0.82, 0.24, 1);
}

.quick-recording-popover.open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.quick-recording-popover .quick-recording-feedback {
  margin-top: 0;
}

.quick-recording-popover .microphone-level-track {
  margin-top: 8px;
}

.quick-recording-popover .cancel-recording-button {
  width: 100%;
}

.quick-finder-privacy {
  margin: 8px 1px 0;
  color: var(--analyzer-muted);
  font-size: 0.61rem;
  line-height: 1.32;
}

.recording-feedback[data-state="playing"] .recording-dot {
  background: #23845f;
  box-shadow: 0 0 0 4px rgba(35, 132, 95, 0.13);
  animation: recording-dot-pulse 1.25s ease-in-out infinite;
}

@keyframes quick-recorder-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes quick-recorder-intro-halo {
  0% { opacity: 0; transform: scale(0.88); }
  34% { opacity: 0.72; }
  100% { opacity: 0; transform: scale(1.28); }
}

@keyframes quick-recorder-active {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 7px rgba(0, 0, 0, 0.13); }
  50% { transform: scale(1.09); box-shadow: 0 7px 18px rgba(119, 73, 83, 0.28); }
}

@keyframes quick-recorder-processing {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.04); }
  100% { transform: rotate(360deg) scale(1); }
}

[dir="rtl"] .quick-recording-popover {
  text-align: right;
}

@media (max-width: 700px) {
  .quick-scale-finder {
    right: max(14px, env(safe-area-inset-right));
    left: auto;
    top: auto;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .quick-scale-finder-button {
    width: 82px;
  }

  .quick-finder-icon-ring {
    width: 56px;
    height: 56px;
  }

  .quick-finder-icon-core {
    width: 39px;
    height: 39px;
    font-size: 1.12rem;
  }

  .quick-finder-copy {
    width: 102px;
  }

  .quick-finder-copy strong {
    font-size: 0.72rem;
  }

  .quick-finder-copy small {
    font-size: 0.57rem;
  }
}

@media (max-width: 430px) {
  .quick-recording-popover {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: auto;
    transform-origin: bottom center;
  }

  [dir="rtl"] .quick-recording-popover {
    right: 10px;
    left: 10px;
  }

  .quick-finder-copy small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quick-finder-icon-ring,
  .quick-finder-icon-ring::after,
  .quick-scale-finder-button.arming .quick-finder-icon-ring,
  .quick-scale-finder-button.recording .quick-finder-icon-ring,
  .quick-scale-finder-button.processing .quick-finder-icon-ring,
  .recording-feedback[data-state="playing"] .recording-dot {
    animation: none !important;
  }

  .quick-finder-icon-ring,
  .quick-recording-popover {
    transition-duration: 0.01ms !important;
  }
}


/* =========================================================
   Two-stage microphone permission flow — v5.4
   First activation requests permission only. Recording begins
   on the next deliberate hold after the button reports ready.
   ========================================================= */
.quick-scale-finder-button.permission-needed .quick-finder-icon-ring,
.hold-record-button.permission-needed .record-button-ring {
  animation: permission-ready-pulse 1.8s ease-in-out 2;
}

.quick-scale-finder-button.permission-needed .quick-finder-icon-core,
.hold-record-button.permission-needed .record-button-core {
  filter: saturate(0.72);
}

.quick-scale-finder-button.permission-ready .quick-finder-icon-ring,
.hold-record-button.permission-ready .record-button-ring {
  box-shadow:
    inset 0 0 0 1px rgba(72, 98, 95, 0.22),
    0 0 0 4px rgba(72, 98, 95, 0.08);
}

.recording-feedback[data-state="ready"] .recording-dot {
  background: #48625f;
  box-shadow: 0 0 0 3px rgba(72, 98, 95, 0.13);
}

@keyframes permission-ready-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.055); }
}

@media (prefers-reduced-motion: reduce) {
  .quick-scale-finder-button.permission-needed .quick-finder-icon-ring,
  .hold-record-button.permission-needed .record-button-ring {
    animation: none !important;
  }
}
