﻿/*
 * 《穹野纪》 — Archival Editorial Paper Aesthetic inspired by 1in8b.life
 * Crisp hairlines, sage-paper default + nocturnal dark mode toggle,
 * crimson stamp accent (#8C1D3C) & archival teal (#0F6E68), large serif prose.
 */

:root {
  --paper: #EBF0ED;
  --card: #F7FAF8;
  --card2: #F0F4F2;
  --ink: #13212A;
  --ink2: #4A5A61;
  --ink3: #5F6E72;
  --rule: #C7D2CE;
  --rule2: #DCE4E1;
  --accent: #8C1D3C;
  --accent-ink: #FFFFFF;
  --accent-soft: #F3E3E8;
  --stamp: #0F6E68;
  --stamp-soft: #DCEDEA;
  --good: #2B7A4E;
  --gold: #9C7020;
  --bad: #B0362B;
  --grid-0: #E5DCD5;
  --grid-1: #F3E2B3;
  --grid-2: #7FBF86;
  --grid-3: #0B5C63;
  --shadow: 0 1px 0 rgba(19, 33, 42, 0.04), 0 8px 24px -12px rgba(19, 33, 42, 0.16);
  --f-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", Georgia, serif;
  --f-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;
}

[data-theme="dark"] {
  --paper: #0D1316;
  --card: #141D21;
  --card2: #1A252A;
  --ink: #E5ECE9;
  --ink2: #A6B8BC;
  --ink3: #83979C;
  --rule: #2A383E;
  --rule2: #1F2B30;
  --accent: #DF5E82;
  --accent-ink: #0D1316;
  --accent-soft: rgba(223, 94, 130, 0.16);
  --stamp: #4CC0AF;
  --stamp-soft: rgba(76, 192, 175, 0.14);
  --good: #4ABA7A;
  --gold: #DFB054;
  --bad: #EA6D63;
  --grid-0: #242E33;
  --grid-1: #6B5B35;
  --grid-2: #3A7A58;
  --grid-3: #3BA99C;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 10px 28px -12px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

html.modal-open, body.modal-open { overflow: hidden !important; }

body { isolation: isolate; }
#ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.page-view:not([hidden]) > .wrap { animation: view-in 230ms ease-out; }

.serif { font-family: var(--f-serif); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.stamp-txt { color: var(--stamp); }
.accent-txt { color: var(--accent); }
.muted-sm { font-size: 12.5px; color: var(--ink3); }
.lbl { font-size: 12px; color: var(--ink3); letter-spacing: 0.04em; margin-bottom: 2px; }

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 96px;
}
.wrap.narrow { max-width: 780px; }
.wrap.medium { max-width: 960px; }

/* Utility Top Bar */
.util-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.util-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.util-nick {
  font-size: 13px;
  color: var(--ink2);
  padding: 0 6px;
}

.pill-btn {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.pill-btn:hover { border-color: var(--ink); }
.pill-btn.dark {
  background: var(--ink);
  color: var(--card);
  border-color: var(--ink);
}
.pill-btn.sm { padding: 4px 11px; font-size: 12.5px; }

.audio-controls {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink2);
}
.audio-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.audio-toggle:hover, .audio-toggle[aria-pressed="true"] { color: var(--stamp); }
.audio-toggle:disabled { cursor: default; opacity: .5; }
.audio-volume { width: 58px; height: 18px; accent-color: var(--stamp); cursor: pointer; }
.audio-eq { display: inline-flex; align-items: center; gap: 2px; height: 13px; }
.audio-eq i { width: 2px; height: 11px; border-radius: 1px; background: currentColor; transform: scaleY(.35); }
.audio-eq i:nth-child(2) { transform: scaleY(.65); }
.audio-eq i:nth-child(3) { transform: scaleY(.48); }
.audio-controls.is-playing .audio-eq i { animation: equalize 1.25s ease-in-out infinite alternate; }
.audio-controls.is-playing .audio-eq i:nth-child(2) { animation-delay: -.74s; }
.audio-controls.is-playing .audio-eq i:nth-child(3) { animation-delay: -.35s; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--stamp);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* Buttons */
.btn-crimson {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  padding: 11px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.14s ease;
}
.btn-crimson:hover:not(:disabled) { filter: brightness(1.08); }
.btn-crimson.sm { padding: 8px 16px; font-size: 13.5px; }

.btn-outline {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 4px;
  padding: 11px 20px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-outline:hover:not(:disabled) { border-color: var(--ink); }
.btn-outline:disabled, .btn-crimson:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-outline.sm { padding: 8px 15px; font-size: 13.5px; }

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.panel-kicker, .kicker {
  font-size: 12px;
  color: var(--stamp);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.panel-h1 { font-size: 28px; font-weight: 700; line-height: 1.25; }
.panel-h2 { font-size: 20px; font-weight: 700; line-height: 1.3; }
.card-h3 { font-size: 15px; font-weight: 700; color: var(--ink); }

.card-head-row, .section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.callout-stamp {
  background: var(--stamp-soft);
  border-left: 3px solid var(--stamp);
  border-radius: 2px;
  padding: 12px 15px;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.75;
}
.callout-stamp code {
  font-family: var(--f-mono);
  font-weight: 700;
  color: var(--stamp);
}

/* Landing Hero */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.95fr;
  gap: 44px;
  align-items: start;
  margin-bottom: 42px;
}

.hero-title {
  font-size: clamp(64px, 9.5vw, 124px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.02em;
  margin: 8px 0 22px;
}
.accent-char { color: var(--accent); }

.hero-lede {
  font-size: 17.5px;
  line-height: 1.88;
  color: var(--ink2);
  margin-bottom: 20px;
}

.hero-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--rule);
}

.stat-counter strong {
  display: block;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}
.stat-counter span { font-size: 12.5px; color: var(--ink3); }

/* Right Birth Probability Card */
.prob-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 14px 0 16px;
}

