:root {
  color-scheme: dark;
  --ink: #11110f;
  --ink-soft: #191916;
  --panel: #20201c;
  --panel-raised: #272621;
  --line: #3a3932;
  --line-light: #4b493f;
  --cream: #f2eddc;
  --muted: #a8a392;
  --faint: #777467;
  --amber: #e9a23b;
  --amber-bright: #ffbd56;
  --red: #dc6455;
  --green: #59c58b;
  --green-bright: #77e6aa;
  --shadow: 0 24px 70px rgb(0 0 0 / 28%);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 300px;
  margin: 0;
  background:
    radial-gradient(circle at 73% 18%, rgb(233 162 59 / 6%), transparent 28rem),
    var(--ink);
  color: var(--cream);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  color: inherit;
}

button {
  border: 0;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber-bright);
  outline-offset: 3px;
}

.grain {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.site-header {
  height: 96px;
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 34px;
  display: flex;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid #2b2b26;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  width: 92px;
  height: auto;
  display: block;
  filter: drop-shadow(0 5px 12px rgb(0 0 0 / 35%));
  transition: transform .2s ease, filter .2s ease;
}

.brand:hover .brand-logo {
  transform: translateY(-1px);
  filter: drop-shadow(0 7px 15px rgb(233 112 25 / 18%));
}

.header-kicker {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--faint);
  font-size: .77rem;
  letter-spacing: .05em;
}

.header-kicker strong {
  color: var(--cream);
  font-size: .7rem;
  letter-spacing: .12em;
}

.header-kicker span {
  padding-left: 14px;
  border-left: 1px solid #3a3932;
}

.privacy-pill {
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid #33332e;
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
}

.privacy-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgb(89 197 139 / 60%);
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 28px auto 48px;
  display: grid;
  grid-template-columns: 338px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #34332d;
  border-radius: 22px;
  background: var(--ink-soft);
  box-shadow: var(--shadow);
}

.control-panel {
  min-width: 0;
  padding: 34px 30px;
  background:
    linear-gradient(150deg, rgb(255 255 255 / 2%), transparent 30%),
    #1d1d19;
  border-right: 1px solid var(--line);
}

.panel-heading {
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--amber-bright);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .19em;
  text-transform: uppercase;
}

.panel-heading h1 {
  max-width: 230px;
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.15rem;
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -.035em;
}

.panel-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: .79rem;
  line-height: 1.55;
}

.field-group {
  margin-bottom: 22px;
}

.field-group label,
.field-label {
  display: block;
  color: #d5d0c0;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .055em;
}

.field-group label {
  margin-bottom: 9px;
  text-transform: uppercase;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.label-row label {
  margin: 0;
}

.text-button {
  padding: 2px;
  background: transparent;
  color: var(--amber-bright);
  cursor: pointer;
  font-size: .68rem;
}

.select-wrap {
  position: relative;
  min-width: 0;
}

.select-wrap select {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  height: 44px;
  padding: 0 38px 0 13px;
  appearance: none;
  border: 1px solid var(--line-light);
  border-radius: 8px;
  background: #24241f;
  font-size: .78rem;
  cursor: pointer;
}

.select-wrap svg {
  position: absolute;
  top: 18px;
  right: 14px;
  width: 10px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  pointer-events: none;
}

.calibration-block,
.switch-row {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid #33322c;
}

.field-help {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: .68rem;
}

.stepper {
  height: 34px;
  display: grid;
  grid-template-columns: 30px 68px 30px;
  align-items: stretch;
  border: 1px solid var(--line-light);
  border-radius: 7px;
  overflow: hidden;
}

.stepper button {
  background: #2d2c27;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}

.stepper button:hover {
  background: #393831;
  color: var(--cream);
}

.stepper output {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-inline: 1px solid var(--line-light);
  color: var(--cream);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .74rem;
}

.stepper small {
  color: var(--faint);
  font-size: .57rem;
}

.switch-row {
  position: relative;
  border-bottom: 1px solid #33322c;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #3a3932;
  transition: background .2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .2s ease, background .2s ease;
}

.switch-row input:checked + .switch {
  background: #765824;
}

.switch-row input:checked + .switch::after {
  transform: translateX(16px);
  background: var(--amber-bright);
}

.input-level {
  margin: 25px 0 22px;
}

#levelText {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .66rem;
}

.level-track {
  position: relative;
  height: 7px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #0e0e0c;
}

.level-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .06s linear, background .2s ease;
}

