:root {
  --bg: #0c0a12;
  --surface: #161022;
  --elevated: #1f1830;
  --border: #352848;
  --text: #f0eaf7;
  --text-warm: #e8e6e3;
  --muted: #9a8fb0;
  --gold: #d4af37;
  --gold-dim: #9a7b2e;
  --accent: #b794f6;
  --accent-glow: rgba(212, 175, 55, 0.18);
  --read-max: 42rem;
  --major: #e8d5ff;
  --wand: #c45c3e;
  --cup: #4a90c2;
  --sword: #8b9dc3;
  --pentacle: #6b9e6b;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --panel-soft-bg: rgba(255, 255, 255, 0.02);
  --panel-soft-border: rgba(255, 255, 255, 0.09);
  --panel-soft-radius: 10px;
  --panel-muted-bg: rgba(255, 255, 255, 0.012);
  --panel-muted-border: rgba(255, 255, 255, 0.06);
  --focus: #f0c96b;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.stochastic-panel {
  margin: 0 auto 1rem;
  max-width: 1400px;
  border-color: rgba(212, 175, 55, 0.34);
}

.stochastic-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-kicker {
  margin: 0 0 0.25rem;
  color: var(--gold);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stochastic-head h2 {
  margin: 0;
}

.stochastic-note {
  max-width: 58rem;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.stochastic-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.stochastic-grid label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.stochastic-grid input {
  width: 100%;
}

.stochastic-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.stochastic-metric {
  display: grid;
  gap: 0.18rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--panel-soft-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
}

.stochastic-metric span {
  color: var(--muted);
  font-size: 0.68rem;
}

.stochastic-metric strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1rem;
}

@media (max-width: 900px) {
  .stochastic-grid,
  .stochastic-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stochastic-scan {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--panel-soft-border);
}

.stochastic-scan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
}

.stochastic-scan-head h3 {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text);
}

.stochastic-scan-hint {
  color: var(--muted);
  font-size: 0.7rem;
}

.stochastic-charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.65rem;
}

.stochastic-chart-card {
  margin: 0;
  padding: 0.6rem 0.7rem 0.45rem;
  border: 1px solid var(--panel-soft-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
}

.stochastic-chart-card figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
}

.stochastic-chart-card figcaption span { color: var(--muted); }
.stochastic-chart-card figcaption strong { color: var(--gold); font-weight: 600; }

.stochastic-chart {
  display: block;
  width: 100%;
  height: 72px;
  margin-top: 0.4rem;
}

.model-scope-note {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.65rem;
  border-left: 2px solid rgba(212, 175, 55, 0.5);
  border-radius: 0 var(--panel-soft-radius) var(--panel-soft-radius) 0;
  background: var(--panel-muted-bg);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.model-scope-note strong { color: var(--text-warm); }

@media (max-width: 900px) {
  .stochastic-charts { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .stochastic-head { flex-direction: column; }
  .stochastic-head .ghost { width: 100%; }
  .stochastic-grid,
  .stochastic-metrics { grid-template-columns: 1fr; }
}

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

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #2a1f40 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.55;
}

::selection {
  background: rgba(212, 175, 55, 0.28);
  color: #fff;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

a:hover {
  color: var(--gold);
  text-shadow: 0 0 10px var(--accent-glow);
}

/* 长文阅读区：限制行宽，公式与正文不挤成一团 */
.reading-prose {
  max-width: var(--read-max);
  margin-left: auto;
  margin-right: auto;
}

.reading-prose p {
  margin: 0 0 1.15em;
}

.reading-prose p:last-child {
  margin-bottom: 0;
}

.section-divider {
  text-align: center;
  margin: 1.75rem 0;
  color: var(--gold-dim);
  font-size: 0.85rem;
  letter-spacing: 0.45em;
  opacity: 0.75;
  user-select: none;
}

.physics-panel .section-divider {
  margin: 0.5rem 0 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.35em;
}

.katex,
.katex-display,
.katex .mord,
.katex .mop,
.katex .mbin,
.katex .mrel {
  color: var(--text-warm);
}

.cn-compliance-banner {
  border-bottom: 1px solid rgba(212, 175, 55, 0.32);
  background: linear-gradient(
    180deg,
    rgba(110, 28, 42, 0.45) 0%,
    rgba(22, 16, 34, 0.92) 100%
  );
  color: var(--text);
  padding: 0.55rem 0.75rem 0.6rem;
}

.cn-compliance-banner-inner {
  max-width: 40rem;
  margin: 0 auto;
  font-size: 0.68rem;
  line-height: 1.52;
  text-align: center;
  text-wrap: balance;
}

.cn-compliance-banner-inner p {
  margin: 0 0 0.38rem;
}

.cn-compliance-banner-inner p:last-child {
  margin-bottom: 0;
}

.cn-compliance-banner-inner strong {
  color: var(--gold-dim);
  font-weight: 600;
}

.cn-compliance-banner-minor {
  font-size: 0.64rem;
  color: var(--muted);
  opacity: 0.95;
}

.cn-compliance-banner-minor strong {
  color: var(--major);
}

.app-header {
  text-align: center;
  padding: 1.1rem 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(45, 32, 68, 0.5), transparent);
  position: relative;
}

.app-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.55), transparent);
  pointer-events: none;
}

