.tuner-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(236, 181, 82, .45);
  border-radius: 999px;
  color: #efeee3;
  background: rgba(236, 181, 82, .08);
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}

.tuner-trigger svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: #ecb552;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tuner-trigger:hover {
  border-color: #ecb552;
  color: #ecb552;
  background: rgba(236, 181, 82, .16);
  transform: translateY(-1px);
}

.tuner-dialog {
  --tuner-bg: #10130f;
  --tuner-surface: #181c16;
  --tuner-gold: #ecb552;
  --tuner-gold-bg: #272319;
  --tuner-green: #91c48c;
  --tuner-green-bg: #253024;
  --tuner-ink: #efeee3;
  --tuner-muted: #969984;
  --tuner-border: #555b4c;
  width: min(440px, calc(100vw - 20px));
  max-height: min(92dvh, 780px);
  padding: 0;
  border: 1px solid rgba(236, 181, 82, .32);
  border-radius: 18px;
  color: var(--tuner-ink);
  background: var(--tuner-bg);
  box-shadow: 0 32px 110px rgba(0, 0, 0, .82);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3f34 transparent;
}

.tuner-dialog::backdrop {
  background: rgba(8, 10, 8, .8);
  backdrop-filter: blur(8px);
}

.tuner-dialog[open] {
  animation: tuner-dialog-in .2s cubic-bezier(.2, .75, .3, 1);
}

@keyframes tuner-dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.97);
  }
}

.tuner-shell {
  padding: 16px 18px 18px;
}

.tuner-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tuner-presets {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 3px;
  border: 1px solid rgba(115, 117, 100, .35);
  border-radius: 11px;
  background: rgba(255, 255, 255, .02);
}

.tuner-preset {
  min-width: 0;
  padding: 7px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--tuner-muted);
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color .16s, background .16s, border-color .16s;
}

.tuner-preset:hover {
  color: var(--tuner-ink);
}

.tuner-preset.is-active {
  color: var(--tuner-gold);
  background: var(--tuner-gold-bg);
  border-color: rgba(236, 181, 82, .65);
}

.tuner-close {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 8px;
  border: 1px solid rgba(115, 117, 100, .42);
  border-radius: 10px;
  color: var(--tuner-muted);
  background: transparent;
  cursor: pointer;
  transition: color .16s, border-color .16s;
}

.tuner-close:hover {
  color: var(--tuner-ink);
  border-color: var(--tuner-gold);
}

.tuner-close svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.tuner-notice {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(236, 181, 82, .38);
  border-radius: 10px;
  background: rgba(39, 35, 25, .85);
  color: #e6d7b4;
  font-size: 11.5px;
  line-height: 1.5;
}

.tuner-notice.is-error {
  border-color: rgba(217, 119, 108, .5);
  background: rgba(52, 26, 24, .7);
  color: #f3c1ba;
}

.tuner-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
}

.tuner-note {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 54px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.01em;
  color: var(--tuner-ink);
  font-variant-numeric: tabular-nums;
  transition: color .18s;
}

.tuner-dialog[data-tune-state="in-tune"] .tuner-note {
  color: var(--tuner-green);
}

.tuner-mic-dot-btn {
  position: absolute;
  top: 12px;
  right: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--tuner-border);
  border-radius: 12px;
  color: var(--tuner-muted);
  background: var(--tuner-bg);
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}

.tuner-mic-dot-btn:hover {
  border-color: var(--tuner-gold);
  transform: translateY(-1px);
}

.tuner-mic-dot-btn:disabled {
  opacity: .55;
  cursor: wait;
}

.tuner-mic-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.8px solid currentColor;
  background: transparent;
  transition: background .18s, border-color .18s, box-shadow .18s;
}

.tuner-mic-dot-btn.is-listening {
  color: var(--tuner-green);
  border-color: rgba(145, 196, 140, .55);
  background: rgba(37, 48, 36, .45);
}

.tuner-mic-dot-btn.is-listening .tuner-mic-dot {
  background: var(--tuner-green);
  border-color: var(--tuner-green);
  box-shadow: 0 0 10px rgba(145, 196, 140, .75);
}

.tuner-ruler-wrap {
  width: 100%;
  margin-top: 2px;
}

.tuner-signal-track {
  width: min(220px, 68%);
  height: 2px;
  margin: 2px auto 0;
  border-radius: 999px;
  background: rgba(150, 153, 132, .18);
  overflow: hidden;
}

.tuner-signal-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(236, 181, 82, .55), rgba(145, 196, 140, .9));
  transition: width 60ms linear;
}