.level-track i {
  position: absolute;
  top: 0;
  right: 4%;
  width: 2px;
  height: 100%;
  background: var(--red);
}

.start-button {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  border-radius: 9px;
  background: var(--amber);
  color: #17130d;
  cursor: pointer;
  font-size: .77rem;
  font-weight: 800;
  letter-spacing: .025em;
  box-shadow: 0 12px 28px rgb(233 162 59 / 14%);
  transition: background .2s ease, transform .2s ease;
}

.start-button:hover {
  background: var(--amber-bright);
  transform: translateY(-1px);
}

.start-button.is-active {
  background: #383730;
  color: var(--cream);
  box-shadow: none;
}

.button-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(17 17 15 / 12%);
}

.button-icon svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.status-text {
  min-height: 2.5em;
  margin: 13px 0 0;
  color: var(--faint);
  font-size: .68rem;
  line-height: 1.4;
  text-align: center;
}

.status-text.is-error {
  color: #ed8a7e;
}

.tuner-workspace {
  min-width: 0;
  padding: 34px 38px 38px;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 1%), transparent 12%),
    #171713;
}

.workspace-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.listening-label {
  margin: 0;
  color: var(--muted);
  font-size: .7rem;
}

.listening-label span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.listening-label.is-active span {
  background: var(--green-bright);
  box-shadow: 0 0 10px rgb(89 197 139 / 80%);
  animation: listen-pulse 1.5s ease-in-out infinite;
}

@keyframes listen-pulse {
  50% { opacity: .45; }
}

.confidence-readout {
  text-align: right;
}

.confidence-readout span {
  display: block;
  margin-bottom: 2px;
  color: var(--faint);
  font-size: .6rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.confidence-readout strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  font-weight: 500;
}

.tuner-display {
  min-height: 460px;
  display: grid;
  grid-template-columns: minmax(170px, .55fr) minmax(400px, 1.45fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #302f2a;
}

.note-readout {
  padding-left: clamp(4px, 2vw, 28px);
}

.note-caption {
  color: var(--muted);
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.detected-note {
  min-height: 148px;
  display: flex;
  align-items: baseline;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  line-height: .9;
  text-shadow: 0 0 38px rgb(242 237 220 / 7%);
}

#noteName {
  font-size: clamp(6.8rem, 11vw, 10rem);
  letter-spacing: -.09em;
}

#noteOctave {
  margin-left: 11px;
  color: var(--amber-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.15rem;
}

.note-readout p {
  margin: 2px 0 0;
  color: var(--faint);
  font-size: .73rem;
}

.note-readout p strong {
  margin-left: 5px;
  color: var(--amber-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .95rem;
}

#targetFrequency {
  margin-left: 7px;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .66rem;
}

.meter-wrap {
  position: relative;
  min-width: 0;
  padding-top: 18px;
}

.pitch-meter {
  width: 100%;
  max-height: 330px;
  overflow: visible;
}

.meter-arc {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}

.meter-arc-left { stroke: var(--amber); }
.meter-arc-center { stroke: var(--green); }
.meter-arc-right { stroke: var(--red); }

.meter-ticks line {
  stroke: #686559;
  stroke-width: 1.5;
}

.meter-ticks line.major {
  stroke: #9d9887;
  stroke-width: 2;
}

.meter-ticks line.center {
  stroke: var(--green-bright);
  stroke-width: 2.5;
}

.meter-labels {
  fill: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.needle {
  color: var(--faint);
  transition: color .2s ease;
}

.needle-body {
  fill: currentColor;
  stroke: rgb(255 255 255 / 22%);
  stroke-width: 1;
}

.needle-pin-outer {
  fill: #24231e;
  stroke: #5b584d;
  stroke-width: 2;
}

.needle-pin {
  fill: var(--cream);
}

.direction-readout {
  position: absolute;
  left: 50%;
  bottom: 21px;
  width: 210px;
  transform: translateX(-50%);
  text-align: center;
}

.direction-readout > span:first-child {
  display: none;
}

.direction-readout strong {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.direction-readout > span:last-child {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-size: .65rem;
}

.tuner-display.is-flat .needle,
.tuner-display.is-flat .direction-readout strong {
  color: var(--amber-bright);
}

.tuner-display.is-sharp .needle,
.tuner-display.is-sharp .direction-readout strong {
  color: #ef796a;
}

.tuner-display.is-tuned .needle,
.tuner-display.is-tuned .direction-readout strong {
  color: var(--green-bright);
}

.target-section {
  padding: 26px 0 28px;
  border-bottom: 1px solid #302f2a;
}

.section-heading,
.analysis-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 400;
}

.tap-hint,
.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: .63rem;
}

.tap-hint svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.string-targets {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, minmax(64px, 1fr));
  gap: 9px;
}