.prob-row {
  display: grid;
  grid-template-columns: 78px 1fr 94px;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.prob-name { font-weight: 600; }
.prob-track { height: 9px; background: var(--rule2); border-radius: 2px; overflow: hidden; }
.prob-fill { height: 100%; background: var(--stamp); }
.prob-val { text-align: right; font-size: 12.5px; color: var(--ink2); }
.prob-foot {
  font-size: 13px;
  color: var(--ink3);
  padding-top: 12px;
  border-top: 1px solid var(--rule2);
}

/* Memorial Strip */
.memorial-section { margin-top: 14px; }
.memorial-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.mem-card {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ink);
  transition: border-color 0.14s ease, transform 0.14s ease;
}
.mem-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.mem-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mem-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 2px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.mem-title { font-size: 19px; font-weight: 700; }
.mem-meta { font-size: 13px; color: var(--ink3); }
.mem-quote {
  font-size: 14.5px;
  line-height: 1.78;
  color: var(--ink2);
  flex: 1;
}
.mem-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--rule2);
  font-size: 13px;
}

/* Sticky Bottom CTA Bar */
.sticky-cta-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -6px 20px rgba(19, 33, 42, 0.08);
}
.sticky-cta-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.sticky-cta-hint { font-size: 13.5px; color: var(--ink2); }
.sticky-cta-btns { display: flex; gap: 10px; }

/* Birth Certificate */
.cert-card { padding: 0; overflow: hidden; }
.cert-band, .idcard-band, .memorial-band {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  letter-spacing: 0.05em;
}
.cert-body { position: relative; padding: 26px 28px; }
.guilloche {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
  opacity: 0.055;
  pointer-events: none;
  animation: guilloche-drift 24s ease-in-out infinite alternate;
}

.cert-top-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.cert-name-input {
  font-size: 30px;
  font-weight: 700;
  border: 0;
  border-bottom: 1.5px dashed var(--rule);
  background: transparent;
  color: var(--ink);
  padding: 2px 4px;
  width: 260px;
  outline: none;
}
.cert-name-input:focus { border-bottom-color: var(--accent); }
.cert-lifespan-box { text-align: right; }
.cert-lifespan-box strong { font-size: 26px; color: var(--accent); }

.cert-fields {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 18px;
  padding: 16px 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
  margin-bottom: 18px;
}
.cert-field strong { display: block; font-size: 15.5px; }