.app-header-taglines {
  max-width: 28rem;
  margin: 0 auto;
  text-align: center;
}

.app-tagline-main {
  margin: 0;
  font-size: clamp(0.85rem, 2.1vw, 1.02rem);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold);
  line-height: 1.45;
}

.app-tagline-sub {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  line-height: 1.65;
  color: var(--muted);
  text-wrap: balance;
}

.app-header h1 {
  margin: 0.85rem 0 0;
  font-weight: 600;
  font-size: clamp(1.35rem, 3vw, 1.65rem);
  letter-spacing: 0.06em;
  color: var(--gold);
}

.app-header p {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.ui-mode-switch {
  margin: 0.8rem auto 0;
  display: inline-flex;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.2rem;
}

.ui-mode-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.ui-mode-btn.is-active {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.4);
  background: rgba(212, 175, 55, 0.12);
}

.mode-hint {
  margin: 0.55rem auto 0;
  max-width: 42rem;
  font-size: 0.73rem;
  line-height: 1.55;
  color: var(--muted);
}

.mode-hint-newbie,
.mode-hint-pro {
  display: none;
}

body[data-ui-mode="newbie"] .mode-hint-newbie,
body[data-ui-mode="pro"] .mode-hint-pro {
  display: inline;
}

.guide-strip {
  padding: 0.7rem 0.9rem;
}

.guide-strip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}

.guide-strip-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.guide-strip-head h2 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

#guide-strip-status {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.guide-strip-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.guide-step-btn {
  font-size: 0.78rem;
  padding: 0.5rem 0.45rem;
}

.guide-step-btn.is-done {
  border-color: rgba(120, 197, 138, 0.45);
  color: #97d9a8;
  background: rgba(60, 145, 82, 0.18);
}

.layout {
  max-width: min(96rem, 100%);
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .layout-main {
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr) minmax(15rem, 20rem);
    align-items: start;
    gap: 1.25rem;
  }
}

.layout-center {
  min-width: 0;
}

.mobile-tabbar {
  display: none;
}

.physics-panel {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.5) rgba(255, 255, 255, 0.04);
}

/* 控制台、数据指标、矩阵等：左对齐便于扫读 */
.physics-panel .physics-console-wrap,
.physics-panel .field-row,
.physics-panel .physics-console-row,
.physics-panel .console-group,
.physics-panel .physics-exp-controls,
.physics-panel .physics-script-controls,
.physics-panel .physics-script-input,
.physics-panel .physics-history-list,
.physics-panel .physics-history-item,
.physics-panel .physics-history-detail,
.physics-panel .physics-exp-rows,
.physics-panel .physics-exp-row,
.physics-panel .physics-exp-status,
.physics-panel .physics-exp-summary,
.physics-panel .physics-op-status,
.physics-panel .physics-op-metrics,
.physics-panel .physics-op-row,
.physics-panel .physics-state-meta,
.physics-panel .physics-state-metrics,
.physics-panel .physics-metric-item,
.physics-panel .physics-approx-note,
.physics-panel .physics-console-status,
.physics-panel #physics-label-metrics,
.physics-panel #physics-joint2-body,
.physics-panel #noise-exp-body,
.physics-panel .physics-state-prob,
.physics-panel .physics-prob-item,
.physics-panel .hilbert-matrix-details,
.physics-panel .hilbert-matrix-toolbar,
.physics-panel .matrix-table-wrap,
.physics-panel table {
  text-align: left;
}

.physics-panel::-webkit-scrollbar {
  width: 6px;
}

.physics-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.physics-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.58), rgba(183, 148, 246, 0.45));
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.physics-panel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.72), rgba(183, 148, 246, 0.62));
}

.physics-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
}

.physics-panel-head h2 {
  margin: 0;
  width: 100%;
  text-align: center;
  text-transform: none;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: var(--muted);
  border-bottom: none;
  padding-bottom: 0;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
}

button.ghost:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

/* 右侧物理面板按钮：弱化“透明感”，统一成可识别控件样式 */
.physics-panel button.ghost {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.015);
  color: rgba(240, 234, 247, 0.9);
}

