/* ECON-ENG Hub — Professional Engineering Economics Platform */
/* Phase 2: Advanced Typography & Layout System */

:root {
  /* Professional Color System */
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --surface: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0ea5e9;
  --accent-dim: #0284c7;
  --warm: #38bdf8;
  --success: #10b981;
  --danger: #f43f5e;
  --formula-bg: #f0f9ff;
  --formula-border: #bae6fd;
  
  /* Spacing System */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Typography Scale */
  --font-sans: "Inter", "Roboto", "DM Sans", system-ui, -apple-system, sans-serif;
  --font-display: "Inter", "Roboto", "DM Sans", system-ui, -apple-system, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  
  --radius: 16px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow: 0 4px 24px rgba(14, 165, 233, 0.08);
  --shadow-lg: 0 12px 40px rgba(14, 165, 233, 0.12);
  --shadow-glow: 0 0 40px rgba(14, 165, 233, 0.15);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark theme - Futuristic */
body.theme-dark {
  --bg: #030712;
  --bg-elev: #0f172a;
  --surface: #1e293b;
  --border: #1e3a5f;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --warm: #7dd3fc;
  --success: #34d399;
  --danger: #fb7185;
  --formula-bg: #0c4a6e;
  --formula-border: #0369a1;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 60px rgba(56, 189, 248, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 全局图像和图表基础样式 - 确保比例正常 */
img,
canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Canvas 图表样式 */
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* 图表类 SVG 样式 */
.chart-container svg,
.viz-wrapper svg,
.figure-wrap svg,
.illustration-card svg,
.viz-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: var(--text-base);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Engineering Grid Background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(14, 165, 233, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 165, 233, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: -1;
  opacity: 0.5;
}

body.theme-dark::before {
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  opacity: 0.8;
}

/* Dark mode background glow effects */
body.theme-dark::after {
  content: "";
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse at 0% 0%, rgba(56, 189, 248, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(56, 189, 248, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  z-index: 1000;
}

/* Main Container */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-3xl);
}

/* Header / Navigation */
.site-header {
  position: sticky;
  top: var(--space-sm);
  z-index: 50;
  margin: var(--space-sm) auto 0;
  max-width: fit-content;
  width: calc(100% - 24px);
  backdrop-filter: blur(16px);
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

body.theme-dark .site-header {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(56, 189, 248, 0.1);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-xs) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--warm));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: var(--text-xs);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand span {
  display: none;
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
  line-height: 1.3;
  margin-top: 2px;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

nav a {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

nav a::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
  border-radius: inherit;
}

nav a:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
  transform: translateY(-2px);
}

nav a:hover::before {
  opacity: 1;
}

nav a[aria-current="page"] {
  color: var(--accent);
  background: rgba(14, 165, 233, 0.08);
  border-color: rgba(14, 165, 233, 0.2);
  text-decoration: none;
  font-weight: 600;
}

nav a[aria-current="page"]::before {
  opacity: 1;
}

/* Theme Toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--accent-dim);
  background: var(--bg-elev);
  transform: scale(1.05);
}

/* Global Search */
.global-search {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.global-search input {
  width: 100%;
  padding: var(--space-sm) var(--space-md) var(--space-sm) 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.global-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.global-search input:hover:not(:focus) {
  border-color: var(--muted);
}

.global-search svg {
  position: absolute;
  left: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  transition: opacity var(--transition-fast);
  width: 18px;
  height: 18px;
  display: inline-block;
}

.global-search input:focus + svg,
.global-search:hover svg {
  opacity: 0.8;
}

/* Hero Section */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  padding: var(--space-3xl) 0 var(--space-2xl);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -200px;
  right: -100px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15), transparent 60%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

.hero::after {
  content: "";
  position: absolute;
  bottom: -100px;
  left: -50px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.12), transparent 60%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

@media (min-width: 880px) {
  .hero {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
  }
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(var(--text-4xl), 7vw, var(--text-6xl));
  font-weight: 800;
  margin: 0 0 var(--space-lg);
  line-height: 0.95;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.hero-copy h2::after {
  content: "";
  position: absolute;
  bottom: -12px;
  left: 0;
  width: 80px;
  height: 4px;
  background: linear-gradient(135deg, var(--accent), var(--warm));
  border-radius: 2px;
}

.hero-copy p {
  margin: 0 0 var(--space-xl);
  color: var(--muted);
  max-width: 54ch;
  font-size: var(--text-lg);
  line-height: 1.75;
  letter-spacing: -0.01em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-smooth);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:hover::before {
  opacity: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--warm));
  border: none;
  color: #FFFFFF;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 30px rgba(14, 165, 233, 0.4);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(-2px) scale(1.01);
}

/* Hero Card / Spotlight */
.hero-card {
  position: relative;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.05), transparent);
  pointer-events: none;
}

.hero-card h3 {
  margin: 0 0 var(--space-md);
  font-size: var(--text-lg);
  font-weight: 700;
}

.hero-spotlight {
  padding-bottom: var(--space-md);
}

.hero-spotlight-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.hero-spotlight-top h3 {
  margin: 0;
}

.hero-viewport {
  position: relative;
  min-height: 160px;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body:not(.theme-dark) .hero-viewport {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  box-shadow: none;
  border-color: #bfdbfe;
}

.hero-slide h4 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
}

body:not(.theme-dark) .hero-slide h4 {
  color: #1e40af;
}

.hero-slide p {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--muted);
}

body:not(.theme-dark) .hero-slide p {
  color: #475569;
}

