:root {
  color-scheme: dark;
  --ink: #f5efe6;
  --muted: #b9b4aa;
  --line: rgba(245, 239, 230, 0.16);
  --panel: rgba(24, 30, 31, 0.72);
  --panel-strong: rgba(34, 42, 41, 0.88);
  --sage: #91b9a3;
  --aqua: #7fc7c4;
  --rose: #d7a2a7;
  --amber: #d9bd74;
  --shadow: rgba(0, 0, 0, 0.38);
  --light-primary: rgba(127, 199, 196, 0.2);
  --light-secondary: rgba(215, 162, 167, 0.16);
  --light-stage: rgba(13, 18, 19, 0.74);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 22% 18%, var(--light-primary), transparent 32rem),
    radial-gradient(circle at 84% 10%, var(--light-secondary), transparent 30rem),
    linear-gradient(135deg, #151b1d 0%, #202826 44%, #18191f 100%);
  color: var(--ink);
  transition: background 650ms ease;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

body.is-locked {
  overflow: hidden;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(16px, 2.4vw, 32px);
  display: grid;
  place-items: center;
}

.sound-stage {
  width: min(1180px, 100%);
  min-height: min(860px, calc(100vh - 32px));
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--light-stage);
  box-shadow: 0 24px 70px var(--shadow);
  padding: clamp(18px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.4vw, 30px);
}

.sound-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
  pointer-events: none;
}

.visualizer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
}

.settings-toggle {
  position: absolute;
  top: clamp(14px, 2vw, 22px);
  right: clamp(14px, 2vw, 22px);
  z-index: 3;
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid rgba(245, 239, 230, 0.18);
  border-radius: 999px;
  background: rgba(13, 18, 19, 0.34);
  color: var(--ink);
  backdrop-filter: blur(16px);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background 180ms ease,
    transform 180ms ease,
    opacity 180ms ease;
}

.settings-toggle:hover {
  background: rgba(245, 239, 230, 0.1);
  transform: translateY(-1px);
}

.settings-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar,
.frequency-readout,
.session-strip,
.controls-grid {
  position: relative;
  z-index: 1;
  transition:
    opacity 320ms ease,
    transform 320ms ease,
    visibility 320ms ease;
}

body.is-immersive .topbar,
body.is-immersive .frequency-readout,
body.is-immersive .session-strip,
body.is-immersive .controls-grid {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(10px);
}

body.is-immersive .sound-stage {
  min-height: calc(100vh - clamp(16px, 2.4vw, 32px) * 2);
  border-color: rgba(245, 239, 230, 0.08);
  background: transparent;
}

body.is-immersive .visualizer {
  opacity: 0.95;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--aqua);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 5.7rem);
  line-height: 0.94;
  font-weight: 780;
}

h2 {
  font-size: 1rem;
  font-weight: 750;
}

.play-button {
  width: clamp(64px, 8vw, 92px);
  aspect-ratio: 1;
  border: 1px solid rgba(245, 239, 230, 0.24);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(145, 185, 163, 0.95), rgba(127, 199, 196, 0.86));
  box-shadow: 0 18px 44px rgba(127, 199, 196, 0.18);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.play-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 50px rgba(127, 199, 196, 0.24);
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 20px solid #14201f;
  transform: translateX(2px);
}

