:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f0f3f8;
  --ink: #171923;
  --muted: #667085;
  --line: #d9dee8;
  --line-strong: #bcc6d6;
  --red: #d92d20;
  --red-soft: #fff1f0;
  --blue: #175cd3;
  --blue-soft: #eff6ff;
  --gold: #b7791f;
  --gold-soft: #fff7e6;
  --green: #027a48;
  --green-soft: #ecfdf3;
  --shadow: 0 18px 45px rgba(20, 32, 54, .10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.65;
  background:
    linear-gradient(90deg, rgba(23, 92, 211, .05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(217, 45, 32, .04) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  margin-right: auto;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: #2f1a05;
  background: var(--gold-soft);
  border: 1px solid #f2d18b;
  border-radius: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
}

.brand-title,
.brand-subtitle {
  display: block;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tab {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.tab:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.tab.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #bfdbfe;
  font-weight: 700;
}

.disclaimer-bar {
  padding: 10px 24px;
  color: #8a1f16;
  background: var(--red-soft);
  border-bottom: 1px solid #ffd2cc;
  font-size: 13px;
  text-align: center;
}

.container {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 70px;
}

.view {
  display: none;
  animation: fade .24s ease;
}

.view.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 430px);
  gap: 26px;
  align-items: start;
}

.hero-copy {
  padding: 38px 0 20px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: 42px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
}

.hero-lead,
.lead {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 680px;
  margin-top: 28px;
}

.metric {
  min-height: 84px;
  padding: 14px;
  background: rgba(255, 255, 255, .75);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
}

.metric small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.gen-panel,
.museum-card,
.chart-box,
.table-wrap,
.about-card,
.method-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.gen-panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading .eyebrow {
  margin-bottom: 6px;
}

.gen-controls {
  display: grid;
  gap: 14px;
}

.gen-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.gen-controls select,
.gen-controls input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.gen-controls select:focus,
.gen-controls input:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 92, 211, .14);
}

.bias-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bias-btn {
  flex: 1;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.bias-btn:hover {
  color: var(--ink);
}

.bias-btn.active[data-bias="hot"] {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.bias-btn.active[data-bias="cold"] {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.primary-btn {
  min-height: 48px;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), #b42318);
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
  transition: transform .12s ease, box-shadow .16s ease, filter .16s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(217, 45, 32, .22);
  filter: saturate(1.04);
}

.primary-btn:active {
  transform: translateY(0);
}

.result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-bottom: 12px;
}

.balls.ticket-list {
  display: grid;
  justify-content: stretch;
  gap: 10px;
}

.ticket-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 9px 10px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-index {
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.ticket-balls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}

.ticket-row .ball {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

.ticket-row .ball.sep {
  width: 10px;
}

.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: #fff;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset -4px -5px 10px rgba(0, 0, 0, .25), 0 8px 18px rgba(20, 32, 54, .16);
  animation: pop .35s ease both;
}

.ball.red {
  background: radial-gradient(circle at 32% 28%, #ff8a8a, var(--red));
}

.ball.blue {
  background: radial-gradient(circle at 32% 28%, #80caff, var(--blue));
}

.ball.sep {
  width: 12px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-weight: 700;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(.55) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.result-meta,
.result-tip {
  margin: 4px 0 0;
  font-size: 13px;
}

.result-meta {
  color: var(--muted);
}

.result-tip {
  color: var(--green);
}

.formula-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.formula-panel > span {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.engine-formula,
.formula {
  margin: 0;
  overflow-x: auto;
  color: var(--ink);
}

.engine-formula .katex-display,
.formula .katex-display {
  margin: 0;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.method-card {
  padding: 18px;
  box-shadow: none;
}

.method-card > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  margin-bottom: 12px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.method-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading .lead {
  margin-top: 8px;
}

.museum-grid {
  display: grid;
  gap: 16px;
}

.museum-card {
  padding: 20px;
}

.museum-card h3 {
  color: var(--ink);
}

.museum-card p {
  color: var(--muted);
}

.museum-card .formula {
  margin: 12px 0;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.museum-card .viz {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.formula-note {
  color: var(--gold);
  font-weight: 800;
}

.ferrers {
  max-height: 240px;
  overflow: auto;
  padding: 12px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid #f2d18b;
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.35;
  white-space: pre;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
}

.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--blue);
}

.range-row .val {
  min-width: 34px;
  color: var(--blue);
  font-weight: 900;
  text-align: right;
}

.chart-box {
  min-height: 320px;
  padding: 18px;
  margin-bottom: 16px;
}

.chart-box h3 {
  margin-bottom: 12px;
}

.chart-box canvas {
  max-height: 280px;
}

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

.disclaimer-inline {
  margin: 12px 0 0;
  padding: 10px 12px;
  color: #8a1f16;
  background: var(--red-soft);
  border: 1px solid #ffd2cc;
  border-radius: 8px;
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.draw-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 14px;
}

.draw-table th,
.draw-table td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.draw-table thead th {
  color: #344054;
  background: var(--surface-soft);
  font-weight: 800;
}

.draw-table tbody tr:hover {
  background: #fafcff;
}

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

.mini-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 2px;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.mini-ball.red {
  background: var(--red);
}

.mini-ball.blue {
  background: var(--blue);
}

.about-card {
  padding: 24px;
  max-width: 900px;
}

.about-card h3 {
  margin-top: 22px;
}

.about-card h3:first-child {
  margin-top: 0;
}

.about-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.site-footer {
  padding: 24px;
  color: var(--muted);
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 13px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

/* 回测控件布局 */
.bt-panel { max-width: none; }
.bt-controls {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}
.bt-controls .primary-btn { min-height: 44px; }
.bt-help {
  margin-top: 10px;
  text-align: left;
}
.bt-summary-wrap,
.bt-chart-box,
.bt-detail-title { margin-top: 18px; }
.bt-detail-title + .table-wrap .draw-table { min-width: 1040px; }

@media (max-width: 920px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .tabs {
    justify-content: flex-start;
  }

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

  .hero-copy {
    padding-top: 12px;
  }

  h1 {
    font-size: 34px;
  }

  .stats-grid,
  .method-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 24px, 1180px);
    padding-top: 22px;
  }

  .site-header {
    padding: 10px 12px;
  }

  .disclaimer-bar {
    padding: 9px 12px;
    text-align: left;
  }

  .tab {
    padding: 6px 9px;
    font-size: 13px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 22px;
  }

  .hero-lead,
  .lead {
    font-size: 15px;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .gen-panel,
  .museum-card,
  .chart-box,
  .about-card {
    padding: 16px;
  }

  .ball {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .ticket-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .ticket-balls {
    justify-content: flex-start;
  }

  .chart-box {
    min-height: 280px;
  }
}
