:root {
  color-scheme: dark;
  --bg: #071013;
  --panel: rgba(16, 27, 31, 0.78);
  --panel-strong: rgba(20, 37, 43, 0.9);
  --line: rgba(178, 220, 224, 0.22);
  --text: #eff8f8;
  --muted: #9fb8ba;
  --cyan: #2dd4bf;
  --green: #a3e635;
  --amber: #fbbf24;
  --violet: #a78bfa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(45, 212, 191, 0.18), transparent 26rem),
    linear-gradient(145deg, #071013 0%, #111b1e 48%, #0c1518 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  height: 100vh;
}

.stage {
  position: relative;
  min-width: 0;
  height: 100vh;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-overlay {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 12px;
  pointer-events: none;
}

.readout,
.metric-strip > div,
.process-band > div {
  border: 1px solid var(--line);
  background: rgba(9, 19, 22, 0.62);
  backdrop-filter: blur(18px);
}

.readout {
  padding: 14px 16px;
  min-height: 76px;
}

.readout span,
.metric-strip span,
.process-band span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.readout strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  line-height: 1;
}

.readout-accent strong {
  color: var(--green);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(24px);
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.32);
  overflow-y: auto;
  scrollbar-color: rgba(45, 212, 191, 0.45) rgba(255, 255, 255, 0.05);
}

.panel-header p {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.panel-header h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.04;
  letter-spacing: 0;
}

.metric-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-strip > div,
.process-band > div {
  padding: 13px 14px;
}

.metric-strip strong,
.process-band strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.controls {
  display: grid;
  gap: 17px;
}

.control {
  display: grid;
  gap: 8px;
}

.control span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #d8e7e8;
  font-size: 0.92rem;
}

.control output {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

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

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.button {
  min-height: 42px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.button:hover {
  border-color: rgba(45, 212, 191, 0.6);
  background: rgba(45, 212, 191, 0.1);
}

.button.primary {
  border-color: rgba(45, 212, 191, 0.75);
  background: rgba(45, 212, 191, 0.18);
  color: #eafffb;
}

.button.recording {
  border-color: rgba(251, 191, 36, 0.8);
  background: rgba(251, 191, 36, 0.18);
}

.flow-legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.flow-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.swatch {
  display: inline-block;
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.swatch-mud {
  color: #b98754;
  background: #b98754;
}

.swatch-liquid {
  color: #38d7cf;
  background: #38d7cf;
}

.swatch-solids {
  color: #5f3a22;
  background: #5f3a22;
}

.process-band {
  display: grid;
  gap: 10px;
  padding-bottom: 2px;
}

@media (max-height: 780px) and (min-width: 901px) {
  .control-panel {
    gap: 14px;
    padding: 20px;
  }

  .panel-header h1 {
    font-size: 1.75rem;
  }

  .controls {
    gap: 13px;
  }

  .readout {
    min-height: 68px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .stage {
    height: 56vh;
    min-height: 360px;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .stage-overlay {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .readout {
    padding: 10px 12px;
    min-height: 58px;
  }

  .readout strong {
    font-size: 1.05rem;
  }
}

@media (max-width: 520px) {
  .stage-overlay {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .readout {
    padding: 8px;
    min-height: 52px;
  }

  .readout span {
    font-size: 0.64rem;
  }

  .readout strong {
    font-size: 0.88rem;
  }
}
