/* Chapter 3 专用样式 - 多维随机变量可视化 */
/* 扩展 Chapter 1 的设计模式，添加 3D 可视化和数学计算支持 */

/* 继承 Chapter 1 的基础样式 */
@import url("chapter1.css");

/* 3D 可视化容器增强 */
#global-bg-blur {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  backdrop-filter: blur(var(--global-bg-blur, 12px));
  background-color: rgba(128, 128, 128, var(--global-bg-tint, 0.12));
  mix-blend-mode: multiply;
}

/* 数学库集成样式 */
.math-visualization {
  position: relative;
  background: rgba(15, 23, 48, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}

.math-visualization::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(34, 211, 238, 0.05),
    transparent 50%
  );
  pointer-events: none;
  z-index: 1;
}

/* Three.js 容器样式 */
.threejs-container {
  position: relative;
  width: 100%;
  height: 300px;
  background: rgba(15, 23, 48, 0.6);
  border-radius: 12px;
  overflow: hidden;
}

.threejs-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Plotly.js 容器样式 */
.plotly-container {
  position: relative;
  width: 100%;
  height: 300px;
  background: rgba(15, 23, 48, 0.6);
  border-radius: 12px;
}

.plotly-container .plotly-graph-div {
  border-radius: 12px;
}

/* 数学参数控制面板 */
.param-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#marginal-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 5;
}

.bg-grid {
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 18px 18px;
}

.title-gradient {
  background: linear-gradient(
    90deg,
    #00f3ff 0%,
    #bf00ff 25%,
    #00ff66 50%,
    #ffc107 75%,
    #ff6b6b 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 3D可视化容器样式 */
.plot-container {
  position: relative;
  background: rgba(15, 23, 48, 0.6);
  border-radius: 12px;
  overflow: hidden;
}

.plot-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(34, 211, 238, 0.05),
    transparent 50%
  );
  pointer-events: none;
  z-index: 1;
}

/* 联合概率表格样式 */
.joint-prob-table {
  background: rgba(15, 23, 48, 0.8);
  border-radius: 8px;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}

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

.joint-prob-table th {
  background: rgba(34, 211, 238, 0.15);
  color: #00f3ff;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.joint-prob-table td {
  padding: 8px 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.joint-prob-table td:hover {
  background: rgba(255, 255, 255, 0.05);
}

.joint-prob-table .marginal-cell {
  background: rgba(167, 139, 250, 0.1);
  color: #bf00ff;
  font-weight: 600;
}

.joint-prob-table .total-cell {
  background: rgba(0, 255, 102, 0.1);
  color: #00ff66;
  font-weight: 700;
}

/* Enhanced interactive table styles */
.joint-prob-container {
  background: rgba(15, 23, 48, 0.6);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.editable-cell {
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
}

.editable-cell:hover {
  background: rgba(34, 211, 238, 0.1) !important;
  border-color: rgba(34, 211, 238, 0.3);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.2);
}

.editable-cell.editing {
  background: rgba(34, 211, 238, 0.2) !important;
  border-color: rgba(34, 211, 238, 0.5);
}

.prob-input {
  background: rgba(15, 23, 48, 0.9);
  border: 1px solid rgba(34, 211, 238, 0.5);
  border-radius: 4px;
  color: white;
  font-size: 0.875rem;
  padding: 2px 4px;
}

.prob-input:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.8);
  box-shadow: 0 0 4px rgba(34, 211, 238, 0.3);
}

.validation-info {
  background: rgba(15, 23, 48, 0.4);
  border-radius: 6px;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.table-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
}

/* Visual highlighting for probability relationships */
.prob-highlight-row {
  background: rgba(34, 211, 238, 0.15) !important;
}

.prob-highlight-col {
  background: rgba(167, 139, 250, 0.15) !important;
}

.prob-highlight-cell {
  background: rgba(0, 255, 102, 0.2) !important;
  border-color: rgba(0, 255, 102, 0.5) !important;
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.3);
}

/* Standardized residual highlighting */
.prob-highlight-low {
  background: rgba(0, 255, 102, 0.1) !important;
  border-color: rgba(0, 255, 102, 0.3) !important;
}

.prob-highlight-medium {
  background: rgba(255, 193, 7, 0.15) !important;
  border-color: rgba(255, 193, 7, 0.4) !important;
  box-shadow: 0 0 8px rgba(255, 193, 7, 0.2);
}