.hero-slide-math {
  margin-top: var(--space-sm);
  overflow-x: auto;
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  background: rgba(0, 0, 0, 0.3);
}

body:not(.theme-dark) .hero-slide-math {
  background: #e0e7ff;
}

.hero-dots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: center;
}

.hero-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font-size: 0;
}

.hero-dot.is-on {
  background: var(--accent);
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px rgba(61, 214, 195, 0.2);
}

.hero-spotlight-nav {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.hero-arrow {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.hero-arrow::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.hero-arrow:hover {
  border-color: var(--accent);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.hero-arrow:hover::before {
  opacity: 1;
}

.hero-arrow:active {
  transform: translateY(0) scale(0.98);
}

.pulse-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Sections */
.section {
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  position: relative;
}

.section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  opacity: 0.5;
}

.section:first-of-type {
  margin-top: var(--space-xl);
  padding-top: 0;
}

.section:first-of-type::before {
  display: none;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-base);
  max-width: 54ch;
  line-height: 1.6;
}

/* Course Grid */
.course-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.course-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  transition: transform var(--transition-smooth), border-color var(--transition-smooth);
}

.course-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent);
}

.course-card .tag {
  display: inline-block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warm);
  margin-bottom: var(--space-sm);
  font-weight: 600;
}

.course-card h3 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-lg);
  font-weight: 600;
}

.course-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.6;
}

/* Hub Layout */
.hub-layout {
  display: grid;
  gap: var(--space-xl);
}

@media (min-width: 900px) {
  .hub-layout {
    grid-template-columns: 280px 1fr;
    align-items: start;
  }
}

.hub-sidebar {
  position: sticky;
  top: 100px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
}

.hub-sidebar label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  display: block;
  margin-bottom: var(--space-sm);
}

.search-wrap {
  margin-top: var(--space-sm);
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: var(--space-sm) var(--space-md) var(--space-sm) 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.search-wrap input:hover:not(:focus) {
  border-color: var(--muted);
}

.search-wrap svg {
  position: absolute;
  left: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.45;
  transition: opacity var(--transition-fast);
  width: 18px;
  height: 18px;
  display: inline-block;
}

.search-wrap input:focus + svg,
.search-wrap:hover svg {
  opacity: 0.8;
}

#search-hint {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Filter Chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.chip {
  font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
  font-weight: 500;
}

.chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.chip:hover::before {
  opacity: 1;
}

.chip.is-on {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.08);
  font-weight: 600;
}

.chip.is-on::before {
  opacity: 1;
}

/* Topic List */
.topic-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.topic-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition-smooth);
  position: relative;
}

.topic-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-lg);
}

.topic-card:hover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.05), transparent);
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

.topic-card > * {
  position: relative;
  z-index: 1;
}

.topic-card summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-lg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: var(--text-lg);
}

.topic-card summary::-webkit-details-marker {
  display: none;
}

.topic-card summary::after {
  content: "+";
  margin-left: auto;
  font-weight: 400;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.topic-card[open] summary::after {
  content: "−";
  transform: rotate(90deg);
}

.topic-meta {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
}

.topic-body {
  padding: 0 var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--border);
}

body:not(.theme-dark) .topic-body {
  color: #334155;
}

.topic-body p {
  margin: var(--space-md) 0;
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.7;
}

/* Formula Box */
.formula-box {
  font-size: var(--text-base);
  background: var(--formula-bg);
  border: 2px solid var(--formula-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  overflow-x: auto;
}

body:not(.theme-dark) .formula-box {
  color: #1e293b;
}

body:not(.theme-dark) .formula-box .katex {
  color: #1e293b;
}

body.theme-dark .formula-box {
  background: var(--formula-bg);
  border-color: var(--formula-border);
}

/* Formula Sheet */
.formula-sheet {
  background: linear-gradient(135deg, var(--formula-bg), rgba(186, 230, 253, 0.3));
  border: 2px solid var(--formula-border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.1);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-smooth);
  padding: var(--space-lg);
}

.formula-sheet::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--warm), var(--accent));
  background-size: 200% 100%;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.formula-sheet:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(14, 165, 233, 0.15);
}

body:not(.theme-dark) .formula-sheet {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.12);
  border-color: #a5b4fc;
}

body:not(.theme-dark) .formula-sheet .katex {
  color: #1e293b;
}

.formula-sheet .katex {
  color: var(--text);
}

.formula-sheet .katex-display {
  margin: 0.2em 0;
  overflow: hidden;
}

.formula-box code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: var(--text-sm);
}

/* Quick Formula Cards */
.quick-formulas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.quick-formula-card {
  position: relative;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-smooth);
  overflow: hidden;
}

.quick-formula-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.quick-formula-card:hover {
  border-color: var(--accent);
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.quick-formula-card:hover::before {
  opacity: 1;
}

body.theme-dark .quick-formula-card {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(56, 189, 248, 0.1);
}

.quick-formula-card .katex {
  font-size: 1.25em;
  position: relative;
  z-index: 1;
}

.quick-formula-card small {
  display: block;
  margin-top: var(--space-sm);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* Figure */
.figure-wrap {
  margin: var(--space-lg) 0;
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: var(--space-md);
}

.figure-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Play Grid */
.play-grid {
  display: grid;
  gap: var(--space-lg);
}

@media (min-width: 820px) {
  .play-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Panels */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xl);
  transition: all var(--transition-smooth);
  position: relative;
}

.panel:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.panel:hover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.05), transparent);
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel h3 {
  margin: 0 0 var(--space-md);
  font-size: var(--text-xl);
  font-weight: 600;
}

