:root {
  --bg:         #12100e;
  --ink:        #e8dcc8;
  --ink-bright: #f0e8d4;
  --ink-dim:    rgba(232,220,200,0.55);
  --ink-faint:  rgba(232,220,200,0.10);
  --gold:       #c8a96e;
  --gold-dim:   rgba(200,169,110,0.55);
  --gold-tint:  rgba(200,169,110,0.10);
  --red:        #e0705a;
  --red-dim:    rgba(224,112,90,0.55);
  --red-tint:   rgba(224,112,90,0.10);
  --blue:       #5aabcf;
  --blue-dim:   rgba(90,171,207,0.55);
  --blue-tint:  rgba(90,171,207,0.10);
  --green:      #7aab78;
  --green-dim:  rgba(122,171,120,0.55);
  --green-tint: rgba(122,171,120,0.10);
  --amber:      #c4933a;
  --amber-dim:  rgba(196,147,58,0.55);
  --amber-tint: rgba(196,147,58,0.10);
  --bg-glass:   rgba(18,16,14,0.94);
  --serif:      'EB Garamond', Georgia, serif;

  --header-h:    56px;
  --rail-w:      230px;
  --content-max: 750px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  font-size: 18px;
  line-height: 1;
  min-height: 100vh;
}

/* ── PROGRESS BAR ── */
#progress-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gold);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 200;
  opacity: 0.65;
  transition: transform 0.1s linear;
}

/* ── HEADER ── */
header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ink-faint);
  display: flex; align-items: center;
  padding: 0 48px;
  justify-content: space-between;
}
.wordmark {
  font-size: 19px; letter-spacing: 0.22em; text-transform: uppercase;
  opacity: 0.85; font-weight: 400; text-decoration: none; color: var(--ink);
}
.header-date { font-size: 13px; font-style: italic; color: var(--ink-dim); }

/* ── PAGE SHELL ── */
.page-outer { display: flex; }

.rail {
  width: var(--rail-w);
  flex-shrink: 0;
  padding: 52px 32px 52px 48px;
  position: fixed;
  top: var(--header-h);
  left: 0;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--ink-faint);
  scrollbar-width: none;
  background: var(--bg);
  z-index: 50;
  transition: opacity 0.3s;
}
.rail::-webkit-scrollbar { display: none; }
.rail.hidden { opacity: 0; pointer-events: none; }

.rail-label {
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 22px; display: block;
}
.rail-item {
  display: flex; align-items: baseline; gap: 10px;
  width: 100%; text-align: left; background: none; border: none;
  font-family: var(--serif); font-size: 13.5px;
  color: var(--ink-dim); padding: 6px 0; cursor: pointer;
  line-height: 1.35; transition: color 0.2s;
  text-decoration: none;
}
.rail-item:hover  { color: var(--ink); }
.rail-item.active { color: var(--gold); font-style: italic; }
.rail-item.h3     { padding-left: 16px; font-size: 13px; }
.rail-num { font-size: 10px; letter-spacing: 0.1em; flex-shrink: 0; font-style: normal; }
.rail-divider { height: 1px; background: var(--ink-faint); margin: 18px 0; }
.rail-btn, .rail-back {
  display: block; width: 100%; text-align: left; background: none; border: none;
  font-family: var(--serif); font-size: 13px; font-style: italic;
  color: var(--ink-dim); padding: 6px 0; cursor: pointer;
  transition: color 0.2s; text-decoration: none;
}
.rail-btn:hover, .rail-back:hover { color: var(--ink); }

.content {
  max-width: var(--content-max);
  padding: 52px 48px 120px;
  min-width: 0;
  margin-left: calc(var(--rail-w) + max(0px, (100vw - var(--rail-w) - var(--content-max)) / 2));
}
.content.no-rail {
  margin-left: max(0px, (100vw - var(--content-max)) / 2);
}

