:root {
  color-scheme: dark;
  --bg: #171614;
  --panel: #24221f;
  --panel-2: #2e2b27;
  --line: #4a4640;
  --text: #f4efe5;
  --muted: #b9afa2;
  --muted-2: #81786d;
  --mint: #62e4ba;
  --mint-2: #1aa27e;
  --amber: #f1b84c;
  --rose: #ff6b7f;
  --violet: #b889ff;
  --cyan: #64c8ff;
  --good: #6ee18d;
  --bad: #ff7067;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(98, 228, 186, 0.05), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 1.13rem;
}

.streak-pill {
  min-width: 112px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 5px 6px 5px 11px;
  background: #1f1d1a;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.streak-pill.is-hot {
  animation: streakPulse 640ms ease-out;
  border-color: rgba(110, 225, 141, 0.8);
}

.streak-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.streak-count {
  display: grid;
  place-items: center;
  width: 32px;
  aspect-ratio: 1;
  background: var(--mint);
  color: #12211c;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 900;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(420px, 0.78fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px var(--shadow);
}

.transport-panel,
.quiz-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 42px;
  margin-bottom: 18px;
  padding: 3px;
  background: #171614;
  border: 1px solid #4d463e;
  border-radius: 8px;
}

.mode-tab {
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.mode-tab.is-active {
  background: #f4efe5;
  color: #191815;
}

.difficulty-control {
  margin-bottom: 14px;
  padding: 0 2px 12px;
  border-bottom: 1px solid #3e3933;
}

.difficulty-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 800;
}

.difficulty-heading output {
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.difficulty-control input {
  display: block;
  width: 100%;
}

#fileInput {
  display: none;
}

.drop-zone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 90px;
  padding: 14px;
  background: #1f1d1a;
  border: 1px dashed #6a6258;
  border-radius: 8px;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone.is-dragging {
  background: #25342d;
  border-color: var(--mint);
  transform: translateY(-1px);
}

.drop-zone strong,
.drop-zone span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.drop-zone span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.drop-mark {
  display: grid;
  place-items: center;
  width: 58px;
  aspect-ratio: 1;
  background: #322c26;
  color: var(--mint);
  border: 1px solid #5c5147;
  border-radius: 8px;
  font-weight: 900;
}

.wave-wrap {
  position: relative;
  margin-top: 16px;
  height: clamp(190px, 28vw, 290px);
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #151411;
  background-size: 100% 25%;
  border: 1px solid #3b3731;
  border-radius: 8px;
  overflow: hidden;
  cursor: ew-resize;
  transition: border-color 150ms ease;
}

.wave-wrap.is-seeking {
  border-color: rgba(244, 239, 229, 0.9);
}

.wave-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#waveCanvas {
  cursor: ew-resize;
  touch-action: none;
}

#feedbackCanvas {
  pointer-events: none;
}

.transport-footer {
  display: grid;
  grid-template-columns: auto minmax(220px, 0.7fr);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
}

