.poly-tuner-overlay {
  --poly-tuner-angle: 0deg;
  --poly-tuner-confidence: 0;
  --poly-tuner-marker-inner: rgba(87, 218, 117, 0.82);
  --poly-tuner-marker-outer: rgba(32, 107, 61, 0.64);
  --poly-tuner-marker-glow: rgba(102, 238, 135, 0.48);
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(3, 6, 9, 0.06), rgba(3, 6, 9, 0.2)),
    rgba(3, 6, 9, 0.04);
  backdrop-filter: blur(0.5px);
  pointer-events: auto;
}

.poly-tuner-overlay[hidden],
.poly-tuner-listen[hidden] {
  display: none !important;
}

.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-note,
.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-meter,
.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-cents,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-note,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-meter,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-cents {
  display: none;
}

.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-card,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-card {
  width: min(344px, calc(100vw - 40px));
  min-height: 150px;
  grid-template-columns: minmax(118px, 1fr) auto;
  column-gap: 8px;
  align-items: center;
  padding: 28px 22px 18px;
}

.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-instrument-row,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-instrument-row {
  width: 100%;
  min-height: 40px;
  grid-column: 1;
  grid-row: 1;
  margin-top: 0;
}

.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-string-number,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-string-number,
.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-string-visual,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-string-visual,
.poly-tuner-overlay[data-tuner-state="listening"] .poly-tuner-instrument {
  display: none;
}

.poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-listen,
.poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-listen {
  grid-column: 2;
  grid-row: 1;
  margin-top: 0;
  justify-self: center;
}

.poly-tuner-overlay[data-tuner-state="listening"] .poly-tuner-instrument-row {
  width: 118px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  padding: 5px 8px;
  border: 1px solid rgba(232, 242, 255, 0.08);
  border-radius: 8px;
  background: rgba(5, 9, 13, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 8px 18px rgba(0, 0, 0, 0.12);
  opacity: var(--poly-tuner-confidence);
  transition: opacity 120ms ease;
}

.poly-tuner-overlay[data-tuner-state="listening"] .poly-tuner-string-number {
  position: absolute;
  width: 1px;
  height: 1px;
  min-width: 0;
  min-height: 0;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.poly-tuner-card {
  position: relative;
  width: min(328px, calc(100vw - 96px));
  min-height: 252px;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 18px 22px 16px;
  border: 1px solid rgba(232, 242, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(21, 27, 34, 0.88), rgba(10, 15, 20, 0.94)),
    rgba(10, 16, 23, 0.88);
  box-shadow:
    0 26px 54px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(255, 255, 255, 0.03);
  transform: translateY(-14px);
  overflow: hidden;
  isolation: isolate;
}

.poly-tuner-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 54%);
  pointer-events: none;
}

.poly-tuner-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(232, 242, 255, 0.1);
  border-radius: 999px;
  background: rgba(22, 29, 38, 0.58);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.poly-tuner-close:hover,
.poly-tuner-close:focus-visible {
  border-color: rgba(243, 181, 92, 0.42);
  outline: none;
}

.poly-tuner-close span,
.poly-tuner-close span::before {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: rgba(244, 248, 255, 0.82);
}

.poly-tuner-close span {
  transform: rotate(45deg);
}

.poly-tuner-close span::before {
  content: "";
  transform: rotate(90deg);
}

.poly-tuner-note {
  min-height: 60px;
  margin-top: 0;
  color: rgba(247, 250, 244, 0.95);
  font-size: 68px;
  font-weight: 760;
  line-height: 0.92;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 16px 32px rgba(0, 0, 0, 0.26);
  opacity: var(--poly-tuner-confidence);
  transition: opacity 120ms ease;
}

.poly-tuner-meter {
  position: relative;
  width: min(240px, 100%);
  height: 94px;
  margin-top: -2px;
}

.poly-tuner-scale {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: var(--poly-tuner-confidence);
  transition: opacity 120ms ease;
}

.poly-tuner-scale-glow,
.poly-tuner-scale-line {
  fill: none;
  stroke-linecap: round;
}

.poly-tuner-scale-glow {
  stroke-width: 12;
  opacity: 0.18;
  filter: blur(5px);
}

.poly-tuner-scale-line {
  stroke-width: 4;
  opacity: 0.88;
}