.panel-lead {
  margin: 0 0 var(--space-lg);
  font-size: var(--text-base);
  color: var(--muted);
  line-height: 1.6;
}

.panel-lead-lg {
  font-size: var(--text-lg);
  color: var(--text);
}

/* Inputs */
.input-row {
  margin-bottom: var(--space-lg);
}

.input-row label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-sm);
  font-weight: 500;
}

.calc-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.calc-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.calc-input:hover:not(:focus) {
  border-color: var(--muted);
}

/* FV Formula */
.fv-formula {
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

.fv-formula .katex {
  font-size: 0.9em;
}

.fv-formula .katex-display {
  overflow: hidden !important;
}

/* Slider */
.slider-row {
  margin-bottom: var(--space-lg);
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-sm);
  font-weight: 500;
}

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

.slider-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

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

.slider-num {
  width: 6.5rem;
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.slider-num:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.slider-num:hover:not(:focus) {
  border-color: var(--muted);
}

/* Calc Tabs */
.calc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-lg);
}

.calc-tab {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.calc-tab::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.calc-tab:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.calc-tab:hover::before {
  opacity: 1;
}

.calc-tab.is-on {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.08);
  font-weight: 600;
}

.calc-tab.is-on::before {
  opacity: 1;
}

.calc-panel {
  display: none;
}

.calc-panel.is-visible {
  display: block;
}

.calc-panel h3 {
  margin-top: 0;
  font-size: var(--text-xl);
  font-weight: 600;
}

/* Calculator Layout */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

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

.calc-form {
  width: 100%;
  padding-left: var(--space-lg);
}

@media (min-width: 900px) {
  .calc-form {
    padding-left: var(--space-xl);
  }
}

.calc-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  min-height: 320px;
}

.illustration-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-sm);
  border: 1px solid var(--border);
  width: 100%;
}

.illustration-svg {
  width: 100%;
  height: auto;
}

.illustration-text {
  margin: var(--space-md) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
  min-height: 300px;
  max-height: 400px;
}

.viz-wrapper {
  padding: var(--space-md);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.viz-wrapper canvas {
  width: 100% !important;
  height: auto !important;
  min-height: 350px;
  max-height: 450px;
}

.illustration-card {
  padding: var(--space-md);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

/* Dark mode calc panel */
body.theme-dark .calc-panel {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

body.theme-dark .calc-result {
  background: #0f172a !important;
  color: #22d3ee !important;
  border-color: #334155 !important;
}

.calc-output {
  margin-top: var(--space-lg);
}

.calc-output strong {
  color: var(--accent);
}

.calc-steps {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--surface);
  border-left: 3px solid var(--warm);
  font-size: var(--text-sm);
}

/* Dark mode calc steps */
body.theme-dark .calc-steps {
  background: #0f172a !important;
  color: #cbd5e1 !important;
  border-color: #38bdf8 !important;
}

.calc-steps ol {
  margin: 0;
  padding-left: var(--space-lg);
}

.calc-steps li {
  margin: var(--space-xs) 0;
}

/* Glossary */
.glossary-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.glossary-search {
  margin: var(--space-md) 0;
}

.glossary-search input {
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.glossary-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.glossary-search input:hover:not(:focus) {
  border-color: var(--muted);
}

.glossary-category {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.glossary-category-title {
  margin: 0;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.glossary-table th,
.glossary-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.glossary-table thead th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

.glossary-table tbody tr:last-child td {
  border-bottom: none;
}

.glossary-category.hidden {
  display: none;
}

.glossary-table tbody tr.hidden {
  display: none;
}

.glossary-table tbody tr.highlighted {
  background: rgba(56, 189, 248, 0.15);
}

body:not(.theme-dark) .glossary-table tbody tr.highlighted {
  background: rgba(37, 99, 235, 0.12);
}

/* Steps List */
.steps-list {
  margin: 0 0 var(--space-lg);
  padding-left: var(--space-lg);
  max-width: 58rem;
  color: var(--text);
  line-height: 1.6;
}

.steps-list li {
  margin-bottom: var(--space-sm);
}

/* Pitfalls Grid */
.pitfalls-grid {
  display: grid;
  gap: var(--space-md);
}

@media (min-width: 780px) {
  .pitfalls-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pitfall-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
}

.pitfall-card h3 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-base);
  color: var(--accent);
  font-weight: 600;
}

.pitfall-card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.6;
}

/* Quiz */
.quiz-q {
  font-size: var(--text-lg);
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

.quiz-math {
  margin: var(--space-md) 0;
  overflow: hidden;
}

.quiz-math .katex {
  font-size: 1em;
}

.quiz-math-inline {
  display: inline-block;
  vertical-align: middle;
  margin: 0 var(--space-xs);
}

.quiz-math-inline .katex {
  font-size: 0.95em;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.quiz-options button {
  text-align: left;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.5;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.quiz-options button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.quiz-options button:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateX(4px);
}

.quiz-options button:hover:not(:disabled)::before {
  opacity: 1;
}

.quiz-options button.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  transform: translateX(4px);
}

.quiz-options button.wrong {
  border-color: var(--danger);
  background: rgba(244, 63, 94, 0.1);
  transform: translateX(4px);
}

.quiz-feedback {
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Fill in the Blank styles */
.fillblank-container {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.fillblank-input {
  flex: 1;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-lg);
  transition: all var(--transition-smooth);
}

.fillblank-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

.fillblank-input:disabled {
  background: var(--surface);
  opacity: 0.7;
  cursor: not-allowed;
}

.fillblank-container .btn {
  padding: var(--space-md) var(--space-lg);
}

/* Flash Grid */
.flash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.flash {
  perspective: 800px;
  min-height: 180px;
}

.flash-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.flash.is-flipped .flash-inner {
  transform: rotateY(180deg);
}

.flash-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-md);
  font-size: var(--text-sm);
  overflow: hidden;
}

.flash-front {
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  color: var(--text);
  border-color: var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.flash-back {
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  color: var(--text);
  border-color: var(--border);
  transform: rotateY(180deg);
  font-size: var(--text-xs);
  line-height: 1.4;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Light mode flashcards */
body:not(.theme-dark) .flash-front,
body:not(.theme-dark) .flash-back {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #bfdbfe;
  box-shadow: none;
}

body:not(.theme-dark) .flash-front,
body:not(.theme-dark) .flash-back,
body:not(.theme-dark) .flash-back .katex {
  color: #1e293b;
}

.flash-back .katex {
  color: var(--text);
  font-size: 0.85em;
}

.flash-back .katex-display {
  margin: 0.2em 0;
  white-space: normal;
}

.flash-back {
  overflow: visible;
}

/* Visualization Panels */
.viz-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xl);
}

body.theme-dark .viz-panel {
  background: #1e293b !important;
  border-color: #334155 !important;
}

body.theme-dark .viz-panel .viz-title {
  color: #f1f5f9 !important;
}

body.theme-dark .viz-panel .viz-lead,
body.theme-dark .viz-panel .viz-note {
  color: #cbd5e1 !important;
}

body.theme-dark .viz-svg-wrap {
  background: #1e293b !important;
  border-color: #334155 !important;
}

body.theme-dark .viz-svg-wrap svg {
  background: #1e293b !important;
}

.viz-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-xl);
  font-weight: 600;
}

