/* Statelog — museum quiet, git exactness, investigative hostility.
   Doctrine: docs/UI.md. Change tokens here, never inline. */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,300;0,400;0,500;0,600;1,400&family=IBM+Plex+Sans:wght@400;450;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper:      #f4f1ea;
  --surface:    #faf8f3;
  --surface-2:  #efebe1;
  --ink:        #1a1815;
  --ink-2:      #45403a;
  --ink-3:      #736c61;
  --ink-4:      #9a9287;
  --rule:       #dcd5c8;
  --rule-2:     #e8e2d6;

  --struck:     #7a3f2e;
  --struck-bg:  #f3e6e0;
  --inserted:   #2f5240;
  --inserted-bg:#e4ece5;

  --record:     #3f5468;
  --verified:   #41614c;
  --contested:  #856226;
  --community:  #5f5570;
  --analysis:   #5a5148;

  --serif: 'Spectral', 'Iowan Old Style', Georgia, serif;
  --sans:  'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --rail-l: 216px;
  --rail-r: 292px;
  --gap: 40px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

h1, h2, h3, .serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }

.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: -0.01em; }

.label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--ink-4);
}

/* ---- shell ------------------------------------------------------------ */

.masthead {
  display: flex; align-items: baseline; gap: 18px;
  padding: 0 28px; height: 52px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.masthead .wordmark {
  font-family: var(--serif); font-size: 17px; letter-spacing: 0.02em;
  align-self: center;
}
.masthead .wordmark span { color: var(--ink-4); }
.masthead .spacer { flex: 1; }
.masthead nav { display: flex; gap: 20px; align-self: center; font-size: 13px; color: var(--ink-2); }

.shell {
  display: grid;
  grid-template-columns: var(--rail-l) minmax(0, 1fr) var(--rail-r);
  gap: var(--gap);
  max-width: 1520px; margin: 0 auto; padding: 0 28px 96px;
  align-items: start;
}

.rail { position: sticky; top: 52px; padding-top: 28px; font-size: 13px; }
.rail .label { margin: 22px 0 8px; }
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail li a {
  display: block; padding: 3.5px 0; color: var(--ink-2);
}
.rail li a:hover { color: var(--ink); }
.rail li.on a { color: var(--ink); font-weight: 500; }
.rail li.on a::before {
  content: ''; display: inline-block; width: 3px; height: 3px;
  background: var(--ink); vertical-align: middle; margin-right: 8px;
  margin-left: -11px;
}

.center { padding-top: 28px; min-width: 0; }
.rail-r { padding-top: 28px; }

/* ---- panels ----------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.panel > h2 { font-size: 18px; margin: 0 0 14px; }
.panel-flush { padding: 0; }

.rail-r section { margin-bottom: 30px; }
.rail-r h3 { font-family: var(--sans); font-size: 10px; font-weight: 600;
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--ink-4);
  margin: 0 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--rule); }

dl.facts { margin: 0; font-size: 12.5px; }
dl.facts div { display: flex; justify-content: space-between; gap: 14px;
  padding: 5px 0; border-bottom: 1px solid var(--rule-2); }
dl.facts dt { color: var(--ink-3); white-space: nowrap; }
dl.facts dd { margin: 0; text-align: right; }

/* ---- epistemic status -------------------------------------------------- */

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap;
}
.status::before {
  content: ''; width: 7px; height: 7px; flex: none;
  border: 1.5px solid currentColor;
}
.status.record    { color: var(--record); }
.status.record::before { background: currentColor; }
.status.verified  { color: var(--verified); }
.status.verified::before { transform: rotate(45deg); background: currentColor; }
.status.contested { color: var(--contested); }
.status.contested::before { border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.status.community { color: var(--community); }
.status.community::before { border-radius: 50%; }
.status.analysis  { color: var(--analysis); }
.status.analysis::before { border-radius: 0; transform: rotate(45deg); }
.status.unknown   { color: var(--ink-4); }
.status.unknown::before { border-style: dotted; }

/* ---- the diff ---------------------------------------------------------- */

.change {
  border: 1px solid var(--rule);
  background: var(--surface);
  margin-bottom: 22px;
}
.change > header {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 11px 18px; border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
}
.change > header .path { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
.change > header .spacer { flex: 1; }
.change > header .range { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

.change-body { display: grid; grid-template-columns: minmax(0,1fr) 240px; }
.change-body > .text { padding: 6px 0 14px; border-right: 1px solid var(--rule-2); }
.change-body > .annot { padding: 16px 18px; font-size: 12px; background: #f7f4ed; }

.ctx, .del, .ins {
  display: grid; grid-template-columns: 26px minmax(0,1fr);
  padding: 7px 18px 7px 0;
  font-family: var(--serif); font-size: 15px; line-height: 1.62;
}
.ctx { color: var(--ink-3); }
.ctx::before { content: ''; }
.del { background: var(--struck-bg); border-left: 3px solid var(--struck); }
.ins { background: var(--inserted-bg); border-left: 3px solid var(--inserted); }
.del::before, .ins::before {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  text-align: center; padding-top: 1px; opacity: 0.75;
}
.del::before { content: '\2212'; color: var(--struck); }
.ins::before { content: '+';     color: var(--inserted); }

.linemark {
  grid-column: 2; font-family: var(--sans); font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.11em; text-transform: uppercase; margin-bottom: 3px;
}
.del .linemark { color: var(--struck); }
.ins .linemark { color: var(--inserted); }

.del del, .del .w { text-decoration: line-through;
  text-decoration-thickness: 1px; text-decoration-color: var(--struck);
  background: #ecd6cc; }
.ins ins, .ins .w { text-decoration: none; background: #cfe0d3;
  box-shadow: inset 0 -1px 0 var(--inserted); }

.annot .row { margin-bottom: 15px; }
.annot .row:last-child { margin-bottom: 0; }
.annot .label { display: block; margin-bottom: 3px; }
.annot .val { color: var(--ink-2); }
.annot .val .mono { display: block; color: var(--ink-3); margin-top: 2px; }

/* ---- timeline ---------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0 0 0 2px; }
.timeline li {
  display: grid; grid-template-columns: 92px 18px minmax(0,1fr);
  gap: 0 14px; padding-bottom: 20px; position: relative;
}
.timeline li::before {
  content: ''; position: absolute; left: 105px; top: 14px; bottom: -4px;
  width: 1px; background: var(--rule);
}
.timeline li:last-child::before { display: none; }
.timeline .when { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  text-align: right; padding-top: 3px; }
.timeline .dot { justify-self: center; width: 7px; height: 7px; margin-top: 8px;
  background: var(--paper); border: 1.5px solid var(--ink-3); z-index: 1; }
.timeline li.key .dot { background: var(--ink); border-color: var(--ink); }
.timeline .what { min-width: 0; }
.timeline .what strong { font-weight: 500; font-size: 13.5px; }
.timeline .what p { margin: 2px 0 0; color: var(--ink-3); font-size: 12.5px; }
.timeline .what .cite { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ---- provenance -------------------------------------------------------- */

details.prov { border-top: 1px solid var(--rule-2); }
details.prov > summary {
  cursor: pointer; list-style: none; padding: 9px 0;
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  font-weight: 600; color: var(--ink-4);
}
details.prov > summary::-webkit-details-marker { display: none; }
details.prov > summary::before { content: '+ '; font-family: var(--mono); }
details.prov[open] > summary::before { content: '\2212 '; }
details.prov table { width: 100%; border-collapse: collapse;
  font-family: var(--mono); font-size: 11px; margin-bottom: 12px; }
details.prov td { padding: 4px 10px 4px 0; vertical-align: top;
  border-bottom: 1px solid var(--rule-2); color: var(--ink-2); }
details.prov td:first-child { color: var(--ink-4); white-space: nowrap; width: 108px; }
details.prov td.hash { word-break: break-all; }

/* ---- meters ------------------------------------------------------------ */

.meter { margin-bottom: 9px; font-size: 12px; }
.meter .m-row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.meter .m-row span:last-child { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.meter .bar { height: 3px; background: var(--surface-2); }
.meter .bar i { display: block; height: 100%; background: var(--ink-3); }

/* ---- feed -------------------------------------------------------------- */

.feed { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--rule-2); display: flex; gap: 10px; }
.feed li:last-child { border-bottom: none; }
.feed .ago { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4);
  white-space: nowrap; padding-top: 2px; }
.feed .txt { color: var(--ink-2); }

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-block; padding: 7px 15px; border: 1px solid var(--ink);
  background: transparent; color: var(--ink); font-size: 12px; font-weight: 500;
  letter-spacing: 0.02em; cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn.wide { display: block; width: 100%; text-align: center; }
.btn.quiet { border-color: var(--rule); color: var(--ink-2); }
.btn.quiet:hover { border-color: var(--ink); }

.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--rule); margin-bottom: 26px; }
.tabs a { padding: 0 0 10px; font-size: 13px; color: var(--ink-3); margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom: 2px solid var(--ink); font-weight: 500; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  font-size: 11px; padding: 3px 8px; border: 1px solid var(--rule);
  color: var(--ink-2); background: var(--surface);
}
.tag .dir { font-family: var(--mono); font-weight: 600; margin-right: 4px; }
.tag.up .dir { color: var(--struck); }
.tag.down .dir { color: var(--inserted); }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 180px minmax(0,1fr); }
  .rail-r { grid-column: 2; position: static; }
  .change-body { grid-template-columns: minmax(0,1fr); }
  .change-body > .text { border-right: none; }
  .change-body > .annot { border-top: 1px solid var(--rule); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0,1fr); padding: 0 18px 64px; }
  .rail { position: static; }
}