.poly-tuner-meter-label {
  position: absolute;
  top: 31px;
  z-index: 2;
  color: rgba(223, 230, 232, 0.58);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
  opacity: var(--poly-tuner-confidence);
  transition: opacity 120ms ease;
}

.poly-tuner-meter-label-flat {
  left: 12px;
  color: rgba(255, 184, 104, 0.78);
  transform: rotate(-12deg);
}

.poly-tuner-meter-label-sharp {
  right: 12px;
  color: rgba(107, 226, 213, 0.72);
  transform: rotate(12deg);
}

.poly-tuner-ticks {
  position: absolute;
  inset: 0;
  opacity: var(--poly-tuner-confidence);
  pointer-events: none;
  transition: opacity 120ms ease;
}

.poly-tuner-tick {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 1px;
  height: 10px;
  border-radius: 999px;
  background: rgba(238, 244, 244, 0.2);
  transform:
    translateX(-50%)
    rotate(var(--poly-tuner-tick-angle))
    translateY(-50px);
  transform-origin: 50% 50px;
}

.poly-tuner-tick.is-major {
  height: 15px;
  background: rgba(248, 253, 250, 0.32);
}

.poly-tuner-needle-arm {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  width: 0;
  height: 58px;
  opacity: var(--poly-tuner-confidence);
  transform: rotate(var(--poly-tuner-angle));
  transform-origin: 50% 100%;
  transition:
    opacity 120ms ease,
    transform 96ms linear;
}

.poly-tuner-needle {
  position: absolute;
  left: -1px;
  bottom: 14px;
  width: 2px;
  height: 41px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 250, 190, 0.98), rgba(123, 234, 151, 0.8));
  box-shadow: 0 0 16px rgba(128, 234, 153, 0.44);
}

.poly-tuner-needle::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 10px solid rgba(255, 250, 190, 0.96);
  border-left: 5px solid transparent;
  transform: translateX(-50%);
}

.poly-tuner-marker {
  position: absolute;
  top: 4px;
  left: -13px;
  width: 26px;
  height: 26px;
  border: 1.5px solid rgba(235, 255, 238, 0.82);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 255, 230, 0.98) 0 16%, var(--poly-tuner-marker-inner) 44%, var(--poly-tuner-marker-outer) 100%);
  box-shadow:
    0 0 16px var(--poly-tuner-marker-glow),
    inset 0 2px 7px rgba(255, 255, 255, 0.24);
  transition:
    background 120ms ease,
    box-shadow 120ms ease;
}

.poly-tuner-cents {
  position: relative;
  z-index: 5;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: -8px;
  padding: 0 9px;
  border: 1px solid rgba(232, 242, 255, 0.08);
  border-radius: 999px;
  background: rgba(5, 9, 13, 0.42);
  color: rgba(242, 248, 244, 0.78);
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  opacity: var(--poly-tuner-confidence);
  transition: opacity 120ms ease;
}

.poly-tuner-cents:empty {
  min-height: 22px;
  border-color: transparent;
  background: transparent;
}

.poly-tuner-overlay[data-tuning-direction="flat"] .poly-tuner-needle {
  box-shadow:
    0 0 22px rgba(255, 173, 94, 0.42),
    inset 0 2px 7px rgba(255, 255, 255, 0.2);
}

.poly-tuner-overlay[data-tuning-direction="sharp"] .poly-tuner-needle {
  box-shadow:
    0 0 22px rgba(93, 226, 211, 0.42),
    inset 0 2px 7px rgba(255, 255, 255, 0.2);
}

