:root {
  --bg: #F5F1E8;
  --paper: #FFF9ED;
  --paper-deep: #E8DDC7;
  --ink: #221F1A;
  --muted: #6E6558;
  --line: rgba(58, 48, 36, 0.22);
  --shadow: 0 18px 45px rgba(63, 47, 26, 0.16);
  --card-shadow: 0 10px 25px rgba(49, 39, 25, 0.16);
  --canvas-grid: rgba(99, 75, 42, 0.12);
}

body.dark {
  --bg: #1A1814;
  --paper: #26221B;
  --paper-deep: #332D22;
  --ink: #F5F1E8;
  --muted: #C2B69F;
  --line: rgba(245, 241, 232, 0.18);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --card-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
  --canvas-grid: rgba(245, 241, 232, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 58px;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(186, 117, 23, 0.18), transparent 34rem),
    linear-gradient(135deg, rgba(95, 94, 90, 0.08), transparent 38%),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  transition: background-color 180ms ease, color 180ms ease;
}

body.ai-footer-dismissed {
  padding-bottom: 0;
}

body.ai-footer-dismissed .ai-disclosure-footer {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

button {
  font: inherit;
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid color-mix(in srgb, #BA7517 75%, white);
  outline-offset: 4px;
}

.site-header,
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 0 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.8rem, 8vw, 6.2rem);
}

.hero-hook {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.48;
}

h2 {
  max-width: 720px;
  font-size: clamp(1.65rem, 4vw, 3.1rem);
}

h3 {
  font-size: 1rem;
}

.section-divider-title {
  max-width: none;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.48;
}

.dek {
  max-width: 840px;
  margin: 8px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  line-height: 1.52;
}

.site-header .eyebrow {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.5vw, 1.16rem);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.theme-toggle,
.ai-toggle,
.text-toolbar-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  gap: 10px;
  border-radius: 999px;
}

.theme-toggle {
  padding: 8px 14px;
}

.text-toolbar-button {
  padding: 8px 13px;
  font-size: 0.84rem;
  font-weight: 800;
}

.ai-toggle {
  padding: 8px 14px 8px 10px;
  text-align: left;
}

.theme-toggle:hover,
.ai-toggle:hover,
.text-toolbar-button:hover {
  background: color-mix(in srgb, var(--paper-deep) 58%, var(--paper));
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  background: color-mix(in srgb, var(--line) 64%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background-color 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease;
}

.ai-toggle[aria-pressed="true"] .switch-track {
  background: #0F6E56;
}

.ai-toggle[aria-pressed="true"] .switch-thumb {
  transform: translateX(18px);
}

.toggle-label,
.toggle-subtitle {
  display: block;
}

.toggle-label {
  font-weight: 800;
}

.toggle-subtitle {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.2;
}

.toggle-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #BA7517;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.web-shell {
  position: relative;
  padding-bottom: 36px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding-right: 280px;
}

.legend {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 4;
  flex: 0 0 255px;
  padding: 16px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}

.legend-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-top: 12px;
}

.legend-group {
  display: grid;
  gap: 9px;
}

.legend-group h4 {
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: capitalize;
}

.legend-swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--category-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--category-color) 20%, transparent);
}

.theme-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 24px;
  padding: 4px 8px;
  color: color-mix(in srgb, var(--theme-color) 88%, var(--ink));
  background: color-mix(in srgb, var(--theme-color) 14%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--theme-color) 34%, var(--line));
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.canvas-frame {
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px),
    linear-gradient(var(--canvas-grid) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.history-canvas {
  position: relative;
  min-width: 980px;
  height: 3000px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background:
    linear-gradient(180deg, transparent, rgba(186, 117, 23, 0.08)),
    color-mix(in srgb, var(--paper) 86%, var(--paper-deep));
  overflow: hidden;
}

.history-canvas::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid var(--line);
  pointer-events: none;
}

.arrow-layer,
.event-layer {
  position: absolute;
  inset: 0;
}

