:root {
  color-scheme: light;
  --bg: #f7f8f6;
  --ink: rgba(44, 48, 50, 0.88);
  --dim: rgba(44, 48, 50, 0.42);
  --faint: rgba(44, 48, 50, 0.11);
  --line: rgba(68, 82, 88, 0.58);
  --hot: rgba(16, 18, 20, 0.9);
  --range: rgba(44, 48, 50, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  font-synthesis: none;
}

button,
input,
select,
textarea {
  font: inherit;
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
}

button {
  font-variant-emoji: text;
}

.instrument {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  touch-action: none;
  user-select: none;
  background: var(--bg);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.topbar {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

h1 {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink);
}

p {
  margin: 7px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--dim);
}

button {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--faint);
  border-radius: 8px;
  background: rgba(247, 248, 246, 0.74);
  color: var(--ink);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

button:active,
button.active {
  border-color: rgba(44, 48, 50, 0.58);
  color: var(--hot);
  box-shadow: 0 0 18px rgba(44, 48, 50, 0.08);
}

.primary {
  padding: 0 15px;
  text-transform: uppercase;
  color: #031012;
  background: rgba(44, 48, 50, 0.14);
  border-color: rgba(44, 48, 50, 0.24);
}

.tools {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  top: calc(max(14px, env(safe-area-inset-top)) + 66px);
  z-index: 2;
  display: grid;
  grid-template-columns: 42px;
  gap: 8px;
}

.tool {
  padding: 0;
  color: var(--dim);
}

.planet-panel {
  width: min(300px, 48vw);
  max-height: min(58vh, 430px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  pointer-events: auto;
}

.planet-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(44, 48, 50, 0.32);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}

.planet-panel-head button {
  min-width: 14px;
  min-height: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(44, 48, 50, 0.28);
  font-size: 13px;
  line-height: 14px;
  text-transform: uppercase;
  box-shadow: none;
}

.planet-panel.collapsed {
  width: auto;
  grid-template-rows: auto;
}

.planet-panel.collapsed .planet-list {
  display: none;
}

.planet-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: rgba(44, 48, 50, 0.055) transparent;
  scrollbar-width: thin;
}

.planet-list::-webkit-scrollbar {
  width: 3px;
}

.planet-list::-webkit-scrollbar-track {
  background: transparent;
}

.planet-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(44, 48, 50, 0.045);
}

.planet-list::-webkit-scrollbar-thumb:hover {
  background: rgba(44, 48, 50, 0.08);
}

.planet-empty,
.planet-row {
  border: 1px solid rgba(44, 48, 50, 0.1);
  border-radius: 8px;
  background: rgba(247, 248, 246, 0.62);
}

.planet-empty {
  padding: 10px;
  color: rgba(44, 48, 50, 0.32);
  font-size: 11px;
}

.planet-row {
  display: grid;
  gap: 8px;
  padding: 9px;
  --planet-color: rgba(217, 187, 86, 0.82);
}

.planet-row.selected {
  border-color: rgba(44, 48, 50, 0.3);
}

.planet-row.muted {
  opacity: 0.48;
}

.planet-main {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
}

.planet-name {
  min-width: 0;
  overflow: hidden;
  color: rgba(44, 48, 50, 0.42);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planet-row button {
  min-width: 30px;
  min-height: 30px;
  padding: 0 7px;
  color: rgba(44, 48, 50, 0.5);
  background: rgba(247, 248, 246, 0.38);
  border-color: rgba(44, 48, 50, 0.1);
}

.planet-param {
  display: grid;
  grid-template-columns: 28px 1fr 34px;
  gap: 7px;
  align-items: center;
  color: rgba(44, 48, 50, 0.34);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}

.planet-param output {
  text-align: right;
  color: rgba(44, 48, 50, 0.34);
}

.waveform {
  width: 100%;
  height: 28px;
  display: block;
  border: 1px solid rgba(44, 48, 50, 0.07);
  border-radius: 6px;
  background: rgba(247, 248, 246, 0.42);
}

.waveform polygon {
  fill: rgba(44, 48, 50, 0.18);
}

.waveform .slice-range {
  fill: rgba(217, 187, 86, 0.12);
}

.waveform line {
  stroke: rgba(44, 48, 50, 0.42);
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
}

.waveform .slice-in {
  stroke: rgba(44, 48, 50, 0.28);
}

.waveform .slice-out {
  stroke: rgba(44, 48, 50, 0.5);
}

.waveform.empty {
  height: 10px;
  border-style: dashed;
  opacity: 0.42;
}

.color-param input[type="range"] {
  opacity: 0.72;
}

.color-param input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9bb56 0%, #f4e7b8 26%, #d7e3db 52%, #eecbd0 76%, #dab156 100%);
}

.color-param input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9bb56 0%, #f4e7b8 26%, #d7e3db 52%, #eecbd0 76%, #dab156 100%);
}

.color-param input[type="range"]::-webkit-slider-thumb {
  width: 8px;
  height: 8px;
  margin-top: -2.5px;
  background: var(--planet-color);
  box-shadow: 0 0 0 1px rgba(44, 48, 50, 0.18);
}

.color-param input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 8px;
  background: var(--planet-color);
  box-shadow: 0 0 0 1px rgba(44, 48, 50, 0.18);
}

.color-param output {
  width: 11px;
  height: 11px;
  justify-self: end;
  border-radius: 50%;
  background: var(--planet-color);
  box-shadow: 0 0 0 1px rgba(44, 48, 50, 0.08);
}

.controls {
  position: absolute;
  z-index: 2;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  pointer-events: none;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: rgba(44, 48, 50, 0.32);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: auto;
}

input[type="range"] {
  width: 100%;
  height: 12px;
  accent-color: var(--range);
  opacity: 0.42;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: rgba(44, 48, 50, 0.2);
}

input[type="range"]::-webkit-slider-thumb {
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border: 0;
  border-radius: 50%;
  background: rgba(44, 48, 50, 0.34);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: rgba(44, 48, 50, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 7px;
  height: 7px;
  border: 0;
  border-radius: 50%;
  background: rgba(44, 48, 50, 0.34);
}

.actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.actions button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 11px;
  color: rgba(44, 48, 50, 0.36);
  border-color: rgba(44, 48, 50, 0.1);
  background: rgba(247, 248, 246, 0.42);
  text-transform: uppercase;
}

.actions button.recording {
  color: rgba(16, 18, 20, 0.86);
  border-color: rgba(44, 48, 50, 0.28);
  background: rgba(44, 48, 50, 0.08);
}

.actions button.ready {
  color: rgba(16, 18, 20, 0.72);
  border-color: rgba(44, 48, 50, 0.2);
}

.hidden-file {
  position: fixed;
  left: -100vw;
  top: -100vh;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 720px) {
  .planet-panel {
    width: min(230px, 52vw);
    max-height: min(58vh, 360px);
  }

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

  .actions {
    justify-content: space-between;
  }

  .actions button {
    flex: 1;
  }

}