.cert-lore-box { position: relative; margin-bottom: 18px; }
.cert-lore-box p { font-size: 15.5px; line-height: 1.82; }

.cert-attrs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.cert-attr {
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 3px;
  padding: 10px 8px;
  text-align: center;
}
.cert-attr span { display: block; font-size: 12px; color: var(--ink3); }
.cert-attr strong { font-size: 20px; }

.cert-mrz {
  position: relative;
  font-size: 11.5px;
  color: var(--ink3);
  letter-spacing: 0.08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 0 18px;
}

.cert-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

/* ==================== ACTIVE LIFE HEADER & 3-COLUMN WORKBENCH ==================== */
.life-topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.life-topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 24px 10px;
}
.life-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.life-head-id {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.life-brand { font-size: 18px; font-weight: 700; cursor: pointer; }
.life-age { font-size: 32px; font-weight: 700; line-height: 1; color: var(--ink); }
.life-meta { font-size: 13px; color: var(--ink2); }
.life-score-pill {
  font-size: 13px;
  font-weight: 700;
  color: var(--stamp);
  background: var(--stamp-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.life-prog-track {
  position: relative;
  height: 3px;
  background: var(--rule2);
  margin: 9px 0 10px;
  border-radius: 1px;
  overflow: hidden;
}
.life-prog-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}
.is-flowing .life-prog-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 30%, var(--stamp) 50%, transparent 70%);
  opacity: .24;
  animation: flow-shimmer max(920ms, var(--flow-delay)) linear infinite;
  pointer-events: none;
}

.life-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.ctrl-spacer { flex: 1; }