.prob-highlight-high {
  background: rgba(255, 102, 102, 0.2) !important;
  border-color: rgba(255, 102, 102, 0.5) !important;
  box-shadow: 0 0 12px rgba(255, 102, 102, 0.3);
  animation: pulse-highlight 2s ease-in-out infinite;
}

@keyframes pulse-highlight {
  0%,
  100% {
    box-shadow: 0 0 12px rgba(255, 102, 102, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 102, 102, 0.6);
  }
}

/* 统计仪表盘样式 */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: rgba(15, 23, 48, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.02) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:hover {
  border-color: rgba(34, 211, 238, 0.3);
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.1);
  transform: translateY(-2px);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

/* 参数控制面板样式 - Enhanced */

.param-control .param-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
}

.param-control .param-value {
  font-weight: 600;
  font-family: "Courier New", monospace;
}

/* 自定义滑动条样式 - Enhanced */
.param-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  transition: all 0.3s ease;
  position: relative;
}

.param-slider:hover {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.3);
}

.param-slider:focus {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
}

.param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(34, 211, 238, 0.5);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.param-slider::-webkit-slider-thumb:hover {
  border-color: #00f3ff;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
  transform: scale(1.1);
}

.param-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.6);
}

.param-slider:focus::-webkit-slider-thumb {
  border-color: #00f3ff;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.4),
    0 0 0 3px rgba(34, 211, 238, 0.2);
}

.param-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(34, 211, 238, 0.5);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.param-slider::-moz-range-thumb:hover {
  border-color: #00f3ff;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
  transform: scale(1.1);
}

/* Enhanced parameter control styling */
.param-control {
  background: rgba(15, 23, 48, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.3s ease;
}

.param-control:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 48, 0.8);
}

.param-control:focus-within {
  border-color: rgba(34, 211, 238, 0.3);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.2);
}

/* 按钮样式增强 */
.action-button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.action-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.action-button:hover::before {
  transform: translateX(100%);
}

.action-button:active {
  transform: scale(0.98);
}

/* 独立性检验结果样式 */
.independence-result {
  padding: 1rem;
  border-radius: 12px;
  border: 2px solid;
  text-align: center;
  font-weight: 600;
  transition: all 0.3s ease;
}

.independence-result.independent {
  border-color: rgba(0, 255, 102, 0.5);
  background: rgba(0, 255, 102, 0.1);
  color: #00ff66;
}

.independence-result.dependent {
  border-color: rgba(255, 102, 102, 0.5);
  background: rgba(255, 102, 102, 0.1);
  color: #ff6666;
}

.independence-result.uncertain {
  border-color: rgba(255, 193, 7, 0.5);
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
}

/* 动画效果 */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(34, 211, 238, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.6);
  }
}

.pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes data-flow {
  0% {
    transform: translateX(-100%) scaleX(0);
  }
  50% {
    transform: translateX(0%) scaleX(1);
  }
  100% {
    transform: translateX(100%) scaleX(0);
  }
}

.data-flow::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(34, 211, 238, 0.3),
    transparent
  );
  animation: data-flow 2s ease-in-out infinite;
}

/* Enhanced Responsive Design System */

