/* リセットスタイル */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Computer Modern", "Times New Roman", "Times", serif;
  line-height: 1.5;
  color: #000;
  background: #fff;
  font-size: 14px;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #ddd;
}

/* ヘッダー */
header {
  background: #fff;
  color: #000;
  padding: 1.5rem 1rem;
  text-align: center;
  border-bottom: 2px solid #000;
}

header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}

header p {
  font-size: 0.95rem;
  font-style: italic;
  color: #333;
}

/* メインレイアウト */
.app-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  flex: 1;
  gap: 1rem;
  padding: 1rem;
  align-items: flex-start;  /* 上部に揃える */
}

/* コントロールパネル */
.controls-panel {
  background: #fff;
  border: 1px solid #000;
  padding: 1rem;
  overflow-y: auto;
  height: auto;
  max-height: 815px;
}

.controls-panel h2 {
  color: #000;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
  text-transform: uppercase;
  border-bottom: 1px solid #000;
  padding-bottom: 0.3rem;
  font-family: "Computer Modern", "Times New Roman", serif;
}

.parameter-group {
  margin-bottom: 1.5rem;
  border: 1px solid #ccc;
  padding: 0.8rem;
  background: #fff;
}

.parameter-group h3 {
  color: #000;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
}

.info-text {
  background-color: #f9f9f9;
  padding: 6px 10px;
  border: 1px solid #ddd;
  margin-bottom: 10px;
  font-size: 12px;
  color: #000;
  font-style: italic;
}

.parameter-group label {
  display: block;
  margin-bottom: 0.6rem;
  font-weight: normal;
  color: #000;
  font-size: 13px;
}

.parameter-group input,
.parameter-group select {
  width: 100%;
  padding: 0.3rem;
  border: 1px solid #000;
  font-size: 12px;
  margin-top: 0.2rem;
  background: #fff;
  font-family: "Computer Modern", "Times New Roman", serif;
}

.parameter-group input:focus,
.parameter-group select:focus {
  outline: 2px solid #000;
  border-color: #000;
}

.param-subset {
  margin-top: 0.8rem;
  padding: 0.6rem;
  background: #f9f9f9;
  border: 1px solid #ccc;
}

.brush-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin-top: 0.8rem;
}

.brush-actions button {
  padding: 0.4rem;
  border: 1px solid #000;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-family: "Computer Modern", "Times New Roman", serif;
}

.brush-actions button:hover {
  background: #f0f0f0;
}

.action-buttons {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
}

.primary-button {
  background: #000;
  color: #fff;
  border: 1px solid #000;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: bold;
  font-size: 12px;
  flex: 1;
  font-family: "Computer Modern", "Times New Roman", serif;
  text-transform: uppercase;
}

.primary-button:hover {
  background: #333;
}

button:not(.primary-button) {
  background: #fff;
  border: 1px solid #000;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  font-size: 11px;
  font-family: "Computer Modern", "Times New Roman", serif;
}

button:not(.primary-button):hover {
  background: #f0f0f0;
}

/* キャンバスエリア */
.canvas-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.canvas-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.canvas-wrapper {
  background: #fff;
  border: 1px solid #000;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-wrapper h3 {
  color: #000;
  margin-bottom: 0.8rem;
  font-size: 1rem;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
  text-align: center;
}

.canvas-wrapper canvas {
  border: 2px solid #000;
  cursor: crosshair;
  max-width: 100%;
  height: auto;
}

#aperture-canvas {
  background: #000;
}

#screen-canvas {
  background: #000;
}

.canvas-info {
  margin-top: 0.6rem;
  padding: 0.4rem;
  background: #f9f9f9;
  border: 1px solid #ccc;
  font-size: 11px;
  color: #000;
  text-align: center;
  width: 100%;
  font-family: "Computer Modern", "Times New Roman", serif;
}

.result-info {
  background: #fff;
  border: 1px solid #000;
  padding: 1rem;
}

.result-info h3 {
  color: #000;
  margin-bottom: 0.8rem;
  font-size: 1rem;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
  text-transform: uppercase;
  border-bottom: 1px solid #000;
  padding-bottom: 0.3rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem;
  background: #f9f9f9;
  border: 1px solid #ddd;
}

.info-item label {
  font-weight: normal;
  color: #000;
  font-size: 12px;
}

