:root {
  color-scheme: dark;
  --bg: #0b0d0d;
  --surface: #131717;
  --surface-2: #191f1e;
  --line: #34413e;
  --line-strong: #64736f;
  --text: #f1f4ee;
  --muted: #9ba8a3;
  --green: #9df86f;
  --yellow: #ffda57;
  --cyan: #63d9e6;
  --red: #ff6b5e;
  --black: #070909;
  font-family: Inter, "Segoe UI", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
label,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.site-head {
  min-height: 72px;
  padding: 12px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #0d1010;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--green);
  display: grid;
  place-items: center;
  color: var(--green);
  font: 800 12px/1 ui-monospace, "Cascadia Mono", monospace;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 14px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font: 600 10px/1.3 ui-monospace, "Cascadia Mono", monospace;
}

.head-status {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.head-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.head-status span {
  border: 1px solid var(--line-strong);
  padding: 5px 8px;
  color: var(--muted);
  font: 700 10px/1 ui-monospace, "Cascadia Mono", monospace;
}

.language-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
}

.language-switch a {
  padding: 6px 9px;
  color: var(--muted);
  font: 700 10px/1 ui-monospace, "Cascadia Mono", monospace;
  text-decoration: none;
}

.language-switch a + a {
  border-left: 1px solid var(--line-strong);
}

.language-switch a:hover,
.language-switch a:focus-visible,
.language-switch a[aria-current="page"] {
  color: var(--black);
  background: var(--green);
}

.page-grid {
  width: min(1460px, calc(100% - 32px));
  margin: 28px auto 64px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1040px) 160px;
  justify-content: center;
  align-items: start;
  gap: 26px;
}

.ad-rail {
  min-width: 0;
}

.ad-slot {
  position: sticky;
  top: 20px;
  min-height: 600px;
  border: 1px dashed #4b5754;
  background: #101313;
  color: #697571;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  font-family: ui-monospace, "Cascadia Mono", monospace;
}

.ad-slot span {
  font-size: 9px;
}

.ad-slot b {
  color: #83908b;
  font-size: 15px;
}

.ad-slot small {
  font-size: 10px;
}

