:root {
  color-scheme: dark;
  --ink: #e8f0eb;
  --muted: #a8bab7;
  --subtle: #9aadaa;
  --deep: #071d27;
  --deep-2: #0d2c35;
  --surface: rgba(15, 44, 50, 0.82);
  --surface-bright: rgba(24, 62, 64, 0.85);
  --line: rgba(168, 203, 190, 0.17);
  --line-strong: rgba(168, 203, 190, 0.34);
  --mint: #b7dfc9;
  --mint-strong: #8fd4b5;
  --gold: #d8bf88;
  --warning: #f1b59f;
  --radius: 18px;
  --shadow: 0 24px 70px rgba(0, 6, 10, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 88% 5%, rgba(100, 154, 142, 0.16), transparent 28rem),
    radial-gradient(circle at 2% 45%, rgba(36, 83, 92, 0.28), transparent 30rem),
    var(--deep);
  color: var(--ink);
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

input,
select {
  font-size: 16px;
}

button,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input[type="range"] {
  min-height: 44px;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: var(--mint);
  color: var(--deep);
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

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

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid var(--mint-strong);
  border-radius: 50%;
  color: var(--mint);
  font-size: 1.35rem;
  line-height: 1;
}

.header-note {
  margin: 0;
  color: var(--subtle);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: clamp(2rem, 6vw, 5.5rem);
  align-items: center;
  padding: clamp(3.3rem, 8vw, 7rem) 0 clamp(3rem, 7vw, 5.8rem);
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.75rem;
  color: var(--mint-strong);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.eyebrow-dot,
.scene-live {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(216, 191, 136, 0.1);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin-top: 0;
}

h1 {
  max-width: 13ch;
  margin-bottom: 1.45rem;
  color: #f0f6ee;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.05rem, 6vw, 5.55rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

h1 em {
  color: var(--mint);
  font-style: normal;
}

.lede {
  max-width: 48ch;
  margin-bottom: 1.75rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.12rem);
}

.intro-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.25rem;
  color: var(--subtle);
  font-size: 0.76rem;
}

.intro-meta span span {
  color: var(--gold);
}

.scene-card {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(193, 219, 204, 0.28);
  border-radius: 22px;
  background: #112f35;
  box-shadow: var(--shadow);
  transform: rotate(1deg);
}

.scene-card::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(4, 20, 25, 0.12), rgba(4, 20, 25, 0.58));
  content: "";
  pointer-events: none;
}

.scene-card img {
  display: block;
  width: 100%;
  height: clamp(270px, 36vw, 440px);
  object-fit: cover;
  filter: saturate(0.82) contrast(0.94);
}

.scene-card figcaption {
  position: absolute;
  z-index: 1;
  right: 1.25rem;
  bottom: 1rem;
  left: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #f1f5ea;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scene-card figcaption span:last-child {
  margin-left: auto;
  color: rgba(241, 245, 234, 0.65);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

.status-panel,
.card-surface,
.care-note {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 14px 50px rgba(0, 7, 12, 0.12);
}

.status-panel {
  padding: clamp(1.2rem, 3vw, 2rem);
  border-radius: var(--radius);
}

.status-heading-row,
.section-heading-row,
.master-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.status-heading-row h2,
.section-heading-row h2 {
  margin: 0;
  color: #eff5ed;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.04em;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.55rem;
  min-height: 32px;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.status-pill[data-state="running"] {
  border-color: rgba(143, 212, 181, 0.45);
  color: var(--mint);
}

.status-pill[data-state="stopped"] {
  border-color: rgba(216, 191, 136, 0.45);
  color: var(--gold);
}

.status-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--subtle);
}

.status-pill[data-state="running"] .status-pulse {
  background: var(--mint-strong);
  box-shadow: 0 0 0 5px rgba(143, 212, 181, 0.12);
}

.signal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 0.9fr);
  gap: 2rem;
  align-items: center;
  margin-top: 1.45rem;
}

.signal-copy p {
  margin: 0.18rem 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.signal-copy #audio-context-state {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
}

.signal-meter {
  width: min(100%, 410px);
  height: 5px;
  margin: 1.15rem 0 0.75rem;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(207, 235, 219, 0.1);
}

.signal-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-strong), var(--gold));
  transition: width 180ms ease;
}

