:root {
  --ink: #13110e;
  --panel: #1a1814;
  --raise: #221f1a;
  --line: #2e2a23;
  --paper: #e9e0cc;
  --muted: #a39780;
  --faint: #6a6152;
  --red: #e0583a;
  --arc1: #6fb0a3;
  --arc2: #d6a452;
  --green: #7fb069;
  --both: #e9e0cc;
  --scene: #8497b0;
  --shot: #7d7466;
  --social: #c97b8e;
  --prose: "Spectral", Georgia, serif;
  --mono: "Martian Mono", ui-monospace, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
* { scrollbar-color: var(--line) transparent; }
body {
  display: grid;
  grid-template-columns: 212px 1fr;
  background: var(--ink);
  color: var(--paper);
  font: 400 16px/1.55 var(--prose);
  overflow: hidden;
}
body::after { /* paper grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .05; z-index: 50;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--red); }
button, input, select {
  font: 400 12px var(--mono); color: var(--paper); background: var(--raise);
  border: 1px solid var(--line); border-radius: 2px; padding: 5px 8px;
}
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }
input:focus, select:focus { outline: none; border-color: var(--red); }
input[type=range] { padding: 0; accent-color: var(--red); }
h1, h2, h3 { font-weight: 500; margin: 0; }

/* rail */
.rail {
  border-right: 1px solid var(--line); padding: 22px 16px; display: flex;
  flex-direction: column; gap: 22px; background: var(--panel); min-height: 0;
}
.mark { font: 700 30px/1 var(--prose); letter-spacing: .06em; }
.mark:hover { color: var(--paper); }
.omni { position: relative; }
.omni input { width: 100%; }
.omni-results {
  position: absolute; left: 0; top: calc(100% + 4px); width: 380px; z-index: 40;
  background: var(--raise); border: 1px solid var(--line); max-height: 70vh; overflow: auto;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.omni-results h4 { margin: 0; padding: 8px 10px 4px; font: 400 10px var(--mono);
  text-transform: uppercase; letter-spacing: .1em; color: var(--faint); }
.omni-results a { display: block; padding: 5px 10px; font-size: 14px; }
.omni-results a small { color: var(--muted); font: 300 11px var(--mono); }
.omni-results a.sel, .omni-results a:hover { background: var(--line); color: var(--paper); }
nav { display: flex; flex-direction: column; }
nav a { padding: 7px 0; font-size: 17px; display: flex; justify-content: space-between;
  align-items: baseline; border-bottom: 1px solid var(--line); }
nav a b { font: 300 10px var(--mono); color: var(--faint); }
nav a.active { color: var(--red); }
.rail-foot { margin-top: auto; font: 300 10px/1.8 var(--mono); color: var(--faint); }

/* main */
main { overflow: auto; min-width: 0; position: relative; }
.page { padding: 34px 44px 80px; max-width: 1400px; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.eyebrow { font: 400 11px var(--mono); color: var(--muted); letter-spacing: .08em;
  text-transform: uppercase; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.eyebrow a { color: var(--paper); }
.title { font-size: 40px; line-height: 1.1; margin: 8px 0 18px; }
.title small { font-size: 18px; color: var(--muted); margin-left: 10px; }
.lede { font-size: 19px; color: var(--muted); max-width: 70ch; margin: 0 0 20px; font-style: italic; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.page:has(> .split) { max-width: none; }
.split { display: grid; grid-template-columns: minmax(0, 55vw) minmax(340px, 1fr); gap: 48px; align-items: start; }
.split > :first-child .prose { font-size: 19px; }
/* The panel floats in the middle of the space right of the text, and scrolls on its own. */
.side {
  position: sticky; top: 24px; justify-self: center; width: 100%; max-width: 460px;
  max-height: calc(100vh - 48px); overflow: auto;
  display: flex; flex-direction: column; gap: 26px;
  padding: 22px 24px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
}
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; justify-self: stretch; max-width: none; }
}
.section h3 { font: 400 10px var(--mono); text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
  display: flex; justify-content: space-between; }
.section h3 span { color: var(--faint); }

/* prose */
.prose { font-size: 18px; line-height: 1.75; white-space: pre-wrap; hyphens: auto; }
.prose .n { border-bottom: 1px solid color-mix(in srgb, var(--arc2) 55%, transparent); cursor: pointer; }
.prose .n:hover { color: var(--arc2); }
.prose .tm { background: color-mix(in srgb, var(--arc1) 16%, transparent); }
.prose .focus { background: var(--red); color: var(--ink); }
.cut {
  display: flex; align-items: center; gap: 10px; margin: 14px 0; white-space: normal;
  font: 400 10px var(--mono); color: var(--red); letter-spacing: .1em; text-transform: uppercase;
}
.cut::before, .cut::after { content: ""; flex: 1; border-top: 1px dashed var(--red); opacity: .5; }
.piece { position: relative; padding: 0 0 26px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.piece-head { font: 400 11px var(--mono); color: var(--muted); display: flex; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.piece-head a { color: var(--paper); }
.cont { color: var(--red); }

/* lists */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { font: 400 11px/2 var(--mono); color: var(--faint); }
.kv dd { margin: 0; }
.rows { display: flex; flex-direction: column; }
.row { display: grid; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.row:hover { background: color-mix(in srgb, var(--raise) 70%, transparent); }
.row .id { font: 400 12px var(--mono); color: var(--muted); }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font: 400 11px var(--mono); padding: 2px 7px; border: 1px solid var(--line); border-radius: 2px; white-space: nowrap; }
a.chip:hover { border-color: var(--red); }
.chip.present { border-color: color-mix(in srgb, var(--paper) 40%, transparent); }
.chip.mentioned { color: var(--muted); border-style: dashed; }
.tag { font: 400 10px var(--mono); padding: 1px 5px; border-radius: 2px; background: var(--raise); color: var(--muted); }
.tag.a1 { color: var(--arc1); } .tag.a2 { color: var(--arc2); }
.tag.warn { color: var(--red); }
.list { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.list li { padding: 5px 0; border-bottom: 1px dotted var(--line); }
.card-link { display: block; padding: 7px 0; border-bottom: 1px dotted var(--line); font-size: 14px; }
.card-link b { font: 400 11px var(--mono); color: var(--muted); margin-right: 8px; }
.empty { color: var(--faint); font-style: italic; font-size: 14px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px;
  padding: 10px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--ink); z-index: 5; }
.toolbar label { font: 400 11px var(--mono); color: var(--muted); display: flex; gap: 6px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 220px; }
.count { font: 400 11px var(--mono); color: var(--faint); margin-left: auto; }
mark { background: color-mix(in srgb, var(--red) 35%, transparent); color: var(--paper); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: 10px 0 22px; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; font-size: 12px;
  padding: 10px 16px; color: var(--muted); border-radius: 0; }
.tabs button.on { color: var(--paper); border-bottom-color: var(--red); }

.stats { display: flex; gap: 30px; flex-wrap: wrap; margin: 4px 0 8px; }
.stat b { display: block; font: 500 26px var(--prose); }
.stat span { font: 400 10px var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }

/* facts */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 26px 40px; }
.fact { padding: 5px 0; border-bottom: 1px dotted var(--line); font-size: 15px; }
.fact .meta { font: 300 10px var(--mono); color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.fact q { color: var(--muted); font-style: italic; font-size: 13px; }
.fact.state { opacity: .6; }

/* chronology bars */
.chron .row { grid-template-columns: 70px minmax(0, 1fr) 300px; }
.bar-track { position: relative; height: 14px; }
.bar-track .bar { position: absolute; top: 3px; height: 8px; min-width: 3px; border-radius: 1px; }
.bar-track .axis-line { position: absolute; top: 7px; left: 0; right: 0; border-top: 1px solid var(--line); }
.axis { position: relative; height: 18px; font: 300 10px var(--mono); color: var(--faint); }
.axis span { position: absolute; transform: translateX(-50%); }

/* graph */
.graph-wrap { position: absolute; inset: 0; }
.graph-wrap canvas { display: block; }
.panel {
  position: absolute; z-index: 5; background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line); padding: 14px; backdrop-filter: blur(4px);
  display: flex; flex-direction: column; gap: 10px; font: 400 11px var(--mono);
}
.panel label { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--muted); }
.panel .seg { display: flex; }
.panel .seg button { flex: 1; border-radius: 0; }
.controls { top: 14px; right: 14px; width: 290px; }
.controls input[type=range] { width: 130px; }
.legend { bottom: 14px; left: 14px; gap: 4px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 8px; }
.legend i.dot { width: 9px; height: 9px; border: none; border-radius: 50%; }
.legend i.sq { width: 8px; height: 8px; border: none; }
.inspector { top: 14px; left: 14px; width: 340px; font: 400 14px var(--prose); max-height: calc(100% - 28px); overflow: auto; }
.inspector h2 { font-size: 22px; }
.inspector .actions { display: flex; gap: 6px; }
.graph-title { position: absolute; bottom: 14px; right: 14px; z-index: 5; font: 300 10px var(--mono); color: var(--faint); text-align: right; }

/* timeline */
.tl-scroll { overflow-x: auto; border: 1px solid var(--line); background: var(--panel); position: relative; }
.tl-scroll svg { display: block; }
.tl-scroll text { font: 300 10px var(--mono); fill: var(--faint); }
.tl-scroll .life text { fill: var(--muted); }
.tl-scroll .ev text { fill: var(--red); }
.tl-scroll rect.sc { cursor: pointer; }
.tl-scroll rect.sc:hover { stroke: var(--paper); stroke-width: 1; }
.tl-list .row { grid-template-columns: 110px 70px minmax(0, 1fr) 240px; }

.tip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 380px; padding: 9px 11px;
  background: var(--raise); border: 1px solid var(--line); font-size: 14px; line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0,0,0,.5);
}
.tip b { font: 400 11px var(--mono); color: var(--muted); display: block; margin-bottom: 3px; }

.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 30px; margin-top: 30px; }
.more { margin: 20px 0; }