.physics-panel button.ghost:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.045);
}

.physics-panel-lead {
  margin: 0 auto 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: var(--read-max);
}

.physics-state-board {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--panel-soft-radius);
  background: rgba(0, 0, 0, 0.12);
}

.physics-console-wrap {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid var(--panel-muted-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
}

.physics-console-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin-bottom: 0.34rem;
}

.physics-console-head h4 {
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.8);
  letter-spacing: 0.04em;
}

.physics-console-row {
  margin-bottom: 0.3rem;
}

.physics-console-row input[type="number"] {
  width: 4.7rem;
}

.console-group {
  margin: 0 0 var(--space-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.012);
  padding: 0.4rem 0.45rem;
}

.console-group > summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.86);
  letter-spacing: 0.03em;
}

.console-group-actions {
  margin: 0.38rem 0 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
}

.console-effective {
  font-size: 0.7rem;
  color: var(--muted);
}

.console-hint {
  font-size: 0.68rem;
  color: var(--muted);
}

.console-warn {
  font-size: 0.68rem;
  color: #e9ba7d;
}

.physics-state-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.25rem;
}

.physics-state-head h3 {
  width: 100%;
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(240, 234, 247, 0.9);
  letter-spacing: 0.06em;
}

.physics-state-meta {
  margin: 0 0 var(--space-2);
  font-size: 0.74rem;
  color: var(--muted);
}

.physics-approx-note {
  margin: 0 0 0.45rem;
  font-size: 0.66rem;
  color: #f2d58b;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 7px;
  background: rgba(212, 175, 55, 0.08);
  padding: 0.28rem 0.4rem;
}

.physics-state-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem var(--space-2);
  margin-bottom: var(--space-2);
}

.physics-metric-item {
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.01);
}

.physics-metric-name {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
}

.term-chip {
  text-decoration: underline dotted rgba(212, 175, 55, 0.55);
  text-underline-offset: 2px;
  cursor: help;
}

.physics-metric-value {
  margin-top: 0.14rem;
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
}

.physics-state-prob-wrap h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.physics-state-prob {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.physics-label-wrap,
.physics-insight-wrap,
.physics-joint2-wrap,
.physics-noise-wrap {
  margin-top: var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid var(--panel-muted-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
}

.physics-newbie-more-wrap {
  margin-top: var(--space-3);
  display: none;
}

.physics-newbie-more-wrap button {
  width: 100%;
}

.physics-label-wrap h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.78);
  letter-spacing: 0.04em;
}

.physics-insight-output {
  margin: 0 auto;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  min-height: 4.4rem;
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text-warm);
  max-width: var(--read-max);
  text-align: center;
}

.physics-exp-wrap {
  margin-top: var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid var(--panel-muted-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
}

.physics-exp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin-bottom: 0.35rem;
}

.physics-panel .physics-exp-head h4,
.physics-panel .physics-op-head h4,
.physics-panel .physics-history-head h4,
.physics-panel .physics-script-head h4,
.physics-panel .physics-label-wrap h4,
.physics-panel .physics-state-prob-wrap h4 {
  width: 100%;
  text-align: center;
}

.physics-exp-head h4 {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.78);
  letter-spacing: 0.04em;
}

.physics-exp-controls {
  margin-bottom: 0.35rem;
}

.physics-exp-controls input {
  width: 4.3rem;
}

.physics-exp-status {
  margin: 0 0 0.28rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.physics-exp-summary {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
}

.physics-exp-rows {
  margin-top: 0.28rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.physics-exp-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.72rem;
}

.physics-exp-row-label {
  color: var(--muted);
}

.physics-exp-row-val {
  color: var(--text);
}

.physics-op-wrap {
  margin-top: var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid var(--panel-muted-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
  width: 100%;
  align-self: stretch;
}

.physics-op-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin-bottom: 0.3rem;
}

.physics-op-head h4 {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.78);
  letter-spacing: 0.04em;
}

.physics-op-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
}

.physics-op-status {
  margin: 0 0 0.32rem;
  width: 100%;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: left;
}

.physics-op-metrics {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  width: 100%;
  align-self: stretch;
  text-align: left;
}

.physics-op-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  font-size: 0.72rem;
  align-items: center;
  width: 100%;
  text-align: left;
}

.physics-op-row span:first-child {
  color: var(--muted);
}

.physics-op-row span:last-child {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.physics-history-wrap {
  margin-top: var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: var(--panel-soft-radius);
  background: rgba(255, 255, 255, 0.008);
}

.physics-history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin-bottom: 0.3rem;
}

.physics-history-head h4 {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.74);
  letter-spacing: 0.04em;
}

