/* ウェブフォントは読み込まない（外部アセットゼロ方針・下の --font-* を参照） */

:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #131525;
  --bg-card: rgba(26, 29, 50, 0.65);
  --bg-card-hover: rgba(36, 40, 68, 0.8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(139, 92, 246, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.3);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.2);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.2);
  --accent-yellow: #f59e0b;

  /* OS標準のフォントだけで組む（ウェブフォントを読まないため。日本語も明示的に指定する） */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", YuGothic, "Noto Sans JP", Meiryo, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Noto Sans Mono", "Yu Gothic", monospace;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.95) 0px, var(--bg-primary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ヘッダー */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2rem;
  background: rgba(10, 11, 16, 0.5);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.logo-section h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #a78bfa 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-section span {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 500;
  letter-spacing: 0.5px;
  border: 1px solid var(--border-color);
}

.controls-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ドロップダウン & ボタン汎用 */
select, button {
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

select {
  padding: 0.5rem 2rem 0.5rem 1rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23f3f4f6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

select:hover, select:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.15);
}

button {
  padding: 0.5rem 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

button.primary {
  background: var(--accent-purple);
  border-color: transparent;
  box-shadow: 0 4px 12px var(--accent-purple-glow);
}

button.primary:hover {
  background: #7c3aed;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-purple-glow);
}

button.secondary {
  background: rgba(255, 255, 255, 0.05);
}

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

/* メインレイアウト */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 380px;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
  height: calc(100vh - 75px);
  min-height: 500px;
}

/* ペイン共通 */
.pane {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.pane-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pane-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* 左ペイン：問題 ＆ トレイ */
.problem-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.problem-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--accent-purple);
}

.problem-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.difficulty-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  margin-top: 0.5rem;
}

.difficulty-badge.easy { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.difficulty-badge.normal { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.difficulty-badge.hard { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.difficulty-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

.diff-tab {
  flex: 1;
  text-align: center;
  padding: 0.4rem;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.diff-tab.active {
  background: var(--accent-purple);
  color: white;
  font-weight: 500;
}

/* カード共通スタイル */
.block-card {
  background: rgba(30, 35, 60, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: grab;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.block-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.block-card:active {
  cursor: grabbing;
}

.block-card.sortable-ghost {
  opacity: 0.4;
  background: rgba(139, 92, 246, 0.15);
  border: 1.5px dashed var(--accent-purple);
}

.block-card input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  color: var(--accent-yellow);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 80px;
  text-align: center;
  outline: none;
}

.block-card input:focus {
  border-color: var(--accent-purple);
}

.block-card.dummy-card {
  border-left: 1px solid var(--border-color);
}

.block-card.dummy-card.reveal-error {
  border-left: 3px solid var(--accent-red) !important;
  box-shadow: 0 0 12px var(--accent-red-glow);
}

.block-card.active-line {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--accent-purple);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
  animation: pulse-border 1.5s infinite alternate;
}

@keyframes pulse-border {
  0% { border-color: rgba(139, 92, 246, 0.5); }
  100% { border-color: rgba(139, 92, 246, 1); }
}

/* 中央ペイン：エディタ */
#editor-pane {
  background: rgba(15, 17, 30, 0.7);
}

.editor-workspace {
  height: 100%;
  border-radius: 8px;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  overflow-y: auto;
  position: relative;
}

.editor-workspace::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2.5rem; /* インデントガイド線 */
  width: 1px;
  background: repeating-linear-gradient(to bottom, transparent, transparent 4px, rgba(255, 255, 255, 0.05) 4px, rgba(255, 255, 255, 0.05) 8px);
  pointer-events: none;
}

/* 2次元配置用インデント */
.indent-0 { margin-left: 0; }
.indent-1 { margin-left: 2rem; border-left: 2px solid rgba(139, 92, 246, 0.2); }
.indent-2 { margin-left: 4rem; border-left: 2px solid rgba(16, 185, 129, 0.2); }
.indent-3 { margin-left: 6rem; border-left: 2px solid rgba(245, 158, 11, 0.2); }

.indent-btn-group {
  display: flex;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.block-card:hover .indent-btn-group {
  opacity: 1;
}

.indent-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
}

.indent-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.empty-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.empty-placeholder i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* 右ペイン：実行 ＆ 出力 */
#output-pane {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: transparent;
  border: none;
  box-shadow: none;
}

.output-pane-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sec-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.1);
}

