:root {
  color-scheme: light;
  --shell: #c8ccd2;
  --panel: #e8eaed;
  --panel-2: #f4f5f7;
  --line: #8e949e;
  --ink: #16181c;
  --muted: #3e4450;
  --accent: #0c3d6e;
  --stage: #121418;
  --chip: #d5d8de;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--shell);
  color: var(--ink);
}

button, select, input { font: inherit; color: inherit; }

button, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  height: 22px;
  padding: 0 6px;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }

#app {
  min-width: 1180px;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 236px;
  grid-template-columns: 236px minmax(0, 1fr) 292px;
}

#toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  row-gap: 2px;
  padding: 4px 6px;
  background: #d5d8de;
  border-bottom: 1px solid var(--line);
}

#toolbar label { display: flex; align-items: center; gap: 4px; }

.brand { font-weight: 650; letter-spacing: 0.01em; }
.muted, .note { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

#replay-banner {
  color: var(--accent);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transport { display: flex; align-items: center; gap: 3px; }
#time-slider { width: 120px; }

#left, #inspector {
  background: var(--panel);
  overflow: auto;
  padding: 6px 8px 10px;
}

#left { border-right: 1px solid var(--line); }
#inspector { border-left: 1px solid var(--line); }

h2 {
  margin: 8px 0 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

section label, #left label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0;
}

.facts, .flags, .note { margin: 0 0 6px; line-height: 1.35; }
#left .toggles label { flex-direction: row; align-items: center; gap: 6px; margin: 2px 0; }

#stage {
  position: relative;
  background: var(--stage);
  min-width: 0;
  min-height: 0;
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#stage-status, #legend {
  position: absolute;
  z-index: 2;
  color: #e7e9ee;
  font-size: 11px;
  line-height: 1.35;
  pointer-events: none;
  text-shadow: 0 1px 1px #000;
}

#stage-status { left: 8px; top: 6px; display: flex; flex-direction: column; gap: 1px; }
#legend { right: 8px; top: 6px; text-align: right; }
#stage-error { position: absolute; inset: 40px 16px auto; color: #ffb4a8; }

#inspector dl { margin: 0; }
#inspector dt { margin-top: 6px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
#inspector dd { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

#plots {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 24px minmax(0, 1fr);
  background: var(--panel-2);
  border-top: 1px solid var(--line);
  min-height: 0;
}

#plot-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  border-bottom: 1px solid var(--line);
}

#plot-readout { flex: 1; overflow: hidden; text-overflow: ellipsis; }

#plot-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 0;
}

.plot-card { min-width: 0; min-height: 0; border-right: 1px solid var(--line); position: relative; }
.plot-card:last-child { border-right: 0; }
.plot-card canvas { width: 100%; height: 100%; display: block; }

.chip {
  display: inline-block;
  margin: 0 3px 3px 0;
  padding: 0 4px;
  background: var(--chip);
  border: 1px solid var(--line);
  font-size: 10px;
}

#provenance-list { max-height: 140px; overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 10px; }
#provenance-list div { padding: 1px 0; border-bottom: 1px solid #d5d8de; }

.swatch { display: inline-block; width: 8px; height: 8px; margin-right: 4px; vertical-align: middle; }

#study-plot { width: 100%; height: 96px; background: #fff; border: 1px solid var(--line); display: block; margin: 0 0 6px; }
#study-variants { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
#study-variants button { height: auto; white-space: normal; text-align: left; padding: 3px 6px; }
