:root {
  color-scheme: dark;
  --page: #141619;
  --panel: #1d2025;
  --screen: #17191d;
  --line: #32353d;
  --text: #f4f1e9;
  --muted: #b6bac4;
  --gold: #e8c88e;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: Inter, system-ui, sans-serif;
  font-family: var(--sans);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button, input, select { color: inherit; }
h1, h2, p { margin: 0; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
[hidden] { display: none !important; }

.wrapper { width: min(1136px, calc(100% - 64px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; z-index: 5; top: 10px; left: 10px; padding: 10px 16px; border-radius: 8px; background: var(--gold); color: var(--page); transform: translateY(-200%); }
.skip-link:focus { transform: none; }

.site-header { border-bottom: 1px solid #292b32; }
.header-inner, .footer-inner { display: flex; align-items: center; justify-content: space-between; }
.header-inner { min-height: 75px; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; line-height: 1.23; }
.brand img { object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .98rem; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.navigation { display: flex; gap: clamp(.15rem, 1.6vw, 1.5rem); }
.navigation a { display: flex; align-items: center; min-height: 44px; padding-inline: 11px; border-radius: 8px; color: var(--muted); font-size: .875rem; font-weight: 600; }
.navigation a:hover { color: var(--text); background: var(--panel); }

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 286px;
  margin: 32px 0 24px;
  padding: clamp(24px, 4.5vw, 56px);
  border: 1px solid #3b3732;
  border-radius: 24px;
  background: #1d1b1a;
}
.hero img {
  position: absolute;
  z-index: -2;
  inset: 0 0 0 auto;
  width: 71%;
  height: 100%;
  object-fit: cover;
  object-position: 46% 58%;
}
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(90deg, #1d1b1a 27%, #1d1b1afa 37%, #1d1b1a90 59%, #1d1b1a18 90%);
}
.hero h1 { font: 400 clamp(3.2rem, 6.7vw, 6.1rem)/.85 var(--serif); letter-spacing: -.035em; }
.hero h1 em { color: var(--gold); font-weight: 400; }
.hero p { max-width: 27rem; margin-top: 22px; color: #dfd9cf; }
.noscript { margin-bottom: 16px; color: var(--gold); }

.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tool {
  min-width: 0;
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  scroll-margin-top: 16px;
}
.tuner { --accent: #b6e0c1; --accent-bg: #2a3a34; }
.metronome { --accent: #d8caf8; --accent-bg: #393247; }
.piano { --accent: #bfd2f7; --accent-bg: #30394b; grid-column: 1 / -1; }
.tool-header { display: flex; gap: 13px; align-items: center; margin-bottom: 18px; }
.tool-header h2 { font-size: clamp(1.15rem, 2.3vw, 1.42rem); letter-spacing: -.035em; line-height: 1.2; }
.tool-header p { margin-top: 4px; color: var(--muted); font-size: .875rem; }
.tool-icon { display: grid; flex: 0 0 44px; place-items: center; height: 44px; border-radius: 12px; color: var(--accent); background: var(--accent-bg); }
.icon { display: inline-block; position: relative; flex-shrink: 0; width: 18px; height: 18px; color: inherit; }
.icon::before, .icon::after { content: ""; position: absolute; }
.icon-wave { background: linear-gradient(currentColor, currentColor) 0 50% / 2px 7px, linear-gradient(currentColor, currentColor) 4px 50% / 2px 12px, linear-gradient(currentColor, currentColor) 8px 50% / 2px 18px, linear-gradient(currentColor, currentColor) 12px 50% / 2px 10px, linear-gradient(currentColor, currentColor) 16px 50% / 2px 6px; background-repeat: no-repeat; }
.icon-metronome::before { inset: 2px 2px 1px; background: currentColor; clip-path: polygon(33% 0, 67% 0, 100% 100%, 0 100%, 33% 0, 42% 12%, 16% 86%, 84% 86%, 58% 12%, 42% 12%); }
.icon-metronome::after { bottom: 4px; left: 8px; width: 2px; height: 11px; background: currentColor; transform: rotate(29deg); transform-origin: bottom; }
.icon-piano { height: 15px; border: 2px solid currentColor; border-radius: 2px; background: linear-gradient(currentColor, currentColor) 33% 100% / 1px 100%, linear-gradient(currentColor, currentColor) 66% 100% / 1px 100%; background-repeat: no-repeat; }
.icon-piano::before { top: 0; left: 4px; width: 3px; height: 6px; background: currentColor; box-shadow: 4px 0 currentColor; }
.icon-mic::before { inset: 0 6px 5px; border: 1.5px solid currentColor; border-radius: 5px; }
.icon-mic::after { inset: 5px 3px 2px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 8px 8px; }
.icon-mic { background: linear-gradient(currentColor, currentColor) 50% 100% / 1.5px 3px no-repeat; }
.icon-play::before { inset: 2px 2px 2px 5px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.icon-stop::before { inset: 3px; background: currentColor; border-radius: 2px; }

.tool-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  padding: 13px clamp(12px, 3.5vw, 38px);
  border: 1px solid #2b2e35;
  border-radius: 12px;
  background: var(--screen);
}
.tuner-readout { display: flex; align-items: baseline; justify-content: center; gap: 14px; }
.tuner-note { min-width: 1.3ch; font-size: clamp(2.65rem, 6vw, 3.15rem); font-weight: 600; letter-spacing: -.075em; line-height: 1.15; }
.tuner-frequency, .tuner-scale, #tuner-cents { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.tuner-meter { width: min(100%, 390px); margin-top: 14px; }
.tuner-track {
  position: relative;
  height: 18px;
  background: linear-gradient(90deg, #596070, #8a8e85 35%, #91b89e 46% 54%, #8a8e85 65%, #596070) 50% 50% / 100% 2px no-repeat;
}
.tuner-track::before {
  content: "";
  position: absolute;
  inset: 5px 0;
  background: linear-gradient(#838997, #838997) 0 50% / 1px 100%, linear-gradient(#838997, #838997) 25% 50% / 1px 60%, linear-gradient(var(--accent), var(--accent)) 50% 50% / 2px 100%, linear-gradient(#838997, #838997) 75% 50% / 1px 60%, linear-gradient(#838997, #838997) 100% 50% / 1px 100%;
  background-repeat: no-repeat;
}
.tuner-needle { position: absolute; top: 0; left: var(--position, 50%); width: 3px; height: 100%; border-radius: 4px; background: var(--gold); transform: translateX(-50%); transition: left 85ms linear; }
.tuner-scale { display: grid; grid-template-columns: repeat(3, 1fr); }
.tuner-scale span:nth-child(2) { text-align: center; }
.tuner-scale span:last-child { text-align: right; }
.tuner-feedback { display: flex; justify-content: center; align-items: center; gap: 9px; min-height: 29px; margin-top: 4px; text-align: center; font-size: .875rem; }
.tuner-screen[data-pitch="tuned"] :is(.tuner-note, #tuner-status) { color: var(--accent); }
.tuner-screen[data-pitch="tuned"] .tuner-needle { background: var(--accent); }

.tempo { display: flex; align-items: center; justify-content: center; gap: clamp(.5rem, 2vw, 1.35rem); }
.step-button, .secondary, .meter-picker select {
  min-height: 44px;
  border: 1px solid #40444e;
  border-radius: 9px;
  background: #25282f;
}
.step-button { display: grid; place-items: center; width: 44px; padding: 0; line-height: 1; font-size: 1.25rem; }
.step-button:hover:not(:disabled), .secondary:hover, .meter-picker select:hover { background-color: #30343e; }
.tempo-number { display: grid; justify-items: center; min-width: 5.3rem; }
.tempo-number input {
  width: 5.5rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--accent);
  background: transparent;
  text-align: center;
  font-size: clamp(2.4rem, 6vw, 3.05rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.065em;
  line-height: 1.05;
}
.tempo-number span { color: var(--muted); font-weight: 600; font-size: .875rem; }
input[type="number"] { appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.range { height: 24px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tempo-range { width: min(100%, 280px); margin: 8px 0; }
.beat-lights { display: flex; align-items: center; justify-content: center; gap: 9px; height: 12px; }
.beat-lights span { width: 8px; height: 8px; border-radius: 50%; background: #626673; }
.beat-lights span.is-accent { outline: 1px solid var(--accent); outline-offset: 2px; }
.beat-lights span.is-beat { background: var(--accent); box-shadow: 0 0 12px #d8caf875; }

.tool-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 11px; margin-top: 16px; }
.action, .secondary, .meter-picker select { padding-inline: 13px; font-size: .875rem; font-weight: 650; }
.action { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid transparent; border-radius: 9px; background: var(--accent); color: #181c21; }
.action:hover:not(:disabled) { filter: brightness(1.095); }
.reference { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .875rem; }
.reference input { width: 3.5rem; min-height: 44px; padding: 5px; border: 1px solid #40444e; border-radius: 9px; background: #25282f; text-align: center; }
.meter-picker select { appearance: none; padding-right: 32px; }
.meter-picker { position: relative; }
.meter-picker::after { content: ""; position: absolute; top: 17px; right: 13px; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.tool-help { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.tool > .tool-help { margin-top: 11px; }

.piano-header { flex-wrap: wrap; }
.octaves { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.octaves span { min-width: 7.5ch; text-align: center; color: var(--accent); font-size: .875rem; font-variant-numeric: tabular-nums; }
.piano-instrument { padding: 12px; border: 1px solid #343842; border-radius: 12px; background: #14161a; }
.piano-scroll { overflow-x: auto; scrollbar-color: #757b8d #1f2229; }
.piano-keyboard { position: relative; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); min-width: 610px; height: clamp(153px, 20vw, 210px); }
.piano-key {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 0 0 9px;
  border: 1px solid #15171d;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(#e0dcd3, #f7f3e9 76%);
  box-shadow: inset 0 -5px #ccc8be;
  color: #24252d;
  font-size: .78rem;
  font-weight: 650;
  touch-action: pan-x;
  user-select: none;
  -webkit-user-select: none;
}
.piano-key.is-black {
  position: absolute;
  z-index: 1;
  top: 0;
  left: var(--left);
  width: 4%;
  height: 60%;
  padding-bottom: 6px;
  border-color: #101217;
  background: linear-gradient(#22252c, #303540);
  box-shadow: inset 0 -5px #16181e, 0 4px 5px #13151a66;
  color: var(--text);
  transform: translateX(-50%);
}
.piano-key kbd { font: 600 .75rem/1.25 var(--sans); opacity: .75; }
.piano-key:focus-visible { z-index: 2; outline-offset: -3px; outline-color: #486ba9; }
.piano-key.is-black:focus-visible { outline-color: var(--accent); }
.piano-key.is-playing { background: #b9d0f2; box-shadow: inset 0 -3px #8da8d5; }
.piano-key.is-black.is-playing { background: #536a95; box-shadow: inset 0 -3px #334669; }
.piano-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 10px; }
.keyboard-help kbd { font-family: inherit; font-weight: 700; color: var(--text); }
.touch-help { display: none; }
.volume-label { display: flex; align-items: center; gap: 9px; font-size: .875rem; color: var(--muted); }
.volume-label input { width: 92px; }

.site-footer { margin-top: 36px; border-top: 1px solid #292b32; color: var(--muted); font-size: .875rem; }
.footer-inner { min-height: 66px; }
.site-footer a:hover { color: var(--text); }

@media (max-width: 795px) {
  .wrapper { width: calc(100% - 40px); }
  .tool { padding: 17px; }
  .tool-grid { gap: 16px; }
}

@media (max-width: 670px) {
  .wrapper { width: calc(100% - 28px); }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { min-height: 246px; margin-top: 20px; }
  .hero img { width: 100%; object-position: 56% 60%; }
  .hero::after { background: linear-gradient(90deg, #1d1b1af7 0, #1d1b1ad4 40%, #1d1b1a54 100%); }
  .hero p { max-width: 22rem; }
  .touch-help { display: block; }
}

@media (max-width: 400px) {
  .header-inner { flex-wrap: wrap; gap: 3px; padding-block: 11px 4px; }
  .navigation { width: 100%; }
  .navigation a { flex: 1; justify-content: center; padding-inline: 6px; }
  .octaves { margin-left: 0; }
}

@media (pointer: coarse) {
  .keyboard-help, .piano-key kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tuner-needle { transition: none; }
}