.ctrl-btn {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 3px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ctrl-btn:hover:not(:disabled) { border-color: var(--ink); }
.ctrl-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ctrl-btn.primary {
  background: var(--ink);
  color: var(--card);
  border-color: var(--ink);
}
.ctrl-btn.crimson-outline {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.flow-speeds {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
}
.flow-speeds button {
  min-width: 35px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: inherit;
  background: transparent;
  color: var(--ink2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.flow-speeds button:hover { color: var(--stamp); }
.flow-speeds button[aria-pressed="true"] {
  border-color: var(--stamp);
  background: var(--stamp-soft);
  color: var(--stamp);
  font-weight: 700;
}
.flow-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink3);
  font-size: 12px;
  white-space: nowrap;
}
.flow-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.is-flowing .flow-status { color: var(--stamp); border-color: var(--stamp); }
.flow-status.is-decision { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.flow-speeds button:focus-visible, .audio-toggle:focus-visible, .audio-volume:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

/* 3-Column Layout */
.life-wrap { padding-top: 20px; padding-bottom: 48px; }
.life-grid {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr) 272px;
  gap: 18px;
  align-items: start;
}
.col-left, .col-center, .col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Passport ID Card */
.idcard { padding: 0; overflow: hidden; }
.idcard-band { padding: 7px 14px; font-size: 11.5px; }
.idcard-body { position: relative; padding: 14px 16px; }
.id-head { position: relative; display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.id-monogram {
  width: 50px;
  height: 50px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--card2);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.id-name { font-size: 21px; font-weight: 700; line-height: 1.2; }
.id-sub { font-size: 12.5px; color: var(--ink2); margin-top: 2px; }

.id-fields {
  position: relative;
  display: grid;
  grid-template-columns: 74px 1fr;
  row-gap: 6px;
  font-size: 13px;
  padding: 10px 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
}
.id-fields dt { color: var(--ink3); }
.id-fields dd { color: var(--ink); font-weight: 500; text-align: right; }
.id-mrz {
  position: relative;
  margin-top: 9px;
  font-size: 10.5px;
  color: var(--ink3);
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status Bars (1in8b exact feel) */
.bars-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 44px 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.bar-lbl { color: var(--ink2); }
.bar-track { height: 10px; background: var(--rule2); border-radius: 1px; overflow: hidden; }
.bar-fill { height: 100%; transition: width 0.25s ease; }
.fill-good { background: var(--good); }
.fill-gold { background: var(--gold); }
.fill-stamp { background: var(--stamp); }
.fill-accent { background: var(--accent); }
.bar-val { text-align: right; font-size: 13px; font-weight: 600; }

.dashed-rule { border-top: 1px dashed var(--rule); margin: 14px 0; }

.mini-stats-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  text-align: center;
}
.mini-stats-5 span { display: block; font-size: 11px; color: var(--ink3); }
.mini-stats-5 strong { display: inline-block; font-size: 15px; }

.score-summary-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.score-summary-mini strong { display: block; font-size: 20px; }

/* People (Family & Bonds) */
.people-list { display: flex; flex-direction: column; }
.person-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 13.5px;
}
.person-row:last-child { border-bottom: 0; }
.person-role { color: var(--ink3); font-size: 12.5px; min-width: 56px; flex-shrink: 0; }
.person-main { flex: 1; text-align: right; }
.person-name { font-weight: 600; }
.person-sub { font-size: 12px; color: var(--ink3); margin-top: 2px; line-height: 1.5; }
.person-dead { color: var(--ink3); text-decoration: line-through; }

/* Yearly Focus Pills */
.focus-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.focus-pill {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}
.focus-pill:hover { border-color: var(--stamp); }
.focus-pill strong { display: block; font-size: 13.5px; line-height: 1.2; }
.focus-pill span { display: block; font-size: 11px; color: var(--ink3); margin-top: 2px; }
.focus-pill.active {
  background: var(--stamp);
  border-color: var(--stamp);
  color: #ffffff;
}
.focus-pill.active span { color: rgba(255, 255, 255, 0.86); }

/* Chronicle Timeline (1in8b heart & soul!) */
.chronicle-sub { font-size: 12px; color: var(--stamp); margin-bottom: 10px; }
.chronicle-feed {
  max-height: 640px;
  overflow-y: auto;
  padding-right: 4px;
}

.c-row {
  display: grid;
  grid-template-columns: 3.8em 1fr 22px;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--rule2);
  cursor: pointer;
  transition: background 0.12s ease;
}
.c-row:hover { background: var(--card2); }
.c-row.is-new { animation: chronicle-ink 220ms ease-out; }
.c-age { font-size: 13px; color: var(--ink3); padding-top: 2px; }
.c-body { min-width: 0; }
.c-choice {
  font-size: 12.5px;
  color: var(--ink3);
  border-left: 2px solid var(--rule);
  padding-left: 8px;
  margin-bottom: 5px;
}
.c-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.c-text {
  font-size: 15.5px;
  line-height: 1.82;
  color: var(--ink);
}
.c-row.tone-bad .c-text { color: var(--bad); }
.c-row.tone-milestone .c-title { color: var(--stamp); }
.c-row.tone-death .c-text { color: var(--accent); font-weight: 700; }

.c-note {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink2);
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.c-note-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--stamp-soft);
  color: var(--stamp);
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}

.c-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.c-delta {
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--card2);
  color: var(--ink2);
  border: 1px solid var(--rule2);
}
.c-delta.pos { color: var(--good); }
.c-delta.neg { color: var(--bad); }

.c-star {
  font-size: 14px;
  color: var(--rule);
  text-align: right;
  user-select: none;
}
.c-row.starred .c-star { color: var(--gold); }

/* Right Column: Life Map Grid */
.life-map-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}
.lm-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--rule2);
  position: relative;
}
.lm-cell.lv0 { background: var(--grid-0); }
.lm-cell.lv1 { background: var(--grid-1); }
.lm-cell.lv2 { background: var(--grid-2); }
.lm-cell.lv3 { background: var(--grid-3); }
.lm-cell.cap { box-shadow: inset 0 0 0 2px var(--accent); }
.lm-cell.is-current::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid var(--stamp);
  border-radius: 3px;
  animation: map-pulse 2.25s ease-out infinite;
}

.map-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink3);
}
.legend-swatches { display: inline-flex; gap: 3px; }
.legend-swatches i { width: 10px; height: 10px; border-radius: 1px; display: inline-block; }
.sw0 { background: var(--grid-0); }
.sw1 { background: var(--grid-1); }
.sw2 { background: var(--grid-2); }
.sw3 { background: var(--grid-3); }

