:root {
  --panel-w: 360px;
  --lights-w: 208px;
  --bg: #05070d;
  --panel-bg: #0b1018;
  --panel-border: #1b2433;
  --text: #cdd6e4;
  --text-dim: #6b7689;
  --accent: #5b8cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ---- Left "Lights" panel ---- */
#lights-panel {
  flex: 0 0 var(--lights-w);
  width: var(--lights-w);
  height: 100%;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#lights-panel header {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--panel-border);
}

#lights-panel h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.lights-hint {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
}

#lights-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}

.light-sep {
  width: 100%;
  height: 0;
  border: none;
  border-top: 1px solid var(--panel-border);
  margin: 10px 0;
}

.light-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.light-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.light-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.light-color {
  width: 26px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  background: none;
  cursor: pointer;
}

/* Each param stacks vertically: a label/value line, then a full-width slider. */
.param {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.param-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.param-top label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.param-top .val {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.param input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 0;
  accent-color: #8aa6ff;
}

/* ---- 3D stage ---- */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

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

#phase-hud {
  position: absolute;
  top: 20px;
  left: 24px;
  max-width: 340px;
  padding: 14px 18px;
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid rgba(91, 140, 255, 0.18);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

#phase-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

#phase-desc {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}

#phase-controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

#phase-controls button {
  background: rgba(91, 140, 255, 0.12);
  border: 1px solid rgba(91, 140, 255, 0.3);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#phase-controls button:hover {
  background: rgba(91, 140, 255, 0.24);
}

#phase-controls button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#hint {
  position: absolute;
  bottom: 16px;
  left: 24px;
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
}

/* ---- Bottom progress bars (per-phase goal meters) ---- */
.bottom-progress {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  width: min(620px, 70%);
  padding: 12px 16px 13px;
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid rgba(91, 140, 255, 0.18);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.bottom-progress.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.bp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.bp-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.bp-pct {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.bp-track {
  height: 10px;
  border-radius: 6px;
  background: #11161f;
  overflow: hidden;
}

.bp-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background-size: 620px 100%;
  transition: width 0.2s linear;
}

/* Daylight: night -> deep blue -> violet -> orange -> daylight blue */
.bp-fill--day {
  background-image: linear-gradient(
    90deg,
    #0c2150,
    #5b3b6e,
    #ff7a3c,
    #ffd0a0,
    #6fa8ff
  );
}

/* Storm calming: stormy dark -> settling blue -> clear calm */
.bp-fill--calm {
  background-image: linear-gradient(90deg, #1a2336, #2b4a8f, #5b8cff, #8fd0ff);
}

.bp-hint {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
}

/* ---- Right panel ---- */
#panel {
  flex: 0 0 var(--panel-w);
  width: var(--panel-w);
  height: 100%;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#panel header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--panel-border);
}

#panel h1 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#sync-meter {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label value"
    "bar bar";
  gap: 6px 10px;
  align-items: center;
}

#sync-label {
  grid-area: label;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#sync-value {
  grid-area: value;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#sync-bar {
  grid-area: bar;
  height: 8px;
  border-radius: 5px;
  background: #161d28;
  overflow: hidden;
}

#sync-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, #2b4a8f, #5b8cff, #ffd27a);
  transition: width 0.12s linear;
}

#sync-readout {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}

#sync-ring {
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
}

#sync-explain {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-dim);
}

#sync-explain em {
  color: var(--text);
  font-style: normal;
  font-weight: 600;
}

#storm-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--panel-border);
}

#storm-section h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#storm-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 10px;
  align-items: center;
}

#storm-controls label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#storm-controls input[type="range"] {
  width: 100%;
  accent-color: #8aa6ff;
}

#storm-controls .val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 40px;
  text-align: right;
}

#lanes {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lane {
  background: #0e131c;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
}

/* An excluded person is only dropped from the synchrony calculation - their
   cloud bulb keeps breathing, so keep their breath waveform (the "light") fully
   lit and just mute the header to mark them as not counted. */
.lane.excluded .lane-head {
  opacity: 0.5;
}

.lane.excluded .lane-name::after {
  content: " - not counted";
  font-weight: 400;
  color: var(--text-dim);
  font-size: 11px;
}

.lane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.lane-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.lane-name {
  font-size: 13px;
  font-weight: 600;
}

.lane-enable {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lane-enable input {
  accent-color: var(--accent);
}

.lane-wave {
  width: 100%;
  height: 56px;
  border-radius: 6px;
  background: #070a10;
  cursor: ew-resize;
  display: block;
  touch-action: none;
}

.lane-sliders {
  margin-top: 9px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 10px;
  align-items: center;
}

.lane-sliders label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.lane-sliders .val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 48px;
  text-align: right;
}

#panel footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--panel-border);
}

#panel footer p {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
}