/* Mobile-first approach with progressive enhancement */
@media (max-width: 480px) {
  /* Extra small devices (phones) */
  .hero-title {
    font-size: 1.75rem;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 0.875rem;
    line-height: 1.4;
  }

  /* Single column layout for mobile */
  .flex.flex-col.lg\\:flex-row {
    flex-direction: column;
  }

  /* Stack visualization grids vertically */
  .grid.grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Reduce padding on mobile */
  .glass-card {
    padding: 1rem;
  }

  /* Smaller parameter controls */
  .param-control {
    padding: 0.75rem;
  }

  /* Compact statistics dashboard */
  .stats-dashboard {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.5rem;
    text-align: left;
  }

  .stat-card .stat-value {
    font-size: 1.25rem;
  }

  /* Touch-friendly controls */
  .param-slider {
    height: 8px;
  }

  .param-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -8px;
  }

  .param-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  /* Compact joint probability table */
  .joint-prob-table {
    font-size: 0.625rem;
  }

  .joint-prob-table th,
  .joint-prob-table td {
    padding: 4px 6px;
  }

  /* Canvas size optimization for mobile */
  canvas {
    max-width: 100%;
    height: auto;
  }

  /* Scenario tabs - vertical stack on mobile */
  #scenario-tabs {
    flex-direction: column;
    gap: 0.5rem;
  }

  .scenario-tab {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 768px) {
  /* Small devices (tablets) */
  .hero-title {
    font-size: 2.25rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  /* Two-column grid for tablets */
  .stats-dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .joint-prob-table {
    font-size: 0.75rem;
  }

  .joint-prob-table th,
  .joint-prob-table td {
    padding: 6px 8px;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-card .stat-value {
    font-size: 1rem;
  }

  /* Responsive visualization containers */
  .visualization-3d,
  .plot-container {
    min-height: 200px;
  }

  /* Touch-friendly parameter controls */
  .param-slider {
    height: 6px;
  }

  .param-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -7px;
  }

  .param-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  /* Compact control panels */
  .param-control {
    padding: 0.875rem;
  }

  /* Responsive scenario switching */
  #scenario-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }

  .scenario-tab {
    flex: 1;
    min-width: 120px;
    font-size: 0.875rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Medium devices (small laptops) */
  .hero-title {
    font-size: 2.75rem;
  }

  .hero-subtitle {
    font-size: 1.125rem;
  }

  /* Three-column grid for medium screens */
  .stats-dashboard {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Optimal visualization sizes */
  .visualization-3d,
  .plot-container {
    min-height: 250px;
  }
}

@media (min-width: 1025px) {
  /* Large devices (desktops) */
  .hero-title {
    font-size: 3.5rem;
  }

  .hero-subtitle {
    font-size: 1.25rem;
  }

  /* Four-column grid for large screens */
  .stats-dashboard {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Full-size visualizations */
  .visualization-3d,
  .plot-container {
    min-height: 300px;
  }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  .glass-card {
    backdrop-filter: blur(12px);
  }
}

/* Landscape orientation optimizations for mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 0.875rem;
  }

  /* Horizontal layout for landscape */
  .grid.grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Compact vertical spacing */
  .glass-card {
    padding: 0.75rem;
  }

  .param-control {
    padding: 0.5rem;
  }
}

/* Print styles */
@media print {
  .glass-card {
    background: white;
    color: black;
    border: 1px solid #ccc;
  }

  canvas {
    max-width: 100%;
    height: auto;
  }

  .param-slider,
  button {
    display: none;
  }
}

/* 工具提示样式 */
.tooltip {
  position: absolute;
  background: rgba(15, 23, 48, 0.95);
  border: 1px solid rgba(34, 211, 238, 0.5);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
  color: #fff;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
}

.tooltip.show {
  opacity: 1;
}

.tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(34, 211, 238, 0.5) transparent transparent transparent;
}

/* 导航链接活跃状态 */
.active-section {
  background: rgba(34, 211, 238, 0.2) !important;
  border-color: rgba(34, 211, 238, 0.6) !important;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.3) !important;
  transform: scale(1.05);
}

/* Hero区域导航链接增强 */
#hero-links a {
  position: relative;
  overflow: hidden;
}

#hero-links a::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

#hero-links a:hover::before {
  transform: translateX(100%);
}

/* 主题标签悬浮效果增强 */
.hero-subtitle + div span {
  transition: all 0.3s ease;
  cursor: pointer;
}

.hero-subtitle + div span:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

/* 公式显示区域增强 */
.glass-card .katex {
  color: rgba(255, 255, 255, 0.95);
}

.glass-card .katex .mord {
  color: rgba(34, 211, 238, 0.9);
}

.glass-card .katex .mrel {
  color: rgba(167, 139, 250, 0.9);
}

.glass-card .katex .mop {
  color: rgba(0, 255, 102, 0.9);
}

/* 响应式导航增强 */
@media (max-width: 768px) {
  #hero-links {
    flex-direction: column;
    align-items: center;
  }

  #hero-links a {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  .hero-subtitle + div {
    gap: 0.5rem;
  }

  .hero-subtitle + div span {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
  }
}

/* 加载动画 */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #00f3ff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 数据可视化画布增强 */
canvas {
  border-radius: 8px;
  transition: all 0.3s ease;
}

canvas:hover {
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.2);
}

/* 选择器样式统一 */
select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 32px;
  transition: all 0.2s ease;
}

select:focus {
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}

/* 输入框样式 */
input[type="number"] {
  transition: all 0.2s ease;
}

input[type="number"]:focus {
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.1);
  outline: none;
}
/* 场景切换样式 */
.scenario-tab {
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
}

.scenario-tab:not(.active) {
  opacity: 0.7;
}

.scenario-tab.active {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.3);
}

.scenario-tab.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  border-radius: 1px;
}

.scenario-content {
  transition: all 0.4s ease;
}

.scenario-content.hidden {
  display: none;
}

.scenario-controls {
  transition: all 0.4s ease;
}