.viz-lead {
  margin: 0 0 var(--space-lg);
  color: var(--muted);
  font-size: var(--text-base);
  max-width: 72ch;
  line-height: 1.6;
}

.viz-note {
  margin: var(--space-md) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.viz-split {
  display: grid;
  gap: var(--space-xl);
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .viz-split {
    grid-template-columns: minmax(220px, 280px) 1fr;
    align-items: start;
  }
}

.data-table-wrap {
  min-width: 0;
}

.field-row {
  margin-bottom: var(--space-md);
}

.field-row label {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.field-row input[type="number"] {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.field-row input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.field-row input[type="number"]:hover:not(:focus) {
  border-color: var(--muted);
}

/* Dark mode calculator inputs */
body.theme-dark .field-row input[type="number"],
body.theme-dark .calc-panel input[type="number"] {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

body.theme-dark .field-row input[type="number"]::placeholder,
body.theme-dark .calc-panel input[type="number"]::placeholder {
  color: #64748b !important;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

/* Dark mode data table */
body.theme-dark .data-table th,
body.theme-dark .data-table td {
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

body.theme-dark .data-table th {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}

body.theme-dark .data-table tbody tr:nth-child(odd),
body.theme-dark .data-table tbody tr:nth-child(even) {
  background: #1e293b !important;
}

body.theme-dark .data-table {
  color: #f1f5f9 !important;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  vertical-align: middle;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
}

.data-table input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.data-table input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.data-table input[type="number"]:hover:not(:focus) {
  border-color: var(--muted);
}

.viz-svg-wrap {
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: var(--space-md);
  min-height: 200px;
}

/* Light mode viz panel */
body:not(.theme-dark) .viz-svg-wrap {
  background: #ffffff;
  border-color: #e2e8f0;
}

/* Dark mode viz panel */
body.theme-dark .viz-svg-wrap {
  background: #1e293b;
  border-color: #334155;
}

.viz-svg-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

body.theme-dark .viz-svg-wrap svg {
  background: #1e293b;
}

/* Dark mode CFD table */
body.theme-dark .cfd-cf {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

body.theme-dark .cfd-cf::placeholder {
  color: #64748b !important;
}

.cfd-cf-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.cfd-cf-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cfd-add-btn, .cfd-remove-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cfd-add-btn {
  background: white;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.cfd-add-btn:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 2px 6px rgba(0, 102, 204, 0.3);
}

.cfd-remove-btn {
  background: white;
  color: var(--color-error);
  border-color: var(--color-error);
  font-size: 16px;
}

.cfd-remove-btn:hover {
  background: var(--color-error);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

body.theme-dark .cfd-add-btn {
  background: #1e293b;
  color: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.theme-dark .cfd-add-btn:hover {
  background: #0284c7;
  color: white;
}

body.theme-dark .cfd-remove-btn {
  background: #1e293b;
  color: #dc2626;
  border-color: #dc2626;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.theme-dark .cfd-remove-btn:hover {
  background: #dc2626;
  color: white;
}

/* Challenge Section */
.challenge-layout {
  display: grid;
  gap: var(--space-xl);
}

@media (min-width: 960px) {
  .challenge-layout {
    grid-template-columns: 1fr 360px;
    align-items: start;
  }
}

.challenge-main {
  min-width: 0;
}

.challenge-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xl);
  transition: all var(--transition-smooth);
  position: relative;
}

.challenge-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.challenge-card:hover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.05), transparent);
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

.challenge-card > * {
  position: relative;
  z-index: 1;
}

.challenge-card h3 {
  margin-top: 0;
  font-size: var(--text-xl);
  font-weight: 600;
}

.field-grid {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.field fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: 0;
}

.field fieldset label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-right: var(--space-md);
  font-size: var(--text-sm);
  color: var(--text);
}

.field > span {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.field input[type="text"] {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.field input[type="text"]:hover:not(:focus) {
  border-color: var(--muted);
}

.err {
  color: var(--danger);
  font-size: var(--text-sm);
  margin-top: var(--space-md);
}

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

.ch-progress {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-md);
}

/* Leaderboard Styles */
.lb-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.lb-label {
  font-weight: 600;
  color: var(--muted);
  font-size: var(--text-sm);
}

.lb-tabs {
  display: flex;
  background: var(--surface);
  padding: var(--space-xs);
  border-radius: var(--radius-full);
  gap: var(--space-xs);
}

.lb-tab {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.lb-tab:hover {
  background: rgba(14, 165, 233, 0.1);
  color: var(--accent);
}

.lb-tab.is-on {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow);
}

.table-scroll {
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.leaderboard-scroll {
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--surface);
}

.leaderboard-scroll::-webkit-scrollbar {
  width: 8px;
}

.leaderboard-scroll::-webkit-scrollbar-track {
  background: var(--surface);
  border-radius: 4px;
}

.leaderboard-scroll::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-table thead {
  background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
}

.lb-table th {
  padding: var(--space-md);
  text-align: left;
  color: white;
  font-weight: 700;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lb-table td {
  padding: var(--space-md);
  font-size: var(--text-base);
  border-top: 1px solid var(--border);
  color: var(--text);
}

.lb-table tbody tr {
  transition: background 0.2s ease;
}

.lb-table tbody tr:hover {
  background: rgba(14, 165, 233, 0.05);
}

.lb-table tbody tr:nth-child(1) td:first-child {
  font-weight: 800;
  color: #f59e0b;
  font-size: var(--text-xl);
}

.lb-table tbody tr:nth-child(2) td:first-child {
  font-weight: 800;
  color: #9ca3af;
  font-size: var(--text-lg);
}

.lb-table tbody tr:nth-child(3) td:first-child {
  font-weight: 800;
  color: #b45309;
  font-size: var(--text-lg);
}

/* References Section */
.footer-refs-label {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--muted);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.footer-refs-label::before {
  content: "📚";
  font-size: var(--text-xl);
}

.footer-refs-cite {
  background: var(--surface);
  padding: var(--space-lg) var(--space-xl);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.6;
  text-align: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.footer-refs-cite::before {
  content: "“";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: var(--space-xs);
  font-size: 4rem;
  opacity: 0.08;
  font-family: Georgia, serif;
  line-height: 1;
}

.footer-refs-cite cite {
  font-style: italic;
  font-weight: 500;
}

/* Interactive Playground Styles */
.play-panel {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.play-panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(14, 165, 233, 0.2);
}

.play-panel-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.journey-simulator .input-row label {
  display: block;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
}

.journey-simulator .input-row input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  transition: all 0.2s ease;
}

.journey-simulator .input-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

.journey-result {
  margin-top: var(--space-lg);
}

.journey-years {
  background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
  color: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow);
}

.journey-label {
  display: block;
  font-size: var(--text-sm);
  opacity: 0.9;
  margin-bottom: var(--space-xs);
}

.journey-value {
  display: block;
  font-size: var(--text-4xl);
  font-weight: 800;
}

.journey-chart {
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.investment-game .game-scenarios {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  align-items: center;
  justify-content: center;
}

.game-scenario {
  flex: 1;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.game-scenario:hover {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.05);
}

.scenario-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.scenario-detail {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
}

.scenario-volatility {
  font-size: var(--text-xs);
  color: var(--muted);
  padding: var(--space-xs);
  background: var(--bg);
  border-radius: var(--radius-full);
  display: inline-block;
}

.game-vs {
  font-weight: 900;
  font-size: var(--text-xl);
  color: var(--accent);
}

.game-controls {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  margin-bottom: var(--space-md);
}

.game-results {
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: center;
}

.cashflow-builder .period-add {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--space-lg);
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.cashflow-builder .period-add input,
.cashflow-builder .period-add select {
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-base);
  flex: 1;
  min-width: 100px;
}

.cashflow-builder .period-add button {
  flex: none;
}

.cashflow-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.cashflow-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.cashflow-item:last-child {
  border-bottom: none;
}

.cashflow-type-outflow {
  color: var(--danger);
  font-weight: 600;
}

.cashflow-type-inflow {
  color: var(--success);
  font-weight: 600;
}

.cashflow-viz {
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.cashflow-summary {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  color: white;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 600;
}

.sprint-game .sprint-stats {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  justify-content: center;
}

.sprint-stat {
  flex: 1;
  text-align: center;
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.stat-label {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.stat-value {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent);
}

.sprint-question {
  background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
  color: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: var(--text-lg);
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-md);
}

.sprint-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.sprint-option {
  padding: var(--space-md);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sprint-option:hover {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.05);
}

.sprint-option.correct {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.sprint-option.wrong {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--text-lg);
}

/* 🏥 Bankruptcy Doctor Styles — Theme-Aware */
.bankruptcy-doctor-panel {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-elev) 100%);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: var(--space-xl);
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.bankruptcy-doctor-panel::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 70%);
  animation: pulse 4s ease-in-out infinite;
}

/* Progress Dashboard */
.progress-dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  position: relative;
  z-index: 10;
}

.progress-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  background: color-mix(in srgb, var(--bg-elev) 85%, transparent);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  gap: var(--space-xs);
}

.progress-icon {
  font-size: 1.5rem;
}

.progress-label {
  font-size: var(--text-sm);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress-value {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1); opacity: 1; }
}