.string-button {
  position: relative;
  min-width: 0;
  min-height: 66px;
  padding: 10px 8px;
  overflow: hidden;
  border: 1px solid #3b3a33;
  border-radius: 9px;
  background: #20201c;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.string-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: transparent;
}

.string-button:hover {
  transform: translateY(-2px);
  border-color: #666255;
  background: #282721;
}

.string-button.is-active {
  border-color: rgb(233 162 59 / 65%);
  background: #2b271e;
}

.string-button.is-active::before {
  background: var(--amber-bright);
}

.string-button.is-playing {
  border-color: var(--green);
}

.string-button strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  font-weight: 400;
}

.string-button span {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .56rem;
}

.chromatic-message {
  grid-column: 1 / -1;
  min-height: 66px;
  display: grid;
  place-items: center;
  border: 1px dashed #3b3a33;
  border-radius: 9px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: .98rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 25px;
}

.analysis-card {
  min-width: 0;
  padding: 17px 18px 14px;
  border: 1px solid #36352f;
  border-radius: 12px;
  background: #1c1c18;
}

.analysis-heading {
  margin-bottom: 11px;
}

.legend i {
  width: 14px;
  height: 2px;
  display: inline-block;
  background: var(--green);
}

.range-button {
  padding: 5px 8px;
  border: 1px solid #49473e;
  border-radius: 5px;
  background: #26251f;
  color: var(--amber-bright);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .6rem;
}

.analysis-card canvas {
  width: 100%;
  height: 116px;
  display: block;
  border-radius: 6px;
  background: #11110f;
}

footer {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto 34px;
  display: flex;
  justify-content: space-between;
  gap: 30px;
  color: #676458;
  font-size: .65rem;
}

footer p {
  margin: 0;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .control-panel {
    padding-inline: 24px;
  }

  .tuner-workspace {
    padding-inline: 28px;
  }

  .tuner-display {
    grid-template-columns: 160px minmax(360px, 1fr);
  }

  .string-targets {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
  }
}

@media (max-width: 860px) {
  .site-header {
    padding-inline: 20px;
  }

  .header-kicker {
    display: none;
  }

  .app-shell {
    width: min(700px, calc(100% - 28px));
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading h1 {
    max-width: none;
  }

  .tuner-display {
    grid-template-columns: 1fr;
    padding-top: 34px;
  }

  .note-readout {
    padding-left: 0;
    text-align: center;
  }

  .detected-note {
    min-height: 110px;
    justify-content: center;
  }

  #noteName {
    font-size: 7.5rem;
  }

  .meter-wrap {
    width: min(600px, 100%);
    margin: -20px auto 0;
  }
}

@media (max-width: 620px) {
  .site-header {
    height: 74px;
  }

  .brand-logo {
    width: 70px;
  }

  .privacy-pill {
    width: 9px;
    height: 9px;
    margin-left: auto;
    padding: 0;
    border: 0;
    overflow: hidden;
    color: transparent;
  }

  .privacy-dot {
    position: absolute;
    width: 9px;
    height: 9px;
    margin: 0;
  }

  .app-shell {
    width: 100%;
    margin: 0 0 28px;
    border-inline: 0;
    border-radius: 0;
  }

  .control-panel,
  .tuner-workspace {
    padding: 28px 20px;
  }

  .panel-heading {
    margin-bottom: 26px;
  }

  .tuner-workspace {
    padding-top: 30px;
  }

  .tuner-display {
    min-height: 430px;
  }

  #noteName {
    font-size: 6.5rem;
  }

  .pitch-meter {
    min-height: 250px;
  }

  .direction-readout {
    bottom: 17px;
  }

  .section-heading {
    align-items: flex-end;
  }

  .string-targets {
    grid-template-columns: repeat(3, 1fr);
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  footer {
    width: calc(100% - 40px);
    flex-direction: column;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