.poly-tuner-listen {
  min-height: 40px;
  margin-top: 9px;
  padding: 0 14px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.poly-tuner-instrument-row {
  position: relative;
  z-index: 5;
  width: min(232px, 100%);
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0;
  margin-top: 6px;
  padding: 2px;
  border: 1px solid rgba(232, 242, 255, 0.09);
  border-radius: 8px;
  background: rgba(4, 8, 12, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 8px 18px rgba(0, 0, 0, 0.12);
}

.poly-tuner-instrument {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 0 30px 0 12px;
  border: 0;
  border-radius: 6px;
  background:
    linear-gradient(45deg, transparent 50%, rgba(239, 246, 251, 0.78) 50%) calc(100% - 16px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, rgba(239, 246, 251, 0.78) 50%, transparent 50%) calc(100% - 11px) 50% / 6px 6px no-repeat,
    transparent;
  color: rgba(242, 248, 244, 0.92);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 720;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
}

.poly-tuner-instrument:focus-visible {
  outline: 1px solid rgba(126, 240, 176, 0.42);
  outline-offset: 1px;
}

.poly-tuner-string-number {
  position: relative;
  z-index: 5;
  min-width: 74px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-left: 1px solid rgba(232, 242, 255, 0.08);
  border-radius: 0 6px 6px 0;
  background: rgba(126, 240, 176, 0.06);
  color: rgba(223, 246, 230, 0.84);
  font-size: 0.7rem;
  font-weight: 760;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  transition: opacity 120ms ease;
}

.poly-tuner-string-visual {
  position: relative;
  width: 100%;
  height: 28px;
  display: grid;
  grid-template-rows: repeat(var(--poly-tuner-neck-string-count, 6), minmax(0, 1fr));
  align-items: center;
  padding: 3px 8px 3px 12px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(238, 248, 240, 0.18) 0 1px, transparent 1px 100%) 24% 0 / 18px 100% repeat-x,
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    rgba(8, 12, 16, 0.54);
  box-shadow:
    inset 3px 0 0 rgba(233, 211, 156, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.poly-tuner-string-visual[data-string-count="4"] {
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.poly-tuner-string-visual[data-string-count="6"] {
  grid-template-rows: repeat(6, minmax(0, 1fr));
}

.poly-tuner-string-visual::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(232, 242, 255, 0.11);
  transform: translateY(-50%);
}

.poly-tuner-neck-string {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: var(--poly-tuner-string-thickness, 1.5px);
  border-radius: 999px;
  background: rgba(226, 234, 232, 0.28);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.28);
  transition:
    background 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.poly-tuner-neck-string.is-active {
  background: linear-gradient(90deg, rgba(255, 250, 190, 0.98), rgba(113, 235, 150, 0.94));
  box-shadow:
    0 0 12px rgba(108, 238, 141, 0.58),
    0 0 4px rgba(255, 250, 190, 0.42);
  transform: scaleY(1.8);
}

.poly-tuner-neck-string.is-active::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -1px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(246, 255, 222, 0.98);
  box-shadow: 0 0 12px rgba(113, 235, 150, 0.62);
  transform: translateY(-50%);
}

.poly-tuner-overlay[data-has-signal="false"] .poly-tuner-string-number {
  color: rgba(223, 246, 230, 0.36);
  background: rgba(255, 255, 255, 0.02);
}

.poly-tuner-overlay[data-has-signal="false"] .poly-tuner-neck-string {
  background: rgba(226, 234, 232, 0.18);
  box-shadow: none;
}

@media (max-width: 900px) {
  .poly-tuner-overlay {
    padding: 14px;
  }

  .poly-tuner-card {
    width: clamp(218px, 50vw, 260px);
    min-height: 232px;
    padding: 16px 16px 14px;
    border-radius: 8px;
    transform: translateY(-8px);
  }

  .poly-tuner-overlay[data-tuner-state="idle"] .poly-tuner-card,
  .poly-tuner-overlay[data-tuner-state="starting"] .poly-tuner-card {
    width: min(312px, calc(100vw - 28px));
    min-height: 144px;
    grid-template-columns: minmax(108px, 1fr) auto;
    column-gap: 6px;
    padding: 28px 14px 16px;
  }

  .poly-tuner-close {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
  }

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

  .poly-tuner-meter {
    width: min(204px, 100%);
    height: 88px;
    margin-top: -1px;
  }

  .poly-tuner-meter-label {
    top: 30px;
    font-size: 0.62rem;
  }

  .poly-tuner-meter-label-flat {
    left: 7px;
  }

  .poly-tuner-meter-label-sharp {
    right: 7px;
  }

  .poly-tuner-listen {
    min-height: 38px;
    margin-top: 8px;
    padding: 0 12px;
    font-size: 0.82rem;
  }

  .poly-tuner-instrument-row {
    width: min(202px, 100%);
    min-height: 34px;
    padding: 2px;
    margin-top: 6px;
  }

  .poly-tuner-cents {
    min-height: 20px;
    margin-top: -8px;
    padding: 0 8px;
    font-size: 0.66rem;
  }

  .poly-tuner-instrument {
    min-height: 28px;
    padding-left: 10px;
    padding-right: 26px;
    font-size: 0.74rem;
    border-radius: 6px;
  }

  .poly-tuner-string-number {
    min-width: 62px;
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.64rem;
  }
}