/* Items & Mini Diplomacy */
.items-archive { display: flex; flex-direction: column; gap: 9px; }
.item-row {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule2);
}
.item-row:last-child { border-bottom: 0; padding-bottom: 0; }
.item-head { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; }
.item-desc { font-size: 12.5px; color: var(--ink2); margin-top: 2px; line-height: 1.55; }

.diplo-mini-list { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.diplo-mini-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.rel-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 2px;
}
.rel-ally { background: var(--stamp-soft); color: var(--stamp); }
.rel-tense { background: rgba(156, 112, 32, 0.14); color: var(--gold); }
.rel-hostile { background: var(--accent-soft); color: var(--accent); }
.rel-neutral { background: var(--card2); color: var(--ink3); }

/* ==================== MODALS (Decision & Biography) ==================== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(13, 19, 22, 0.62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
}

.modal-paper {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 24px 28px;
  box-shadow: 0 24px 60px rgba(13, 19, 22, 0.35);
}
.modal-mask:not([hidden]) > .modal-paper {
  transform-origin: 50% 15%;
  animation: modal-unfold 280ms ease-out;
}
.bio-paper-modal { max-width: 820px; }

.modal-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.modal-kicker-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-crimson-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 2px;
  background: var(--accent);
  color: var(--accent-ink);
}

.dec-title { font-size: 24px; font-weight: 700; margin-bottom: 14px; line-height: 1.35; }
.dec-prose {
  font-size: 17px;
  line-height: 1.92;
  color: var(--ink);
  white-space: pre-line;
  margin-bottom: 16px;
}
.dec-lore { margin-bottom: 12px; font-size: 13.5px; }
.dec-warn {
  margin-bottom: 12px;
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.6;
  border-radius: 2px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.dec-warn strong { color: var(--accent); }
.dec-status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 12px;
  border-radius: 3px;
  border: 1px dashed var(--rule);
  background: var(--card2);
  color: var(--ink2);
}
.ds-item b { color: var(--ink); font-weight: 700; }
.ds-item.is-warn, .ds-item.is-warn b { color: var(--accent); }
.ds-sep { color: var(--rule); }

.dec-choices { display: flex; flex-direction: column; gap: 9px; }
.dec-choice-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--rule);
  background: var(--card2);
  color: var(--ink);
  border-radius: 3px;
  padding: 13px 15px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.dec-choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--card);
}
.dec-choice-btn:disabled { opacity: 0.48; cursor: not-allowed; }
.dec-idx {
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink3);
  padding-top: 2px;
}
.dec-choice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.dec-choice-lbl { font-size: 15.5px; font-weight: 600; line-height: 1.45; }
.dec-chance {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 2px;
  background: var(--stamp-soft);
  color: var(--stamp);
  flex-shrink: 0;
}
.dec-chance.low { background: var(--accent-soft); color: var(--accent); }
.dec-choice-hint { font-size: 13px; color: var(--ink2); margin-top: 4px; line-height: 1.55; }
.dec-choice-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.dec-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  color: var(--ink2);
}

/* ==================== END MEMORIAL & BIOGRAPHY ==================== */
.memorial-full { padding: 0; overflow: hidden; }
.memorial-body { padding: 26px 28px; }
.memorial-header {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--rule);
  margin-bottom: 18px;
}
.grade-stamp {
  width: 68px;
  height: 68px;
  border-radius: 4px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 800;
  flex-shrink: 0;
}
#view-ended:not([hidden]) .grade-stamp, #bio-modal:not([hidden]) .grade-stamp {
  animation: stamp-drop 420ms 100ms both cubic-bezier(.22, .72, .35, 1);
}
.memorial-h-info { flex: 1; min-width: 220px; }
.memorial-name { font-size: 28px; font-weight: 700; }
.memorial-death { font-size: 14.5px; color: var(--bad); margin-top: 4px; }
.memorial-score-box { text-align: right; }
.memorial-score-box strong { font-size: 34px; color: var(--accent); line-height: 1; }