.info-item span {
  color: #000;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

/* レンジスライダーのスタイル */
input[type="range"] {
  width: calc(100% - 60px);
  margin-right: 10px;
}

/* フッター */
footer {
  background: #fff;
  color: #000;
  text-align: center;
  padding: 0.8rem;
  margin-top: auto;
  border-top: 1px solid #000;
  font-size: 11px;
  font-family: "Computer Modern", "Times New Roman", serif;
}

/* レスポンシブデザイン */
@media (max-width: 1200px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .controls-panel {
    order: 2;
  }

  .canvas-area {
    order: 1;
  }
}

@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .canvas-container {
    grid-template-columns: 1fr;
  }

  .app-layout {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .controls-panel,
  .canvas-wrapper,
  .result-info {
    padding: 1rem;
  }
}

/* 計算中のスタイル */
.calculating {
  opacity: 0.7;
  pointer-events: none;
}

.calculating::after {
  content: "計算中...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  z-index: 1000;
}

/* エラー表示 */
.error {
  background: #fff;
  color: #000;
  border: 2px solid #000;
  padding: 0.6rem;
  margin: 0.8rem 0;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
}

/* 成功表示 */
.success {
  background: #f9f9f9;
  color: #000;
  border: 1px solid #000;
  padding: 0.6rem;
  margin: 0.8rem 0;
  font-family: "Computer Modern", "Times New Roman", serif;
}

/* 論文スタイル追加 */
.paper-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

.abstract {
  margin-bottom: 2rem;
  padding: 1rem;
  border: 1px solid #000;
  background: #f9f9f9;
}

.abstract h2 {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.8rem;
  text-transform: uppercase;
}

.abstract p {
  text-align: justify;
  font-size: 13px;
}

.paper-content section {
  margin-bottom: 2rem;
}

.paper-content h2 {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 1rem;
  border-bottom: 1px solid #000;
  padding-bottom: 0.3rem;
}

.paper-content h3 {
  font-size: 1rem;
  font-weight: bold;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
}

.paper-content h4 {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 0.6rem;
  color: #000;
}

.paper-content p {
  margin-bottom: 1rem;
  text-align: justify;
  font-size: 14px;
}

/* MathJax表示の調整 */
.MathJax {
  font-size: 0.9em !important;
}

.MathJax_Display {
  margin: 1rem 0 !important;
}

/* 参考文献 */
.references ol {
  padding-left: 1.5rem;
}

.references li {
  margin-bottom: 0.5rem;
  font-size: 13px;
  line-height: 1.4;
}

/* シミュレーション部分のスタイル調整 */
.simulation-section {
  padding-top: 2rem;
}

.app-layout {
  margin-top: 1.5rem;
}

/* パラメータスライダーのスタイル */
.param-slider {
  width: 100% !important;
  height: 6px;
  border: none !important;
  outline: none;
  background: transparent;
  cursor: pointer;
  margin: 8px 0 !important;
  padding: 0 !important;
  -webkit-appearance: none;
  appearance: none;
}

/* WebKitスライダーのトラック */
.param-slider::-webkit-slider-track {
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, #f0f0f0 0%, #ddd 100%);
  border: 1px solid #000;
  border-radius: 0;
}

/* WebKitスライダーのつまみ */
.param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  width: 18px;
  background: #fff;
  border: 2px solid #000;
  border-radius: 0;
  cursor: pointer;
  margin-top: -7px;
  box-shadow: 0 0 0 1px #fff;
}

.param-slider::-webkit-slider-thumb:hover {
  background: #f5f5f5;
  box-shadow: 0 0 0 2px #fff, 0 0 3px rgba(0, 0, 0, 0.3);
}

.param-slider::-webkit-slider-thumb:active {
  background: #e5e5e5;
}

/* Firefoxスライダーのトラック */
.param-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, #f0f0f0 0%, #ddd 100%);
  border: 1px solid #000;
  border-radius: 0;
  cursor: pointer;
}

/* Firefoxスライダーのつまみ */
.param-slider::-moz-range-thumb {
  height: 18px;
  width: 18px;
  background: #fff;
  border: 2px solid #000;
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 0 0 1px #fff;
}

.param-slider::-moz-range-thumb:hover {
  background: #f5f5f5;
  box-shadow: 0 0 0 2px #fff, 0 0 3px rgba(0, 0, 0, 0.3);
}

.param-slider::-moz-range-thumb:active {
  background: #e5e5e5;
}

/* 波長スライダー専用の色付きトラック */
.wavelength-slider::-webkit-slider-track {
  background: linear-gradient(
    to right,
    #8b00ff 0%,
    /* 380nm - 紫 */ #4b0082 12%,
    /* 420nm - 藍 */ #0000ff 25%,
    /* 460nm - 青 */ #00ff00 50%,
    /* 550nm - 緑 */ #ffff00 75%,
    /* 580nm - 黄 */ #ff7f00 87%,
    /* 620nm - オレンジ */ #ff0000 100% /* 700nm - 赤 */
  );
  border: 1px solid #000;
}

.wavelength-slider::-moz-range-track {
  background: linear-gradient(
    to right,
    #8b00ff 0%,
    /* 380nm - 紫 */ #4b0082 12%,
    /* 420nm - 藍 */ #0000ff 25%,
    /* 460nm - 青 */ #00ff00 50%,
    /* 550nm - 緑 */ #ffff00 75%,
    /* 580nm - 黄 */ #ff7f00 87%,
    /* 620nm - オレンジ */ #ff0000 100% /* 700nm - 赤 */
  );
  border: 1px solid #000;
}