.level-selector {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
}

.level-item {
  flex: 1;
  min-width: 140px;
  padding: var(--space-md);
  border: 2px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.level-item:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.level-item.level-completed {
  border-color: var(--success);
  box-shadow: 0 0 15px color-mix(in srgb, var(--success) 25%, transparent);
}

.level-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}

.level-name {
  font-size: var(--text-sm);
  color: var(--text);
}

/* Game Area */
.game-area {
  position: relative;
  z-index: 10;
}

.game-stage {
  animation: fadeIn 0.4s ease;
}

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

.hidden {
  display: none;
}

/* Case Introduction */
.case-intro {
  text-align: center;
}

.case-header {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.case-tag {
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
  border-radius: 8px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  font-size: var(--text-sm);
}

.case-number {
  padding: var(--space-sm) var(--space-md);
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 8px;
  font-weight: 700;
  color: var(--muted);
}

.case-title {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--space-md);
}

.case-narrative {
  font-size: var(--text-lg);
  color: var(--text);
  max-width: 700px;
  margin: 0 auto var(--space-xl);
  line-height: 1.7;
}

.ecg-chart {
  width: 100%;
  max-width: 500px;
  margin: 0 auto var(--space-xl);
  background: var(--bg-elev);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 16px;
  padding: var(--space-lg);
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.1);
  transition: all 0.3s ease;
}