.bench {
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.bench > section {
  padding: clamp(22px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
}

.bench > section:last-child {
  border-bottom: 0;
}

.intro-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 36px;
  align-items: end;
  background: #101414;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font: 700 11px/1.4 ui-monospace, "Cascadia Mono", monospace;
}

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

h1 {
  max-width: none;
  margin-bottom: 14px;
  font-size: clamp(2.2rem, 4vw, 3rem);
  line-height: 1.03;
  letter-spacing: 0;
  word-break: keep-all;
}

h2 {
  margin-bottom: 5px;
  font-size: clamp(1.2rem, 2.4vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: #c4cdc9;
  font-size: 15px;
  line-height: 1.85;
}

.scope-readout,
.result-readout {
  margin: 0;
  border-top: 1px solid var(--line);
}

.scope-readout div,
.result-readout div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.scope-readout dt,
.result-readout dt,
.scope-readout dd,
.result-readout dd {
  margin: 0;
  font: 700 10px/1.4 ui-monospace, "Cascadia Mono", monospace;
}

.scope-readout dt,
.result-readout dt {
  color: var(--muted);
}

.scope-readout dd,
.result-readout dd {
  color: var(--yellow);
  text-align: right;
}

.section-heading {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.section-heading > span {
  padding-top: 5px;
  color: var(--yellow);
  font: 800 10px/1.2 ui-monospace, "Cascadia Mono", monospace;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.source-input-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 12px;
  align-items: stretch;
}

.source-drop {
  min-height: 218px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 18px;
  color: inherit;
  background: #0f1312;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.source-drop:hover,
.source-drop:focus-visible {
  border-color: var(--cyan);
  background: #10191a;
}

.source-drop.is-dragging {
  border-color: var(--yellow);
  background: #211e12;
}

.source-drop.is-accepted {
  border-color: var(--green);
  background: #111a10;
}

.source-drop.is-error {
  border-color: var(--red);
  background: #1d1211;
}

.source-drop.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.source-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.source-drop-copy small,
.source-drop-copy b,
.source-drop-copy > span {
  display: block;
}

.source-drop-copy small,
.recorder-head,
.record-state {
  font-family: ui-monospace, "Cascadia Mono", monospace;
}

.source-drop-copy small {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
}

.source-drop-copy b {
  margin-top: 12px;
  font-size: clamp(1rem, 2vw, 1.3rem);
  line-height: 1.35;
}

.source-drop-copy > span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.file-action,
.button,
.icon-button {
  min-height: 44px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
}

.file-action,
.button {
  padding: 10px 16px;
}

.file-action,
.button-primary {
  border: 1px solid var(--green);
  background: var(--green);
  color: #0b1308;
}

.file-action {
  width: fit-content;
}

.recorder-panel {
  min-height: 218px;
  padding: 18px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #111515;
}

.recorder-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.recorder-head output {
  color: var(--yellow);
}

.record-state {
  min-height: 46px;
  margin: 16px 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: #0d1010;
  font-size: 10px;
  font-weight: 800;
}

.record-state i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #66716d;
  box-shadow: 0 0 0 4px #26302d;
}

.recorder-panel.is-recording .record-state {
  color: var(--text);
  border-color: var(--red);
}

.recorder-panel.is-recording .record-state i {
  background: var(--red);
  box-shadow: 0 0 0 4px #44201c;
  animation: record-pulse 1s steps(2, end) infinite;
}

.record-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.record-actions .button-record {
  grid-column: 1 / -1;
}

.button-record {
  border: 1px solid var(--red);
  background: transparent;
  color: #ff9b92;
}

.mic-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

@keyframes record-pulse {
  50% {
    opacity: 0.35;
  }
}

.button-secondary,
.icon-button {
  border: 1px solid var(--line-strong);
  background: #151a19;
  color: var(--text);
}

.button-download {
  border: 1px solid var(--cyan);
  background: transparent;
  color: var(--cyan);
}

.button:disabled,
.icon-button:disabled,
.process-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.icon-button {
  width: 44px;
  padding: 0;
}

.source-status {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #101313;
}

.source-status b,
.source-status span {
  display: block;
}

.source-status b {
  font: 800 11px/1.4 ui-monospace, "Cascadia Mono", monospace;
}

.source-status div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.status-light {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #65716d;
  box-shadow: 0 0 0 4px #26302d;
}

.source-status.is-ready .status-light {
  background: var(--green);
  box-shadow: 0 0 0 4px #253b21;
}

.source-status.is-busy .status-light {
  background: var(--yellow);
  box-shadow: 0 0 0 4px #443a18;
}

.pitch-scope {
  margin: 0;
  border: 1px solid var(--line-strong);
  background: var(--black);
}

#pitch-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 5.2;
  touch-action: none;
}

.pitch-scope figcaption {
  min-height: 42px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font: 700 9px/1.3 ui-monospace, "Cascadia Mono", monospace;
}

.pitch-scope figcaption span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-line {
  width: 20px;
  height: 0;
  border-top: 2px solid;
}

.legend-raw {
  border-color: var(--cyan);
}

.legend-target {
  border-width: 4px;
  border-color: var(--yellow);
}

.legend-block {
  width: 12px;
  height: 8px;
  background: #3f4845;
}

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

.mode-control label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.mode-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-control label > span {
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #111515;
}

.mode-control b,
.mode-control small {
  display: block;
}

.mode-control b {
  font-size: 13px;
}

.mode-control small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.mode-control input:checked + span {
  border-color: var(--yellow);
  background: #221f13;
  box-shadow: inset 4px 0 0 var(--yellow);
}

.control-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 150px 150px minmax(250px, 1fr);
  gap: 10px;
}

.field,
.strength-field {
  padding: 12px;
  border: 1px solid var(--line);
  background: #111515;
}

.field > span,
.strength-head {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font: 700 9px/1.2 ui-monospace, "Cascadia Mono", monospace;
}

.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 7px 9px;
  color: var(--text);
  background: #0d1010;
}