.muted-text,
.tiny-note,
.form-note {
  color: var(--subtle) !important;
  font-size: 0.72rem !important;
}

.visualizer {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  min-height: 90px;
  padding: 1rem;
  border: 1px solid rgba(168, 203, 190, 0.14);
  border-radius: 13px;
  background: rgba(2, 17, 23, 0.35);
}

.visualizer span {
  display: block;
  min-height: 4px;
  height: 10%;
  border-radius: 99px;
  background: linear-gradient(to top, rgba(143, 212, 181, 0.3), var(--mint-strong));
  opacity: 0.45;
  transition: height 100ms ease, opacity 180ms ease;
}

.visualizer[data-active="true"] span {
  opacity: 0.85;
}

.mixer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 1.15rem;
  align-items: start;
  margin-top: 1.15rem;
}

.card-surface {
  border-radius: var(--radius);
}

.mixer-main {
  min-width: 0;
  padding: clamp(1.2rem, 3vw, 2rem);
}

.section-heading-row {
  margin-bottom: 1.25rem;
}

.section-heading-row.compact {
  align-items: center;
  margin-bottom: 1.15rem;
}

.section-heading-row .section-kicker,
.status-heading-row .section-kicker {
  margin-bottom: 0.35rem;
}

.tiny-note {
  margin: 0;
  letter-spacing: 0.12em;
}

.layers-list {
  display: grid;
  gap: 0.55rem;
}

.layer-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 48px minmax(120px, 0.85fr);
  gap: 0.85rem;
  align-items: center;
  min-width: 0;
  padding: 0.72rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 13px;
  background: rgba(6, 27, 32, 0.43);
  transition: border-color 160ms ease, background 160ms ease;
}

.layer-card:has(input[data-layer-toggle]:checked) {
  border-color: rgba(143, 212, 181, 0.18);
  background: rgba(26, 61, 60, 0.48);
}

.layer-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(183, 223, 201, 0.24);
  border-radius: 12px;
  color: var(--mint);
  font-family: Georgia, serif;
  font-size: 1.5rem;
  line-height: 1;
}

.icon-rain { background: rgba(112, 170, 189, 0.18); }
.icon-leaves { background: rgba(115, 169, 126, 0.18); }
.icon-stream { background: rgba(98, 155, 178, 0.18); }
.icon-thunder { background: rgba(132, 119, 156, 0.18); }
.icon-insects { background: rgba(173, 161, 103, 0.17); }

.layer-info {
  min-width: 0;
}

.layer-info h3 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
}