body.theme-dark .ecg-chart {
  box-shadow: 0 4px 30px rgba(56, 189, 248, 0.15);
}

/* Intuition Vote */
.intuition-vote h3 {
  text-align: center;
  color: #f59e0b;
  margin-bottom: var(--space-md);
}

.vote-question {
  text-align: center;
  color: var(--text);
  font-size: var(--text-lg);
  margin-bottom: var(--space-lg);
}

.vote-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.vote-option {
  padding: var(--space-xl);
  border: 2px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.vote-option:hover {
  border-color: var(--accent);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.vote-option.selected {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 15%, transparent);
}

.timer-bar {
  width: 100%;
  height: 8px;
  background: color-mix(in srgb, var(--text) 20%, transparent);
  border-radius: 4px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success) 0%, var(--accent) 50%, var(--danger) 100%);
  width: 100%;
  transition: width 0.1s linear;
}

/* Tool Selection */
.tool-select h3 {
  text-align: center;
  margin-bottom: var(--space-sm);
  color: var(--accent);
}

.tool-hint {
  text-align: center;
  color: var(--muted);
  margin-bottom: var(--space-lg);
}

.tool-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.tool-option {
  padding: var(--space-lg);
  border: 2px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tool-option:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.tool-option.selected {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--success) 20%, transparent);
}

.tool-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: var(--space-sm);
}

.tool-name {
  font-weight: 700;
  color: var(--text);
  display: block;
}

/* Calculation */
.calc-wrapper {
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  border-radius: 12px;
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  border: 1px solid var(--border);
}

.marr-slider {
  margin-bottom: var(--space-lg);
  display: flex;
  gap: var(--space-md);
  align-items: center;
  flex-wrap: wrap;
}

.marr-slider label {
  color: var(--muted);
  font-weight: 600;
  flex: 0 0 auto;
}

.marr-slider input {
  flex: 1;
  min-width: 200px;
}

.viz-wrapper {
  background: var(--bg-elev);
  border-radius: 8px;
  padding: var(--space-md);
}

/* Revelation */
.revelation {
  text-align: center;
}

/* 彻底禁用shatter-overlay，不再让画面变暗 */
.shatter-overlay {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

.revelation-title {
  font-size: 2rem;
  color: var(--danger);
  margin-bottom: var(--space-lg);
}

.revelation-content {
  background: color-mix(in srgb, #f59e0b 10%, transparent);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.revelation-text {
  font-size: var(--text-lg);
  color: var(--text);
}

.revelation-result {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  align-items: center;
  margin-bottom: var(--space-xl);
}

.user-choice, .correct-choice {
  padding: var(--space-lg) var(--space-xl);
  border-radius: 12px;
  font-weight: 700;
  font-size: var(--text-lg);
}

.user-choice {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 2px solid var(--danger);
  color: var(--text);
}

.correct-choice {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  border: 2px solid var(--success);
  color: var(--text);
}

.vs {
  font-size: 1.5rem;
  color: var(--muted);
  font-weight: 800;
}

/* Prescription */
.prescription h3 {
  text-align: center;
  margin-bottom: var(--space-lg);
  color: var(--success);
}

.prescription-card {
  background: linear-gradient(135deg, color-mix(in srgb, #f59e0b 15%, transparent) 0%, color-mix(in srgb, #f59e0b 10%, transparent) 100%);
  border: 2px solid #f59e0b;
  border-radius: 16px;
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.prescription-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.prescription-tag {
  font-size: 2rem;
  font-weight: 800;
  color: #f59e0b;
}

.prescription-title {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text);
}

.prescription-text {
  font-size: var(--text-lg);
  color: var(--text);
  line-height: 1.7;
}

.mistake-book {
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.mistake-book h4 {
  color: var(--muted);
  margin-bottom: var(--space-md);
}

.mistake-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-sm);
}

.prescription-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

/* Tool Popup */
.tool-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.tool-popup-content {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-elev) 100%);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: var(--space-xl);
  max-width: 500px;
  width: 90%;
  position: relative;
  box-shadow: var(--shadow-glow);
}

.tool-popup-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-weight: bold;
}