/* ── PAGE HEADER BLOCK ── */
.page-eyebrow {
  font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 30px; display: block;
}
.page-title {
  font-size: 56px; font-weight: 400; line-height: 1.08;
  color: var(--ink-bright); margin-bottom: 26px; letter-spacing: -0.3px;
}
.page-intro {
  font-size: 18px; font-style: italic; line-height: 1.78;
  border-left: 2px solid var(--gold-dim);
  padding-left: 20px; margin-bottom: 16px;
  color: var(--ink);
}
.page-meta {
  font-size: 13px; font-style: italic; color: var(--ink-dim);
  margin-bottom: 52px; line-height: 1.6;
}
.page-divider {
  height: 1px; background: var(--ink-faint); margin-bottom: 56px;
}

/* ── RESPONSIVE ── */
@media (max-width: 860px) {
  header      { padding: 0 24px; }
  .page-outer { padding: 0 24px; }
  .rail       { display: none; }
  .content, .content.no-rail {
    padding: 36px 24px 80px;
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
  }
  .page-title { font-size: 40px; }
}
@media (max-width: 480px) {
  .page-title             { font-size: 34px; }
  .content, .content.no-rail { padding: 28px 20px 72px; }
}

/* ── BODY TEXT ── */
.body-text { font-size: 18px; line-height: 1.44; color: var(--ink); }
.body-text p { margin-bottom: 18px; text-align: justify; }
.body-text p:last-child { margin-bottom: 0; }
.body-text em { color: var(--gold); font-style: italic; }
.body-text strong { color: var(--ink-bright); font-weight: 500; }
.body-text a {
  color: var(--gold); text-decoration: none;
  border-bottom: 1px solid var(--gold-dim);
  transition: opacity 0.18s;
}
.body-text a:hover { opacity: 0.72; }
.body-text blockquote {
  border-left: 2px solid var(--gold-dim);
  padding: 2px 0 2px 20px;
  margin: 1.6em 0;
  color: var(--ink-dim);
  font-style: italic;
}
.body-text blockquote p { text-align: left; margin-bottom: 0; }
.body-text ul, .body-text ol { padding-left: 1.6em; margin-bottom: 1.4em; }
.body-text li { line-height: 1.72; margin-bottom: 0.4em; }
.body-text hr { border: none; border-top: 1px solid var(--ink-faint); margin: 3em auto; width: 40%; }

/* ── CALLOUT ── */
.callout {
  border-left: 2px solid var(--gold-dim);
  padding: 18px 20px;
  margin: 28px 0;
  background: var(--gold-tint);
}
.callout-label {
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 10px; display: block;
}
.callout p {
  font-size: 16px; line-height: 1.44; color: var(--ink);
  margin-bottom: 10px; text-align: justify;
}
.callout p:last-child { margin-bottom: 0; }
.callout em { color: var(--gold); font-style: italic; }

/* ── INLINE DATA LABELS ── */
.label-red   { font-style: normal; font-size: 0.92em; letter-spacing: 0.04em; color: var(--red);   border-bottom: 1px solid var(--red-dim); }
.label-blue  { font-style: normal; font-size: 0.92em; letter-spacing: 0.04em; color: var(--blue);  border-bottom: 1px solid var(--blue-dim); }
.label-green { font-style: normal; font-size: 0.92em; letter-spacing: 0.04em; color: var(--green); border-bottom: 1px solid var(--green-dim); }
.label-amber { font-style: normal; font-size: 0.92em; letter-spacing: 0.04em; color: var(--amber); border-bottom: 1px solid var(--amber-dim); }

/* ── CTA BUTTON ── */
.cta-btn {
  display: inline-block;
  background: none;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: var(--serif);
  font-size: 17px; font-style: italic;
  padding: 12px 28px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  letter-spacing: 0.04em;
}
.cta-btn:hover { background: var(--gold-tint); border-color: var(--gold); }

/* ── GHOST BUTTON ── */
.ghost-btn {
  background: none; border: 1px solid var(--ink-faint);
  color: var(--ink-dim); font-family: var(--serif); font-size: 12px;
  font-style: italic; padding: 7px 12px; cursor: pointer;
  transition: border-color 0.2s, color 0.2s; text-align: left;
  letter-spacing: 0.04em;
}
.ghost-btn:hover { border-color: var(--gold-dim); color: var(--gold); }

