:root {
  --bg: #f6f5ef;
  --panel: rgba(246, 245, 239, .96);
  --ink: #111;
  --muted: #555;
  --line: #111;
  --chip: #ecebe4;
  --trace: #111;
  --trace-soft: rgba(17, 17, 17, .16);
  --font: "SF Mono", "IBM Plex Mono", "Roboto Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.45 var(--font);
}

main {
  min-height: 100%;
}

#waveform,
#sphere {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 50% 52%, rgba(17, 17, 17, .055), transparent 32%),
    var(--bg);
}

#waveform {
  display: block;
}

#sphere {
  display: none;
}

.topbar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: start;
  pointer-events: none;
}

.brand,
.controls,
.readout {
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
}

.brand {
  max-width: 640px;
  padding: 10px 12px;
}

h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0;
}

.owner-label {
  display: inline-block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  text-decoration: underline;
}

.owner-label:hover,
.owner-label:focus-visible {
  color: var(--muted);
  text-decoration: underline;
}

.app-switcher {
  position: relative;
  display: inline-block;
  padding-right: 18px;
  cursor: pointer;
}

.app-switcher select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
}

.app-switcher::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--ink);
  transform: translateY(-35%);
  pointer-events: none;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: end;
  flex-wrap: wrap;
  padding: 8px;
}

button,
input,
select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

button {
  min-width: 82px;
  padding: 0 10px;
  cursor: pointer;
  font-weight: 400;
  text-transform: uppercase;
}

button[aria-pressed="true"],
button.active {
  background: var(--chip);
}

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

.field {
  display: grid;
  grid-template-columns: auto 138px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

input[type="range"] {
  width: 138px;
  padding: 0;
  accent-color: var(--ink);
}

select {
  width: 122px;
  padding: 0 28px 0 8px;
  text-transform: uppercase;
}

.view-field {
  grid-template-columns: auto 122px;
}

.toggle {
  height: 34px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle i {
  position: relative;
  width: 36px;
  height: 16px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-style: normal;
}

.toggle i::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--ink);
  transition: transform .12s ease;
}

.toggle:has(input:checked) {
  background: var(--chip);
}

.toggle input:checked + i::before {
  transform: translateX(20px);
}

.toggle:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.readout {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.readout > div {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.readout .layer-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-height: 48px;
  padding-right: 12px;
}

.readout > div:last-child {
  border-right: 0;
}

.readout span,
.readout b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  letter-spacing: 0;
}

.readout span {
  color: var(--muted);
  font-size: 12px;
}

.readout b {
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
}

.layer-control.disabled .layer-frequency,
.layer-control.disabled b {
  opacity: .42;
}

.layer-frequency {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  width: 100%;
  max-width: 100%;
  align-items: baseline;
  justify-content: flex-start;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.layer-frequency input {
  appearance: auto;
  -webkit-appearance: auto;
  width: 7.5ch;
  height: auto;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  color: var(--muted);
  caret-color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
  opacity: 1;
  text-align: left;
}

.layer-frequency input::-webkit-inner-spin-button,
.layer-frequency input::-webkit-outer-spin-button {
  opacity: 1;
  display: block;
  -webkit-appearance: inner-spin-button;
}

.layer-frequency input:focus-visible {
  outline: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.layer-frequency em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
  text-transform: uppercase;
}

.layer-control b {
  grid-column: 1;
  grid-row: 2;
}

.layer-switch {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
  align-self: center;
  width: 40px;
  height: 18px;
  cursor: pointer;
}

.layer-switch input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.layer-switch i {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  background: var(--chip);
  font-style: normal;
}

.layer-switch i::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--ink);
  transition: transform .12s ease;
}

.layer-switch input:checked + i::before {
  transform: translateX(22px);
}

.layer-switch:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.site-motto {
  position: fixed;
  left: 12px;
  bottom: 80px;
  z-index: 6;
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font: 12px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: 0;
}

.site-motto a {
  color: inherit;
  text-decoration: none;
}

.site-motto a:hover {
  text-decoration: underline;
}

@media (max-width: 820px) {
  .topbar {
    top: 8px;
    left: 8px;
    right: 8px;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .brand {
    padding: 8px 10px;
  }

  h1 {
    font-size: 13px;
  }

  .controls {
    justify-content: start;
    gap: 6px;
    padding: 6px;
  }

  button,
  input[type="range"],
  select {
    height: 30px;
    font-size: 12px;
  }

  button {
    min-width: 74px;
    padding: 0 8px;
  }

  .toggle {
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }

  .field {
    grid-template-columns: auto minmax(120px, 1fr);
    flex: 1 1 220px;
  }

  input[type="range"] {
    width: 100%;
  }

  .readout {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-motto {
    left: 8px;
    bottom: 177px;
    font-size: 11px;
  }

  .readout > div {
    padding: 8px 10px;
    border-bottom: 0;
  }

  .readout .layer-control {
    min-height: 44px;
    padding-right: 10px;
  }

  .readout > div:nth-child(2n) {
    border-right: 0;
  }

  .readout > div:nth-last-child(-n+2) {
    border-bottom: 0;
  }
}