.score-bd-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.bd-cell {
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 3px;
  padding: 11px 10px;
  text-align: center;
}
.bd-cell span { display: block; font-size: 12px; color: var(--ink3); }
.bd-cell strong { display: block; font-size: 19px; margin: 2px 0; }
.bd-cell small { font-size: 11.5px; color: var(--stamp); }

.epitaph-box {
  background: var(--accent-soft);
  border: 1px solid var(--rule);
  border-left: 3.5px solid var(--accent);
  border-radius: 3px;
  padding: 15px 20px;
  margin-bottom: 18px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.epitaph-stamp {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 2px;
  background: var(--accent);
  color: var(--accent-ink);
  flex-shrink: 0;
}
.epitaph-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--ink);
  flex: 1;
  min-width: 220px;
}

.bio-paper {
  background: var(--card2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--stamp);
  border-radius: 3px;
  padding: 22px 26px;
  font-size: 16.5px;
  line-height: 1.96;
  margin-bottom: 20px;
}
.bio-chapter {
  margin-bottom: 18px;
}
.bio-chapter:last-child {
  margin-bottom: 0;
}
.bio-chap-head {
  font-size: 15px;
  font-weight: 700;
  color: var(--stamp);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--rule);
}
.bio-chap-p {
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--ink);
  margin-bottom: 8px;
  text-indent: 2em;
}
.bio-chap-p:last-child {
  margin-bottom: 0;
}

.end-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.ms-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 10px 0 12px;
  font-size: 14px;
  color: var(--ink2);
}
.ms-list li::before { content: "· "; color: var(--accent); font-weight: 900; }
.items-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.item-chip {
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  background: var(--card2);
}

/* ==================== LEADERBOARD ==================== */
.table-scroll { overflow-x: auto; margin-top: 14px; }
.arch-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.arch-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink3);
  border-bottom: 1.5px solid var(--rule);
  white-space: nowrap;
}
.arch-table td {
  padding: 12px;
  border-bottom: 1px solid var(--rule2);
  white-space: nowrap;
}
.arch-table tbody tr { cursor: pointer; }
.arch-table tbody tr:hover td { background: var(--card2); }
.arch-table tbody tr.is-me td { background: var(--stamp-soft); }
.arch-table .num { text-align: right; }

.rk-pill {
  display: inline-block;
  min-width: 30px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 2px;
  font-weight: 700;
  font-size: 13px;
  background: var(--card2);
}
.rk-pill.rk1 { background: var(--accent); color: var(--accent-ink); }
.rk-pill.rk2 { background: var(--ink); color: var(--card); }
.rk-pill.rk3 { background: var(--stamp); color: #fff; }
.sub-cell { display: block; font-size: 12px; color: var(--ink3); }

.select-ctrl, .text-ctrl {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 3px;
  padding: 8px 12px;
  font-size: 13.5px;
  outline: none;
}
.text-ctrl { flex: 1; min-width: 180px; }
.text-ctrl:focus, .select-ctrl:focus { border-color: var(--accent); }

/* ==================== LORE & 7-RACE GRAPH ==================== */
.lore-intro-panel, .diplo-panel, .codex-panel { margin-bottom: 20px; }
.lore-prose {
  font-size: 17px;
  line-height: 1.92;
  color: var(--ink2);
  white-space: pre-line;
  margin: 12px 0 20px;
}
.regions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.region-box {
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 3px;
  padding: 15px 17px;
}
.region-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 8px; }
.region-box h3 { font-size: 17px; }
.region-box p { font-size: 14px; color: var(--ink2); line-height: 1.72; }

.diplo-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink2); }
.diplo-legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; }
.lg-ally { background: var(--stamp); }
.lg-tense { background: var(--gold); }
.lg-hostile { background: var(--accent); }

.diplo-split {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 24px;
  align-items: start;
}
.diplo-svg-wrap {
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 4px;
  padding: 10px;
}
.diplo-svg-wrap svg { width: 100%; height: auto; display: block; }
.diplo-edge-flow {
  pointer-events: none;
  stroke-width: 3.1;
  stroke-dasharray: 6 23;
  stroke-linecap: round;
  animation: edge-flow 2.9s linear infinite;
}
.diplo-node { cursor: pointer; }
.diplo-node:focus:not(:focus-visible) { outline: none; }