/* ── ALERTS ── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--red-dim);
  background: var(--red-tint);
  margin-bottom: 8px;
  font-size: 13px; line-height: 1.55;
  color: var(--ink);
}
.alert.warn { border-color: var(--amber-dim); background: var(--amber-tint); }
.alert-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.alert-text { flex: 1; }
.alert-text strong { color: var(--ink); }

/* ── STATUS DOT ── */
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  display: inline-block;
}
.status-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green-dim); }
.status-dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber-dim); }
.status-dot.red   { background: var(--red);   box-shadow: 0 0 6px var(--red-dim); }

/* ── READOUT PANEL ── */
.readout-group { margin-bottom: 24px; }
.readout-group-label {
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 12px; display: block;
  padding-bottom: 7px; border-bottom: 1px solid var(--ink-faint);
}
.readout-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; border-bottom: 1px solid var(--ink-faint);
}
.readout-row:last-child { border-bottom: none; }
.readout-key { font-size: 13px; color: var(--ink-dim); font-style: italic; flex: 1; min-width: 0; }
.readout-val {
  font-size: 15px; color: var(--ink); text-align: right;
  font-weight: 400; letter-spacing: 0.01em; flex-shrink: 0; margin-left: 12px;
}
.readout-val .val-sub { font-size: 12px; color: var(--ink-dim); margin-left: 6px; font-style: italic; }

/* ── DATA TABLE ── */
.table-wrap { width: 100%; overflow-x: auto; margin-bottom: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead tr { border-bottom: 1px solid var(--ink-faint); }
.data-table th {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 400; color: var(--ink-dim); padding: 0 12px 10px 0;
  text-align: left; white-space: nowrap;
}
.data-table th:last-child, .data-table td:last-child { padding-right: 0; }
.data-table td {
  padding: 9px 12px 9px 0; border-bottom: 1px solid var(--ink-faint);
  color: var(--ink); vertical-align: top; line-height: 1.4;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .num    { font-variant-numeric: tabular-nums; }
.data-table .val-em { color: var(--ink-bright); }
.data-table .muted  { color: var(--ink-dim); font-size: 12px; }
.data-table .phase-name { font-style: italic; color: var(--ink-dim); }

/* ── TOGGLE ── */
.toggle {
  background: none; border: none; cursor: pointer; font-family: var(--serif);
  display: flex; align-items: center; gap: 7px; padding: 0; flex-shrink: 0;
}
.toggle-track {
  display: inline-flex; align-items: center;
  width: 32px; height: 17px; border-radius: 9px;
  background: var(--ink-faint); border: 1px solid var(--ink-faint);
  position: relative; transition: background 0.2s, border-color 0.2s; flex-shrink: 0;
}
.toggle[aria-pressed="true"] .toggle-track { background: var(--gold-tint); border-color: var(--gold-dim); }
.toggle-thumb {
  position: absolute; left: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ink-dim); transition: left 0.2s, background 0.2s;
}
.toggle[aria-pressed="true"] .toggle-thumb { left: 17px; background: var(--gold); }
.toggle-state {
  font-size: 11px; font-style: italic; letter-spacing: 0.06em;
  color: var(--ink-dim); min-width: 16px; transition: color 0.2s;
}
.toggle[aria-pressed="true"] .toggle-state { color: var(--gold); }
.toggle-label { font-size: 13px; color: var(--ink-dim); font-style: italic; flex: 1; }

/* ── SLIDER ── */
.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 1px; background: var(--ink-faint); outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); cursor: pointer; transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.35); }
.slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); border: none; cursor: pointer;
}