.arrow-layer {
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.arrow-layer * {
  pointer-events: none;
}

.event-layer {
  z-index: 2;
  pointer-events: none;
}

.arrow-path {
  fill: none;
  stroke: var(--arrow-color);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.72;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12));
}

.arrow-head {
  fill: var(--arrow-color);
  opacity: 0.72;
}

.arrow-path.is-faded {
  opacity: 0.3;
  stroke-dasharray: 8 8;
}

.arrow-label {
  fill: var(--muted);
  paint-order: stroke;
  stroke: color-mix(in srgb, var(--paper) 82%, transparent);
  stroke-width: 5px;
  stroke-linejoin: round;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.72rem;
  font-style: italic;
  opacity: 0.86;
  pointer-events: none;
}

.arrow-label.is-faded {
  opacity: 0.3;
}

.arrow-head.is-faded {
  opacity: 0.3;
}

.event-card {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 188px;
  min-height: 124px;
  transform: translate(-50%, -50%);
  padding: 15px 15px 14px;
  color: var(--ink);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--paper) 94%, white), var(--paper));
  border: 1px solid color-mix(in srgb, var(--category-color) 45%, var(--line));
  border-left: 7px solid var(--category-color);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.event-card-actions {
  position: absolute;
  top: 50%;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.event-card-actions-right {
  right: -12px;
  transform: translate(100%, -50%) translateX(8px);
}

.event-card-actions-left {
  left: -12px;
  transform: translate(-100%, -50%) translateX(-8px);
}

.event-card:hover .event-card-actions,
.event-card:focus-within .event-card-actions,
.event-card.is-action-visible .event-card-actions {
  opacity: 1;
  pointer-events: auto;
}

.event-card:hover .event-card-actions-right,
.event-card:focus-within .event-card-actions-right,
.event-card.is-action-visible .event-card-actions-right {
  transform: translate(100%, -50%);
}

.event-card:hover .event-card-actions-left,
.event-card:focus-within .event-card-actions-left,
.event-card.is-action-visible .event-card-actions-left {
  transform: translate(-100%, -50%);
}

.event-card-actions::before {
  content: "";
  position: absolute;
  top: -18px;
  bottom: -18px;
  width: 28px;
}

.event-card-actions-right::before {
  left: -28px;
}

.event-card-actions-left::before {
  right: -28px;
}

.event-card-action {
  min-height: 34px;
  min-width: 118px;
  padding: 0 12px;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--paper));
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(49, 39, 25, 0.16);
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  backdrop-filter: blur(5px);
}

.event-card-action:hover {
  color: #fff;
  background: #185FA5;
  border-color: #185FA5;
}