.scenario-controls.hidden {
  display: none;
}

.scenario-stats {
  transition: all 0.3s ease;
}

.scenario-stats.hidden {
  display: none;
}

/* 词向量场景特殊样式 */
.word-tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.word-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.word-tag.selected {
  box-shadow: 0 0 12px currentColor;
  transform: scale(1.1);
}

/* 物理场景特殊样式 */
.physics-constant {
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

.velocity-indicator {
  position: relative;
  display: inline-block;
}

.velocity-indicator::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 2px solid transparent;
  border-bottom: 2px solid transparent;
}

/* 3D可视化容器增强 */
.visualization-3d {
  position: relative;
  background: radial-gradient(
    circle at center,
    rgba(15, 23, 48, 0.9),
    rgba(15, 23, 48, 0.7)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.visualization-3d::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
      circle at 20% 20%,
      rgba(34, 211, 238, 0.1),
      transparent 40%
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(167, 139, 250, 0.1),
      transparent 40%
    );
  pointer-events: none;
  z-index: 1;
}

/* 语义相似度热力图样式 */
.similarity-heatmap {
  position: relative;
}

.similarity-heatmap canvas {
  border: 1px solid rgba(167, 139, 250, 0.3);
}

/* 分子速度分布样式 */
.velocity-distribution {
  position: relative;
}

.velocity-distribution canvas {
  border: 1px solid rgba(0, 255, 102, 0.3);
}

/* 动画效果增强 */
@keyframes scenario-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scenario-content:not(.hidden) {
  animation: scenario-fade-in 0.5s ease-out;
}

@keyframes pulse-border {
  0%,
  100% {
    border-color: rgba(34, 211, 238, 0.3);
  }
  50% {
    border-color: rgba(34, 211, 238, 0.8);
  }
}

.active-visualization {
  animation: pulse-border 2s ease-in-out infinite;
}

/* 响应式场景切换 */
@media (max-width: 768px) {
  .scenario-tab {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
  }

  .scenario-tab i {
    display: block;
    margin-bottom: 0.25rem;
  }
}

/* 工具提示增强 */
.scenario-tooltip {
  position: absolute;
  background: rgba(15, 23, 48, 0.95);
  border: 1px solid rgba(34, 211, 238, 0.5);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #fff;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
  max-width: 200px;
  text-align: center;
}

.scenario-tooltip.show {
  opacity: 1;
}

/* 加载状态样式 */
.scenario-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
}

.scenario-loading .loading-spinner {
  margin-right: 0.5rem;
}

/* Touch Controls and Mobile Interactions */
.touch .param-slider {
  min-height: 44px;
  padding: 12px 0;
}

.touch .param-slider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.touch .param-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.touch-active {
  transform: scale(1.05);
  transition: transform 0.1s ease;
}

.touch button,
.touch .scenario-tab {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 16px;
}

.touch .joint-prob-table td.editable-cell {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 8px;
}

/* Canvas Touch Interactions */
canvas.touch-enabled {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Swipe Gesture Indicators */
.swipe-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.3;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.swipe-indicator.left {
  left: 10px;
}

.swipe-indicator.right {
  right: 10px;
}

.swipe-indicator:hover {
  opacity: 0.7;
}

/* Touch Feedback */
.touch-feedback {
  position: relative;
  overflow: hidden;
}

.touch-feedback::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
  pointer-events: none;
}

.touch-feedback.active::after {
  width: 100px;
  height: 100px;
}

/* Responsive Canvas Containers */
.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.canvas-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Mobile-Optimized Visualizations */
@media (max-width: 768px) {
  .visualization-3d,
  .plot-container {
    min-height: 200px;
    max-height: 300px;
  }

  .canvas-container {
    min-height: 180px;
  }

  /* Simplified contour plots for mobile */
  .mobile .contour-plot {
    filter: blur(0.5px);
  }

  /* Reduced scatter plot density */
  .mobile .scatter-plot {
    opacity: 0.8;
  }
}

/* Orientation-specific styles */
@media (max-width: 768px) and (orientation: landscape) {
  .hero-section {
    padding: 1rem 0;
  }

  .glass-card {
    padding: 0.75rem;
  }

  .visualization-3d,
  .plot-container {
    min-height: 150px;
    max-height: 200px;
  }
}

/* High DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  .glass-card {
    backdrop-filter: blur(12px);
  }

  .param-slider::-webkit-slider-thumb {
    border-width: 2px;
  }
}

/* Accessibility Enhancements for Touch */
.touch .focus-visible {
  outline: 3px solid rgba(34, 211, 238, 0.6);
  outline-offset: 2px;
}