/* ── STYLED SELECT ── */
.styled-select {
  width: 100%; background: transparent;
  border: 1px solid var(--ink-faint); color: var(--ink-dim);
  font-family: var(--serif); font-size: 13px; font-style: italic;
  padding: 7px 26px 7px 10px; cursor: pointer; outline: none;
  transition: border-color 0.2s, color 0.2s;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(232,220,200,0.55)'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.styled-select:hover { border-color: var(--gold-dim); color: var(--ink); }
.styled-select option { background: var(--bg); }

/* ── NARRATIVE COMPONENTS ── */
.story-footer {
  margin-top: 72px;
  padding-top: 36px;
  border-top: 1px solid var(--ink-faint);
  font-size: 13px; font-style: italic;
  color: var(--ink-dim);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.footer-back {
  color: var(--gold); text-decoration: none; font-style: italic;
  border-bottom: 1px solid var(--gold-dim);
  transition: opacity 0.18s; font-size: 16px;
}
.footer-back:hover { opacity: 0.72; }
.state-msg {
  padding: 48px 0;
  font-size: 18px; font-style: italic;
  color: var(--ink-dim); line-height: 1.7;
}
.state-msg a { color: var(--gold); }

/* ── PROSE ARCHETYPE ── */
.prose { font-size: 18px; line-height: 1.44; color: var(--ink); }
.prose p { margin-bottom: 18px; text-align: justify; }
.prose p:last-child { margin-bottom: 0; }
.prose em { color: var(--gold); font-style: italic; }
.prose strong { color: var(--ink-bright); font-weight: 500; }
.prose a {
  color: var(--gold); text-decoration: none;
  border-bottom: 1px solid var(--gold-dim); transition: opacity 0.18s;
}
.prose a:hover { opacity: 0.72; }
.prose blockquote {
  border-left: 2px solid var(--gold-dim);
  padding: 2px 0 2px 20px; margin: 1.6em 0;
  color: var(--ink-dim); font-style: italic;
}
.prose blockquote p { text-align: left; margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.6em; margin-bottom: 1.4em; }
.prose li { line-height: 1.72; margin-bottom: 0.4em; }
.prose hr { border: none; border-top: 1px solid var(--ink-faint); margin: 3em auto; width: 40%; }
.prose h2 {
  font-size: 26px; font-weight: 400; color: var(--ink-bright);
  margin-top: 2.6em; margin-bottom: 0.75em; line-height: 1.2;
  scroll-margin-top: 80px; padding-bottom: 12px; border-bottom: 1px solid var(--ink-faint);
}
.prose h3 {
  font-size: 19px; font-weight: 400; font-style: italic; color: var(--ink);
  margin-top: 2em; margin-bottom: 0.6em; line-height: 1.3; scroll-margin-top: 80px;
}
.prose h4, .prose h5, .prose h6 {
  font-size: 16px; font-weight: 500; color: var(--ink-dim);
  margin-top: 1.6em; margin-bottom: 0.5em;
  letter-spacing: 0.05em; text-transform: uppercase;
  font-style: normal; scroll-margin-top: 80px;
}
.prose code {
  font-family: 'Courier New', monospace; font-size: 0.85em;
  background: var(--ink-faint); padding: 0.1em 0.35em; border-radius: 2px;
}
.prose pre {
  background: var(--ink-faint); border: 1px solid var(--ink-faint);
  padding: 1.2em 1.4em; overflow-x: auto; margin-bottom: 1.4em; border-radius: 2px;
}
.prose pre code { background: none; padding: 0; }

/* ── POEM ARCHETYPE ── */
.poem { font-size: 20px; line-height: 2; color: var(--ink); }
.poem p { margin-bottom: 2.2em; text-align: left; }
.poem p:last-child { margin-bottom: 0; }
.poem em { color: var(--gold); font-style: italic; }
.poem strong { color: var(--ink-bright); font-weight: 500; }
.poem a {
  color: var(--gold); text-decoration: none;
  border-bottom: 1px solid var(--gold-dim); transition: opacity 0.18s;
}
.poem a:hover { opacity: 0.72; }
.content.no-rail:has(.poem) { --content-max: 680px; padding: 60px 48px 140px; }
.content.no-rail:has(.poem) .page-title { font-size: 52px; margin-bottom: 28px; text-wrap: pretty; }
.content.no-rail:has(.poem) .page-eyebrow { margin-bottom: 28px; }
@media (max-width: 860px) {
  .content.no-rail:has(.poem) { padding: 36px 24px 90px; }
  .content.no-rail:has(.poem) .page-title { font-size: 38px; }
}
@media (max-width: 480px) {
  .content.no-rail:has(.poem) .page-title { font-size: 32px; }
}