.tuner-ruler {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.tuner-ruler-zone {
  fill: var(--tuner-green-bg);
  transition: fill .18s;
}

.tuner-dialog[data-tune-state="in-tune"] .tuner-ruler-zone {
  fill: rgba(145, 196, 140, .28);
}

.tuner-ruler-tick {
  stroke: var(--tuner-muted);
  stroke-width: 1.2;
  opacity: .72;
}

.tuner-ruler-tick.is-major {
  opacity: .95;
}

.tuner-ruler-tick.is-zero {
  stroke: var(--tuner-ink);
  opacity: .95;
}

.tuner-ruler-label {
  fill: var(--tuner-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
}

.tuner-ruler-cursor {
  opacity: 0;
  transition: transform 85ms cubic-bezier(.22, .8, .36, 1), opacity .16s ease;
}

.tuner-ruler-cursor.is-visible {
  opacity: 1;
}

.tuner-ruler-cursor-halo {
  fill: rgba(236, 181, 82, .25);
}

.tuner-ruler-cursor-dot {
  fill: var(--tuner-gold);
}

.tuner-dialog[data-tune-state="in-tune"] .tuner-ruler-cursor-halo {
  fill: rgba(145, 196, 140, .3);
}

.tuner-dialog[data-tune-state="in-tune"] .tuner-ruler-cursor-dot {
  fill: var(--tuner-green);
}

.tuner-status {
  margin: 4px 0 0;
  color: var(--tuner-gold);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  transition: color .18s;
}

.tuner-dialog[data-tune-state="in-tune"] .tuner-status {
  color: var(--tuner-green);
}

.tuner-frequency {
  margin: 4px 0 0;
  color: var(--tuner-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.tuner-headstock-stage {
  position: relative;
  width: min(352px, 100%);
  aspect-ratio: 360 / 356;
  margin: 8px auto 6px;
  user-select: none;
  -webkit-user-select: none;
}

.tuner-headstock-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tuner-headstock-svg [data-string-hit] {
  cursor: pointer;
}

.tuner-peg {
  position: absolute;
  width: clamp(50px, 16%, 64px);
  height: clamp(50px, 16%, 64px);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border: 1.5px solid #737564;
  border-radius: 50%;
  color: var(--tuner-ink);
  background: var(--tuner-bg);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease;
}

.tuner-peg:hover {
  border-color: var(--tuner-gold);
  transform: translate(-50%, -50%) scale(1.04);
}

.tuner-peg:active {
  transform: translate(-50%, -50%) scale(.96);
}

.tuner-peg.is-selected {
  border-width: 2px;
  border-color: var(--tuner-gold);
  color: var(--tuner-gold);
  background: #262217;
  box-shadow: 0 0 18px rgba(236, 181, 82, .16);
}

.tuner-dialog[data-tune-state="in-tune"] .tuner-peg.is-selected {
  border-color: var(--tuner-green);
  color: var(--tuner-green);
  background: #17241a;
  box-shadow: 0 0 20px rgba(145, 196, 140, .24);
}

.tuner-peg.is-playing {
  animation: tuner-peg-pulse .9s ease-out infinite;
}

@keyframes tuner-peg-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(236, 181, 82, .5);
  }
  100% {
    box-shadow: 0 0 0 11px rgba(236, 181, 82, 0);
  }
}

.tuner-peg-num {
  font-size: 13px;
  line-height: 1.05;
  opacity: .88;
}

.tuner-peg-note {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.05;
}

.tuner-headstock-stage.is-chromatic .tuner-peg {
  opacity: .84;
}

.tuner-mode-hint {
  margin: 0 0 8px;
  color: var(--tuner-muted);
  font-size: 11px;
  text-align: center;
}

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

.tuner-mode-btn {
  height: 44px;
  border: 1px solid var(--tuner-border);
  border-radius: 12px;
  color: var(--tuner-muted);
  background: var(--tuner-bg);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .16s, background .16s, color .16s;
}

.tuner-mode-btn:hover:not(:disabled) {
  color: var(--tuner-ink);
  border-color: rgba(236, 181, 82, .55);
}

.tuner-mode-btn.is-active {
  border-color: var(--tuner-gold);
  color: var(--tuner-gold);
  background: var(--tuner-gold-bg);
}

.tuner-mode-btn:disabled {
  opacity: .38;
  cursor: default;
}

@media (max-width: 480px) {
  .tuner-dialog {
    width: calc(100vw - 16px);
    max-height: 94dvh;
    border-radius: 16px;
  }

  .tuner-shell {
    padding: 14px 12px 14px;
  }

  .tuner-note {
    font-size: 48px;
    min-height: 54px;
  }

  .tuner-mic-dot-btn {
    width: 40px;
    height: 40px;
  }

  .tuner-status {
    font-size: 18px;
  }

  .tuner-peg-num {
    font-size: 11px;
  }

  .tuner-peg-note {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tuner-dialog[open],
  .tuner-peg.is-playing,
  .tuner-ruler-cursor {
    animation: none !important;
    transition: none !important;
  }
}