.layer-info h3 span {
  color: var(--subtle);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.layer-info p {
  overflow: hidden;
  margin: 0.12rem 0 0;
  color: var(--subtle);
  font-size: 0.71rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  cursor: pointer;
}

.switch-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.switch {
  position: relative;
  display: block;
  width: 36px;
  height: 21px;
  border-radius: 99px;
  background: rgba(168, 203, 190, 0.22);
  transition: background 160ms ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform 160ms ease, background 160ms ease;
}

.switch-label input:checked + .switch {
  background: rgba(143, 212, 181, 0.42);
}

.switch-label input:checked + .switch::after {
  background: var(--mint);
  transform: translateX(15px);
}

.switch-label input:focus-visible + .switch {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.range-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

input[type="range"] {
  width: 100%;
  min-width: 0;
  height: 30px;
  margin: 0;
  accent-color: var(--mint-strong);
  cursor: pointer;
}

.range-label output,
.master-heading output {
  min-width: 2.7rem;
  color: var(--mint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  text-align: right;
}

.master-control {
  margin-top: 1.3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.master-heading {
  align-items: baseline;
  margin-bottom: 0.25rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.master-control input {
  width: 100%;
}

.master-control .tiny-note {
  margin: 0.2rem 0 0;
}

.mixer-side {
  display: grid;
  gap: 1.15rem;
  min-width: 0;
}

.mixer-side .card-surface {
  padding: 1.25rem;
}

.preset-list {
  display: grid;
  gap: 0.45rem;
}

.preset-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 58px;
  padding: 0.55rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(5, 25, 31, 0.4);
  color: var(--muted);
  text-align: left;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.preset-button:hover,
.preset-button.is-selected {
  border-color: rgba(143, 212, 181, 0.36);
  background: rgba(34, 76, 70, 0.55);
  color: var(--ink);
}

.preset-button span:first-child {
  display: grid;
  gap: 0.05rem;
}

.preset-button strong {
  font-size: 0.84rem;
}

.preset-button small {
  color: var(--subtle);
  font-size: 0.66rem;
}

.preset-button > span:last-child {
  color: var(--mint);
  font-size: 1.1rem;
}

.card-symbol,
.timer-icon {
  color: var(--gold);
  font-size: 1.15rem;
}

.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.primary-button:active,
.secondary-button:active,
.text-button:active,
.preset-button:active {
  transform: translateY(1px);
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 0.7rem 1rem;
  background: var(--mint);
  color: var(--deep);
}

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

.secondary-button {
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line-strong);
  background: rgba(36, 79, 76, 0.35);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--mint-strong);
  background: rgba(49, 100, 88, 0.5);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.button-row > .secondary-button {
  flex: 1 1 120px;
}

.form-note {
  min-height: 1.2rem;
  margin: 0.65rem 0 0;
  line-height: 1.45;
}

.timer-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.55rem 0.65rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
}

select {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(5, 25, 31, 0.65);
  color: var(--ink);
}

.timer-form #start-timer {
  grid-column: 1 / -1;
  width: 100%;
}

.timer-form .text-button {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 44px;
  padding: 0.2rem 0;
  background: transparent;
  color: var(--subtle);
  font-size: 0.72rem;
}

.timer-form .text-button:not(:disabled):hover {
  color: var(--mint);
}

.timer-status {
  min-height: 1.35rem;
  margin: 0.8rem 0 0;
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
}

.settings-card > p {
  margin: -0.2rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.55;
}

.settings-actions {
  margin-top: 0;
}

.file-button {
  position: relative;
  display: inline-flex;
  overflow: hidden;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-button:focus-within {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.settings-actions .secondary-button {
  flex: 1 1 120px;
}

.settings-card #settings-error:not(:empty):not([data-state="success"]) {
  color: var(--warning) !important;
}

.settings-card #settings-error[data-state="success"] {
  color: var(--mint) !important;
}

.care-note {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-top: 1.15rem;
  padding: 1rem 1.2rem;
  border-color: rgba(216, 191, 136, 0.2);
  background: rgba(52, 54, 43, 0.25);
}

.care-mark {
  display: grid;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.8rem;
}

.care-note h2 {
  margin: 0 0 0.2rem;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
}

.care-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.5rem 0 2.8rem;
  color: var(--subtle);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 940px) {
  .mixer-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .settings-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 32px, 620px);
  }

  .site-header {
    min-height: 64px;
  }

  .header-note {
    display: none;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 2.2rem;
    padding-top: 3.2rem;
  }

  h1 {
    max-width: 10ch;
    font-size: clamp(3rem, 14vw, 4.6rem);
  }

  .scene-card {
    transform: none;
  }

  .signal-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .mixer-side {
    grid-template-columns: 1fr;
  }

  .settings-card {
    grid-column: auto;
  }
}

@media (max-width: 500px) {
  .page-shell {
    width: min(100% - 24px, 440px);
  }

  .intro {
    padding-top: 2.4rem;
  }

  .scene-card img {
    height: 260px;
  }

  .scene-card figcaption {
    right: 0.8rem;
    bottom: 0.7rem;
    left: 0.8rem;
    font-size: 0.66rem;
  }

  .scene-card figcaption span:last-child {
    display: none;
  }

  .status-heading-row,
  .section-heading-row {
    align-items: flex-start;
  }

  .status-pill {
    padding-inline: 0.55rem;
    font-size: 0.65rem;
  }

  .layer-card {
    grid-template-columns: 40px minmax(0, 1fr) 44px;
    gap: 0.55rem;
    padding: 0.7rem;
  }

  .range-label {
    grid-column: 1 / -1;
    padding-left: 0.05rem;
  }

  .range-label input {
    min-width: 0;
  }

  .mixer-main,
  .mixer-side .card-surface,
  .status-panel {
    padding: 1rem;
  }

  .site-footer {
    display: grid;
    padding-bottom: 2rem;
  }
}

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

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