:root {
  --bg: #0e1012;
  --panel: #16191d;
  --panel2: #1c2026;
  --border: #2a3038;
  --text: #e6e8ec;
  --muted: #9aa3b0;
  --accent: #e8a54b;
  --accent2: #5eead4;
  --danger: #f07178;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

a {
  color: var(--accent2);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  grid-template-rows: auto 1fr auto;
  gap: 0;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 16, 18, 0.92);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.brand .sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pill:hover {
  border-color: #4a5568;
}
.pill[aria-pressed="true"] {
  background: #2a2418;
  border-color: var(--accent);
  color: var(--accent);
}

.stage-wrap {
  position: relative;
  min-height: 420px;
  background: #121518;
  border-right: 1px solid var(--border);
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 480px;
  touch-action: none;
  cursor: grab;
}
#stage:active {
  cursor: grabbing;
}

.stage-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  font-size: 0.7rem;
  color: rgba(230, 232, 236, 0.55);
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  font-family: var(--mono);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 20px;
  background: var(--panel);
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}

.side h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.energy {
  margin: 2px 0 0;
  color: var(--accent);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.blurb,
.compare {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.compare {
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.stat .lbl {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}
.stat .val {
  font-family: var(--mono);
  font-size: 0.85rem;
}
.stat.wide {
  grid-column: 1 / -1;
}

.block-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 6px;
}

.scrub {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scrub-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
#travel-range {
  flex: 1;
  accent-color: var(--accent);
}
#scrub-readout {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent2);
  min-width: 110px;
  text-align: right;
}

#force-curve {
  width: 100%;
  height: 120px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}

.curve-note {
  font-size: 0.7rem;
  color: var(--muted);
  margin: 4px 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover {
  border-color: #556070;
}
.btn.primary {
  background: #2a2418;
  border-color: var(--accent);
  color: var(--accent);
}
.btn.ghost {
  background: transparent;
}

.scene-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.scene-row .lbl {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

details.assumptions {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  padding: 0 12px;
}
details.assumptions summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 0.82rem;
  font-weight: 600;
  list-style: none;
}
details.assumptions summary::-webkit-details-marker {
  display: none;
}
details.assumptions summary::before {
  content: "▸ ";
  color: var(--muted);
}
details.assumptions[open] summary::before {
  content: "▾ ";
}
.assumptions .body {
  padding: 0 0 12px;
  font-size: 0.78rem;
  color: var(--muted);
}
.assumptions .body ul {
  margin: 6px 0 0;
  padding-left: 1.1em;
}

.foot {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 0.72rem;
  color: var(--muted);
  background: #0a0c0e;
}
.foot strong {
  color: #c8ccd4;
  font-weight: 600;
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #222830;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
  }
  .stage-wrap {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 360px;
  }
  #stage {
    min-height: 360px;
  }
  .side {
    max-height: none;
  }
}