.touch .param-slider:focus {
  outline: 3px solid rgba(34, 211, 238, 0.6);
  outline-offset: 4px;
}

/* Loading States for Touch Devices */
.touch .loading {
  pointer-events: none;
  opacity: 0.6;
}

.touch .loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: rgba(34, 211, 238, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Performance Optimization Indicators */
.performance-notification {
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.webgl-fallback-message {
  margin: 1rem 0;
}

.performance-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
}

.performance-indicator.good {
  background: rgba(34, 197, 94, 0.2);
  color: rgb(34, 197, 94);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.performance-indicator.warning {
  background: rgba(251, 191, 36, 0.2);
  color: rgb(251, 191, 36);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.performance-indicator.critical {
  background: rgba(239, 68, 68, 0.2);
  color: rgb(239, 68, 68);
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulse-critical 2s infinite;
}

@keyframes pulse-critical {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Frame Rate Monitor */
.fps-monitor {
  position: fixed;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.5rem;
  border-radius: 0.375rem;
  font-family: monospace;
  font-size: 0.75rem;
  z-index: 1000;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.fps-monitor:hover {
  opacity: 1;
}

.fps-monitor.hidden {
  display: none;
}

/* Memory Usage Indicator */
.memory-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.memory-bar {
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.memory-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.3s ease;
  border-radius: 2px;
}

/* Quality Settings */
.quality-selector {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.quality-option {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.375rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quality-option:hover {
  border-color: rgba(34, 211, 238, 0.5);
  color: rgba(34, 211, 238, 0.9);
}

.quality-option.active {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.5);
  color: rgb(34, 211, 238);
}

/* Performance Metrics Dashboard */
.performance-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

/* Historical Information Styles */
.historical-item {
  transition: all 0.3s ease;
  cursor: pointer;
}

.historical-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.modern-app-item {
  transition: all 0.3s ease;
  cursor: pointer;
}

.modern-app-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.timeline-item {
  transition: all 0.3s ease;
  cursor: pointer;
}

.timeline-item:hover {
  transform: scale(1.02);
}

.timeline-content {
  transition: all 0.3s ease;
}

.timeline-modern {
  transition: all 0.3s ease;
}

/* Historical Modal Styles */
#historical-modal,
#mathematician-modal {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Interactive Timeline Styles */
.timeline-item[data-year] {
  position: relative;
}

.timeline-item[data-year]:hover::before {
  content: attr(data-year);
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 48, 0.95);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 10;
}

/* Concept Highlighting */
.concept-highlight {
  animation: conceptPulse 2s ease-in-out;
}

@keyframes conceptPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(34, 211, 238, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.6);
    transform: scale(1.05);
  }
}

/* Responsive Historical Info */
@media (max-width: 768px) {
  .historical-item,
  .modern-app-item {
    padding: 0.75rem;
  }

  .historical-item .flex {
    flex-direction: column;
    text-align: center;
  }

  .modern-app-item .flex {
    flex-direction: column;
    text-align: center;
  }

  .timeline-item {
    flex-direction: column;
    text-align: center;
  }

  .timeline-item .w-1\/2 {
    width: 100%;
    padding: 0.5rem 0;
  }

  .timeline-item .w-4 {
    margin: 0.5rem auto;
  }
}
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(15, 23, 48, 0.6);
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.performance-metric {
  text-align: center;
}

.performance-metric-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.25rem;
}

.performance-metric-value {
  font-size: 1rem;
  font-weight: 600;
  font-family: monospace;
}

.performance-metric-value.good {
  color: rgb(34, 197, 94);
}

.performance-metric-value.warning {
  color: rgb(251, 191, 36);
}

.performance-metric-value.critical {
  color: rgb(239, 68, 68);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .performance-indicator.critical {
    animation: none;
  }

  .performance-loading::after {
    animation: none;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .performance-indicator {
    border-width: 2px;
  }

  .quality-option {
    border-width: 2px;
  }
}

/* ============================================================
   背景等高线（柏林噪声）氛围层
   性能优化后默认开启，但压暗到「只做氛围、不抢内容」的程度：
   - 噪声画布与边缘光条各降透明度
   - 需要更强/更弱时改这里的 opacity，或在 URL 加 ?bg=0 关闭
   ============================================================ */
#bg-noise {
  opacity: 0.34;
  --noise-brightness: 0.72;
  --noise-contrast: 1.04;
}

#marginal-glow {
  opacity: 0.26;
}