.tool-popup-close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 50%;
}

.tool-popup-title {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: var(--space-md);
}

.tool-popup-details {
  color: var(--text);
  line-height: 1.7;
}

.tool-popup-details dt {
  font-weight: 700;
  color: var(--accent);
  margin-top: var(--space-sm);
}

.tool-popup-details dd {
  margin-left: var(--space-md);
}

/* Hidden class */
.hidden {
  display: none !important;
}

/* Tool Option with Info Button */
.tool-option {
  position: relative;
}

.tool-info-btn {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(14, 165, 233, 0.2);
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
  .bankruptcy-doctor-panel {
    padding: var(--space-lg);
  }

  .level-item {
    min-width: 120px;
  }

  .case-title {
    font-size: 1.5rem;
  }
}

/* 人生财富模拟器样式 */
.life-simulator-panel {
  padding: var(--space-xl);
}

.sim-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.sim-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.sim-icon {
  font-size: 2.5rem;
}

.sim-title h2 {
  margin: 0;
  color: var(--accent);
  font-size: var(--text-2xl);
}

.sim-description {
  color: var(--muted);
  font-size: var(--text-lg);
  margin: 0;
}

.sim-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: var(--space-xl);
}

.sim-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.control-section h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--text-lg);
  color: var(--text);
}

.career-options,
.investment-options,
.spending-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.career-option,
.invest-option,
.spending-option {
  padding: var(--space-md);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s ease;
}

.career-option:hover,
.invest-option:hover,
.spending-option:hover {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.05);
}

.career-option.selected,
.invest-option.selected,
.spending-option.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(14,165,233,0.1) 0%, rgba(56,189,248,0.1) 100%);
  box-shadow: 0 4px 12px rgba(14,165,233,0.15);
}

.career-name,
.invest-name,
.spending-name {
  font-weight: 700;
  font-size: var(--text-lg);
  margin-bottom: var(--space-xs);
}

.career-detail,
.invest-detail,
.spending-detail {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-sm);
}

.career-stats {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--accent);
  font-weight: 600;
}

.sim-buttons {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.sim-buttons .btn {
  flex: 1;
}

/* 可视化区域 */
.sim-visualization {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.year-progress {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.year-label {
  font-weight: 700;
  font-size: var(--text-lg);
  min-width: 70px;
}

.progress-bar {
  flex: 1;
  height: 12px;
  background: var(--surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--warm) 100%);
  transition: width 0.5s ease;
  border-radius: var(--radius-full);
}

.event-area {
  background: linear-gradient(135deg, rgba(16,185,129,0.08) 0%, rgba(14,165,233,0.08) 100%);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.event-message {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
}

.chart-section {
  background: var(--surface);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
}

.chart-section h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: var(--text-lg);
}

.chart-canvas-wrapper {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.metric-card {
  background: linear-gradient(135deg, rgba(14,165,233,0.08) 0%, rgba(56,189,248,0.08) 100%);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border);
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.metric-value {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--accent);
}

.knowledge-card {
  background: linear-gradient(135deg, rgba(16,185,129,0.08) 0%, rgba(52,211,153,0.08) 100%);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 2px solid rgba(16,185,129,0.2);
}

.knowledge-card h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--text-lg);
  color: #10b981;
}

.knowledge-card p {
  margin: 0;
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.6;
}

