:root {
  --dark: #393232;
  --ink: #211d1d;
  --white: #ffffff;
  --off: #f8f6f3;
  --paper: #fffaf3;
  --mint: #aee6df;
  --mint-soft: #ddf8f4;
  --red: #c42030;
  --red-deep: #8f1721;
  --soft: #6f6666;
  --muted: #776e6e;
  --line: rgba(57, 50, 50, 0.11);
  --mint-line: rgba(174, 230, 223, 0.62);
  --shadow: 0 24px 70px rgba(33, 29, 29, 0.1);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --screen: #ead9a3;
  --green: #58b77a;
  --orange: #d9902f;
  --case: #1c1818;
  --case-2: #342e2d;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--dark);
  font-family: var(--sans);
  line-height: 1.65;
  background:
    radial-gradient(circle at 12% 7%, rgba(174, 230, 223, 0.3), transparent 27rem),
    radial-gradient(circle at 92% 21%, rgba(196, 32, 48, 0.08), transparent 28rem),
    linear-gradient(180deg, #fff 0%, var(--off) 52%, #fff 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(57, 50, 50, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, rgba(57, 50, 50, 0.02) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 78%);
}

a { color: inherit; text-decoration: none; }
button, select { font: inherit; }
button { touch-action: manipulation; }

.ambient-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ambient-orbs span {
  position: absolute;
  border-radius: 999px;
  filter: blur(42px);
  opacity: 0.14;
}

.ambient-orbs span:nth-child(1) {
  width: 280px;
  height: 280px;
  left: -90px;
  top: 20vh;
  background: var(--mint);
}

.ambient-orbs span:nth-child(2) {
  width: 220px;
  height: 220px;
  right: -70px;
  top: 48vh;
  background: rgba(196, 32, 48, 0.22);
}

.ambient-orbs span:nth-child(3) {
  width: 180px;
  height: 180px;
  left: 42%;
  bottom: -80px;
  background: rgba(174, 230, 223, 0.72);
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(174, 230, 223, 0.64);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.nav-inner {
  width: min(1120px, calc(100% - 36px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  color: var(--dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--mint-line);
  border-radius: 999px;
  color: var(--dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.72);
}

.app {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 58px 0 34px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 44px;
  align-items: end;
  padding: 34px 0 54px;
}

.hero-copy-wrap { max-width: 780px; }

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 14px;
  color: rgba(196, 32, 48, 0.88);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.eyebrow::before,
.section-kicker::before {
  content: "";
  width: 30px;
  height: 1px;
  background: currentColor;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2,
h3 {
  margin-bottom: 0;
  color: var(--dark);
  font-family: var(--serif);
  font-weight: 650;
  letter-spacing: -0.045em;
}

h1 {
  max-width: 850px;
  font-size: clamp(4rem, 9.5vw, 7.7rem);
  line-height: 0.88;
}

h1 em {
  color: var(--red);
  font-family: var(--serif);
  font-weight: 500;
}

h2 {
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 0.98;
}

.hero-copy {
  max-width: 680px;
  margin: 24px 0 0;
  color: rgba(57, 50, 50, 0.76);
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  font-weight: 500;
}

.hero-note {
  position: relative;
  padding: 22px 22px 24px;
  border: 1px solid var(--mint-line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 46px rgba(33, 29, 29, 0.07);
}

.hero-note span,
.section-number {
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.hero-note p {
  margin: 38px 0 0;
  color: var(--dark);
  font-family: var(--serif);
  font-size: 1.55rem;
  line-height: 1.02;
}

.app-state {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.app-state span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.connection-state::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(88, 183, 122, 0.15);
}

.connection-state.offline::before {
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(217, 144, 47, 0.15);
}

.workspace {
  display: block;
  width: min(100%, 820px);
  margin-inline: auto;
}

.card {
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.card {
  border: 1px solid rgba(174, 230, 223, 0.58);
  background: rgba(255, 255, 255, 0.86);
}

.tuner-card { padding: clamp(18px, 3vw, 30px); }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}

.section-heading.compact { margin-bottom: 18px; }
.section-heading h2 { max-width: 520px; }

.tuner-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.34);
  border-radius: 25px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), transparent 25%),
    linear-gradient(180deg, var(--case-2), var(--case));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -20px 38px rgba(0, 0, 0, 0.24),
    0 24px 55px rgba(33, 29, 29, 0.2);
}

.tuner-shell::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -28px;
  height: 38px;
  border-radius: 999px;
  background: rgba(174, 230, 223, 0.22);
  filter: blur(18px);
}

.tuner-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tuner-screen {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border: 2px solid rgba(0, 0, 0, 0.42);
  border-radius: 18px;
  padding: 14px 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 42%),
    var(--screen);
  box-shadow:
    inset 0 2px 18px rgba(255, 255, 255, 0.22),
    inset 0 -24px 34px rgba(89, 63, 28, 0.17);
}

.status-lights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.status-light {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: rgba(33, 29, 29, 0.58);
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-light span {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(33, 29, 29, 0.18);
  border-radius: 50%;
  background: rgba(33, 29, 29, 0.17);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.status-light.low.active span,
.status-light.high.active span {
  background: #d54f38;
  box-shadow: 0 0 18px rgba(213, 79, 56, 0.76);
}

.status-light.tuned.active span {
  background: var(--green);
  box-shadow: 0 0 18px rgba(88, 183, 122, 0.86);
}

.analog-meter {
  position: relative;
  width: min(100%, 460px);
  aspect-ratio: 2.25 / 1;
  margin: 2px auto 0;
}

.scale-arc {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 2%;
  height: 92%;
  border-top: 5px solid rgba(33, 29, 29, 0.68);
  border-left: 5px solid rgba(33, 29, 29, 0.68);
  border-right: 5px solid rgba(33, 29, 29, 0.68);
  border-radius: 999px 999px 0 0;
}

.scale-ticks {
  position: absolute;
  inset: 13%;
  z-index: 1;
  opacity: 0.58;
  background: conic-gradient(from 230deg at 50% 100%, rgba(33,29,29,.72) 0deg 2deg, transparent 2deg 12deg, rgba(33,29,29,.48) 12deg 14deg, transparent 14deg 24deg, rgba(33,29,29,.48) 24deg 26deg, transparent 26deg 38deg, rgba(33,29,29,.72) 38deg 40deg, transparent 40deg 50deg, rgba(33,29,29,.48) 50deg 52deg, transparent 52deg 64deg, rgba(33,29,29,.48) 64deg 66deg, transparent 66deg 78deg, rgba(33,29,29,.72) 78deg 80deg, transparent 80deg 360deg);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.scale-label {
  position: absolute;
  z-index: 2;
  color: rgba(33, 29, 29, 0.78);
  font-size: 0.72rem;
  font-weight: 900;
}

.label-minus-50 { left: 2%; bottom: 14%; }
.label-minus-25 { left: 18%; top: 18%; }
.label-zero { left: 50%; top: 2%; transform: translateX(-50%); }
.label-plus-25 { right: 18%; top: 18%; }
.label-plus-50 { right: 2%; bottom: 14%; }

.analog-needle {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 3;
  width: 5px;
  height: 78%;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  transform: translateX(-50%) rotate(0deg);
  transform-origin: 50% 100%;
  transition: transform 0.08s linear;
  box-shadow: 0 0 10px rgba(196, 32, 48, 0.3);
}

.needle-pivot {
  position: absolute;
  left: 50%;
  bottom: -9px;
  z-index: 4;
  width: 28px;
  height: 28px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, #f8f6f3 0 24%, var(--red) 25% 54%, #2a1214 55%);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
}

.note-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
}

.note {
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(5rem, 14vw, 8rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.06em;
  line-height: 0.86;
}

.octave {
  color: var(--red);
  font-size: 2rem;
  font-weight: 900;
}

.data-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 10px;
}

.data-row > div {
  padding: 11px;
  border: 1px solid rgba(33, 29, 29, 0.14);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.48);
  text-align: center;
}

.label,
.select-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.data-row strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.control-strip {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 20px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.primary-btn {
  width: 100%;
  background: var(--red);
  color: var(--white);
  box-shadow: 0 16px 34px rgba(196, 32, 48, 0.2);
}

.primary-btn:hover { background: var(--red-deep); }
.primary-btn:disabled { cursor: wait; opacity: 0.72; }

.reference-control {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.reference-control .select-label {
  color: rgba(255, 255, 255, 0.58);
  margin-bottom: 3px;
}

select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 0.9rem;
}

.feedback {
  min-height: 52px;
  margin: 18px 4px 0;
  color: var(--muted);
  line-height: 1.55;
}

.feedback.error,
.feedback.warning {
  padding: 12px 14px;
  border: 1px solid rgba(196, 32, 48, 0.18);
  border-radius: 16px;
  background: rgba(196, 32, 48, 0.06);
  color: var(--red-deep);
}

.feedback.listening { color: var(--dark); }

.cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 36px;
  align-items: end;
  margin-top: 26px;
  padding: clamp(26px, 5vw, 48px);
  border-radius: 34px;
  background:
    radial-gradient(circle at 90% 10%, rgba(174, 230, 223, 0.18), transparent 20rem),
    var(--red);
  color: var(--white);
  box-shadow: 0 24px 60px rgba(196, 32, 48, 0.18);
}

.cta h2 {
  max-width: 720px;
  color: var(--white);
  font-size: clamp(2.3rem, 5vw, 4.6rem);
}

.cta p:not(.section-kicker) {
  max-width: 700px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.78);
}

.secondary-btn {
  min-width: 220px;
  border-color: rgba(255, 255, 255, 0.22);
  background: var(--white);
  color: var(--red-deep);
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 6px 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.app-footer > div {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.footer-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legacy-meter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.debug-panel {
  display: none;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(33, 29, 29, 0.9);
  color: var(--white);
}

.debug-panel.visible { display: block; }
.debug-panel h2 { color: var(--white); }

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.debug-grid span {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
}

.debug-grid strong {
  display: block;
  color: var(--white);
}

.debug-log {
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.78);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.72rem;
}

@media (display-mode: standalone) {
  .site-nav { padding-top: env(safe-area-inset-top); }
  .app { padding-bottom: max(34px, env(safe-area-inset-bottom)); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr 190px; }
  .cta { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 680px) {
  .nav-inner,
  .app { width: min(100% - 22px, 1120px); }
  .nav-inner { min-height: 64px; }
  .brand { font-size: 0.68rem; letter-spacing: 0.14em; }
  .nav-back { min-height: 38px; padding: 8px 12px; font-size: 0.63rem; }
  .app { padding-top: 30px; }
  .hero { grid-template-columns: 1fr; gap: 22px; padding: 20px 2px 38px; }
  h1 { font-size: clamp(3.7rem, 18vw, 5.8rem); }
  .hero-note { display: none; }
  .tuner-card { border-radius: 24px; }
  .tuner-card { padding: 16px; }
  .section-heading { margin-bottom: 18px; }
  .section-heading h2 { font-size: 2.15rem; }
  .tuner-shell { padding: 11px; border-radius: 19px; }
  .tuner-screen { padding: 10px 8px 12px; border-radius: 14px; }
  .tuner-topbar { font-size: 0.58rem; }
  .analog-meter { aspect-ratio: 2.35 / 1; }
  .note-display { min-height: 78px; }
  .control-strip, .data-row, .debug-grid { grid-template-columns: 1fr; }
  .cta { padding: 26px 20px; border-radius: 26px; }
  .secondary-btn { width: 100%; }
  .app-footer { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 410px) {
  .status-light { font-size: 0.56rem; }
  .note { font-size: 5rem; }
}
