:root {
  color-scheme: dark;
  --bg: #0b0d11;
  --surface: #141820;
  --surface-raised: #1a1f29;
  --surface-soft: #202631;
  --line: #303746;
  --line-bright: #465064;
  --text: #f7f9f2;
  --muted: #9ea7b5;
  --lime: #c9ff4a;
  --lime-dark: #92c20f;
  --cyan: #61d9ff;
  --amber: #ffbd59;
  --red: #ff6d78;
  --radius-large: 26px;
  --radius: 17px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -10%, rgba(201, 255, 74, 0.1), transparent 33rem),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 34px 34px, 34px 34px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

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

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  color: #0b0d11;
  background: var(--lime);
  border-radius: 10px;
  font-weight: 800;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  padding: 0.8rem max(1.25rem, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 13, 17, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  text-decoration: none;
  font-size: 1.38rem;
  font-weight: 850;
  letter-spacing: -0.045em;
}

.brand img {
  border-radius: 11px;
}

.brand span span {
  color: var(--lime);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.prototype-tag {
  padding: 0.38rem 0.68rem;
  border: 1px solid rgba(201, 255, 74, 0.28);
  border-radius: 999px;
  color: var(--lime);
  background: rgba(201, 255, 74, 0.07);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  width: min(1180px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4.5rem) 0 5rem;
}

.lesson-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.45rem;
  color: var(--lime);
  font-size: 0.79rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lesson-intro h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 4.75rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.lesson-intro p:last-child {
  max-width: 660px;
  margin: 1.15rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
}

.lesson-progress {
  flex: 0 0 220px;
  padding-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.progress-track {
  height: 7px;
  margin-top: 0.6rem;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.progress-track span {
  display: block;
  width: 16.66%;
  height: 100%;
  border-radius: inherit;
  background: var(--lime);
  transition: width 300ms ease;
}

.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 1.25rem;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.028), transparent 45%), var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  letter-spacing: -0.035em;
}

.target-panel,
.listener-panel {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.target-panel::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 360px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(201, 255, 74, 0.075);
  filter: blur(4px);
  pointer-events: none;
}

.string-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 31px;
  padding: 0.34rem 0.64rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cdd3dc;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #697282;
}

.status-pill[data-state="live"] {
  color: var(--lime);
  border-color: rgba(201, 255, 74, 0.35);
}

.status-pill[data-state="live"] i {
  background: var(--lime);
  box-shadow: 0 0 0 6px rgba(201, 255, 74, 0.09);
  animation: statusPulse 1.5s ease-in-out infinite;
}

.status-pill[data-state="waiting"] {
  color: var(--amber);
}

.status-pill[data-state="error"] {
  color: var(--red);
}

.target-note {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 128px;
  padding: 1.25rem 0 0.4rem;
}