/* 响应式设计 */
@media (max-width: 1100px) {
  .sim-layout {
    grid-template-columns: 1fr;
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  :root {
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --text-xs: 10px;
    --text-sm: 12px;
    --text-base: 14px;
  }
  
  /* 1. 让搜索框也跟随滚动，不sticky */
  .site-header {
    position: relative;
    top: auto;
    width: calc(100% - 12px);
    margin: 8px auto;
    border-radius: 24px;
  }
  
  .header-inner {
    padding: 6px 10px;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
  }
  
  .header-inner::-webkit-scrollbar {
    display: none;
  }
  
  .brand {
    flex-shrink: 0;
    min-width: fit-content;
  }
  
  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }
  
  .brand h1 {
    font-size: 12px;
    white-space: nowrap;
  }
  
  nav {
    flex-shrink: 0;
    order: initial;
    width: auto;
    justify-content: flex-start;
  }
  
  nav ul {
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: nowrap;
  }
  
  nav a {
    padding: 4px 10px;
    font-size: 10px;
    white-space: nowrap;
  }
  
  .global-search {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    order: initial;
  }
  
  .global-search input {
    font-size: 11px;
    padding: 6px 12px;
  }
  
  .theme-toggle {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
    flex-shrink: 0;
  }
  
  .container {
    padding: var(--space-lg) var(--space-md);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  
  main {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  
  .panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .knowledge-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  
  .topic-card {
    padding: var(--space-md);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
  }
  
  .topic-list {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .hub-layout {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .hub-sidebar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  /* 2. 优化图片和图表显示 - 确保比例正常 */
  .figure-wrap {
    padding: 0;
    margin: var(--space-sm) 0;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
  }
  
  .figure-wrap svg {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
  }
  
  .chart-container {
    width: 100%;
    overflow: visible;
    padding: 4px;
    box-sizing: border-box;
  }
  
  .chart-container canvas {
    width: 100% !important;
    height: 400px !important;
    min-height: 400px;
    max-height: 500px;
    display: block;
  }
  
  .illustration-card {
    width: 100%;
    padding: 4px;
    box-sizing: border-box;
    margin: 0;
  }
  
  .viz-svg-wrap {
    width: 100%;
    display: block;
    padding: 4px;
    box-sizing: border-box;
    overflow: visible;
  }
  
  .viz-svg-wrap svg {
    width: 100%;
    height: auto;
    display: block;
  }
  
  .viz-split {
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
  }
  
  .calc-illustration {
    padding: 4px;
    margin: 0;
  }
  
  .calc-illustration svg {
    width: 100%;
    height: auto;
    min-height: 200px;
  }
  
  .viz-wrapper {
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
    margin: var(--space-sm) 0;
  }
  
  .viz-wrapper canvas {
    width: 100% !important;
    height: auto !important;
    min-height: 350px;
    max-height: 450px;
    display: block;
  }
  
  .bankruptcy-doctor-panel {
    padding: var(--space-sm);
  }
  
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }
  
  .level-card {
    padding: var(--space-md);
  }
  
  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
  
  table th,
  table td {
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
  
  /* 3. 排名榜格式改进 - 确保表格宽度合适 */
  .leaderboard, .ranking {
    padding: var(--space-md);
    width: 100%;
    box-sizing: border-box;
  }
  
  .leaderboard-list, .ranking-list {
    gap: var(--space-sm);
  }
  
  .leaderboard-item, .ranking-item {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
  }
  
  .lb-aside {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .table-scroll {
    width: 100%;
    overflow-x: auto;
  }

  .leaderboard-scroll {
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--surface);
  }

  .leaderboard-scroll::-webkit-scrollbar {
    width: 6px;
  }

  .leaderboard-scroll::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
  }

  .leaderboard-scroll::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
  }

  .lb-table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
  }
  
  .lb-table th,
  .lb-table td {
    padding: 10px 8px;
    font-size: 12px;
    text-align: center;
    word-break: break-word;
    white-space: normal;
  }
  
  .lb-table th:nth-child(1),
  .lb-table td:nth-child(1) {
    width: 10%;
    min-width: 40px;
  }
  
  .lb-table th:nth-child(2),
  .lb-table td:nth-child(2) {
    width: 45%;
    text-align: left;
    min-width: 120px;
  }
  
  .lb-table th:nth-child(3),
  .lb-table td:nth-child(3) {
    width: 25%;
    min-width: 60px;
  }
  
  .lb-table th:nth-child(4),
  .lb-table td:nth-child(4) {
    width: 20%;
    min-width: 70px;
  }
  
  /* 4. 优化计算器步骤面板 */
  .calc-steps {
    padding: var(--space-sm);
    margin-top: var(--space-sm);
    font-size: 11px;
    border-radius: 8px;
    border-left-width: 3px;
  }
  
  .calc-steps ol {
    padding-left: var(--space-md);
    margin: 0;
  }
  
  .calc-steps li {
    margin: 4px 0;
    line-height: 1.5;
  }
  
  /* 5. 优化游戏结果对比卡片 */
  .revelation-content {
    padding: var(--space-md);
    border-radius: 12px;
  }
  
  .revelation-text {
    font-size: var(--text-sm);
    line-height: 1.6;
  }
  
  .revelation-result {
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
  }
  
  .user-choice, .correct-choice {
    padding: var(--space-md);
    border-radius: 12px;
    font-size: var(--text-sm);
    font-weight: 600;
    width: 100%;
    max-width: 240px;
    text-align: center;
    word-wrap: break-word;
  }
  
  .vs {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--muted);
  }
  
  /* 6. 优化计算输出区域 */
  .calc-output {
    padding: var(--space-sm);
    font-size: var(--text-sm);
  }
  
  /* 7. 优化图表容器 */
  .illustration-card {
    padding: var(--space-sm);
    margin: 0;
  }
  
  .calc-illustration {
    padding: 0;
    margin-top: var(--space-md);
  }
  
  .viz-panel {
    margin: var(--space-md) 0;
  }
  
  .viz-panel h3 {
    font-size: var(--text-base);
    margin-bottom: var(--space-sm);
  }
  
  .viz-panel p {
    font-size: var(--text-sm);
    line-height: 1.5;
  }
  
  /* 8. 优化游戏面板 */
  .bankruptcy-doctor-panel {
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
  }
  
  .bankruptcy-doctor-panel h2 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-sm);
  }
  
  .bankruptcy-doctor-panel p {
    font-size: var(--text-sm);
    line-height: 1.6;
  }
  
  /* 9. 优化计算器面板 */
  .calc-panel {
    padding: var(--space-md);
  }
  
  .calc-panel h3 {
    font-size: var(--text-base);
    margin-bottom: var(--space-md);
  }
  
  .calc-form {
    padding: 0;
  }
  
  .input-row {
    margin-bottom: var(--space-sm);
  }
  
  .input-row label {
    font-size: var(--text-xs);
    margin-bottom: 4px;
  }
  
  .input-row input {
    padding: 8px 10px;
    font-size: var(--text-sm);
  }
  
  .btn {
    padding: 8px 16px;
    font-size: 12px;
  }
  
  .btn-lg {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .sim-buttons {
    flex-direction: column;
  }
}