.sec-content {
  padding: 1rem;
  overflow-y: auto;
}

/* 変数モニター */
.var-monitor-section {
  flex: 1;
}

.vars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.var-badge {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
}

.var-name {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
}

.var-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-yellow);
  transition: color 0.5s ease;
}

.var-value.changed {
  color: var(--accent-green);
  animation: flash-green 0.8s ease-out;
}

@keyframes flash-green {
  0% { transform: scale(1.15); filter: brightness(1.3); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* 配列ビジュアライザ */
.array-container {
  margin-top: 0.8rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
  padding-top: 0.8rem;
}

.array-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}

.array-box-list {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.array-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  width: 38px;
  height: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  position: relative;
}

.array-box .val {
  font-size: 0.9rem;
  font-weight: 600;
}

.array-box .idx {
  font-size: 0.6rem;
  color: var(--text-muted);
  position: absolute;
  bottom: 1px;
}

.array-box.highlight {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

/* コンソール */
.console-section {
  height: 140px;
}

.console-output {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  background: #05060a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  height: 100px;
  overflow-y: auto;
}

.console-line {
  margin-bottom: 0.25rem;
  border-left: 2px solid var(--accent-purple);
  padding-left: 0.5rem;
}

/* トランスパイルプレビュー */
.preview-section {
  height: 140px;
}

.preview-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #34d399;
  background: #05060a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  height: 100px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* 操作パネル・判定表示 */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}

.status-bar.success {
  display: flex;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-bar.fail {
  display: flex;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 6, 10, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  z-index: 100;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  padding: 0.2rem;
}

.modal-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 60vh;
}

.prompt-textarea {
  width: 100%;
  height: 250px;
  background: #05060a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: none;
  outline: none;
}

.prompt-textarea:focus {
  border-color: var(--accent-purple);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* フッター */
footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: rgba(10, 11, 16, 0.3);
}

/* レスポンシブ調整 */
@media (max-width: 1200px) {
  main {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: visible;
  }
  .pane {
    height: 500px;
  }
}

/* 学習モード選択タブ */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  background: rgba(10, 11, 16, 0.4);
  backdrop-filter: blur(10px);
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border-color);
  z-index: 9;
}

.mode-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-normal);
}

.mode-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  color: white;
  background: linear-gradient(135deg, var(--accent-purple) 0%, #6d28d9 100%);
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  transform: translateY(-1px);
}

/* ==========================================================================
   モバイル＆タッチデバイス最適化 (レスポンシブ強化)
   ========================================================================== */

/* スマホ縦・横対応の画面幅調整 */
@media (max-width: 992px) {
  /* メインレイアウトを1カラムにして全画面表示 */
  main {
    grid-template-columns: 1fr !important;
    height: auto;
    overflow-y: visible;
    padding: 0.75rem;
    gap: 1rem;
  }

  .pane {
    height: auto;
    max-height: none;
    border-radius: 12px;
  }

  /* 左ペイン：問題とトレイをコンパクトにする */
  #left-pane {
    display: flex;
    flex-direction: column;
  }

  .problem-card {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
  }

  #problem-desc {
    font-size: 0.85rem;
    line-height: 1.4;
  }

  /* タッチパネルでカードトレイからエディタへドラッグしやすいよう、
     スマホサイズではトレイのカードリストを「横スクロール型」のコンパクトトレイに変更 */
  #tray-list {
    display: flex;
    flex-direction: row !important;
    overflow-x: auto;
    gap: 0.6rem;
    padding: 0.6rem;
    min-height: 90px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  #tray-list .block-card {
    flex: 0 0 auto;
    width: auto;
    min-width: 170px;
    margin-bottom: 0;
    touch-action: pan-x; /* 横スクロールを滑らかに */
    user-select: none;
  }

  /* 中央ペイン：エディタの領域を十分確保 */
  #editor-pane {
    min-height: 380px;
  }

  #editor-list {
    min-height: 320px;
  }

  /* インデントボタン等のタップエリア拡張 */
  .indent-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  /* 右ペイン：変数・コンソール・プレビューの折りたたみ */
  #output-pane {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .output-grid {
    grid-template-columns: 1fr; /* スマホでは変数とプレビューを縦に積む */
    gap: 1rem;
    height: auto;
  }

  #console-output {
    height: 140px;
  }
}

