:root {
  color-scheme: dark;
  --bg: #16161d;
  --bg-deep: #0c101a;
  --ink: #e2e2e2;
  --paper: #f7f4ee;
  --muted: #9a9ca3;
  --dim: #666972;
  --gold: #d9b66f;
  --gold-line: rgba(217, 182, 111, 0.28);
  --violet: #9381d8;
  --violet-line: rgba(147, 129, 216, 0.75);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -15%, rgba(37, 47, 72, 0.42), transparent 42rem),
    linear-gradient(180deg, #16161d 0%, #11131b 100%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

#historyParticles {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.back-link,
.journal-link {
  position: fixed;
  top: 28px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  min-height: 35px;
  padding: 0 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 2px;
  transition: color 180ms ease, transform 180ms ease;
}

.back-link {
  left: 28px;
  gap: 9px;
}

.journal-link {
  right: 28px;
}

.journal-link:hover,
.journal-link:focus-visible,
.back-link:hover,
.back-link:focus-visible {
  color: var(--gold);
}

.back-link:hover,
.back-link:focus-visible {
  transform: translateX(-2px);
}

.journal-link:focus-visible,
.back-link:focus-visible,
.record-button:focus-visible,
.empty-state a:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 5px;
}

.ledger-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 40px, 960px);
  min-height: calc(100vh - 80px);
  margin: 0 auto;
  padding: 88px 0 116px;
}

.ledger-header {
  width: 100%;
  margin: 0 auto 70px;
  text-align: center;
}

.ledger-kicker {
  margin: 0 0 17px;
  color: var(--gold);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 5px;
}

.ledger-header h1 {
  margin: 0;
  color: var(--ink);
  font-family: "Times New Roman", "Songti SC", serif;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: clamp(5px, 1vw, 10px);
  text-indent: clamp(5px, 1vw, 10px);
}

.ledger-title-cn {
  margin: 15px 0 0;
  color: var(--paper);
  font-family: "Songti SC", "STSong", serif;
  font-size: 15px;
  letter-spacing: 10px;
  text-indent: 10px;
}

.ledger-note {
  margin: 22px 0 0;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 2px;
}

.ledger-region,
.timeline {
  width: 100%;
}

.timeline {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 0 24px 58px;
}

.timeline::before {
  position: absolute;
  top: 9px;
  bottom: 0;
  left: 18px;
  width: 1px;
  content: "";
  background: repeating-linear-gradient(
    to bottom,
    rgba(217, 182, 111, 0.44) 0,
    rgba(217, 182, 111, 0.44) 4px,
    transparent 4px,
    transparent 10px
  );
}

.timeline-entry {
  position: relative;
  margin: 0 0 52px;
}

.timeline-entry:last-child {
  margin-bottom: 0;
}

.timeline-node {
  position: absolute;
  top: 8px;
  left: -48px;
  width: 17px;
  height: 17px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 5px rgba(22, 22, 29, 0.94), 0 0 18px rgba(217, 182, 111, 0.12);
}

.timeline-entry[data-status="complete"] .timeline-node::after {
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  content: "";
  background: var(--gold);
  box-shadow: 0 0 11px rgba(217, 182, 111, 0.54);
}

.timeline-entry[data-status="pending"] .timeline-node {
  border-style: dashed;
  opacity: 0.55;
}

.record-button {
  display: block;
  width: 100%;
  padding: 0 0 22px;
  border: 0;
  border-bottom: 1px solid rgba(217, 182, 111, 0.14);
  color: inherit;
  background: transparent;
  text-align: left;
}

.record-button:not(:disabled) {
  cursor: pointer;
}

.record-button:not(:disabled)::after {
  position: absolute;
  top: 7px;
  right: 2px;
  color: rgba(217, 182, 111, 0.55);
  content: "↗";
  font-family: Arial, sans-serif;
  font-size: 14px;
  transition: color 180ms ease, transform 180ms ease;
}

.record-button:not(:disabled):hover::after,
.record-button:not(:disabled):focus-visible::after {
  color: var(--gold);
  transform: translate(2px, -2px);
}

.record-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.record-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 30px 16px 0;
  color: var(--gold);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.record-status {
  padding-left: 15px;
  border-left: 1px solid var(--gold-line);
  color: var(--dim);
}

.record-question {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  letter-spacing: 1px;
}

.record-question strong {
  margin-right: 10px;
  color: var(--gold);
  font-family: "Times New Roman", serif;
  font-size: 14px;
  font-weight: 400;
}