.diplo-dossier {
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 4px;
  padding: 18px 20px;
}
.dossier-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.dossier-desc { font-size: 15px; line-height: 1.82; color: var(--ink2); margin: 10px 0 14px; }
.dossier-rel-item {
  padding: 9px 0;
  border-top: 1px solid var(--rule2);
  font-size: 13.5px;
}
.dossier-rel-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.dossier-rel-desc { font-size: 13px; color: var(--ink2); line-height: 1.65; }

.codex-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}
.codex-item {
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 3px;
  padding: 14px 16px;
}
.codex-item h4 { font-size: 16.5px; margin-bottom: 4px; }
.codex-item p { font-size: 13.5px; color: var(--ink2); line-height: 1.7; margin-top: 5px; }

/* Profile */
.profile-split { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.sync-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--card2);
  border: 1px dashed var(--rule);
  border-radius: 3px;
}
.sync-strip code { font-size: 19px; font-weight: 700; color: var(--stamp); letter-spacing: 0.08em; }
.past-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.past-btn {
  width: 100%;
  text-align: left;
  background: var(--card2);
  border: 1px solid var(--rule2);
  border-radius: 3px;
  padding: 11px 14px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.past-btn:hover { border-color: var(--accent); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  background: var(--ink);
  color: var(--card);
  padding: 9px 18px;
  border-radius: 4px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.value-pop { animation: value-pop 205ms ease-out; }
.bar-fill.value-pop, .life-prog-fill.value-pop { --pop-offset: 0px; }

@keyframes view-in { from { opacity: .72; } to { opacity: 1; } }
@keyframes equalize { from { transform: scaleY(.32); } to { transform: scaleY(1); } }
@keyframes guilloche-drift { from { transform: translateX(-1.2%); } to { transform: translateX(1.2%); } }
@keyframes flow-shimmer { from { transform: translateX(-72%); } to { transform: translateX(72%); } }
@keyframes chronicle-ink {
  from { opacity: .48; transform: translateY(-4px); background: var(--stamp-soft); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes value-pop {
  35% { transform: translateY(var(--pop-offset, -.065em)); filter: brightness(1.28); }
}
@keyframes map-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--stamp-soft); }
  58% { box-shadow: 0 0 0 3px var(--stamp-soft); }
}
@keyframes modal-unfold {
  from { opacity: .48; transform: translateY(-7px) scaleY(.976); }
  to { opacity: 1; transform: translateY(0) scaleY(1); }
}
@keyframes stamp-drop {
  0% { opacity: 0; transform: translateY(-10px) rotate(-5deg) scale(1.08); }
  66% { opacity: 1; transform: translateY(1px) rotate(-1deg) scale(.98); }
  100% { opacity: 1; transform: none; }
}
@keyframes edge-flow { to { stroke-dashoffset: -29; } }

@media (prefers-reduced-motion: reduce) {
  .page-view:not([hidden]) > .wrap,
  .audio-controls.is-playing .audio-eq i,
  .guilloche,
  .is-flowing .life-prog-track::after,
  .lm-cell.is-current::after,
  .modal-mask:not([hidden]) > .modal-paper,
  #view-ended:not([hidden]) .grade-stamp,
  #bio-modal:not([hidden]) .grade-stamp { animation: none; }
  .diplo-edge-flow { display: none; }
  .c-row.is-new, .value-pop { animation-duration: .001ms; }
  .life-prog-fill, .bar-fill { transition: none; }
}

/* Responsive */
@media (max-width: 1020px) {
  .life-grid { grid-template-columns: 290px 1fr; }
  .col-right { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .hero, .memorial-grid, .diplo-split, .regions-grid, .profile-split, .end-two-col { grid-template-columns: 1fr; }
  .life-grid { grid-template-columns: 1fr; }
  .col-right { grid-template-columns: 1fr; }
  .cert-fields { grid-template-columns: 1fr 1fr; }
  .score-bd-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .wrap { padding: 14px 14px 96px; }
  .cert-attrs { grid-template-columns: repeat(3, 1fr); }
  .life-topbar-inner { padding-inline: 14px; }
  .life-controls .ctrl-spacer { display: none; }
}