/* スマホ横持ち（ランドスケープ）最適化 */
@media (max-width: 992px) and (orientation: landscape) {
  /* 横持ちの時はトレイとエディタを左右に並べられるように調整 */
  main {
    grid-template-columns: 1fr 1.2fr !important;
    align-items: stretch;
  }

  #left-pane {
    height: auto;
    max-height: 80vh;
  }

  /* 横スクロールではなく通常の縦並びにしてドラッグエリアを広げる */
  #tray-list {
    flex-direction: column !important;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    max-height: 40vh;
    white-space: normal;
  }

  #tray-list .block-card {
    width: 100%;
    min-width: 0;
    margin-bottom: 0.5rem;
    touch-action: pan-y;
  }

  #editor-pane {
    height: auto;
    max-height: 80vh;
  }

  #output-pane {
    grid-column: span 2;
  }

  .output-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* タッチ操作のためのフィードバック（ホバーの代わりにタップ時のアクティブエフェクト） */
.block-card:active {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

/* タッチデバイスでのスクロールバーの視認性向上 */
#tray-list::-webkit-scrollbar {
  height: 6px;
}
#tray-list::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.4);
  border-radius: 3px;
}
#tray-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

/* 固定ロックカードのスタイル */
.block-card.locked-card {
  background: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  border-left-color: #64748b !important; /* グレー系で固定であることを表現 */
  cursor: default !important; /* 掴むカーソルを無効化 */
  box-shadow: none !important;
  opacity: 0.8;
  position: relative;
}

.block-card.locked-card:hover {
  transform: none !important;
  box-shadow: none !important;
  background: rgba(255, 255, 255, 0.03) !important;
}

.block-card.locked-card .indent-btn-group {
  display: none !important; /* インデント操作を非表示に */
}

/* ロックカードの鍵アイコン表示 */
.block-card.locked-card::after {
  content: "\f023"; /* FontAwesomeのlockアイコン */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: #64748b;
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
}

/* ==========================================================================
   第3期：視認性向上・操作ガイド・ステップ言語化（ナレーション）のオーバーライド
   ========================================================================== */

/* 左右ペイン・各種文字サイズ拡大（視認性向上） */
#problem-desc {
  font-size: 1.05rem !important;
  line-height: 1.65 !important;
  color: #f1f5f9 !important; /* よりはっきりした白へ */
}

.block-text {
  font-size: 1.05rem !important;
  color: #ffffff !important;
  font-weight: 500 !important;
}

/* 変数モニターのバッジ */
.var-card {
  font-size: 0.95rem !important;
  padding: 0.5rem 0.75rem !important;
}
.var-name {
  color: #cbd5e1 !important; /* 明るめのグレー */
}
.var-value {
  color: #38bdf8 !important; /* 明るめの水色 */
  font-weight: bold !important;
}

/* コンソール出力 */
#console-output {
  font-size: 1rem !important;
  line-height: 1.6 !important;
  color: #f1f5f9 !important;
  padding: 1rem !important;
}

/* Python変換プレビュー */
#preview-code {
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  color: #e2e8f0 !important;
}

/* 左ペイン（トレイ）内の操作ガイド */
.operation-guide {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: #ddd6fe;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.operation-guide i {
  color: #a78bfa;
}

