* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 14px;
  color: #888;
}

/* 控制面板 */
.controls {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 14px;
  color: #aaa;
  font-weight: 500;
}

.control-group select {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.control-group select:hover,
.control-group select:focus {
  border-color: #667eea;
}

.control-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  outline: none;
  cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: 2px solid #fff;
  transition: transform 0.1s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: 2px solid #fff;
}

#thickness-value,
#wavelength-value {
  color: #667eea;
  font-weight: 700;
}

/* 模式切换按钮组 */
.mode-toggle {
  grid-column: 1 / -1;
}

.toggle-group {
  display: flex;
  gap: 0;
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2a2a4a;
  align-self: flex-start;
}

.toggle-option {
  padding: 7px 20px;
  font-size: 14px;
  cursor: pointer;
  color: #888;
  transition: all 0.2s;
  user-select: none;
}

.toggle-option input[type="radio"] {
  display: none;
}

.toggle-option.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.toggle-option:not(.active):hover {
  color: #e0e0e0;
  background: #1e2a4a;
}

/* 图表区域 */
.chart-container {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

#chart {
  width: 100%;
  height: 520px;
}

/* 信息面板 */
.info-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.info-card {
  background: #1a1a2e;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}

.info-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: #e0e0e0;
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: #555;
  margin-top: 30px;
  padding-bottom: 10px;
}

/* 物理原理说明面板 */
.theory-panel {
  background: #1a1a2e;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid #2a2a4a;
  overflow: hidden;
}

.theory-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  list-style: none;
}

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

.theory-summary:hover {
  background: #1e2a4a;
}

.theory-icon {
  font-size: 14px;
  color: #667eea;
  transition: transform 0.2s;
}

.theory-title {
  font-size: 15px;
  font-weight: 600;
  color: #e0e0e0;
}

.theory-hint {
  font-size: 12px;
  color: #555;
  margin-left: auto;
}

.theory-content {
  padding: 0 20px 20px;
  border-top: 1px solid #2a2a4a;
}

.theory-section {
  margin-top: 18px;
}

.theory-section h3 {
  font-size: 15px;
  color: #667eea;
  margin-bottom: 8px;
  font-weight: 600;
}

.theory-section p {
  font-size: 13px;
  line-height: 1.7;
  color: #bbb;
  margin-bottom: 10px;
}

.model-diagram {
  background: #0f0f1a;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  font-size: 14px;
  color: #e0e0e0;
  text-align: center;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  letter-spacing: 0.5px;
}

.formula {
  background: #0f0f1a;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  text-align: center;
  overflow-x: auto;
}

.formula-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.formula-row .formula {
  margin-bottom: 0;
}

.theory-note {
  background: #16213e;
  border-left: 3px solid #764ba2;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 12px;
  color: #999;
  line-height: 1.6;
}

.theory-note strong {
  color: #aaa;
}

/* KaTeX 颜色自定义 */
.katex {
  color: #e0e0e0;
  font-size: 1.15em;
}

/* 响应式 */
@media (max-width: 640px) {
  .controls {
    grid-template-columns: 1fr;
  }
  .info-panel {
    grid-template-columns: repeat(2, 1fr);
  }
  header h1 {
    font-size: 22px;
  }
  #chart {
    height: 380px;
  }
  .formula-row {
    grid-template-columns: 1fr;
  }
  .model-diagram {
    font-size: 12px;
    padding: 10px;
  }
}
