:root {
  --bg: #100e0c;
  --sheet: #16130f;
  --ink: #efe7d8;
  --muted: #a39886;
  --dim: #6f675b;
  --line: #3a3228;
  --gold: #e2b657;
  --gold-dim: #8d6b32;
  --clay: #d07a4a;
  --open: #c4a46a;
  --eat: #7f97a6;
  --church: #b7a48a;
  --danger: #8c3d3d;
  --top-h: 48px;
  --freeze-h: 0px;
  --map-w: 86px;
  --status-h: 32px;
  --reader-w: 440px;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; }
a { color: var(--gold); }

.mast {
  padding: 12px 18px 10px;
  padding-right: calc(var(--map-w) + 16px);
}
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 8px 18px;
  padding-right: calc(var(--map-w) + 16px);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.brand { min-width: 0; }
.views { display: flex; gap: 4px; }
.top-actions { display: flex; gap: 14px; align-items: center; }
.jump { margin: 0; }
.legend {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  max-width: 980px;
}
.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
h1 {
  margin: 1px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.views button {
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 2px;
  color: var(--muted);
  cursor: pointer;
}
.views button[aria-selected="true"] {
  color: var(--ink);
  border-color: var(--gold);
  background: #2a2318;
}
.views button:hover { color: var(--ink); }
.charts { display: flex; gap: 4px; }
.charts[hidden] { display: none; }
.charts button {
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 2px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.charts button[aria-selected="true"] {
  color: var(--ink);
  border-color: var(--gold);
  background: #2a2318;
}
.charts button:hover { color: var(--ink); }
#jump {
  width: 128px;
  background: #1b1814;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 13px;
}
#jump:focus { outline: 1px solid var(--gold); border-color: var(--gold); }
.text-btn {
  cursor: pointer;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.text-btn:hover { color: var(--ink); }

.workspace { padding-right: var(--map-w); padding-bottom: var(--status-h); }
body.reader-open .workspace { padding-right: calc(var(--map-w) + var(--reader-w)); }

#stage { padding: 8px 18px 64px; }

.hint {
  margin: 14px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.section-title {
  margin: 28px 0 8px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #d9ccb6;
}
.section-title span { color: var(--dim); letter-spacing: 0.04em; text-transform: none; font-size: 13px; }

.band {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 8px;
  align-items: stretch;
}
.band-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}
.band .kicker {
  grid-column: 2;
  margin: 0 0 -2px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.grid {
  display: grid;
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}
.grid.upper { grid-template-columns: 124px repeat(3, minmax(190px, 1fr)); }
.grid.lower { grid-template-columns: 124px repeat(7, minmax(156px, 1fr)); }
body.chart-adjusted .grid.lower { grid-template-columns: 124px repeat(7, minmax(156px, 1fr)) 132px var(--map-w); }

.year {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
  text-align: right;
  padding: 8px 10px 8px 0;
  border-right: 1px solid var(--line);
  align-self: stretch;
}
.year b {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
}
.year span {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}
.freeze {
  position: sticky;
  top: var(--top-h);
  z-index: 5;
  grid-column: 1 / -1;
  display: grid;
  column-gap: 8px;
  background: var(--bg);
}
.grid.upper > .freeze { grid-template-columns: 124px repeat(3, minmax(190px, 1fr)); }
.grid.lower > .freeze { grid-template-columns: 124px repeat(7, minmax(156px, 1fr)); }
body.chart-adjusted .grid.lower > .freeze { grid-template-columns: 124px repeat(7, minmax(156px, 1fr)) 132px var(--map-w); }
body.chart-adjusted.reader-open .grid.lower,
body.chart-adjusted.reader-open .grid.lower > .freeze {
  grid-template-columns: 124px repeat(7, minmax(156px, 1fr)) 132px calc(var(--map-w) + var(--reader-w));
}
.rail {
  display: grid;
  grid-template-rows: subgrid;
  grid-template-columns: 1fr 1fr 1fr;
  column-gap: 4px;
  position: relative;
  z-index: 1;
  min-width: 0;
  background: var(--bg);
}
.rail .bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--gold-dim);
  padding: 6px 0 8px;
  min-width: 0;
}
.rail .y1260 { background: #2a2318; }
.rail .y1290 { background: #1e2a28; border-color: #3d5c58; }
.rail .y1335 { background: #2a221c; border-color: var(--clay); }
.rail b {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.1;
  white-space: nowrap;
  color: var(--gold);
}
.rail span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold);
  text-align: center;
}
.range-note {
  margin: 10px 0 0;
  max-width: 88ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.super {
  padding: 6px 4px 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.super.open { color: var(--open); }
.super.eat { color: var(--eat); }
.colhead {
  padding: 4px 4px 6px;
  border-bottom: 1px solid var(--line);
}
.colhead strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}
.colhead em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}
.colhead.open strong { color: #f0e2c4; }
.colhead.eat strong { color: #d5e2ea; }

.wash {
  position: relative;
  z-index: 0;
  border-radius: 2px;
}
.wash.long { background: rgba(140, 61, 61, 0.16); }
.wash.end { background: rgba(226, 182, 87, 0.08); }

.cell {
  position: relative;
  z-index: 1;
  text-align: left;
  background: #1c1915;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 9px 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
}
.cell.half-open { border-top: 3px solid var(--open); }
.cell.half-eat { border-top: 3px solid var(--eat); }
.cell.half-church { border-top: 3px solid var(--church); }
.cell:hover { border-color: #8a7040; }
.cell.is-kin { border-color: #6d5830; background: #221c14; }
.cell.is-on {
  border-color: var(--gold);
  background: #2c2418;
  box-shadow: 0 0 0 1px var(--gold);
}
.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.church-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.church-ref {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #f3efe6;
}
.church-ref i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
#reader .church-refs { margin: 0 0 10px; }
.cell .ref {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--gold);
}
.cell .ex {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.35;
}
.cell .when {
  margin-top: auto;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}
.cell.marker .ex { color: #d9d0c2; font-style: italic; }

#reader {
  position: fixed;
  top: var(--top-h);
  right: var(--map-w);
  bottom: var(--status-h);
  width: var(--reader-w);
  background: #14110e;
  border-left: 1px solid var(--line);
  z-index: 25;
  overflow: auto;
  padding: 18px 18px 32px;
}
#reader[hidden] { display: none; }
#reader .reader-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
#reader h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.3;
  margin: 8px 0;
}
#reader .when { color: var(--muted); margin: 0 0 14px; }
#reader .section-label { margin: 16px 0 6px; }
#reader .reading {
  margin: 4px 0 6px;
  padding: 10px 12px 4px;
  border-left: 3px solid var(--gold);
  background: #1a1612;
}
#reader .reading.open { border-left-color: var(--eat); }
#reader .reading.ahead { border-left-color: #d27a4a; }
#reader .reading p { margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: #efe6d6; }
#reader .reading .eyebrow { margin-bottom: 6px; }
#reader .gloss { font-size: 15px; line-height: 1.5; color: #ddd4c4; }
#reader .gloss p { margin: 0 0 10px; }
.tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.tag.open { color: var(--eat); }
.tag.ahead { color: #e0a07a; }
.scripture { margin: 8px 0 16px; }
.scripture h3 {
  margin: 14px 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
.scripture p { margin: 0 0 7px; font-family: var(--serif); font-size: 16.5px; line-height: 1.45; }
.scripture sup {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--gold);
  margin-right: 4px;
  letter-spacing: 0;
}
.note {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}
.siblings { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.siblings button, .nav-row button {
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 2px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}
.siblings button:hover, .nav-row button:hover { color: var(--ink); border-color: var(--gold); }
.nav-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; }
.cross { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.cross button { color: var(--gold); cursor: pointer; }

#minimap {
  position: fixed;
  top: var(--top-h);
  right: 0;
  bottom: var(--status-h);
  width: var(--map-w);
  background: #0c0b09;
  border-left: 1px solid var(--line);
  z-index: 28;
  display: flex;
  flex-direction: column;
  padding: 6px 8px 6px 0;
}
.map-cap {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 0 4px 18px;
}
#map-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.ch {
  flex: var(--n) 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.ch i {
  position: absolute;
  left: 2px;
  top: 0;
  font-style: normal;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  color: #5c554a;
  pointer-events: none;
}
.ln {
  flex: 1 1 0;
  min-height: 1px;
  margin-left: 18px;
  background: #2a261f;
}
.ln.kin { background: var(--gold-dim); }
.ln.also { background: var(--clay); }
.ln.lit { background: var(--gold); }
.ln.view { box-shadow: inset 2px 0 0 #f3ecdf; }

#status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--status-h);
  z-index: 32;
  background: #0c0b09;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: var(--status-h);
  padding: 0 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order { max-width: 1100px; }
.cell, .passage, .run, .chapter { scroll-margin-top: calc(var(--top-h) + var(--freeze-h, 0px) + 12px); }
.moment { margin: 28px 0; scroll-margin-top: calc(var(--top-h) + 12px); }
.moment header { display: flex; gap: 14px; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.moment header .yr {
  font-family: var(--mono);
  color: var(--gold);
  font-size: 13px;
  min-width: 108px;
}
.moment header h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; }
.moment .lead { color: var(--dim); font-size: 13px; margin: 6px 0 0; }
.sync {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.passage {
  border-top: 3px solid var(--line);
  padding-top: 8px;
  cursor: pointer;
  text-align: left;
  display: block;
  width: 100%;
}
.passage.half-open { border-top-color: var(--open); }
.passage.half-eat { border-top-color: var(--eat); }
.passage.half-church { border-top-color: var(--church); }
.passage.is-on { background: #241e16; }
.passage h3 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
.passage p { font-family: var(--serif); font-size: 16px; line-height: 1.45; margin: 0 0 7px; }
.passage sup { font-family: var(--mono); font-size: 10px; color: var(--gold); margin-right: 3px; }
.passage .marker-line { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0; }

.book { max-width: 680px; margin: 8px auto 0; }
.chapter { margin: 22px 0 8px; scroll-margin-top: calc(var(--top-h) + 8px); }
.chapter h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  margin: 0 0 8px;
  color: #d9ccb6;
}
.run { margin: 0 0 12px; scroll-margin-top: calc(var(--top-h) + 8px); }
.runhead {
  display: block;
  margin: 0 0 4px;
  padding: 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-align: left;
}
.runhead:hover, .run.is-on .runhead { color: var(--gold); }
.run.is-on { background: rgba(226, 182, 87, 0.06); }
.verse { margin: 0 0 6px; font-family: var(--serif); font-size: 17.5px; line-height: 1.45; }
.verse sup { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-right: 4px; }

dialog {
  width: min(640px, calc(100vw - 48px));
  background: #18150f;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
dialog article { padding: 20px 22px 16px; }
dialog h2 { font-family: var(--serif); font-weight: 500; margin: 4px 0 10px; }
dialog p, dialog li { font-size: 15px; line-height: 1.5; color: #e4dccb; }
dialog ul { padding-left: 18px; }
dialog li { margin: 4px 0; }
dialog form { margin-top: 8px; }

body.is-fullscreen .mast { display: none; }
body.is-fullscreen .top {
  position: fixed;
  top: 8px;
  right: calc(var(--map-w) + 14px);
  left: auto;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  z-index: 40;
}
body.is-fullscreen .views,
body.is-fullscreen .jump,
body.is-fullscreen #about-open { display: none; }
body.is-fullscreen #fullscreen {
  background: #1b1814;
  border: 1px solid var(--line);
  padding: 4px 8px;
}
body.is-fullscreen.reader-open .top { right: calc(var(--map-w) + var(--reader-w) + 14px); }

@media (max-width: 980px) {
  .top { flex-wrap: wrap; }
  .legend { margin-top: 6px; }
  :root { --reader-w: min(440px, 100vw - var(--map-w)); }
  body.reader-open .workspace { padding-right: var(--map-w); }
  body.chart-adjusted.reader-open .grid.lower,
  body.chart-adjusted.reader-open .grid.lower > .freeze {
    grid-template-columns: 124px repeat(7, minmax(156px, 1fr)) 132px var(--map-w);
  }
  #reader { left: 0; right: var(--map-w); width: auto; }
}

.wing-name {
  margin: 0;
  padding: 7px 18px;
  background: #1c1916;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.wing-name a { color: var(--gold); }