.physics-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  max-height: 8.4rem;
  overflow-y: auto;
  padding-right: 0.2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(183, 148, 246, 0.5) rgba(255, 255, 255, 0.03);
}

.physics-history-list::-webkit-scrollbar {
  width: 5px;
}

.physics-history-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.physics-history-list::-webkit-scrollbar-thumb {
  background: rgba(183, 148, 246, 0.58);
  border-radius: 6px;
}

.physics-history-list::-webkit-scrollbar-thumb:hover {
  background: rgba(183, 148, 246, 0.72);
}

.physics-history-item {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.32rem 0.42rem;
  font-size: 0.72rem;
  color: var(--text);
}

.physics-history-item.is-active {
  border-color: rgba(183, 148, 246, 0.45);
  background: rgba(183, 148, 246, 0.12);
}

.physics-history-item small {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
}

.physics-history-detail {
  margin-top: 0.34rem;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.38rem 0.42rem;
  white-space: pre-wrap;
}

.physics-script-wrap {
  margin-top: var(--space-3);
  padding: var(--space-2) calc(var(--space-2) + 0.05rem);
  border: 1px solid var(--panel-muted-border);
  border-radius: var(--panel-soft-radius);
  background: var(--panel-muted-bg);
}

.physics-script-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.45rem;
  margin-bottom: 0.3rem;
}

.physics-script-head h4 {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(240, 234, 247, 0.78);
  letter-spacing: 0.04em;
}

.physics-script-controls {
  margin-bottom: 0.35rem;
}

.physics-script-controls input[type="number"] {
  width: 5.1rem;
}

.physics-script-input {
  width: 100%;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  padding: 0.45rem 0.5rem;
  resize: vertical;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.45) rgba(255, 255, 255, 0.03);
}

.physics-script-input::-webkit-scrollbar {
  width: 6px;
}

.physics-script-input::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.physics-script-input::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.5);
  border-radius: 6px;
}

.physics-script-input::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.68);
}

.physics-script-status {
  margin: 0.32rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.physics-log-details {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
}

body[data-ui-mode="newbie"] [data-advanced] {
  display: none !important;
}

body[data-ui-mode="newbie"] [data-newbie-hide] {
  display: none !important;
}

body[data-ui-mode="newbie"] .physics-console-wrap {
  display: none !important;
}

body[data-ui-mode="newbie"] .physics-newbie-more-wrap {
  display: block;
}

body[data-ui-mode="pro"] #btn-upgrade-pro {
  display: none !important;
}

.term-tooltip {
  position: fixed;
  z-index: 380;
  max-width: min(20rem, calc(100vw - 1.2rem));
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.38);
  background: linear-gradient(170deg, #1e1a2a, #15111f);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.4;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.physics-prob-item {
  display: grid;
  grid-template-columns: 2.65rem 1fr 2.55rem;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.66rem;
  color: var(--text);
}

.physics-prob-bar {
  height: 0.33rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.physics-prob-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.88), rgba(183, 148, 246, 0.92));
}

/* 量子栏滚动条：细、暗色轨道，避免原生粗白条 */
.physics-log-details {
  margin-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  padding-top: 0.5rem;
}

.physics-log-details > summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.physics-log-details[open] > summary {
  color: rgba(240, 234, 247, 0.86);
}

.physics-steps {
  flex: 1;
  min-height: 0;
  max-height: 14rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.55rem 0.4rem 0.2rem 0;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.45) rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  overscroll-behavior: contain;
}

.physics-steps::-webkit-scrollbar {
  width: 5px;
}

.physics-steps::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  margin: 2px 0;
}

.physics-steps::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.5), rgba(212, 175, 55, 0.22));
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.physics-steps::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.55);
}

.physics-step {
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-top: 2px solid rgba(212, 175, 55, 0.4);
  padding: 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
}

.physics-step-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-bottom: 0.55rem;
  line-height: 1.4;
}

.physics-step-formulas {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-warm);
}

/* 侧栏内公式：深色主题下统一颜色与字号 */
.physics-panel .katex,
.physics-panel .katex-display,
.physics-panel .mjx-chtml {
  color: var(--text-warm) !important;
}

.physics-panel .physics-step-formulas .katex {
  font-size: clamp(0.72rem, 0.66rem + 0.3vw, 0.84rem);
}

.physics-panel .physics-step-formulas .katex-display {
  margin: 0.35rem auto;
  text-align: center;
}

.physics-panel .physics-step-formulas .katex-display-wrap {
  text-align: center;
}

.physics-panel .physics-step-formulas .katex-inline-wrap {
  text-align: center;
}