.record-verdict {
  max-width: 640px;
  margin: 0;
  color: var(--paper);
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.7;
  letter-spacing: 1px;
}

.record-type {
  display: block;
  margin-top: 7px;
  color: var(--dim);
  font-family: Arial, sans-serif;
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.mini-deck {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.mini-card {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(217, 182, 111, 0.5);
  border-radius: 2px;
  background:
    linear-gradient(45deg, transparent 46%, rgba(217, 182, 111, 0.42) 47% 53%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, rgba(217, 182, 111, 0.28) 47% 53%, transparent 54%),
    #151a25;
  color: rgba(247, 244, 238, 0.82);
  font-family: "Times New Roman", serif;
  font-size: 7px;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 2px rgba(22, 22, 29, 0.88);
}

.mini-card::after {
  position: absolute;
  inset: 8px 5px;
  border: 1px solid rgba(217, 182, 111, 0.28);
  border-radius: 50%;
  content: "";
}

.mini-card.is-reversed {
  transform: rotate(180deg);
  opacity: 0.58;
}

.mini-card.is-fourth {
  border-color: var(--violet);
  box-shadow: inset 0 0 0 2px rgba(22, 22, 29, 0.88), 0 0 13px rgba(147, 129, 216, 0.28);
}

.pending-copy {
  margin: 9px 0 0;
  color: var(--dim);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 1px;
}

.empty-state {
  max-width: 560px;
  margin: 76px auto 0;
  padding: 52px 24px;
  border: 1px solid rgba(217, 182, 111, 0.16);
  background: rgba(12, 16, 26, 0.2);
  text-align: center;
}

.empty-sigil {
  display: block;
  margin-bottom: 19px;
  color: var(--gold);
  font-family: "Times New Roman", serif;
  font-size: 30px;
}

.empty-state p {
  margin: 0;
  color: var(--paper);
  font-family: "Songti SC", serif;
  font-size: 17px;
  letter-spacing: 4px;
}

.empty-state > span:not(.empty-sigil) {
  display: block;
  margin: 15px 0 30px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 1px;
}

.empty-state a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 21px;
  border: 1px solid var(--gold-line);
  color: var(--gold);
  background: linear-gradient(135deg, rgba(25, 35, 55, 0.66), rgba(12, 16, 27, 0.74));
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 2px;
}

.ledger-footer {
  position: fixed;
  right: 26px;
  bottom: 20px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(154, 156, 163, 0.42);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 1.5px;
  pointer-events: none;
}

.ledger-footer i {
  width: 22px;
  height: 1px;
  background: rgba(217, 182, 111, 0.25);
}

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  z-index: 10;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--gold-line);
  background: var(--bg-deep);
  color: var(--gold);
  text-align: center;
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .back-link,
  .journal-link {
    top: max(17px, env(safe-area-inset-top));
    font-size: 10px;
    letter-spacing: 1px;
  }

  .back-link {
    left: max(8px, env(safe-area-inset-left));
  }

  .journal-link {
    right: max(8px, env(safe-area-inset-right));
  }

  .ledger-shell {
    width: min(100% - 28px, 960px);
    padding-top: 82px;
    padding-bottom: 90px;
  }

  .ledger-header {
    margin-bottom: 56px;
  }

  .ledger-kicker {
    padding-left: 4px;
    font-size: 8px;
    letter-spacing: 3px;
  }

  .ledger-header h1 {
    font-size: clamp(28px, 8vw, 38px);
    letter-spacing: 4px;
    text-indent: 4px;
  }

  .ledger-title-cn {
    font-size: 13px;
    letter-spacing: 7px;
    text-indent: 7px;
  }

  .ledger-note {
    font-size: 9px;
    line-height: 1.8;
  }

  .timeline {
    padding-left: 42px;
  }

  .timeline::before {
    left: 10px;
  }

  .timeline-entry {
    margin-bottom: 43px;
  }

  .timeline-node {
    left: -40px;
    width: 15px;
    height: 15px;
  }

  .record-button:not(:disabled)::after {
    display: none;
  }

  .record-meta {
    flex-wrap: wrap;
    gap: 7px 10px;
    margin-right: 0;
    line-height: 1.7;
  }

  .record-status {
    padding-left: 10px;
  }

  .record-question {
    font-size: 11px;
  }

  .record-verdict {
    font-size: 17px;
  }

  .ledger-footer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