/* スライダー値の表示 */
.param-slider + span {
  font-weight: bold;
  font-family: monospace;
  font-size: 12px;
  color: #000;
}

/* リアルタイム計算ステータス */
.realtime-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: "Computer Modern", "Times New Roman", serif;
  color: #000;
  background: #f9f9f9;
  padding: 8px 12px;
  border: 1px solid #ccc;
  margin-top: 8px;
}

/* ステータスインジケーター */
.status-indicator {
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  transition: color 0.3s ease;
}

/* アクティブ状態 (緑)  */
.status-indicator.active {
  color: #008000;
  animation: pulse 2s infinite;
}

/* 計算中状態 (オレンジ)  */
.status-indicator.calculating {
  color: #ff6600;
  animation: blink 1s infinite;
}

/* エラー状態 (赤)  */
.status-indicator.error {
  color: #ff0000;
  animation: none;
}

/* アニメーション */
@keyframes pulse {
  0%,
  50%,
  100% {
    opacity: 1;
  }
  25%,
  75% {
    opacity: 0.5;
  }
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  25%,
  75% {
    opacity: 0.3;
  }
}

/* アクションボタンの調整 */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.action-buttons button {
  padding: 8px 16px;
  border: 1px solid #000;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: "Computer Modern", "Times New Roman", serif;
  font-weight: bold;
}

.action-buttons button:hover {
  background: #f5f5f5;
}

.action-buttons button:active {
  background: #e5e5e5;
}

/* 光学系の位置関係図 */
.geometry-diagram {
  background: #fff;
  border: 1px solid #000;
  padding: 1rem;
}

.geometry-diagram h4 {
  color: #000;
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
  text-transform: uppercase;
  border-bottom: 1px solid #000;
  padding-bottom: 0.3rem;
}

.diagram-container {
  position: relative;
  width: 100%;
  min-height: 80px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  padding: 20px;
  margin-bottom: 10px;
}

/* 数直線の背景 */
.number-line {
  position: relative;
  height: 40px;
  width: 100%;
  margin: 0 auto;
}

.line-background {
  position: absolute;
  top: 50%;
  left: 20px;
  right: 20px;
  height: 2px;
  background: #000;
  transform: translateY(-50%);
}

.line-background::before,
.line-background::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: #000;
  transform: translateY(-50%);
}

.line-background::before {
  left: -4px;
}

.line-background::after {
  right: -4px;
}

/* 位置マーカー */
.position-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}

.marker-label {
  font-size: 11px;
  font-weight: bold;
  font-family: "Computer Modern", "Times New Roman", serif;
  color: #000;
  background: #fff;
  padding: 2px 6px;
  border: 1px solid #000;
  white-space: nowrap;
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
}

.marker-point {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #000;
  background: #fff;
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
}

.distance-label {
  font-size: 10px;
  font-family: "Courier New", monospace;
  color: #333;
  background: #f9f9f9;
  padding: 1px 4px;
  border: 1px solid #ccc;
  white-space: nowrap;
  position: absolute;
  top: 35px;
  left: 50%;
  transform: translateX(-50%);
}

/* 特定のマーカーの色分け */
.source-marker .marker-point {
  background: #ffcccc;
  border-color: #cc0000;
}

.source-marker .marker-label {
  color: #cc0000;
  border-color: #cc0000;
}

.aperture-marker .marker-point {
  background: #ccffcc;
  border-color: #00cc00;
}

.aperture-marker .marker-label {
  color: #00cc00;
  border-color: #00cc00;
}

.screen-marker .marker-point {
  background: #ccccff;
  border-color: #0000cc;
}

.screen-marker .marker-label {
  color: #0000cc;
  border-color: #0000cc;
}

/* 総距離表示 */
.total-distance {
  text-align: center;
  margin-top: 10px;
  padding: 8px;
  background: #fff;
  border: 1px solid #000;
  font-size: 12px;
  font-family: "Computer Modern", "Times New Roman", serif;
  font-weight: bold;
  color: #000;
}

.total-distance span:first-child {
  color: #666;
  font-weight: normal;
}

.total-distance span:last-child {
  color: #000;
  font-family: "Courier New", monospace;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .diagram-container {
    min-height: 60px;
    padding: 15px;
  }
  
  .number-line {
    height: 30px;
  }
  
  .marker-point {
    width: 10px;
    height: 10px;
    top: 15px;
    transform: translate(-50%, -50%);
  }
  
  .marker-label {
    font-size: 10px;
    padding: 1px 4px;
    top: -5px;
  }
  
  .distance-label {
    font-size: 9px;
    top: 25px;
  }
}