.physics-step-formulas .katex-display-wrap + .katex-inline-wrap,
.physics-step-formulas .katex-display-wrap + .katex-display-wrap {
  margin-top: 0.65rem;
}

.physics-step-formulas .katex-display-wrap:first-child {
  margin-top: 0.35rem;
}

.katex-inline-wrap {
  display: block;
  margin-top: 0.45rem;
  padding-top: 0.25rem;
  line-height: 1.5;
  color: var(--text-warm);
}

/* 独立公式卡片：与正文拉开层次 */
.katex-display-wrap,
.math-block {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 0.85rem 1rem;
  margin: 0.65rem 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 8, 18, 0.55);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  scrollbar-width: thin;
  scrollbar-color: rgba(183, 148, 246, 0.45) rgba(255, 255, 255, 0.04);
}

.katex-display-wrap::-webkit-scrollbar {
  height: 4px;
}

.katex-display-wrap::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.katex-display-wrap::-webkit-scrollbar-thumb {
  background: rgba(183, 148, 246, 0.45);
  border-radius: 4px;
}

.katex-display-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(183, 148, 246, 0.65);
}

.physics-step-note {
  margin: 0.75rem 0 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.6;
}

.hilbert-matrix-details {
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hilbert-matrix-details > summary {
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.hilbert-matrix-lead {
  margin: 0.55rem 0 0.5rem;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.4;
}

.hilbert-matrix-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.55rem;
}

.hilbert-matrix-field {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.hilbert-matrix-field input,
.hilbert-matrix-field select {
  font-size: 0.78rem;
}

.matrix-title-katex {
  margin: 0.35rem 0;
  font-size: 0.85rem;
}

.matrix-sigma-note {
  margin: 0.2rem 0 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  margin: 0 0 0.55rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.matrix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.matrix-legend-dot {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.matrix-table-wrap {
  max-width: 100%;
  overflow: auto;
  max-height: min(72vh, 30rem);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.4rem;
  /* 整张 78×78 横向滚动 */
  overscroll-behavior: contain;
}

.matrix-heatmap {
  --matrix-cell: 5px;
  display: grid;
  grid-template-columns: repeat(var(--matrix-n, 78), var(--matrix-cell));
  grid-auto-rows: var(--matrix-cell);
  gap: 1px;
  width: max-content;
  max-width: none;
  margin: 0 auto;
}

.matrix-cell {
  width: var(--matrix-cell);
  height: var(--matrix-cell);
  box-sizing: border-box;
  flex-shrink: 0;
  border-radius: 1px;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.matrix-cell--one {
  background: linear-gradient(145deg, #e8c547, #b8922e);
}

.matrix-cell--minus_one {
  background: linear-gradient(145deg, #e85555, #a83232);
}

.matrix-cell--zero {
  background: rgba(28, 26, 38, 0.92);
}

.matrix-cell--i {
  background: linear-gradient(145deg, #9b7aed, #5c3daf);
}

.matrix-cell--minus_i {
  background: linear-gradient(145deg, #3dc9d8, #1d7a88);
}

.matrix-cell--other {
  background: repeating-linear-gradient(
    -45deg,
    rgba(160, 140, 100, 0.55),
    rgba(160, 140, 100, 0.55) 3px,
    rgba(80, 70, 55, 0.65) 3px,
    rgba(80, 70, 55, 0.65) 6px
  );
}

.matrix-footnote {
  margin: 0.45rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.panel:hover {
  border-color: rgba(212, 175, 55, 0.22);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.panel h2 {
  margin: 0 0 0.65rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.35rem;
}

.deck-stat {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold);
  margin: 0.25rem 0 0.6rem;
  transition: color 0.2s ease;
}

@keyframes deck-stat-pulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.07);
    color: var(--accent);
    text-shadow: 0 0 12px rgba(183, 148, 246, 0.45);
  }
  100% {
    transform: scale(1);
  }
}

.deck-stat--tick #deck-remaining {
  display: inline-block;
  animation: deck-stat-pulse 0.48s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.deck-stat small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

.ai-panel {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.ai-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.ai-input {
  width: 100%;
  resize: vertical;
  min-height: 4.2rem;
  background: #0e0c14;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0.45rem;
}

.ai-status {
  margin: 0.4rem 0 0.35rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.ai-output {
  margin: 0;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  min-height: 4.4rem;
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text-warm);
  max-width: var(--read-max);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button, .btn {
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s ease, box-shadow 0.15s ease;
}

button:active, .btn:active {
  transform: scale(0.97);
}

button:hover, .btn:hover {
  border-color: var(--gold-dim);
  background: #262035;
}

/* 延迟说明浮层出现时，加强按钮高亮 */
button.help-tip-active {
  border-color: var(--gold) !important;
  background: #2a2238 !important;
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.45), 0 6px 20px rgba(0, 0, 0, 0.35);
  color: var(--text);
}

button.primary.help-tip-active {
  background: linear-gradient(160deg, #4a3868, #322850) !important;
  color: var(--gold);
}

button.danger.help-tip-active {
  border-color: #c07070 !important;
  box-shadow: 0 0 0 1px rgba(224, 160, 160, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
}

button.ghost.help-tip-active {
  border-color: var(--gold-dim) !important;
  background: rgba(212, 175, 55, 0.12) !important;
  color: var(--gold);
}

#help-tooltip.help-tooltip,
.help-tooltip {
  position: fixed;
  z-index: 300;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  background: linear-gradient(165deg, #1e2030, #15121c);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

button.primary {
  background: linear-gradient(160deg, #3d2d5c, #2a2040);
  border-color: var(--gold-dim);
  color: var(--gold);
}

button.primary:hover {
  border-color: var(--gold);
}

button.danger {
  border-color: #6b3030;
  color: #e8a0a0;
}

input[type="number"], select {
  background: #0e0c14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
  font-size: 0.88rem;
}

label.inline {
  font-size: 0.82rem;
  color: var(--muted);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.spread-zone .field-row:last-child {
  margin-bottom: 0;
}

.shuffle-hint {
  margin: 0 0 0.65rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  transition: opacity 0.35s ease;
}

.shuffle-hint:not([hidden]) {
  animation: hint-breathe 2.8s ease-in-out infinite;
}

@keyframes hint-breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.78;
  }
}

.shuffle-hint[hidden] {
  display: none !important;
}

.spread-draw-one-row {
  align-items: center;
}

.spread-one-status {
  flex: 1;
  min-width: 8rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.timeflow-controls {
  margin-bottom: 0.55rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid rgba(212, 175, 55, 0.24);
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.05);
}

.range-inline {
  flex: 1;
  min-width: 140px;
  accent-color: var(--gold);
}

.reading-board {
  min-height: 8rem;
  transition: box-shadow 0.35s ease;
}

.reading-board.reading-board--peek {
  animation: reading-board-glow 0.55s ease;
}

@keyframes reading-board-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
  }
  40% {
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.28), 0 8px 40px rgba(0, 0, 0, 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
  }
}

.reading-placeholder {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 2rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.reading-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: center;
}

.position-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  max-width: 11rem;
}

.position-label {
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-align: center;
}

.position-label--pending {
  color: var(--muted);
}

/* —— 抽牌动效（批量交错 / 单张落下） —— */
@keyframes deal-card-in {
  from {
    opacity: 0;
    transform: translateY(1.35rem) scale(0.88) rotate(-2.5deg);
    filter: blur(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
    filter: blur(0);
  }
}

@keyframes deal-card-glow {
  0%,
  100% {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  }
  50% {
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5), 0 0 28px rgba(212, 175, 55, 0.14),
      0 0 20px rgba(183, 148, 246, 0.08);
  }
}

@keyframes deal-label-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes deal-img-unveil {
  from {
    filter: brightness(0.5) saturate(0.8);
  }
  to {
    filter: brightness(1) saturate(1);
  }
}

@keyframes deal-single-slap {
  from {
    opacity: 0;
    transform: translateY(2.2rem) scale(0.72) rotate(-7deg);
  }
  55% {
    opacity: 1;
    transform: translateY(-6px) scale(1.04) rotate(2deg);
  }
  to {
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.position-slot--deal-batch .position-label {
  animation: deal-label-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--slot-i, 0) * 0.07s);
}

.reading-cards .tarot-card.tarot-card--deal-in {
  animation: deal-card-in 0.58s cubic-bezier(0.22, 1, 0.36, 1) backwards,
    deal-card-glow 1.5s ease-out 0.15s;
  animation-delay: calc(var(--deal-i, 0) * 0.085s);
  will-change: transform, opacity, filter;
}

.reading-cards .tarot-card.tarot-card--deal-in .tarot-card-visual img {
  animation: deal-img-unveil 0.65s ease backwards;
  animation-delay: calc(var(--deal-i, 0) * 0.085s + 0.1s);
}

.position-slot--deal-single .tarot-card {
  animation: deal-single-slap 0.65s cubic-bezier(0.34, 1.35, 0.64, 1) both;
  will-change: transform;
}

.position-slot--deal-single .position-label {
  animation: deal-label-in 0.4s ease backwards;
}

@media (prefers-reduced-motion: reduce) {
  .tarot-card--deal-in,
  .tarot-card--deal-in .tarot-card-visual img,
  .position-slot--deal-batch .position-label,
  .position-slot--deal-single .tarot-card,
  .position-slot--deal-single .position-label,
  .deck-stat--tick #deck-remaining,
  .reading-board--peek,
  .shuffle-hint:not([hidden]) {
    animation: none !important;
  }

  .panel:hover {
    transform: none;
  }

  button:active,
  .btn:active {
    transform: none;
  }

  .reading-cards .tarot-card:hover {
    transform: none;
  }
}

.tarot-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 11rem;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.tarot-card--flip {
  cursor: pointer;
  perspective: 1200px;
}

.tarot-card--flip .tarot-card-inner {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.64s cubic-bezier(0.2, 0.75, 0.2, 1);
}

.tarot-card--flip.is-flipped .tarot-card-inner {
  transform: rotateY(180deg);
}

.tarot-card-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tarot-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.45);
  background:
    radial-gradient(circle at 50% 30%, rgba(212, 175, 55, 0.2), transparent 48%),
    repeating-linear-gradient(
      45deg,
      rgba(183, 148, 246, 0.18),
      rgba(183, 148, 246, 0.18) 7px,
      rgba(35, 22, 55, 0.72) 7px,
      rgba(35, 22, 55, 0.72) 14px
    ),
    linear-gradient(160deg, #221533, #120d1a);
  box-shadow: inset 0 0 0 2px rgba(212, 175, 55, 0.2);
  transform: rotateY(0deg);
}

.tarot-card-back::before {
  content: "✶";
  font-size: 2rem;
  color: rgba(212, 175, 55, 0.82);
  text-shadow: 0 0 14px rgba(212, 175, 55, 0.35);
}

.tarot-card-front {
  transform: rotateY(180deg);
}

.tarot-card--flip:not(.is-flipped) .tarot-card-front {
  pointer-events: none;
}

.reading-cards .tarot-card:hover {
  border-color: rgba(212, 175, 55, 0.22);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(183, 148, 246, 0.06);
  transform: translateY(-3px);
}

.tarot-card-visual {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: #0e0c14;
  transition: transform 0.35s ease;
}

.tarot-card-visual.is-reversed {
  transform: rotate(180deg);
}

.tarot-card-visual img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 20rem;
  object-fit: cover;
  vertical-align: middle;
}

.tarot-card--compact .tarot-card-visual img {
  max-height: 6.5rem;
}

.tarot-card-caption {
  padding: 0.45rem 0.3rem 0.35rem;
  flex: 1;
  position: relative;
}

.tarot-card .zh {
  font-size: clamp(0.85rem, 2.6vw, 1.02rem);
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
}

.card-prob {
  display: inline-block;
  font-size: 0.58rem;
  line-height: 1;
  padding: 0.12rem 0.28rem;
  border-radius: 999px;
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.42);
  background: rgba(14, 10, 23, 0.72);
  transform: translateY(-1px);
}

.tarot-card .en {
  font-size: 0.6rem;
  color: rgba(240, 234, 247, 0.72);
  text-align: center;
  line-height: 1.2;
}

.tarot-card .meta-row {
  font-size: 0.58rem;
  color: rgba(240, 234, 247, 0.55);
  text-align: center;
  margin-top: 0.15rem;
}

.rev-badge {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
  font-size: 0.6rem;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  background: rgba(20, 12, 30, 0.92);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
}

.tarot-card.suit-major .tarot-card-caption {
  background: linear-gradient(180deg, #2a1f38, #161018);
}

.tarot-card.suit-wands .tarot-card-caption {
  background: linear-gradient(180deg, #3d231c, #151210);
}

.tarot-card.suit-cups .tarot-card-caption {
  background: linear-gradient(180deg, #1e3548, #101418);
}

.tarot-card.suit-swords .tarot-card-caption {
  background: linear-gradient(180deg, #283448, #101418);
}

.tarot-card.suit-pentacles .tarot-card-caption {
  background: linear-gradient(180deg, #243628, #101510);
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.55rem;
  max-height: 22rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.gallery-grid .tarot-card {
  max-width: none;
  cursor: default;
}

.gallery-grid .tarot-card .zh {
  font-size: 0.72rem;
}

.section-toggle {
  margin-top: 0.75rem;
}

footer.site-footer {
  text-align: center;
  padding: 1.35rem 1rem 1.75rem;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, rgba(22, 16, 34, 0.6), transparent);
  max-width: 44rem;
  margin: 0 auto;
}

.tbk-footer {
  margin: 0 0 1.1rem;
  padding: 0.85rem 0.75rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(10, 8, 18, 0.45);
  text-align: center;
}

.tbk-footer-title {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
}

.tbk-footer-disclosure {
  margin: 0 0 0.75rem;
  font-size: 0.68rem;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: balance;
}

.tbk-footer-disclosure strong {
  color: var(--text);
  font-weight: 600;
}

.tbk-footer-pending {
  display: block;
  margin-top: 0.35rem;
  color: #e9ba7d;
}

.tbk-footer-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.55rem;
}

.tbk-footer-item {
  margin: 0;
  min-width: 0;
}

.tbk-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  height: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
  text-decoration: none;
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

a.tbk-card.is-live:hover {
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.tbk-card.is-placeholder {
  opacity: 0.82;
  border-style: dashed;
  cursor: default;
}

.tbk-card-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-warm);
  line-height: 1.35;
}

.tbk-card-desc {
  flex: 1;
  font-size: 0.64rem;
  line-height: 1.45;
  color: var(--muted);
}

.tbk-card-cta {
  margin-top: 0.15rem;
  font-size: 0.64rem;
  color: var(--gold-dim);
  letter-spacing: 0.04em;
}

a.tbk-card.is-live .tbk-card-cta {
  color: var(--gold);
}

.tbk-footer-config-hint {
  margin: 0.65rem 0 0;
  font-size: 0.62rem;
  line-height: 1.5;
  color: var(--muted);
}

.tbk-footer-config-hint code {
  font-size: 0.9em;
  color: rgba(240, 234, 247, 0.85);
}

.site-footer-disclaimer {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.22);
  background: rgba(212, 175, 55, 0.05);
  color: var(--text);
  font-size: 0.7rem;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}

.site-footer-meta {
  text-align: left;
  margin: 0 auto;
  max-width: 40rem;
  font-size: 0.68rem;
  line-height: 1.55;
}

.site-footer-meta p {
  margin: 0 0 0.65rem;
}

.site-footer-meta p:last-child {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--elevated);
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 50;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 959px) {
  body {
    padding-bottom: calc(4.7rem + env(safe-area-inset-bottom, 0px));
  }

  .layout {
    padding: 0.72rem;
    gap: 0.72rem;
  }

  .layout-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.72rem;
  }

  .panel {
    padding: 0.78rem 0.8rem;
    border-radius: 10px;
  }

  .physics-panel {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }

  .physics-state-metrics {
    grid-template-columns: 1fr;
  }

  .guide-strip-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .physics-exp-controls input {
    width: 4rem;
  }

  .layout-main[data-mobile-view] > [data-mobile-panel] {
    display: none;
  }

  .layout-main[data-mobile-view] > [data-mobile-panel].is-active {
    display: block;
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(10px);
    background: linear-gradient(180deg, rgba(27, 20, 40, 0.96), rgba(20, 15, 30, 0.92));
  }

  .mobile-tabbar[data-mobile-view] {
    display: flex;
    position: fixed;
    left: 0.6rem;
    right: 0.6rem;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    padding: 0.45rem;
    border-radius: 14px;
    background: rgba(19, 14, 28, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.25);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    gap: 0.45rem;
  }

  .mobile-tabbar-item {
    flex: 1;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    padding: 0.5rem 0.4rem;
  }

  .mobile-tabbar-item.is-active {
    color: var(--gold);
    border-color: rgba(212, 175, 55, 0.42);
    background: linear-gradient(180deg, rgba(76, 55, 108, 0.5), rgba(44, 32, 65, 0.5));
  }

  .reading-cards {
    gap: 0.6rem;
    justify-content: center;
  }

  .position-slot {
    width: min(45vw, 10rem);
    max-width: none;
  }

  .tarot-card {
    max-width: none;
  }

  .tarot-card-visual img {
    max-height: none;
  }

  input[type="number"],
  select,
  button,
  .btn {
    font-size: 0.84rem;
  }

  .field-row {
    gap: 0.38rem;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0.85rem 0.65rem 0.8rem;
  }

  .cn-compliance-banner {
    padding: 0.46rem 0.55rem;
  }

  .cn-compliance-banner-inner {
    font-size: 0.64rem;
  }

  .deck-stat {
    font-size: 1.55rem;
  }

  .reading-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .position-slot {
    width: 100%;
  }

  .position-label {
    font-size: 0.68rem;
  }

  .tarot-card .zh {
    font-size: 0.92rem;
  }

  .tarot-card .en {
    font-size: 0.56rem;
  }

  .tarot-card .meta-row {
    font-size: 0.55rem;
  }

  .title-row {
    gap: 0.28rem;
  }

  .card-prob {
    font-size: 0.54rem;
    padding: 0.1rem 0.24rem;
  }

  .toast {
    width: min(92vw, 23rem);
    text-align: center;
  }
}
