:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #191d20;
  --panel-strong: #22272b;
  --ink: #f3f5f6;
  --muted: #a6b0b8;
  --line: #333a40;
  --accent: #22c55e;
  --accent-strong: #86efac;
  --blue: #38bdf8;
  --red: #f97373;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.16), transparent 34rem),
    linear-gradient(180deg, #111416 0%, #15191c 48%, #101214 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.sound-console {
  min-height: calc(100vh - 56px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 32, 0.92);
  box-shadow: var(--shadow);
}

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

.language-picker { display: grid; gap: 5px; color: var(--muted); font-size: .8rem; font-weight: 800; }
.language-picker select { min-height: 34px; padding: 0 8px; }
.version { margin-left: 8px; color: var(--muted); font-weight: 700; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1.1rem;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 92px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-strong);
  font-weight: 800;
}

.status-pill.playing {
  color: #052e16;
  border-color: transparent;
  background: var(--accent-strong);
}

.player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(56, 189, 248, 0.13), transparent 48%),
    var(--panel-strong);
}

.frequency-readout {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.frequency-readout span {
  color: var(--accent-strong);
  font-weight: 900;
  text-transform: uppercase;
}

.frequency-readout strong {
  font-size: clamp(3rem, 11vw, 7rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.frequency-readout small {
  color: var(--muted);
  font-size: 0.98rem;
}

.control-row {
  display: flex;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-width: 98px;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  border: 0;
  color: #052e16;
  background: var(--accent);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #111416;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.preset-card {
  display: grid;
  position: relative;
}

.preset-card.dragging {
  opacity: 0.55;
  transform: scale(1.03);
}

.preset-card.drop-target {
  outline: 2px dashed var(--blue);
  outline-offset: 4px;
}

.drag-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.preset {
  min-width: 0;
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
  display: flex;
  flex-direction: column;
}

.preset span,
.preset strong {
  display: block;
}

.preset small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.preset-grid { grid-auto-rows: 132px; }
.research-panel { margin-top: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.research-panel p, .research-panel li { color: var(--muted); line-height: 1.65; }
.research-panel ul { margin: 12px 0 0; padding-left: 20px; }
.research-panel a { color: var(--blue); }
.app-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 18px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; text-align: center; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.footer-links a { color: var(--blue); }

.preset span {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
  text-transform: uppercase;
}

.preset strong {
  font-size: 1.12rem;
  letter-spacing: 0;
}

.preset.active {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.13);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.78fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.field {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.field span,
.note {
  color: var(--muted);
}

.field span,
.field output {
  font-weight: 800;
}

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

select {
  grid-column: 2 / 4;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #111416;
}

.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.segment {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #111416;
  font-weight: 900;
}

.segment.active {
  color: #052e16;
  border-color: transparent;
  background: var(--accent);
}

.visualizer {
  height: 180px;
  position: relative;
  margin: 20px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111416;
}

.wave {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68%;
  aspect-ratio: 1;
  border: 2px solid rgba(134, 239, 172, 0.48);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
}

.playing .wave {
  animation: pulse 2.2s linear infinite;
}

.wave-two {
  animation-delay: 0.55s;
  border-color: rgba(56, 189, 248, 0.38);
}

.wave-three {
  animation-delay: 1.1s;
  border-color: rgba(249, 115, 115, 0.32);
}

.note {
  line-height: 1.6;
}

.session-controls {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.compact-field {
  margin-top: 0;
}

.toggle-row {
  color: var(--muted);
  font-weight: 800;
}

@keyframes pulse {
  0% {
    opacity: 0.75;
    transform: translate(-50%, -50%) scale(0.18);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.12);
  }
}

@media (max-width: 860px) {
  .topbar,
  .player,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .status-pill {
    justify-self: start;
  }

  .control-row {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }

  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 20px, 1120px);
    padding: 10px 0;
  }

  .sound-console {
    min-height: calc(100vh - 20px);
    padding: 14px;
  }

  .player,
  .panel {
    padding: 14px;
  }

  .preset-grid,
  .segments,
  .field {
    grid-template-columns: 1fr;
  }

  .field output,
  select {
    grid-column: auto;
  }

  .frequency-readout strong {
    font-size: 3rem;
  }
}
