:root {
  --bg: #f4efe4;
  --panel: rgba(255, 252, 246, 0.94);
  --ink: #182126;
  --muted: #5d676f;
  --line: rgba(24, 33, 38, 0.12);
  --accent: #135d66;
  --accent-soft: rgba(19, 93, 102, 0.12);
  --death: #c44536;
  --ci: #ef8f00;
  --lapse: #2c7a3f;
  --survive: #456173;
  --card-shadow: 0 18px 40px rgba(24, 33, 38, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(19, 93, 102, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(196, 69, 54, 0.16), transparent 24%),
    linear-gradient(180deg, #f7f4ed 0%, var(--bg) 100%);
}

.page-shell {
  max-width: 1460px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1.06;
  max-width: 12ch;
}

.hero-copy {
  margin: 16px 0 0;
  max-width: 70ch;
  color: var(--muted);
  line-height: 1.72;
  font-size: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
}

.hero-note {
  padding: 24px;
}

.principles {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.main-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
}

.panel {
  padding: 22px;
}

.builder-panel { grid-column: span 7; }
.formula-panel { grid-column: span 5; }
.checkpoints-panel { grid-column: span 12; }
.charts-panel { grid-column: span 12; }
.table-panel { grid-column: span 12; }
.examples-panel { grid-column: span 12; }

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

.section-heading h2 {
  font-size: 24px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}

.ghost-button:hover {
  background: rgba(24, 33, 38, 0.05);
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.preset-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 15px;
  background: #e8dfcd;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.preset-button.is-active {
  background: var(--accent);
  color: white;
}

.tokens-wrap {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.token {
  border-radius: 999px;
  padding: 10px 16px;
  color: white;
  font-weight: 700;
  cursor: grab;
  user-select: none;
}

.token:active {
  cursor: grabbing;
}

.token-death { background: var(--death); }
.token-ci { background: var(--ci); }
.token-lapse { background: var(--lapse); }

.helper-text,
.summary-label,
.chart-header span,
.example-card p,
.callout p {
  color: var(--muted);
}

.helper-text {
  margin: 0 0 16px;
  line-height: 1.6;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.month-cell {
  min-height: 86px;
  border: 1px dashed rgba(24, 33, 38, 0.18);
  border-radius: 16px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.6);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.month-cell.is-drop-target {
  border-color: var(--accent);
  background: rgba(19, 93, 102, 0.08);
  transform: translateY(-2px);
}

.month-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.month-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.pill-death { background: var(--death); }
.pill-ci { background: var(--ci); }
.pill-lapse { background: var(--lapse); }
.pill-empty {
  color: var(--muted);
  border: 1px dashed rgba(24, 33, 38, 0.14);
  padding: 8px 12px;
  border-radius: 999px;
}

.scenario-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.formula-block {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(19, 93, 102, 0.06);
  margin-bottom: 12px;
}

.formula-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

code {
  display: block;
  white-space: normal;
  line-height: 1.8;
  font-size: 14px;
  color: var(--ink);
}

.callout {
  margin-top: 18px;
  border-left: 4px solid var(--accent);
  padding: 6px 0 6px 14px;
}

.checkpoint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.checkpoint-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.checkpoint-card h3 {
  font-size: 22px;
  margin-bottom: 6px;
}

.checkpoint-total {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 18px;
}

.driver-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.driver-cell {
  border-radius: 14px;
  padding: 14px;
  background: #fbf9f3;
  border: 1px solid rgba(24, 33, 38, 0.08);
}

.driver-cell strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.driver-value {
  font-size: 24px;
  font-weight: 800;
}

.driver-death strong,
.driver-death .driver-value { color: var(--death); }
.driver-ci strong,
.driver-ci .driver-value { color: var(--ci); }
.driver-lapse strong,
.driver-lapse .driver-value { color: var(--lapse); }

.chart-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chart-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chart-svg {
  width: 100%;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(245, 239, 228, 0.95));
  border: 1px solid rgba(24, 33, 38, 0.1);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(24, 33, 38, 0.1);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1160px;
}

thead {
  background: #efe6d7;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(24, 33, 38, 0.08);
  text-align: right;
  font-size: 14px;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.example-card {
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(24, 33, 38, 0.08);
}

.example-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.example-card p {
  line-height: 1.7;
  margin: 0 0 10px;
}

.example-card button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  cursor: pointer;
}

.legend-row {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

@media (max-width: 1180px) {
  .hero,
  .chart-stack,
  .checkpoint-grid,
  .examples-grid,
  .scenario-summary {
    grid-template-columns: 1fr;
  }

  .builder-panel,
  .formula-panel {
    grid-column: span 12;
  }
}

@media (max-width: 820px) {
  .page-shell {
    padding: 18px 14px 36px;
  }

  .timeline-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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