.target-note-name {
  color: var(--lime);
  font-size: clamp(5rem, 13vw, 8.2rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.09em;
  text-shadow: 0 0 42px rgba(201, 255, 74, 0.15);
}

.target-note-octave {
  margin: 0.55rem 0 0 0.45rem;
  color: #dce3d2;
  font-size: 1.5rem;
  font-weight: 800;
}

.target-frequency {
  align-self: end;
  margin: 0 0 0.6rem 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.tab-wrap {
  padding: 0.7rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  background: rgba(4, 6, 8, 0.36);
}

.tab-diagram {
  display: block;
  width: 100%;
  min-height: 180px;
}

.tab-label {
  fill: #778191;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px;
  font-weight: 800;
  text-anchor: middle;
}

.tab-label.active {
  fill: var(--lime);
}

.tab-line {
  stroke: #343b48;
  stroke-width: 2;
}

.tab-line.active {
  stroke: var(--lime-dark);
  stroke-width: 4;
}

.tab-marker {
  fill: var(--lime);
  filter: drop-shadow(0 0 10px rgba(201, 255, 74, 0.28));
}

.tab-fret {
  fill: #0b0d11;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 25px;
  font-weight: 900;
  text-anchor: middle;
}

.pluck-arrow {
  fill: none;
  stroke: var(--lime);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: arrowBounce 1.5s ease-in-out infinite;
}

.target-actions {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 50px;
  gap: 0.65rem;
  margin-top: 1rem;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 820;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button svg,
.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-primary {
  color: #0b0d11;
  background: var(--lime);
  box-shadow: 0 10px 30px rgba(201, 255, 74, 0.14);
}

.button-primary:hover {
  background: #d7ff75;
}

.button-secondary,
.icon-button,
.button-ghost {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-soft);
}

.button-secondary:hover,
.icon-button:hover,
.button-ghost:hover {
  border-color: var(--line-bright);
  background: #262d39;
}

.button-small {
  min-height: 38px;
  padding: 0.4rem 0.75rem;
  border-radius: 10px;
  font-size: 0.82rem;
}

.listener-panel {
  display: flex;
  flex-direction: column;
}

.detected-readout {
  display: grid;
  justify-items: center;
  min-height: 207px;
  padding: 2.1rem 0 1.2rem;
}

.detected-label {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detected-readout strong {
  margin-top: 0.1rem;
  font-size: clamp(4.4rem, 12vw, 7rem);
  line-height: 1;
  letter-spacing: -0.065em;
  font-variant-numeric: tabular-nums;
}

.detected-readout > span:last-child {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.tuning-meter {
  padding: 0.35rem 0.1rem 1.35rem;
}

.meter-scale,
.meter-words {
  display: flex;
  justify-content: space-between;
  color: #788292;
  font-size: 0.69rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meter-rail {
  position: relative;
  height: 12px;
  margin: 0.42rem 0 0.52rem;
  border-radius: 99px;
  background: linear-gradient(90deg, #4053a0, #62749f 36%, #78a91d 48%, #78a91d 52%, #9f7854 65%, #9d4050);
}

.in-tune-zone {
  position: absolute;
  left: 43%;
  top: -3px;
  width: 14%;
  height: 18px;
  border: 1px solid rgba(201, 255, 74, 0.7);
  border-radius: 99px;
}

.meter-centre {
  position: absolute;
  left: 50%;
  top: -7px;
  width: 2px;
  height: 26px;
  background: rgba(255, 255, 255, 0.75);
}

.meter-needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 23px;
  height: 23px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  transition: left 90ms linear;
}

.feedback-box {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 0.75rem;
  min-height: 68px;
  margin-top: auto;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #d9dee6;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.89rem;
}

.feedback-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-soft);
}

.feedback-icon svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feedback-box[data-state="correct"],
.feedback-box[data-state="success"] {
  color: var(--lime);
  border-color: rgba(201, 255, 74, 0.32);
  background: rgba(201, 255, 74, 0.07);
}

.feedback-box[data-state="tune"] {
  color: var(--amber);
  border-color: rgba(255, 189, 89, 0.3);
  background: rgba(255, 189, 89, 0.06);
}

.feedback-box[data-state="try"],
.feedback-box[data-state="error"] {
  color: #ff9ca5;
  border-color: rgba(255, 109, 120, 0.28);
  background: rgba(255, 109, 120, 0.06);
}

.listen-button {
  width: 100%;
  margin-top: 0.8rem;
}

.listen-button.is-listening {
  color: var(--text);
  border-color: var(--line-bright);
  background: var(--surface-soft);
  box-shadow: none;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.42rem;
  margin: 0.8rem 0 0;
  color: #838d9c;
  font-size: 0.72rem;
  text-align: center;
}

.privacy-note svg {
  flex: 0 0 15px;
  width: 15px;
  margin-top: 0.08rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chord-lab {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4rem);
  margin-top: 1.25rem;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
}

.chord-lab h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.65rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.chord-lab-copy > p:last-child {
  margin: 1rem 0 0;
  color: var(--muted);
}

.chord-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.chord-card {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 7, 10, 0.34);
}

.chord-card h3 {
  margin: 0;
  color: var(--lime);
  font-size: 1.1rem;
  text-align: center;
}

.chord-card svg {
  display: block;
  width: 100%;
  max-height: 184px;
}

.chord-grid {
  stroke: #667080;
  stroke-width: 2;
}

.chord-nut {
  stroke: #dfe4ea;
  stroke-width: 6;
}

.chord-open {
  fill: #c6ccd5;
  font-size: 23px;
  font-weight: 700;
  text-anchor: middle;
}

.chord-finger {
  fill: var(--lime);
}

.chord-finger-number {
  fill: #0b0d11;
  font-size: 13px;
  font-weight: 900;
  text-anchor: middle;
}

.prototype-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border-left: 3px solid var(--cyan);
  border-radius: 0 12px 12px 0;
  color: var(--muted);
  background: rgba(97, 217, 255, 0.055);
  font-size: 0.84rem;
}

.prototype-note strong {
  color: var(--cyan);
  white-space: nowrap;
}

.success-toast {
  position: fixed;
  right: max(1rem, calc((100vw - 1180px) / 2));
  bottom: 1.25rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: min(330px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border: 1px solid rgba(201, 255, 74, 0.35);
  border-radius: 15px;
  color: var(--text);
  background: #1a201a;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(130%);
  transition: opacity 220ms ease, transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.success-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.success-toast > span:last-child {
  display: grid;
}

.success-toast small {
  color: var(--muted);
}

.success-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #0b0d11;
  background: var(--lime);
}

.success-mark svg {
  width: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.noscript {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 80;
  padding: 1rem;
  color: #101216;
  background: var(--amber);
  border-radius: 12px;
  text-align: center;
  font-weight: 800;
}

@keyframes statusPulse {
  50% { opacity: 0.55; }
}

@keyframes arrowBounce {
  50% { transform: translateY(5px); }
}

@media (max-width: 900px) {
  .practice-grid,
  .chord-lab {
    grid-template-columns: 1fr;
  }

  .lesson-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .lesson-progress {
    width: 100%;
    flex-basis: auto;
  }

  .chord-lab-copy {
    max-width: 620px;
  }
}

@media (max-width: 570px) {
  .topbar {
    min-height: 66px;
    padding: 0.65rem 1rem;
  }

  .brand {
    font-size: 1.2rem;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .prototype-tag {
    display: none;
  }

  .app-shell {
    width: min(100% - 1.25rem, 1180px);
    padding-top: 1.75rem;
  }

  .lesson-intro h1 {
    font-size: 2.65rem;
  }

  .target-panel,
  .listener-panel {
    padding: 1rem;
    border-radius: 20px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .string-badge,
  .status-pill {
    font-size: 0.7rem;
  }

  .target-note {
    min-height: 105px;
  }

  .tab-diagram {
    min-height: 145px;
  }

  .detected-readout {
    min-height: 185px;
  }

  .chord-list {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
    overflow-x: auto;
  }

  .chord-card {
    min-width: 100px;
    padding: 0.5rem;
  }

  .prototype-note {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .prototype-note strong {
    white-space: normal;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
