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

:root {
  --bg: #0d0d0f;
  --surface: #111115;
  --surface2: #16161c;
  --border: rgba(255,255,255,0.07);
  --text: #d8d8e0;
  --text-muted: #555560;
  --corp: #e05a5a;
  --corp-dim: #7a1a1a;
  --open: #5ae0a0;
  --open-dim: #1a4a35;
  --ind: #5aaae0;
  --ind-dim: #1a2a4a;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 14px;
  flex-shrink: 0;
}

header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #fff;
}

header .tagline {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  flex: 1;
}

#tick-display {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Main layout ── */
main {
  display: flex;
  height: calc(100vh - 42px - 82px);
}

/* ── Canvas ── */
.canvas-area {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

#sim-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

/* ── Controls panel ── */
.controls-panel {
  width: 258px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 20px;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-section h3 {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

/* Presets */
.preset-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  margin-bottom: 4px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  border-radius: 2px;
}

.preset-btn:hover {
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.025);
}

.preset-btn.active {
  border-color: var(--open);
  background: rgba(90,224,160,0.06);
  color: var(--open);
}

/* Sliders */
.slider-row {
  margin-bottom: 13px;
}

.slider-row:last-child { margin-bottom: 0; }

.slider-row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.sl-label {
  font-size: 11px;
  color: var(--text);
}

.sl-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--open);
  min-width: 26px;
  text-align: right;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--open);
  cursor: pointer;
  transition: background 0.12s;
}

input[type=range]:hover::-webkit-slider-thumb {
  background: #80eebc;
}

/* Playback */
.playback-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.playback-btns button {
  padding: 7px 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.12s, background 0.12s;
}

.playback-btns button:hover {
  border-color: rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.03);
}

#btn-speed { grid-column: 1 / -1; }

/* Legend */
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.legend-item:last-child { margin-bottom: 0; }

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-corp { background: var(--corp-dim); border: 1.5px solid var(--corp); }
.dot-open { background: var(--open-dim); border: 1.5px solid var(--open); }
.dot-ind  { background: var(--ind-dim);  border: 1.5px solid var(--ind);  }

/* ── Stats footer ── */
.stats-bar {
  height: 82px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: stretch;
  padding: 0 20px;
  gap: 0;
  overflow: hidden;
}

.stat-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 22px 0 0;
  min-width: 110px;
  gap: 4px;
}

.stat-block + .stat-block {
  padding-left: 22px;
  border-left: 1px solid var(--border);
}

.stat-lbl {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-val {
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
}

.stat-bar {
  height: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 1px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 1px;
  transition: width 0.3s ease, background-color 0.5s ease;
}

/* Chart */
.chart-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 24px;
  padding-right: 4px;
  border-left: 1px solid var(--border);
  min-width: 0;
}

.chart-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 5px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--text-muted);
}

.chart-legend-line {
  width: 16px;
  height: 2px;
  border-radius: 1px;
}

#timeline-svg {
  width: 100%;
  height: 42px;
  display: block;
  overflow: visible;
}
