:root {
  color-scheme: dark;
  --tuner-bg: #06090c;
  --tuner-panel: rgba(16, 20, 26, 0.78);
  --tuner-panel-strong: rgba(13, 18, 24, 0.94);
  --tuner-border: rgba(230, 238, 246, 0.13);
  --tuner-text: #eff5f4;
  --tuner-muted: rgba(227, 236, 236, 0.62);
  --tuner-warm: #ffc06f;
  --tuner-teal: #60dfd0;
  --tuner-green: #7cf18d;
  --tuner-red: #ff6e6e;
  --tuner-neck: #141a1a;
  --tuner-neck-edge: #283233;
  --tuner-metal: #d9ded8;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -18%, rgba(96, 223, 208, 0.16), transparent 38%),
    linear-gradient(180deg, #0b1115 0%, var(--tuner-bg) 54%, #030506 100%);
  color: var(--tuner-text);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

.tuner-page {
  min-height: 100dvh;
}

.tuner-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px 18px calc(var(--fiume-footer-reserved, 56px) + 18px);
}

.tuner-workbench {
  width: min(100%, 720px);
  min-height: calc(100dvh - var(--fiume-footer-reserved, 56px) - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  justify-items: center;
  align-items: center;
  gap: 16px;
}

.tuner-toolbar {
  align-self: start;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(100%, 520px);
  padding: 8px;
  border: 1px solid var(--tuner-border);
  border-radius: 8px;
  background: rgba(8, 12, 16, 0.72);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px) saturate(1.08);
}

.tuner-selects {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  flex: 1 1 auto;
}

.tuner-select-label {
  position: relative;
  min-width: 0;
  display: block;
}

.tuner-select-label::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(239, 245, 244, 0.72);
  transform: translateY(-34%);
  pointer-events: none;
}

.tuner-select {
  width: 100%;
  min-height: 42px;
  padding: 0 32px 0 13px;
  border: 1px solid rgba(230, 238, 246, 0.13);
  border-radius: 6px;
  appearance: none;
  background: rgba(5, 9, 13, 0.82);
  color: var(--tuner-text);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1;
  outline: none;
}

.tuner-select:hover,
.tuner-select:focus-visible {
  border-color: rgba(96, 223, 208, 0.46);
}

.tuner-start-button {
  min-height: 42px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid rgba(255, 192, 111, 0.34);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tuner-warm), #ff986b);
  color: #1d140d;
  font-size: 0.9rem;
  font-weight: 820;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 18px 36px rgba(255, 156, 92, 0.18);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    filter 150ms ease;
}

.tuner-start-button:hover,
.tuner-start-button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 20px 40px rgba(255, 156, 92, 0.22);
}

.tuner-start-button:disabled {
  cursor: progress;
  filter: saturate(0.72);
  opacity: 0.78;
}

.tuner-page.is-listening .tuner-start-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(235, 242, 242, 0.09);
  color: var(--tuner-text);
  box-shadow: none;
}

.tuner-start-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
}

.tuner-start-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tuner-instrument {
  --string-count: 6;
  width: min(100%, 520px);
  align-self: stretch;
  min-height: 0;
  display: grid;
  grid-template-rows: 118px minmax(340px, 1fr);
  gap: 0;
}

.tuner-headstock {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(var(--string-count), minmax(34px, 1fr));
  align-items: end;
  gap: 7px;
  padding: 0 18px 8px;
}

.tuner-meter {
  --string-color: rgba(130, 145, 150, 0.46);
  --string-opacity: 0.28;
  --needle-angle: 0deg;
  min-width: 0;
  display: grid;
  grid-template-rows: 20px 58px 18px;
  justify-items: center;
  align-items: center;
  color: var(--string-color);
  opacity: calc(0.46 + (var(--string-opacity) * 0.54));
  transition:
    color 130ms ease,
    opacity 180ms ease;
}

.tuner-meter-note {
  color: rgba(245, 250, 247, 0.9);
  font-size: 0.74rem;
  font-weight: 820;
  line-height: 1;
}

.tuner-meter-gauge {
  position: relative;
  width: min(54px, 100%);
  height: 54px;
  border-top: 2px solid rgba(230, 238, 246, 0.16);
  border-left: 2px solid rgba(230, 238, 246, 0.08);
  border-right: 2px solid rgba(230, 238, 246, 0.08);
  border-radius: 54px 54px 5px 5px;
  background:
    linear-gradient(90deg, rgba(255, 110, 110, 0.22), rgba(124, 241, 141, 0.16) 50%, rgba(255, 110, 110, 0.22)),
    rgba(5, 9, 12, 0.62);
  overflow: hidden;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.28);
}

.tuner-meter-gauge::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 2px;
  height: 38px;
  background: rgba(239, 245, 244, 0.2);
  transform: translateX(-50%);
}

.tuner-meter-needle {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 2px;
  height: 38px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
  transform: translateX(-50%) rotate(var(--needle-angle));
  transform-origin: 50% 100%;
  transition:
    transform 110ms ease-out,
    background-color 130ms ease,
    box-shadow 130ms ease;
}

.tuner-meter-needle::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.tuner-meter-cents {
  color: rgba(232, 238, 236, 0.72);
  font-size: 0.66rem;
  font-weight: 760;
  line-height: 1;
}

