/* --- 1. アイランド・ヘッダー全体のレイアウト --- */
.bb-tool-island { 
  margin: -60px auto 80px; 
  padding: 40px; 
  background: #fff; 
  border-radius: 12px; 
  box-shadow: 0 30px 60px rgba(0,0,0,.1); 
  border: 1px solid #edf2f7; 
  max-width: 1080px; 
  box-sizing: border-box; 
  transition: max-width 0.4s ease; /* フォーカスモード時の変化を滑らかに */
}

.bb-tool-header { margin-bottom: 20px; }
.bb-tool-title { font-size: 24px; font-weight: 900; color: #1a202c; margin-bottom: 8px; }
.bb-tool-intro { font-size: 14px; color: #718096; line-height: 1.6; }

/* --- 2. プリセットバー（上段） --- */
.editor-toolbar-top { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  padding: 12px 16px; 
  background: #f1f5f9; 
  border: 1px solid #e2e8f0; 
  border-bottom: none; 
  border-radius: 8px 8px 0 0; 
  flex-wrap: wrap;
}
.preset-label { font-size: 11px; font-weight: 800; color: #64748b; text-transform: uppercase; }
.preset-group { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-preset { 
  background: #fff; border: 1px solid #cbd5e1; padding: 4px 12px; border-radius: 4px; 
  font-size: 11px; font-weight: 700; color: #475569; cursor: pointer; transition: 0.2s; 
}
.btn-preset:hover { background: #e2e8f0; color: #1e293b; border-color: #94a3b8; }

/* --- 3. メインツールバー（中段：折り返し対応） --- */
.editor-toolbar { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
  padding: 12px; 
  background: #f8fafc; 
  border: 1px solid #e2e8f0; 
  align-items: center; 
  position: relative; 
}

/* すべてのボタンの高さを36pxで統一 */
.btn-tool, .btn-layout-toggle, .btn-clean-setup, .btn-clean {
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-tool { background: #fff; border: 1px solid #cbd5e1; color: #475569; min-width: 40px; }
.btn-tool:hover { background: #f1f5f9; border-color: #94a3b8; color: #1e293b; }

.toolbar-separator { width: 1px; height: 24px; background: #e2e8f0; margin: 0 4px; }

/* レイアウト・編集トグル */
.btn-layout-toggle { background: #fff; border: 1px solid #cbd5e1; color: #6366f1; }
.btn-layout-toggle.is-active { background: #6366f1; color: #fff; border-color: #4f46e5; }
.btn-layout-toggle:hover { background: #f5f3ff; border-color: #a5b4fc; }

/* 掃除設定（右寄せを解除してラップに対応） */
.clean-settings-wrap { position: relative; }
.btn-clean-setup { background: #fff; border: 1px solid #cbd5e1; color: #475569; }

/* 浄化ボタン（PC時は右端、折り返し時は左に流れる） */
.btn-clean { 
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%); 
  color: #fff; 
  border: none; 
  padding: 0 20px; 
  font-weight: 800; 
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2); 
}
.btn-clean:hover { opacity: 0.9; transform: translateY(-1px); }

@media (min-width: 960px) {
  .btn-clean { margin-left: auto; } /* 広い時だけ右端へ */
}

/* 設定パネル */
.clean-settings-panel { 
  display: none; position: absolute; bottom: 100%; right: 0; background: #fff; 
  border: 1px solid #e2e8f0; padding: 16px; border-radius: 8px; 
  box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 100; min-width: 200px; margin-bottom: 10px; 
}
.clean-settings-panel.is-active { display: flex; flex-direction: column; gap: 8px; }
.clean-settings-panel label { font-size: 12px; color: #475569; cursor: pointer; display: flex; align-items: center; gap: 8px; }

/* --- 4. エディタコンテナ --- */
.editor-container { display: flex; border: 1px solid #e2e8f0; border-top: none; border-radius: 0 0 8px 8px; overflow: hidden; height: 550px; }
.editor-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pane-edit { background: #fff; position: relative; border-right: 1px solid #e2e8f0; }
.pane-code { background: #0f172a; }
.pane-label { padding: 8px 16px; font-size: 10px; font-weight: 800; letter-spacing: 0.1em; color: #94a3b8; border-bottom: 1px solid rgba(0,0,0,0.05); }

#visual-editor {
  flex: 1;
  padding: 24px;
  outline: none;
  /* ✅ 修正：16px → 15px に変更し、少し引き締める */
  font-size: 15px;
  /* ✅ 修正：行間も少し調整して、詰まりすぎず広すぎない設定に */
  line-height: 1.75;
  color: #2d3748;
  overflow-y: auto;
}
#visual-editor:empty:before { content: attr(placeholder); color: #a0aec0; cursor: text; }

.editor-status-bar { padding: 10px 16px; background: #f8fafc; border-top: 1px solid #e2e8f0; display: flex; gap: 16px; font-size: 11px; font-weight: 700; color: #94a3b8; }

.code-wrapper { flex: 1; position: relative; overflow: hidden; }
.code-view { margin: 0; padding: 24px; height: 100%; overflow-y: auto; box-sizing: border-box; }
.code-view code { font-family: 'Fira Code', 'Consolas', monospace; font-size: 13px; line-height: 1.6; color: #e2e8f0; white-space: pre-wrap; word-break: break-all; }

.btn-copy { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,0.1); color: #cbd5e1; border: 1px solid rgba(255,255,255,0.2); padding: 4px 12px; font-size: 11px; font-weight: 700; border-radius: 4px; cursor: pointer; }
.btn-copy:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* --- 5. 執筆集中（フォーカス）モード --- */
#editor-layout-root.is-focus-mode .pane-code { display: none; }
#editor-layout-root.is-focus-mode .pane-edit { flex: 0 0 100%; border-right: none; }
#editor-layout-root.is-focus-mode #visual-editor {
  max-width: 100%;
  margin: 0;
  /* ✅ 修正：18px → 16px に変更。大きすぎず、集中できるサイズ感へ */
  font-size: 16px;
  /* 余白は広めのまま維持して、ゆったり感は残す */
  padding: 40px;
}
/* --- 6. SPレスポンシブ --- */
@media (max-width: 768px) {
  .bb-tool-island { margin: -80px 0 40px; padding: 16px; }
  .editor-container { flex-direction: column; height: auto; }
  #visual-editor, .code-view { height: 350px; }
  .pane-code { border-top: 2px solid #334155; }
  .editor-toolbar-top { flex-direction: column; align-items: flex-start; }
}