/* 再生時のステップ言語化（ナレーション）吹き出し */
.step-narration {
  background: #1e1b4b !important; /* 濃いインディゴ */
  border: 1px solid #4338ca !important; /* インディゴ境界 */
  border-radius: 6px !important;
  padding: 0.5rem 0.75rem !important;
  margin-top: 0.5rem !important;
  font-size: 0.85rem !important; /* カード本体よりは一回り小さくして差別化 */
  color: #e0e7ff !important; /* 薄い青 */
  line-height: 1.5 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  animation: slideFadeIn 0.2s ease-out forwards !important;
  white-space: normal !important;
  text-align: left !important;
  width: 100% !important;
  box-sizing: border-box !important;
  position: relative !important;
  z-index: 10 !important;
}

.step-narration i {
  color: #818cf8 !important;
  flex-shrink: 0 !important;
}

@keyframes slideFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* カードレイアウトを左寄せにし、インデントボタンを左端に置くための調整 */
.block-card {
  justify-content: flex-start !important;
  gap: 0.75rem !important;
}

.block-card .block-text {
  flex-grow: 1 !important;
  text-align: left !important;
}

.indent-btn-group {
  flex-shrink: 0 !important;
  order: -1 !important; /* HTMLの順序に関わらず確実に最左端へ配置する予備策 */
}

/* きほん解説アコーディオンのプレミアムスタイル */
.guide-accordion {
  background: rgba(139, 92, 246, 0.04);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, background-color 0.2s;
}

.guide-accordion:hover {
  background: rgba(139, 92, 246, 0.07);
  border-color: rgba(139, 92, 246, 0.25);
}

.guide-header {
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #ddd6fe;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.guide-header i.fa-graduation-cap {
  color: #a78bfa;
  margin-right: 0.3rem;
}

.guide-body {
  border-top: 1px solid rgba(139, 92, 246, 0.1);
  background: rgba(15, 23, 42, 0.5);
}

.guide-item code {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  color: #f59e0b;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ==========================================================================
   第4期：横長1本のリボンヘッダー統合スタイル
   ========================================================================== */
header {
  padding: 0.6rem 2rem !important; /* 縦幅をコンパクトに抑える */
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

/* ヘッダー内に統合された mode-tabs */
header .mode-tabs {
  background: transparent !important;
  backdrop-filter: none !important;
  border-bottom: none !important;
  padding: 0 !important;
  margin: 0 auto !important; /* 中央寄せ */
  gap: 0.75rem !important;
  z-index: 10 !important;
}

header .mode-tab {
  padding: 0.4rem 1.2rem !important;
  font-size: 0.85rem !important;
  border-radius: 20px !important;
}

/* レスポンシブ調整（タブレット・モバイル） */
@media (max-width: 992px) {
  header {
    flex-wrap: wrap !important;
    gap: 0.75rem !important;
    padding: 0.8rem 1rem !important;
  }
  header .mode-tabs {
    order: 3 !important; /* タブを下段にする */
    width: 100% !important;
    margin: 0.2rem 0 0 0 !important;
    justify-content: center !important;
  }
  .controls-section {
    order: 2 !important;
  }
  .logo-section {
    order: 1 !important;
  }
}

@media (max-width: 600px) {
  header {
    justify-content: center !important;
    text-align: center !important;
  }
  .logo-section, .controls-section, header .mode-tabs {
    width: 100% !important;
    justify-content: center !important;
    margin: 0.2rem 0 !important;
  }
}

/* ------------------------------------------------------------------
   情報レンズ（SchoolLenz）への導線
   ------------------------------------------------------------------ */
.logo-section .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 0.15rem;
  transition: color var(--transition-fast);
}
.logo-section .back-link:hover {
  color: var(--accent-purple);
}

/* h1 はグラデーション文字なので、アイコンだけ色を明示する */
.logo-section h1 .fas {
  background-color: #a78bfa;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
footer a:hover {
  color: var(--accent-purple);
}