.tuner-neck-shell {
  position: relative;
  min-height: 0;
  padding: 0 18px;
}

.tuner-nut {
  position: relative;
  z-index: 2;
  height: 10px;
  margin: 0 12px;
  border-radius: 4px;
  background: linear-gradient(180deg, #f0eee4, #a7aca6);
  box-shadow:
    0 2px 10px rgba(255, 255, 255, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.32);
}

.tuner-fretboard {
  --string-count: 6;
  position: relative;
  height: 100%;
  min-height: 340px;
  display: grid;
  grid-template-columns: repeat(var(--string-count), minmax(34px, 1fr));
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(224, 234, 230, 0.13);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 42px,
      rgba(224, 234, 230, 0.18) 43px,
      rgba(224, 234, 230, 0.18) 45px
    ),
    linear-gradient(90deg, rgba(255, 192, 111, 0.08), transparent 20%, transparent 80%, rgba(96, 223, 208, 0.08)),
    linear-gradient(180deg, #1a2322, var(--tuner-neck) 44%, #0c1112 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 18px 0 34px rgba(0, 0, 0, 0.18),
    inset -18px 0 34px rgba(0, 0, 0, 0.18),
    0 22px 54px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.tuner-fretboard::before,
.tuner-fretboard::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16px;
  background: linear-gradient(180deg, var(--tuner-neck-edge), #0d1212);
  opacity: 0.9;
}

.tuner-fretboard::before {
  left: 0;
}

.tuner-fretboard::after {
  right: 0;
}

.tuner-string {
  --string-color: rgba(130, 145, 150, 0.46);
  --string-opacity: 0.24;
  --string-width: 3px;
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  place-items: stretch center;
}

.tuner-string-line {
  width: var(--string-width);
  height: 100%;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 32%),
    currentColor;
  color: var(--string-color);
  opacity: calc(0.3 + (var(--string-opacity) * 0.7));
  box-shadow:
    0 0 calc(4px + (var(--string-opacity) * 18px)) currentColor,
    inset 1px 0 rgba(255, 255, 255, 0.28);
  transition:
    color 120ms ease,
    opacity 180ms ease,
    box-shadow 180ms ease,
    width 180ms ease;
}

.tuner-string-target {
  position: absolute;
  top: 12px;
  left: 50%;
  min-width: 30px;
  padding: 4px 0;
  border-radius: 999px;
  background: rgba(5, 9, 12, 0.62);
  color: rgba(245, 250, 247, 0.92);
  font-size: 0.69rem;
  font-weight: 820;
  line-height: 1;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.tuner-string-number {
  position: absolute;
  bottom: 14px;
  left: 50%;
  color: rgba(232, 238, 236, 0.5);
  font-size: 0.64rem;
  font-weight: 760;
  line-height: 1;
  transform: translateX(-50%);
  pointer-events: none;
}

.tuner-string.is-active .tuner-string-target,
.tuner-string.is-active .tuner-string-number {
  color: var(--string-color);
}

.tuner-focus {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 13px;
  border: 1px solid rgba(230, 238, 246, 0.1);
  border-radius: 999px;
  background: rgba(5, 9, 12, 0.5);
  color: rgba(239, 245, 244, 0.82);
  font-size: 0.8rem;
  font-weight: 760;
  line-height: 1;
  backdrop-filter: blur(14px);
}

.tuner-focus:empty {
  visibility: hidden;
}

.tuner-status {
  min-height: 24px;
  margin: 0;
  color: var(--tuner-muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
}

.tuner-status.is-error {
  color: #ffaaa6;
}

.tuner-status:empty {
  visibility: hidden;
}

.tuner-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  .tuner-shell {
    padding: 12px 12px calc(var(--fiume-footer-reserved, 56px) + 14px);
  }

  .tuner-workbench {
    min-height: calc(100dvh - var(--fiume-footer-reserved, 56px) - 26px);
    gap: 12px;
  }

  .tuner-toolbar {
    width: 100%;
    gap: 8px;
  }

  .tuner-selects {
    gap: 6px;
  }

  .tuner-select {
    min-height: 39px;
    padding-left: 10px;
    font-size: 0.82rem;
  }

  .tuner-start-button {
    min-height: 39px;
    padding: 0 12px;
    font-size: 0.82rem;
  }

  .tuner-start-icon {
    width: 18px;
    height: 18px;
  }

  .tuner-instrument {
    width: min(100%, 420px);
    grid-template-rows: 108px minmax(330px, 1fr);
  }

  .tuner-headstock {
    gap: 5px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .tuner-neck-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .tuner-fretboard {
    gap: 5px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .tuner-meter {
    grid-template-rows: 18px 52px 17px;
  }

  .tuner-meter-gauge {
    width: min(46px, 100%);
    height: 48px;
  }

  .tuner-meter-needle {
    height: 34px;
  }
}

@media (max-width: 410px) {
  .tuner-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .tuner-start-button {
    width: 100%;
  }

  .tuner-instrument {
    grid-template-rows: 98px minmax(318px, 1fr);
  }

  .tuner-meter-note {
    font-size: 0.66rem;
  }

  .tuner-meter-cents {
    font-size: 0.6rem;
  }
}