.time-readout {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.volume-control {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) 42px;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.volume-control output {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(230px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.primary-button,
.ghost-button,
.icon-button,
.segment,
.option-button {
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 130ms ease,
    border-color 130ms ease,
    background 130ms ease,
    color 130ms ease,
    opacity 130ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 104px;
  padding: 0 16px;
  background: var(--mint);
  color: #13211d;
  font-weight: 900;
}

.ghost-button,
.icon-button {
  padding: 0 14px;
  background: #191816;
  color: var(--text);
  border: 1px solid #514b43;
  font-weight: 800;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 102px;
}

.button-icon {
  font-size: 0.94rem;
  transform: translateY(-1px);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 42px;
  padding: 3px;
  background: #171614;
  border: 1px solid #4d463e;
  border-radius: 8px;
}

.segment {
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.segment.is-active {
  background: #f4efe5;
  color: #191815;
}

.icon-button[aria-pressed="true"] {
  background: #342918;
  color: var(--amber);
  border-color: rgba(241, 184, 76, 0.8);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.option-grid {
  display: grid;
  grid-template-columns: 26px repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(72px, auto));
  gap: 6px;
}

.fault-row-label {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 1px solid #464038;
  border-radius: 6px;
  background: #171614;
  font-size: 1.1rem;
  font-weight: 900;
}

.fault-row-label[data-polarity="boost"] {
  color: var(--amber);
}

.fault-row-label[data-polarity="cut"] {
  color: var(--cyan);
}

.option-button {
  position: relative;
  min-width: 0;
  padding: 9px 5px 8px;
  background: #1b1a18;
  color: var(--text);
  border: 1px solid #4a443d;
  text-align: center;
}

.option-button[data-polarity="boost"] {
  box-shadow: inset 0 2px 0 rgba(241, 184, 76, 0.55);
}

.option-button[data-polarity="cut"] {
  box-shadow: inset 0 -2px 0 rgba(100, 200, 255, 0.55);
}

.option-button strong,
.option-button span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.option-button strong {
  font-size: 0.72rem;
  line-height: 1.1;
}

.option-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.15;
}

.option-button.is-selected {
  background: #203b32;
  border-color: var(--mint);
}

.option-button.is-correct {
  background: #193220;
  border-color: var(--good);
}

.option-button.is-wrong {
  background: #3a1e1c;
  border-color: var(--bad);
}

.option-button.is-correct:disabled,
.option-button.is-wrong:disabled {
  opacity: 0.9;
}

.option-button.is-excluded {
  background: #181715;
  border-color: #514a42;
  border-style: dashed;
  opacity: 0.42;
  filter: saturate(0.25);
}

.option-button.is-excluded strong {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.option-button.is-excluded span {
  color: var(--rose);
  font-weight: 800;
  text-transform: uppercase;
}

.answer-actions {
  display: grid;
  grid-template-columns: auto minmax(120px, 0.45fr);
  justify-content: end;
  align-items: center;
  margin-top: 13px;
  gap: 10px;
}

.answer-actions .primary-button {
  width: 100%;
}

.result-panel {
  display: grid;
  gap: 5px;
  min-height: 104px;
  margin-top: 14px;
  padding: 13px;
  background: #1b1a18;
  border: 1px solid #3f3a33;
  border-radius: 8px;
}

.result-panel span {
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-panel strong {
  font-size: 1.04rem;
}

.result-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.result-panel.is-correct {
  border-color: rgba(110, 225, 141, 0.78);
  animation: answerLift 500ms ease-out;
}

.result-panel.is-wrong {
  border-color: rgba(255, 112, 103, 0.8);
  animation: answerShake 420ms ease-out;
}

.result-panel.is-audition {
  border-color: rgba(100, 200, 255, 0.72);
}

.result-panel.is-muted {
  color: var(--muted);
}

.eq-frame {
  height: clamp(220px, 30vw, 330px);
  margin-top: 14px;
  background: #141310;
  border: 1px solid #3b3731;
  border-radius: 8px;
  overflow: hidden;
}

.eq-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.celebrate {
  animation: pageKick 420ms ease-out;
}

@keyframes streakPulse {
  0% {
    box-shadow: 0 0 0 rgba(110, 225, 141, 0);
  }
  45% {
    box-shadow: 0 0 38px rgba(110, 225, 141, 0.26);
  }
  100% {
    box-shadow: 0 12px 28px var(--shadow);
  }
}

@keyframes answerLift {
  0% {
    transform: translateY(6px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes answerShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@keyframes pageKick {
  0% {
    filter: saturate(1);
  }
  48% {
    filter: saturate(1.2);
  }
  100% {
    filter: saturate(1);
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .quiz-panel {
    order: -1;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 22px, 1480px);
    padding-top: 18px;
  }

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

  .transport-panel,
  .quiz-panel {
    padding: 13px;
  }

  .drop-zone,
  .controls {
    grid-template-columns: 1fr;
  }

  .drop-mark {
    width: 48px;
  }

  .transport-footer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .option-grid {
    grid-template-columns: 22px repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(76px, auto));
    gap: 4px;
  }

  .option-button {
    padding: 7px 3px;
  }

  .option-button strong {
    font-size: 0.66rem;
  }

  .option-button span {
    font-size: 0.61rem;
  }

  .primary-button,
  .ghost-button,
  .icon-button {
    width: 100%;
  }

  .answer-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
