:root {
  --bg: #0f1216;
  --panel: #171b21;
  --border: #2a2f38;
  --text: #e6e8eb;
  --muted: #8b93a1;
  --accent: #4da3ff;
  --up: #34c78f;
  --down: #ef5b5b;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0 24px 48px;
}

header {
  padding: 24px 0 8px;
}

h1 { margin: 0; font-size: 1.5rem; }
.sub { color: var(--muted); margin: 4px 0 0; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.8rem; color: var(--muted); }
input, select {
  background: #0d0f13;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.9rem;
}

button#run {
  background: var(--accent);
  border: none;
  color: #06131f;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 6px;
  cursor: pointer;
  height: 34px;
}
button#run:hover { filter: brightness(1.1); }
button#run:disabled { opacity: 0.5; cursor: wait; }

.presets button {
  background: #0d0f13;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  height: 34px;
  cursor: pointer;
}
.presets button:hover { border-color: var(--accent); }
.presets select { min-width: 160px; }
.presets input[type="text"] { min-width: 160px; }

.status { min-height: 1.2em; color: var(--muted); }
.status.error { color: var(--down); }

.warning {
  background: #2a2115;
  border: 1px solid #5c4a1f;
  color: #f2b94b;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

table#legs {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
table#legs th, table#legs td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table#legs th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
table#legs input[type="number"] { width: 90px; }

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

/* Symbol panel + chart, side by side, with a collapsible left panel. */
.workspace {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-top: 16px;
}

.symbol-panel {
  flex: 0 0 380px;
  min-width: 0; /* required for the flex-basis:0 collapse below to actually reach 0 */
  max-width: 380px;
  overflow: hidden;
  transition: flex-basis 0.22s ease, max-width 0.22s ease, opacity 0.18s ease;
  opacity: 1;
}
.symbol-panel table#legs { margin: 0; }

.symbol-panel.collapsed {
  flex-basis: 0;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
}

.panel-toggle {
  flex: 0 0 auto;
  align-self: stretch;
  width: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.panel-toggle:hover { color: var(--text); border-color: var(--accent); }

.chart-panel {
  flex: 1 1 auto;
  min-width: 0; /* let Plotly's container actually shrink/grow inside the flex row */
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chart {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-height: 520px;
}

.timeline {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
}
.timeline label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.timeline label span { color: var(--text); font-variant-numeric: tabular-nums; }
.timeline input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

@media (max-width: 900px) {
  .workspace { flex-direction: column; }
  .symbol-panel, .symbol-panel.collapsed {
    flex-basis: auto;
    max-width: none;
    opacity: 1;
    pointer-events: auto;
  }
  .panel-toggle { display: none; }
}