.play-button.is-playing .play-icon {
  width: 22px;
  height: 28px;
  border: 0;
  transform: none;
  background: linear-gradient(90deg, #14201f 0 34%, transparent 34% 64%, #14201f 64% 100%);
}

.frequency-readout {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.frequency-readout span:first-child {
  font-size: clamp(5.4rem, 22vw, 16rem);
  line-height: 0.78;
  font-weight: 820;
  color: rgba(245, 239, 230, 0.94);
}

.frequency-readout span:last-child {
  color: var(--muted);
  font-size: clamp(1.4rem, 3.5vw, 3rem);
  font-weight: 700;
}

.session-strip {
  width: min(720px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--ink);
}

.session-strip small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.time-pill {
  min-width: 82px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  text-align: center;
  background: rgba(245, 239, 230, 0.08);
  font-variant-numeric: tabular-nums;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1.18fr 1fr 0.74fr;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(22px);
  padding: 16px;
}

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

.icon-button {
  width: 36px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(245, 239, 230, 0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.preset-tabs {
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: rgba(245, 239, 230, 0.06);
}

.preset-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.82rem;
}

.preset-tab.is-active {
  background: rgba(127, 199, 196, 0.16);
  color: var(--ink);
}

.preset-card {
  min-height: 72px;
  text-align: left;
  border: 1px solid rgba(245, 239, 230, 0.12);
  border-radius: 8px;
  background: rgba(245, 239, 230, 0.07);
  padding: 11px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.preset-card.is-active {
  border-color: rgba(127, 199, 196, 0.82);
  background: rgba(127, 199, 196, 0.16);
}

.preset-card strong {
  font-size: 0.94rem;
}

.preset-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.wave-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: rgba(245, 239, 230, 0.06);
}

.wave-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.82rem;
}

.wave-tab.is-active {
  background: rgba(245, 239, 230, 0.14);
  color: var(--ink);
}

.shape-tabs {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: rgba(245, 239, 230, 0.06);
}

.shape-tab {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 6px 7px;
  cursor: pointer;
  font-size: 0.78rem;
}

.shape-tab.is-active {
  background: rgba(217, 189, 116, 0.18);
  color: var(--ink);
}

.slider-row {
  display: grid;
  grid-template-columns: 86px 1fr 64px;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  color: var(--muted);
  font-size: 0.88rem;
}

.slider-row output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

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

.switch-row {
  margin-top: 8px;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.switch {
  width: 58px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(245, 239, 230, 0.1);
  padding: 3px;
  cursor: pointer;
}

.switch span {
  display: block;
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--muted);
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.switch[aria-pressed="true"] {
  background: rgba(127, 199, 196, 0.28);
}

.switch[aria-pressed="true"] span {
  transform: translateX(26px);
  background: var(--aqua);
}

.fibonacci-depth {
  margin-top: 2px;
}

.phi-readout {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 6px;
}

.phi-readout span {
  color: var(--muted);
  font-size: 0.82rem;
}

.phi-readout small {
  color: rgba(245, 239, 230, 0.86);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.timer-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.timer-option {
  min-height: 48px;
  border: 1px solid rgba(245, 239, 230, 0.13);
  border-radius: 8px;
  background: rgba(245, 239, 230, 0.07);
  cursor: pointer;
  font-weight: 760;
}

.timer-option::after {
  content: " min";
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.timer-option.is-active {
  border-color: rgba(217, 189, 116, 0.75);
  background: rgba(217, 189, 116, 0.16);
}

.quiet-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.legal-notice {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.legal-notice summary {
  color: rgba(245, 239, 230, 0.86);
  cursor: pointer;
  font-weight: 700;
}

.legal-notice div {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.legal-notice p {
  margin: 0;
}

.consent-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: clamp(16px, 3vw, 36px);
  background:
    radial-gradient(circle at 22% 18%, var(--light-primary), transparent 32rem),
    linear-gradient(135deg, rgba(10, 14, 15, 0.96), rgba(22, 28, 29, 0.98));
  display: grid;
  place-items: center;
}

.consent-gate.is-hidden {
  display: none;
}

.consent-panel {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 30, 31, 0.92);
  box-shadow: 0 24px 70px var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}

.consent-panel h2 {
  margin-bottom: 14px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
}

.consent-copy {
  display: grid;
  gap: 10px;
  color: rgba(245, 239, 230, 0.86);
  font-size: 0.9rem;
  line-height: 1.55;
}

.consent-check {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
}

.consent-check input {
  margin-top: 3px;
  accent-color: var(--aqua);
}

.consent-button {
  margin-top: 18px;
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(127, 199, 196, 0.58);
  border-radius: 999px;
  background: rgba(127, 199, 196, 0.2);
  cursor: pointer;
  font-weight: 760;
}

.consent-button:disabled {
  border-color: rgba(245, 239, 230, 0.12);
  background: rgba(245, 239, 230, 0.06);
  color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .sound-stage {
    min-height: auto;
  }

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

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

@media (max-width: 620px) {
  .app-shell {
    padding: 0;
  }

  .sound-stage {
    min-height: 100vh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .topbar {
    align-items: center;
  }

  .session-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .preset-list {
    grid-template-columns: 1fr 1fr;
  }

  .slider-row {
    grid-template-columns: 1fr 64px;
    gap: 6px 12px;
  }

  .slider-row input {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