.event-card-action-history {
  border-color: color-mix(in srgb, #A32D2D 42%, var(--line));
}

.event-card-action-history:hover {
  background: #A32D2D;
  border-color: #A32D2D;
}

.event-card-action-history.is-restore {
  color: #185FA5;
  border-color: color-mix(in srgb, #185FA5 62%, var(--line));
}

.event-card-action-history.is-restore:hover {
  color: #fff;
  background: #185FA5;
  border-color: #185FA5;
}

.event-card-action:disabled,
.event-card-action.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.event-card-action:disabled:hover,
.event-card-action.is-disabled:hover {
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border-color: var(--line);
}

.event-card:hover {
  box-shadow: 0 16px 35px rgba(49, 39, 25, 0.22);
  transform: translate(-50%, -50%) translateY(-3px);
}

.event-card.is-removed {
  filter: grayscale(1);
  opacity: 0.48;
  border-color: var(--line);
  border-left-color: #77736A;
}

.event-card.is-removed h3 {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.event-card.is-modified {
  box-shadow:
    inset 0 -3px 0 color-mix(in srgb, #BA7517 70%, transparent),
    var(--card-shadow);
}

.event-modified-dot {
  position: absolute;
  top: 11px;
  right: 11px;
  z-index: 1;
  width: 10px;
  height: 10px;
  background: #BA7517;
  border: 2px solid var(--paper);
  border-radius: 999px;
  box-shadow: 0 0 0 1px color-mix(in srgb, #BA7517 55%, transparent);
}

.event-status-badge {
  position: absolute;
  top: 44px;
  right: 10px;
  z-index: 1;
  max-width: calc(100% - 18px);
  padding: 4px 7px;
  color: var(--ink);
  background: color-mix(in srgb, #BA7517 18%, var(--paper));
  border: 1px solid color-mix(in srgb, #BA7517 42%, var(--line));
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  text-transform: uppercase;
}

.event-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(99, 75, 42, 0.08);
  border-radius: 5px;
  pointer-events: none;
}

.event-card::before {
  content: "";
  position: absolute;
  top: -18px;
  bottom: -18px;
  z-index: 2;
  width: 160px;
  pointer-events: auto;
}

.event-card-action-right::before {
  right: -160px;
}

.event-card-action-left::before {
  left: -160px;
}

.event-year {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  color: #fff;
  background: var(--category-color);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.event-card h3 {
  margin-top: 10px;
  font-size: 1.16rem;
}

.event-cause {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.event-category {
  margin-top: 11px;
  color: var(--category-color);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  padding: 24px;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  transition: opacity 180ms ease, background-color 180ms ease;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.is-visible {
  background: rgba(0, 0, 0, 0.4);
  opacity: 1;
}

.event-modal {
  position: relative;
  width: min(640px, 100%);
  height: 100%;
  overflow: auto;
  padding: 34px;
  color: var(--ink);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--paper) 95%, white), var(--paper)),
    var(--paper);
  border: 1px solid var(--line);
  border-left: 8px solid #BA7517;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.36);
  transform: translateX(26px) scale(0.98);
  transition: transform 180ms ease;
}

.modal-backdrop.is-visible .event-modal {
  transform: translateX(0) scale(1);
}

.event-modal::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  pointer-events: none;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  line-height: 1;
}

.modal-close:hover {
  background: color-mix(in srgb, var(--paper-deep) 62%, transparent);
}

.modal-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding-right: 44px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  max-width: none;
  font-size: clamp(2.05rem, 5vw, 3.4rem);
}

.modal-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 700;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -6px;
}

.theme-section .theme-badges {
  margin-top: 14px;
}

.theme-section .theme-pill {
  min-height: 30px;
  padding: 7px 11px;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  text-transform: none;
}

.ai-info-box {
  margin: 0 0 20px;
  padding: 12px 14px;
  color: var(--muted);
  background: color-mix(in srgb, #BA7517 10%, var(--paper));
  border: 1px solid color-mix(in srgb, #BA7517 30%, var(--line));
  border-left: 5px solid #BA7517;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.modal-year,
.modal-category {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  font-weight: 800;
}

.modal-year {
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--line);
}

.modal-category {
  color: #fff;
  background: var(--category-color);
  text-transform: capitalize;
}

.confidence-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  margin-top: 10px;
  padding: 6px 10px;
  border: 1px solid var(--confidence-border);
  border-radius: 999px;
  color: var(--confidence-ink);
  background: var(--confidence-bg);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.confidence-well-documented {
  --confidence-ink: #0F6E56;
  --confidence-bg: color-mix(in srgb, #0F6E56 12%, var(--paper));
  --confidence-border: color-mix(in srgb, #0F6E56 34%, var(--line));
}

.confidence-reasonable {
  --confidence-ink: #BA7517;
  --confidence-bg: color-mix(in srgb, #BA7517 13%, var(--paper));
  --confidence-border: color-mix(in srgb, #BA7517 36%, var(--line));
}

.confidence-speculative {
  --confidence-ink: var(--muted);
  --confidence-bg: color-mix(in srgb, var(--line) 28%, transparent);
  --confidence-border: var(--line);
}

.modal-category-muted {
  color: var(--muted);
  background: color-mix(in srgb, var(--line) 25%, transparent);
  border: 1px solid var(--line);
}

.history-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
  border-bottom: 1px solid var(--line);
}

.history-tab {
  position: relative;
  padding: 0 0 13px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.history-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
}

.history-tab.is-active {
  color: var(--ink);
}

.history-tab.is-active::after {
  height: 4px;
  background: #BA7517;
}

.history-tab-preview {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.76rem;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.history-tab-panel {
  padding-top: 0;
}

.modified-empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 330px;
  padding: 62px 20px 46px;
  color: var(--muted);
  text-align: center;
}

.modified-empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: #BA7517;
  background: color-mix(in srgb, #BA7517 10%, var(--paper));
  border: 1px solid color-mix(in srgb, #BA7517 34%, var(--line));
  border-radius: 999px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 700;
}

.modified-empty-state h3 {
  color: var(--ink);
  font-size: clamp(1.55rem, 5vw, 2.25rem);
}

.modified-empty-state p {
  max-width: 430px;
  margin: 0;
  line-height: 1.62;
}

.modal-section {
  padding: 26px 0 0;
}

.modal-section h3 {
  font-size: 1.4rem;
}

.inevitability-card {
  position: relative;
  margin-top: 28px;
  padding: 20px;
  background: color-mix(in srgb, var(--paper-deep) 36%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #BA7517 12%, transparent);
}

.inevitability-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.inevitability-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.inevitability-score {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 1;
}

.inevitability-meter {
  height: 18px;
  margin-top: 16px;
  overflow: hidden;
  background: color-mix(in srgb, var(--line) 58%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
}

.inevitability-fill {
  width: var(--inevitability-width);
  height: 100%;
  background: linear-gradient(90deg, #BA7517, #A32D2D);
  border-radius: inherit;
}

.inevitability-label {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  font-weight: 700;
}

.modal-framing,
.modal-empty {
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.dossier-list,
.primary-source-list {
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.62;
  border: 0;
}

.dossier-list li,
.primary-source-list li {
  padding-left: 4px;
  border: 0;
}

.dossier-list li + li,
.primary-source-list li + li {
  margin-top: 9px;
}

.sources-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.sources-list li {
  display: grid;
  gap: 3px;
  color: var(--muted);
}

.sources-list span {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sources-list cite {
  font-style: italic;
  line-height: 1.45;
}

.sources-list a,
.primary-source-list a,
.bibliography-list a {
  color: #185FA5;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, #185FA5 45%, transparent);
  text-underline-offset: 3px;
}

.sources-list a:hover,
.primary-source-list a:hover,
.bibliography-list a:hover {
  color: #BA7517;
}

.external-link-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.78em;
  text-decoration: none;
}

.debate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.debate-panel {
  padding: 17px;
  background: color-mix(in srgb, var(--paper-deep) 28%, transparent);
  border: 1px solid var(--line);
  border-left: 6px solid var(--debate-color);
  border-radius: 8px;
}

.debate-panel-determinist {
  --debate-color: #A32D2D;
}

.debate-panel-contingentist {
  --debate-color: #185FA5;
}

.debate-panel h4 {
  margin: 0;
  color: var(--debate-color);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.debate-panel p {
  margin: 12px 0 0;
  color: var(--ink);
  line-height: 1.62;
}

.debate-panel span {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

.cause-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.cause-card {
  padding: 15px;
  background: color-mix(in srgb, var(--paper-deep) 32%, transparent);
  border: 1px solid color-mix(in srgb, var(--category-color) 38%, var(--line));
  border-left: 5px solid var(--category-color);
  border-radius: 8px;
}

.cause-card h4 {
  margin: 7px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.15;
}

.cause-card p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.cause-year {
  display: inline-flex;
  padding: 3px 8px;
  color: #fff;
  background: var(--category-color);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.remove-history-button {
  width: 100%;
  min-height: 44px;
  margin-top: 30px;
  color: color-mix(in srgb, #7C1F1F 86%, var(--ink));
  background: transparent;
  border: 1px solid color-mix(in srgb, #7C1F1F 65%, var(--line));
  border-radius: 8px;
  box-shadow: none;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.96rem;
  font-weight: 700;
}

.remove-history-button:hover {
  color: #fff;
  background: #7C1F1F;
}

.remove-history-button.is-restore {
  color: #185FA5;
  border-color: color-mix(in srgb, #185FA5 65%, var(--line));
}

.remove-history-button.is-restore:hover {
  color: #fff;
  background: #185FA5;
  border-color: #185FA5;
}

.remove-history-button.is-disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.remove-history-button.is-disabled:hover {
  color: #7C1F1F;
  background: transparent;
}

.retry-modified-button {
  min-height: 46px;
  padding: 0 18px;
  color: #fff;
  background: #185FA5;
  border: 1px solid #185FA5;
  border-radius: 8px;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.modified-dossier {
  padding-top: 28px;
}

.modified-dossier-header {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: color-mix(in srgb, var(--paper-deep) 30%, transparent);
  border: 1px solid var(--line);
  border-left: 6px solid #BA7517;
  border-radius: 8px;
}

.modified-dossier-header h3 {
  margin: 0;
  font-size: clamp(1.65rem, 5vw, 2.45rem);
}

.modified-dossier-header h3 span {
  color: var(--muted);
  font-size: 0.7em;
  font-weight: 500;
}

.original-strikethrough {
  color: var(--text-secondary, var(--muted));
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.75em;
  font-style: italic;
  opacity: 0.6;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.modified-original-title {
  display: block;
}

.modified-reference {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.modified-reference-arrow {
  color: #BA7517;
  font-family: Georgia, "Times New Roman", serif;
}

.modified-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.counterfactual-note {
  margin: 0 0 18px;
  padding: 11px 13px;
  color: var(--ink);
  background: color-mix(in srgb, #BA7517 13%, var(--paper));
  border: 1px solid color-mix(in srgb, #BA7517 35%, var(--line));
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.counterfactual-error {
  margin: -8px 0 18px;
  color: #A32D2D;
  font-size: 0.9rem;
  line-height: 1.45;
}

.counterfactual-error strong,
.counterfactual-error span {
  display: block;
}

.utility-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.got-it-button-secondary {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}

.got-it-button-secondary:hover {
  background: var(--paper-deep);
}

.loading-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 42px 0 18px;
  text-align: center;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-top-color: #BA7517;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.counterfactual-title {
  text-decoration: line-through;
  text-decoration-thickness: 3px;
}

.butterfly-quote {
  margin: 26px 0 0;
  padding: 20px;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper-deep) 38%, transparent);
  border-left: 6px solid #BA7517;
  border-radius: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.2;
}

.timeline-section {
  padding-top: 24px;
}

.timeline-section p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.62;
}

.plausibility-card {
  margin-top: 28px;
  padding: 18px;
  background: color-mix(in srgb, var(--paper-deep) 32%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.plausibility-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.plausibility-score {
  color: #BA7517;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.plausibility-meter {
  height: 13px;
  margin-top: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--line) 52%, transparent);
  border-radius: 999px;
}

.plausibility-fill {
  width: var(--plausibility-width);
  height: 100%;
  background: #BA7517;
  border-radius: inherit;
}

.plausibility-reasoning {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.restore-history-button,
.regenerate-button,
.retry-ai-button {
  width: 100%;
  min-height: 52px;
  margin-top: 26px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  font-weight: 700;
}

.regenerate-button {
  margin-top: 14px;
}

.retry-ai-button {
  margin-top: 14px;
  color: #fff;
  background: #185FA5;
  border-color: #185FA5;
}

.restore-history-button:hover {
  background: var(--paper-deep);
}

.retry-ai-button:hover {
  background: #124E88;
}

.app-notification {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: min(380px, calc(100vw - 32px));
  padding: 13px 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 5px solid #BA7517;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.app-notification.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ai-disclosure-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  padding: 10px 16px;
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 25px rgba(49, 39, 25, 0.08);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.ai-disclosure-footer span {
  display: inline-block;
  max-width: min(980px, calc(100% - 52px));
}

.ai-disclosure-dismiss {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 28px;
  height: 28px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  transform: translateY(-50%);
}

.ai-disclosure-dismiss:hover {
  color: var(--ink);
  background: var(--paper-deep);
}

.utility-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(26, 24, 20, 0.45);
}

.utility-modal {
  width: min(840px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  position: relative;
  padding: 30px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.utility-modal h2 {
  padding-right: 44px;
  font-size: clamp(1.75rem, 4vw, 3rem);
}

.utility-modal h3 {
  margin-top: 26px;
  font-size: 1.35rem;
}

.utility-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1;
}

.about-copy {
  display: grid;
  gap: 32px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.about-copy h3 {
  margin: 0 0 12px;
  color: color-mix(in srgb, var(--ink) 88%, var(--muted));
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.about-copy p {
  margin: 0;
}

.about-credits p {
  color: var(--ink);
}

.got-it-button {
  justify-self: start;
  min-height: 44px;
  padding: 0 18px;
  color: #fff;
  background: #185FA5;
  border: 1px solid #185FA5;
  border-radius: 8px;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.bibliography-content {
  margin-top: 18px;
}

.bibliography-list {
  margin: 12px 0 0;
  padding-left: 24px;
  color: var(--muted);
  line-height: 1.55;
}

.bibliography-list li + li {
  margin-top: 8px;
}

@media (max-width: 767px) {
  .site-header,
  .section-heading {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    padding-top: 0;
  }

  .ai-toggle {
    width: 100%;
  }

  .legend {
    position: static;
    flex: none;
    width: 100%;
  }

  .legend-items {
    grid-template-columns: 1fr;
  }

  .canvas-frame {
    overflow: visible;
    padding: 12px;
  }

  .history-canvas {
    min-width: 0;
    height: auto;
    min-height: 0;
    padding: 22px 0;
    border: 0;
    background:
      linear-gradient(90deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
      color-mix(in srgb, var(--paper) 86%, var(--paper-deep));
  }

  .history-canvas::before,
  .arrow-layer {
    display: none;
  }

  .event-layer {
    position: relative;
    display: grid;
    gap: 16px;
  }

  .event-card {
    position: relative;
    left: auto;
    top: auto;
    width: min(calc(100% - 96px), 420px);
    min-height: 0;
    margin: 0 auto;
    transform: none;
  }

  .event-card-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .event-card-actions-right,
  .event-card:hover .event-card-actions-right,
  .event-card:focus-within .event-card-actions-right,
  .event-card.is-action-visible .event-card-actions-right {
    right: -10px;
    transform: translate(100%, -50%);
  }

  .event-card-actions-left,
  .event-card:hover .event-card-actions-left,
  .event-card:focus-within .event-card-actions-left,
  .event-card.is-action-visible .event-card-actions-left {
    left: -10px;
    transform: translate(-100%, -50%);
  }

  .event-card-action {
    min-width: 72px;
    min-height: 32px;
    padding: 0 9px;
    font-size: 0.68rem;
  }

  .event-card:hover {
    transform: none;
  }

  .modal-backdrop {
    padding: 0;
  }

  .event-modal {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    transform: translateY(18px) scale(0.99);
  }

  .modal-backdrop.is-visible .event-modal {
    transform: translateY(0) scale(1);
  }

  .modal-header {
    padding-right: 36px;
  }

  .history-tabs {
    gap: 10px;
  }

  .history-tab {
    font-size: 0.75rem;
  }

  .inevitability-score-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .debate-grid {
    grid-template-columns: 1fr;
  }
}