.field select:disabled {
  opacity: 0.45;
}

.strength-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.strength-head span:last-child {
  text-align: right;
}

.strength-head output {
  color: var(--yellow);
}

.strength-field input {
  width: 100%;
  accent-color: var(--yellow);
}

.process-button {
  width: 100%;
  margin-top: 12px;
  min-height: 52px;
}

.process-meter {
  height: 4px;
  margin-top: 8px;
  background: #222927;
  overflow: hidden;
}

.process-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--yellow);
  transition: width 160ms linear;
}

.process-status {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.process-status.is-error {
  color: var(--red);
}

.transport {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-readout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.result-readout div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-right: 0;
  flex-direction: column;
  justify-content: flex-start;
}

.result-readout div:last-child {
  border-right: 1px solid var(--line);
}

.result-readout dd {
  margin-top: 4px;
  text-align: left;
}

.note-band {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
  background: #101313;
}

.guide-band {
  background: #0f1212;
}

.guide-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.guide-grid article {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
}

.guide-grid h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.guide-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.note-copy p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.note-copy p:last-child {
  margin-bottom: 0;
}

.site-foot {
  min-height: 70px;
  padding: 18px clamp(18px, 3vw, 42px);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font: 700 9px/1.4 ui-monospace, "Cascadia Mono", monospace;
}

.foot-meta,
.foot-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.foot-nav {
  justify-content: flex-end;
}

.foot-nav a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.foot-nav a:hover,
.foot-nav a:focus-visible {
  color: var(--accent);
  border-bottom-color: currentColor;
}

.sr-only {
  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: 1279px) {
  .page-grid {
    grid-template-columns: minmax(0, 1040px);
  }

  .ad-rail {
    display: none;
  }
}

@media (max-width: 760px) {
  .site-head {
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand small {
    display: none;
  }

  .head-status span:last-child {
    display: none;
  }

  .head-tools {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .language-switch a {
    padding: 5px 7px;
    font-size: 9px;
  }

  .page-grid {
    width: 100%;
    margin: 0 auto;
  }

  .bench {
    border-right: 0;
    border-left: 0;
  }

  .bench > section {
    padding: 24px 16px;
  }

  .intro-band,
  .note-band {
    grid-template-columns: 1fr;
    gap: 22px;
  }

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

  h1 {
    font-size: 2.35rem;
  }

  .section-heading {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }

  .source-input-grid {
    grid-template-columns: 1fr;
  }

  .transport {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .file-action,
  .record-actions .button,
  .transport .button {
    width: 100%;
    min-width: 0;
    padding-right: 10px;
    padding-left: 10px;
    font-size: 12px;
  }

  .transport .icon-button {
    width: 100%;
  }

  .mode-control {
    grid-template-columns: 1fr;
  }

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

  .strength-field {
    grid-column: 1 / -1;
  }

  .result-readout {
    grid-template-columns: 1fr 1fr;
  }

  .result-readout div:nth-child(2) {
    border-right: 1px solid var(--line);
  }

  .result-readout div:nth-child(n + 3) {
    border-top: 0;
  }

  #pitch-canvas {
    min-height: 240px;
    aspect-ratio: 1.35 / 1;
  }

  .pitch-scope figcaption {
    gap: 10px;
  }

  .site-foot {
    flex-direction: column;
    align-items: flex-start;
  }

  .foot-meta,
  .foot-nav {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 2.05rem;
  }

  .lead {
    font-size: 14px;
  }

  .source-drop,
  .recorder-panel {
    min-height: 0;
  }

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

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

  .strength-field {
    grid-column: auto;
  }

  .result-readout {
    grid-template-columns: 1fr;
  }

  .result-readout div,
  .result-readout div:nth-child(2) {
    border-right: 1px solid var(--line);
    border-top: 0;
  }

  .result-readout div:first-child {
    border-top: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .process-meter i {
    transition: none;
  }

  .recorder-panel.is-recording .record-state i {
    animation: none;
  }
}
