/* =========================================================
 * ApolloEditor v1.2.0 - Stylesheet
 * すべてのクラスは .apollo- プレフィックスで競合を避ける
 * ========================================================= */

 .apollo-root {
  --apollo-paper: #ffffff;
  --apollo-ink: #1a1a1a;
  --apollo-muted: #888;
  --apollo-line: #e0e0e0;
  --apollo-accent: #c44536;
  --apollo-hover: #f4f4f4;
  --apollo-active-bg: #1a1a1a;
  --apollo-active-fg: #ffffff;
  --apollo-radius: 6px;
  --apollo-font-sans: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  --apollo-font-serif: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --apollo-font-mono: "SFMono-Regular", "Menlo", "Consolas", monospace;

  font-family: var(--apollo-font-sans);
  color: var(--apollo-ink);
  border: 1px solid var(--apollo-line);
  border-radius: var(--apollo-radius);
  background: var(--apollo-paper);
  overflow: visible;

  /*
   * 固定高さレイアウトのサポート:
   * ルートを flex column にしておくことで、ユーザが
   *   #editor { height: 400px; }  または  <div id="editor" style="height:400px"></div>
   * のようにルートに高さを指定したとき、
   *   - ツールバー (上)         … 高さは内容に従う、固定表示
   *   - エディタ本文 (中央)     … 残り領域を占有し、内部で縦スクロール
   *   - ステータスバー (下)     … 高さは内容に従う、固定表示
   * という挙動になる。高さ未指定なら従来通り内容に応じて伸びる。
   */
  display: flex;
  flex-direction: column;
  /*
   * 子要素 (.apollo-toast 等) を absolute で右下隅に置けるようにする。
   * フォーム内に設置されるケースを想定して、ホスト側のレイアウトに干渉せず
   * 自身を基準に内部 UI を浮かせるために必要。
   */
  position: relative;
}

/* ---------- Toolbar ---------- */
.apollo-toolbar {
  border-bottom: 1px solid var(--apollo-line);
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  background: #fafafa;
  border-radius: var(--apollo-radius) var(--apollo-radius) 0 0;
  /* 固定高さレイアウト時に縮められないようにする (内容に応じた高さを保つ) */
  flex-shrink: 0;
}
.apollo-tb-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--apollo-ink);
  font-family: var(--apollo-font-sans);
  min-width: 32px;
  line-height: 1;
}
.apollo-tb-btn:hover { background: var(--apollo-hover); }
.apollo-tb-btn.active { background: var(--apollo-active-bg); color: var(--apollo-active-fg); }
/* SVG アイコン入りツールバーボタン */
.apollo-tb-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* SVG の縦位置を揃えるため line-height は 0 (SVG 自身が高さを決める) */
  line-height: 0;
  /* SVG 16px + padding 6px 上下 = 28px 程度の高さ。他のテキストボタンと自然に揃う */
  padding: 6px 8px;
}
.apollo-tb-btn-icon svg {
  display: block;
  /* currentColor 継承で色がボタンの color と揃う */
}
.apollo-tb-sep {
  width: 1px;
  height: 20px;
  background: var(--apollo-line);
  margin: 0 4px;
}

/* ---------- スプリットボタン (文字色 / 背景色) ----------
 * 主ボタン: A アイコン + 下端に「現在の色」を示す細い色バー
 * 矢印ボタン: ▼ で色パレットを開く
 * 2 ボタンを密着させて 1 つのコントロール感を出す。
 */
.apollo-tb-color-main {
  /* 縦に: アイコン → 色バー */
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 6px 3px 6px;
  /* 矢印ボタンと隣接させるため右側のラジアスをなくす */
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.apollo-tb-color-main svg { display: block; }
.apollo-tb-color-bar {
  /* 「現在の色」インジケーター: 横幅は親のアイコンと揃える */
  display: block;
  width: 14px;
  height: 3px;
  border-radius: 1px;
  /* 色なし (= 解除状態) のときは枠線で「未設定」を表現 */
  background-color: transparent;
  border: 1px solid var(--apollo-line);
  box-sizing: border-box;
  /* 色付きのときは枠線が見えにくいよう半透明 */
  background-clip: padding-box;
}
.apollo-tb-color-arrow {
  /* 主ボタンの直右に密着させる: 左ラジアスなし、左マージンマイナスで間を詰める */
  padding: 4px 3px;
  min-width: 14px;
  margin-left: -2px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.apollo-tb-color-arrow svg { display: block; }
/* 主ボタンと矢印ボタンを並べた時の hover 時の見た目を少し統一 (連結感) */
.apollo-tb-color-main:hover,
.apollo-tb-color-arrow:hover { background: var(--apollo-hover); }

/* 「⋯」その他メニュー */
.apollo-tb-more {
  font-size: 18px;
  line-height: 0.7;
}
.apollo-tb-overflow-menu {
  /*
   * このポップオーバーは document.body 直下に配置されるため、
   * .apollo-root で定義された CSS 変数 (--apollo-paper 等) が継承されない。
   * そのため、ここで使用する変数を popover 自身にも再定義する
   * (.apollo-root の値と完全に同期させること)
   */
  --apollo-paper: #ffffff;
  --apollo-ink: #1a1a1a;
  --apollo-line: #e0e0e0;
  --apollo-hover: #f4f4f4;
  --apollo-active-bg: #1a1a1a;
  --apollo-active-fg: #ffffff;
  --apollo-radius: 6px;
  --apollo-font-sans: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;

  position: fixed;
  background: var(--apollo-paper);
  border: 1px solid var(--apollo-line);
  border-radius: var(--apollo-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 9999;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  max-width: 360px;
  font-family: var(--apollo-font-sans);
  color: var(--apollo-ink);
}

/* ---------- Editor area ---------- */
.apollo-editor {
  padding: 24px 32px;
  font-family: var(--apollo-font-serif);
  font-size: 16px;
  line-height: 1.8;
  /*
   * 固定高さレイアウト時は flex column の余り領域を占有し、内部スクロールする。
   * 高さ未指定時は子の min-height (.apollo-classic / .apollo-block-area の 200px) で
   * 自然な最低サイズが確保されるため、min-height: 0 にしておいても問題ない。
   */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.apollo-editor [contenteditable]:focus { outline: none; }

/* Classic mode */
.apollo-classic { min-height: 200px; }
.apollo-classic p { margin: 0 0 1em 0; }
.apollo-classic h1, .apollo-classic h2, .apollo-classic h3 {
  font-family: var(--apollo-font-serif);
  font-weight: 600;
  line-height: 1.3;
  margin: 1em 0 .4em;
}
.apollo-classic h1 { font-size: 1.6em; border-bottom: 1px solid var(--apollo-line); padding-bottom: .15em; }
.apollo-classic h2 { font-size: 1.3em; }
.apollo-classic h3 { font-size: 1.1em; }
.apollo-classic blockquote {
  border-left: 3px solid var(--apollo-accent);
  margin: 1em 0;
  padding: .2em 1em;
  color: var(--apollo-muted);
  font-style: italic;
}
.apollo-classic ul, .apollo-classic ol { padding-left: 1.5em; }
.apollo-classic code, .apollo-classic pre {
  background: #f4f4f4;
  font-family: var(--apollo-font-mono);
}
.apollo-classic code { padding: 1px 6px; border-radius: 3px; font-size: .9em; }
.apollo-classic pre { padding: 12px 16px; border-radius: 4px; white-space: pre-wrap; }
.apollo-classic a { color: var(--apollo-accent); }
.apollo-classic img,
.apollo-classic video,
.apollo-classic iframe { max-width: 100%; height: auto; border-radius: 4px; }

/* Block mode */
.apollo-block-area { display: flex; flex-direction: column; gap: 4px; min-height: 200px; }
.apollo-block {
  position: relative;
  padding: 4px 8px 4px 32px;
  border-radius: 4px;
  transition: background .15s;
}
.apollo-block:hover { background: rgba(0,0,0,.02); }
.apollo-handle {
  position: absolute;
  left: 4px;
  top: 12px;
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--apollo-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 3px;
}
.apollo-block:hover .apollo-handle { opacity: 1; }
.apollo-handle:hover { background: var(--apollo-hover); }

.apollo-content { outline: none; }
.apollo-block[data-type="heading1"] .apollo-content { font-size: 1.6em; font-weight: 600; line-height: 1.3; }
.apollo-block[data-type="heading2"] .apollo-content { font-size: 1.3em; font-weight: 600; line-height: 1.3; }
.apollo-block[data-type="heading3"] .apollo-content { font-size: 1.1em; font-weight: 600; line-height: 1.3; }
.apollo-block[data-type="quote"] .apollo-content {
  border-left: 3px solid var(--apollo-accent);
  padding: .2em 1em;
  color: var(--apollo-muted);
  font-style: italic;
}
.apollo-block[data-type="code"] .apollo-content {
  background: #1a1a1a;
  color: #f4f1ea;
  font-family: var(--apollo-font-mono);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: .9em;
  white-space: pre-wrap;
}
.apollo-block[data-type="list"] .apollo-content::before {
  content: "•";
  margin-right: .6em;
  color: var(--apollo-accent);
}
/*
 * 番号付きリスト (numlist) の番号表示。
 * CSS counter で連番を自動生成する。非 numlist ブロックが間に入ったら
 * カウンタをリセットして次の numlist グループを 1 から始める。
 */
.apollo-block-area { counter-reset: apollo-numlist; }
.apollo-block:not([data-type="numlist"]) { counter-reset: apollo-numlist; }
.apollo-block[data-type="numlist"] { counter-increment: apollo-numlist; }
.apollo-block[data-type="numlist"] .apollo-content::before {
  content: counter(apollo-numlist) ".";
  margin-right: .6em;
  color: var(--apollo-accent);
  font-weight: 500;
  min-width: 1.5em;
  display: inline-block;
}

/* Placeholder */
.apollo-content[data-empty="true"]::before,
.apollo-media-caption[data-empty="true"]::before {
  content: attr(data-placeholder);
  color: var(--apollo-muted);
  opacity: .5;
  pointer-events: none;
}

/* ---------- Media block ---------- */
.apollo-media {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0;
}
.apollo-media-img,
.apollo-media-video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}
.apollo-media-embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
}
.apollo-media-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.apollo-media-caption {
  outline: none;
  font-size: .9em;
  color: var(--apollo-muted);
  text-align: center;
  font-style: italic;
  padding: 4px 0;
  min-height: 1.5em;
}
.apollo-media-placeholder {
  display: block;
  width: 100%;
  padding: 32px;
  background: var(--apollo-hover);
  border: 2px dashed var(--apollo-line);
  border-radius: 6px;
  color: var(--apollo-muted);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: all .15s;
}
.apollo-media-placeholder:hover {
  background: #ececec;
  border-color: var(--apollo-muted);
  color: var(--apollo-ink);
}

/* Slash menu */
.apollo-menu {
  /* document.body 直下に配置されるため CSS 変数を再定義する */
  --apollo-line: #e0e0e0;
  --apollo-radius: 6px;
  --apollo-hover: #f4f4f4;
  --apollo-ink: #1a1a1a;
  --apollo-font-sans: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  --apollo-font-mono: "SFMono-Regular", "Menlo", "Consolas", monospace;

  position: fixed;
  background: #fff;
  border: 1px solid var(--apollo-line);
  border-radius: var(--apollo-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 4px;
  z-index: 9999;
  min-width: 180px;
  font-family: var(--apollo-font-sans);
  font-size: 13px;
}
.apollo-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-family: var(--apollo-font-mono);
  font-size: 12px;
  color: var(--apollo-ink);
  white-space: pre;
}
.apollo-menu-item:hover { background: var(--apollo-hover); }

/* ---------- Table block ---------- */
.apollo-table-wrap {
  margin: 4px 0;
  overflow-x: auto;
}
.apollo-table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--apollo-font-sans);
  font-size: 14px;
}
.apollo-table th,
.apollo-table td {
  border: 1px solid var(--apollo-line);
  padding: 8px 12px;
  vertical-align: top;
  min-width: 60px;
}
.apollo-table th {
  background: #f4f4f4;
  font-weight: 600;
  text-align: left;
}
.apollo-table-cell:focus {
  outline: 2px solid var(--apollo-accent);
  outline-offset: -2px;
}
.apollo-table-controls {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.apollo-table-btn {
  background: #fff;
  border: 1px solid var(--apollo-line);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--apollo-font-sans);
  color: var(--apollo-muted);
}
.apollo-table-btn:hover {
  background: var(--apollo-hover);
  color: var(--apollo-ink);
}

/* ---------- HR block ---------- */
.apollo-media-hr {
  border: none;
  border-top: 1px solid var(--apollo-line);
  margin: 16px 0;
}
.apollo-classic hr {
  border: none;
  border-top: 1px solid var(--apollo-line);
  margin: 16px 0;
}
.apollo-classic table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
}
.apollo-classic th,
.apollo-classic td {
  border: 1px solid var(--apollo-line);
  padding: 6px 10px;
}
.apollo-classic th {
  background: #f4f4f4;
}

/* ---------- Color Picker (Google Sheets 風 階調パレット) ----------
 * 構成: 「色なし」ボタン → グレー行 → メインカラーグリッド (5×9)
 *       → 最近使った色 → カスタム色 (input[type=color])
 */
.apollo-color-panel {
  /*
   * このパネルは document.body 直下に配置されるため、
   * .apollo-root で定義された CSS 変数が継承されない。
   * そのため、ここで使用する変数を panel 自身にも再定義する。
   */
  --apollo-line: #e0e0e0;
  --apollo-radius: 6px;
  --apollo-muted: #5f6368;
  --apollo-hover: rgba(0,0,0,.04);
  --apollo-font-sans: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;

  position: fixed;
  background: #fff;
  border: 1px solid var(--apollo-line);
  border-radius: var(--apollo-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 8px;
  z-index: 9999;
  font-family: var(--apollo-font-sans);
  /* セル 18px × 9 列 + gap 2px × 8 + padding 16px = 200px 程度の最小幅 */
  min-width: 196px;
}

/* 「色なし」ボタン (上部、フル幅) */
.apollo-color-none {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 6px;
  margin-bottom: 6px;
  border: 1px solid var(--apollo-line);
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--apollo-muted);
  text-align: left;
}
.apollo-color-none:hover { background: var(--apollo-hover); }
/* 「色なし」アイコン: 白地に赤い斜線 (Google Sheets 風) */
.apollo-color-none-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid var(--apollo-line);
  border-radius: 2px;
  background: #fff;
  position: relative;
  flex-shrink: 0;
}
.apollo-color-none-icon::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  background: #ea4335;
  transform: rotate(-45deg);
  transform-origin: center;
}
.apollo-color-none-label { line-height: 1; }

/* 色セル共通 (グレー行 / メイングリッド / 最近使った色) */
.apollo-color-cell {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
  /* hover で少し拡大 + 縁を濃く (Google Sheets 風の微妙なフィードバック) */
  transition: transform .08s ease, border-color .08s ease;
}
.apollo-color-cell:hover {
  transform: scale(1.18);
  border-color: rgba(0,0,0,.6);
  z-index: 1;
  position: relative;
}

/* グレー行 / 最近使った色行 */
.apollo-color-row {
  display: grid;
  gap: 2px;
  margin-bottom: 4px;
}
.apollo-color-row-gray { grid-template-columns: repeat(9, 18px); }
.apollo-color-row-recent { grid-template-columns: repeat(8, 18px); }

/* メインカラーグリッド (5 行 × 9 列) */
.apollo-color-grid {
  display: grid;
  grid-template-columns: repeat(9, 18px);
  gap: 2px;
  margin-bottom: 4px;
}

/* セクションラベル (「最近使った色」) */
.apollo-color-section-label {
  font-size: 10px;
  color: var(--apollo-muted);
  margin: 6px 0 3px;
  letter-spacing: .02em;
}

/* カスタム色 (input[type=color] による OS ネイティブピッカー) */
.apollo-color-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 5px 6px;
  border-top: 1px solid var(--apollo-line);
  cursor: pointer;
  font-size: 12px;
  color: var(--apollo-muted);
  border-radius: 3px;
}
.apollo-color-custom:hover { background: var(--apollo-hover); }
.apollo-color-custom-input {
  /* OS のカラーピッカーを開くトリガー、見た目は色プレビューのみ表示 */
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--apollo-line);
  border-radius: 2px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.apollo-color-custom-label { line-height: 1; }

/* ---------- Dropdown Picker (Word 風 段落種別 / フォントサイズ等) ----------
 * ColorPicker と同じく document.body 直下に position: fixed で出すパネル。
 * 各項目 = 「✓ + ラベル」、現在値はチェックマーク表示。
 */
.apollo-dropdown-panel {
  /* body 直下なので CSS 変数を再定義 */
  --apollo-line: #e0e0e0;
  --apollo-radius: 6px;
  --apollo-hover: rgba(0,0,0,.04);
  --apollo-accent: #c44536;
  --apollo-font-sans: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;

  position: fixed;
  background: #fff;
  border: 1px solid var(--apollo-line);
  border-radius: var(--apollo-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 4px;
  z-index: 9999;
  font-family: var(--apollo-font-sans);
  /* 縦のスクロールを許容 (見出し 6 まで含めて高さがある) */
  max-height: 70vh;
  overflow-y: auto;
  min-width: 140px;
}

.apollo-dropdown-item {
  display: flex;
  align-items: center;
  /* ラベル左、チェックマーク右に押し出す (Word / Google Docs 風) */
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  border-radius: 3px;
  /* ラベル側で大きいフォントを使う場合のレイアウト崩れ防止 */
  line-height: 1.2;
  /* hover / current の背景色がボタン全幅に乗るように */
  box-sizing: border-box;
}
.apollo-dropdown-item:hover { background: var(--apollo-hover); }
/* 現在選択中: アクセント色のうっすら背景 + ラベル太字でしっかり目立たせる。
 * (Word / Google Docs / Notion 等のドロップダウン UI で広く採用される普遍パターン) */
.apollo-dropdown-item-current {
  background: rgba(196, 69, 54, 0.10);
}
.apollo-dropdown-item-current .apollo-dropdown-label {
  font-weight: 600;
}

/* チェックマーク (右側に配置)。表示は ✓ 単体、固定幅でレイアウトを安定させる */
.apollo-dropdown-check {
  display: inline-block;
  flex-shrink: 0;
  width: 16px;
  text-align: right;
  color: var(--apollo-accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

/* ラベル本体 (style で size / weight を上書きできる) */
.apollo-dropdown-label {
  flex: 1;
  /* デフォルトの見た目: 通常テキスト */
  font-size: 13px;
  color: #202124;
  /* 長いラベル (例: フォントサイズの "12pt") もうまく省略 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Toolbar 上のドロップダウンボタン (段落種別 / フォントサイズ) ---------- */
.apollo-tb-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  /* 通常のボタンより少し詰める */
  padding: 4px 6px;
  /* ラベルが入るので min-width を確保して文字数による幅変動を抑える */
  min-width: 78px;
}
.apollo-tb-dropdown-label {
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  /* 「見出し 1」など最長 4 文字程度に収まる想定 */
  max-width: 70px;
}
.apollo-tb-dropdown-arrow {
  display: inline-flex;
  align-items: center;
  /* シェブロンを少し小さめに */
  opacity: 0.7;
}
.apollo-tb-dropdown-arrow svg { display: block; }

/* ---------- Table Picker (ホバーグリッドでサイズ選択) ---------- */
.apollo-table-picker {
  /* document.body 直下に配置されるため CSS 変数を再定義 */
  --apollo-paper: #ffffff;
  --apollo-line: #e0e0e0;
  --apollo-radius: 6px;
  --apollo-accent: #c44536;
  --apollo-font-sans: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;

  position: fixed;
  background: var(--apollo-paper);
  border: 1px solid var(--apollo-line);
  border-radius: var(--apollo-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 10px;
  z-index: 9999;
  font-family: var(--apollo-font-sans);
  /* ホバー中の選択状態を視覚的に保ちやすくするため、テキスト選択を無効化 */
  user-select: none;
  -webkit-user-select: none;
}
.apollo-table-picker-grid {
  display: grid;
  gap: 2px;
  /* grid-template-columns は JS から動的に設定 */
}
.apollo-table-picker-cell {
  width: 16px;
  height: 16px;
  background: #f7f7f9;
  border: 1px solid #d0d4dc;
  border-radius: 1px;
  cursor: pointer;
  transition: background .05s ease, border-color .05s ease;
}
.apollo-table-picker-cell-active {
  background: #b9d4ff;
  border-color: #4a86e8;
}
.apollo-table-picker-label {
  text-align: center;
  font-size: 12px;
  color: #555;
  margin-top: 8px;
  min-height: 1em;
}

/* ---------- Toast (削除取り消しなどの通知) ----------
 * .apollo-root を position: relative にしているので
 * (skeleton で apollo-root を作成時に設定済み)、
 * absolute 配置で右下隅に固定される。
 * 編集領域が内部スクロールしても toast は付随しない (root の中に居続ける)。
 */
.apollo-toast {
  position: absolute;
  right: 16px;
  bottom: 16px;
  /* 暗めの背景で前景に浮かせる */
  background: #2c2f33;
  color: #ffffff;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-family: var(--apollo-font-sans);
  z-index: 100;
  /* スライドイン演出 */
  animation: apollo-toast-in .18s ease-out;
  /* 編集中のテキストと衝突しないよう選択不可に */
  user-select: none;
  -webkit-user-select: none;
}
@keyframes apollo-toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.apollo-toast-message {
  /* 改行抑制してメッセージは1行表示 */
  white-space: nowrap;
}
.apollo-toast-action {
  background: transparent;
  border: none;
  color: #88c0ff;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 3px;
}
.apollo-toast-action:hover {
  background: rgba(255,255,255,.08);
  text-decoration: underline;
}
.apollo-toast-close {
  background: transparent;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  font-family: inherit;
}
.apollo-toast-close:hover { color: #fff; }

/* ---------- Status bar ---------- */
.apollo-statusbar {
  border-top: 1px solid var(--apollo-line);
  padding: 6px 14px;
  font-size: 11px;
  color: var(--apollo-muted);
  background: #fafafa;
  border-radius: 0 0 var(--apollo-radius) var(--apollo-radius);
  font-family: var(--apollo-font-sans);
  letter-spacing: .03em;
  /* 固定高さレイアウト時に縮められないようにする */
  flex-shrink: 0;
}

/* ---------- Read-only mode ---------- */
.apollo-readonly .apollo-toolbar {
  opacity: .4;
  pointer-events: none;
}
.apollo-readonly .apollo-editor {
  background: #fafafa;
}
.apollo-toolbar-disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---------- Image Resize ---------- */
.apollo-img-selected {
  outline: 2px solid var(--apollo-accent);
  outline-offset: 1px;
  cursor: pointer;
}
.apollo-resize-overlay {
  position: absolute;
  pointer-events: none; /* オーバーレイ自体はクリック透過、ハンドルのみ反応 */
  z-index: 100;
}
.apollo-resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid var(--apollo-accent);
  border-radius: 2px;
  pointer-events: auto;
  box-sizing: border-box;
}
.apollo-handle-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.apollo-handle-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.apollo-handle-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.apollo-handle-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
/* リサイズドラッグ中はテキスト選択無効・カーソル統一 */
body.apollo-resizing {
  cursor: nwse-resize !important;
  user-select: none;
}
body.apollo-resizing * {
  cursor: nwse-resize !important;
}

/* 画像をクリックしやすくするためのカーソル */
.apollo-classic img,
.apollo-media-img {
  cursor: pointer;
}

/* ---------- Search & Replace bar ---------- */
.apollo-search-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: #fafafa;
  border-bottom: 1px solid var(--apollo-line);
  font-family: var(--apollo-font-sans);
  /* 固定高さレイアウト時に縮められないようにする */
  flex-shrink: 0;
}
.apollo-search-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.apollo-search-input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--apollo-line);
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.apollo-search-input:focus {
  border-color: var(--apollo-accent);
}
.apollo-search-btn {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid var(--apollo-line);
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  color: var(--apollo-ink);
  white-space: nowrap;
}
.apollo-search-btn:hover {
  background: var(--apollo-hover);
}
.apollo-search-close {
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
}
.apollo-search-counter {
  font-size: 11px;
  color: var(--apollo-muted);
  min-width: 40px;
  text-align: center;
}

/* 検索ハイライト */
mark.apollo-search-hit {
  background: #fff3a3;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
mark.apollo-search-hit-current {
  background: #ff9b3a;
  color: #fff;
}

/* ---------- Checklist ---------- */
.apollo-block.apollo-checklist-item {
  display: flex;
  /*
   * align-items: center で1行のチェックリスト項目において
   * チェックボックスとテキストの縦位置を確実に揃える。
   * (複数行の場合は中央揃えになるが、checklist は通常1〜2行で使うため許容)
   * margin-top に頼った位置調整はホスト側の input リセット CSS で
   * 上書きされやすいため避ける。
   */
  align-items: center;
  gap: 8px;
  /*
   * 他のブロック (paragraph / list / numlist 等) と同じ padding-left: 32px を
   * 維持することで、ブロックの左側に出るグリップ (⋮⋮) と重ならず、
   * かつ他ブロックと縦軸が揃う。チェックボックスは flex 子要素として
   * その padding 領域の右側 (= 他ブロックでテキストや bullet が始まる位置) に置かれる。
   */
}
.apollo-block.apollo-checklist-item::before {
  /* 通常のブロックスタイルを上書き (リスト項目の bullet を消す) */
  content: none;
}
.apollo-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex: 0 0 auto;
  accent-color: var(--apollo-accent);
  /* margin リセット (ブラウザ既定値や host CSS の影響を排除) */
  margin: 0;
  /* checkbox 自身の高さを line-height ぶん確保して、テキスト行と同等の高さに見せる */
  /* align-items: center が flex 親に効くので、これで縦中央に揃う */
}
.apollo-block.apollo-checklist-item .apollo-content {
  flex: 1 1 auto;
  min-width: 0;
}
.apollo-block.apollo-checked .apollo-content {
  text-decoration: line-through;
  color: var(--apollo-muted);
  opacity: 0.7;
}
/* 出力された HTML 用 (apollo-checklist) */
.apollo-classic ul.apollo-checklist {
  list-style: none;
  padding-left: 0;
}
.apollo-classic ul.apollo-checklist li.apollo-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0;
}
.apollo-classic ul.apollo-checklist li.apollo-check-item[data-checked="true"] {
  text-decoration: line-through;
  color: #888;
}

/* ---------- Drag and Drop ---------- */
.apollo-editor.apollo-drag-over {
  position: relative;
  outline: 2px dashed var(--apollo-accent);
  outline-offset: -2px;
  background: rgba(60, 100, 220, 0.04);
}
.apollo-editor.apollo-drag-over::before {
  content: "📥 画像をドロップ";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--apollo-accent);
  color: #fff;
  padding: 8px 20px;
  border-radius: 4px;
  font-family: var(--apollo-font-sans);
  font-size: 14px;
  font-weight: 500;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.apollo-editor.apollo-drag-over * {
  pointer-events: none; /* ドラッグ中の子要素クリックを抑止 (リスナーが正しく拾える) */
}

/* ---------- Source view (HTML 編集) ---------- */
.apollo-source-view {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--apollo-line);
  border-radius: 4px;
  padding: 12px;
  font-family: var(--apollo-font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: #1a1a1a;
  color: #d4d0c5;
  resize: vertical;
  box-sizing: border-box;
}
.apollo-source-view:focus {
  outline: 2px solid var(--apollo-accent);
  outline-offset: -1px;
}

/* ---------- Modal (MediaPicker) ---------- */
.apollo-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--apollo-font-sans, system-ui, sans-serif);
}
.apollo-modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #1a1a1a;
}
.apollo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e0e0e0;
}
.apollo-modal-title {
  font-size: 15px;
  font-weight: 600;
}
.apollo-modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #888;
  padding: 4px 8px;
  border-radius: 4px;
}
.apollo-modal-close:hover { background: #f4f4f4; }

.apollo-modal-tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid #e0e0e0;
  gap: 4px;
}
.apollo-modal-tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}
.apollo-modal-tab:hover { color: #1a1a1a; }
.apollo-modal-tab.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
  font-weight: 600;
}

.apollo-modal-body {
  padding: 20px;
  overflow-y: auto;
}
.apollo-modal-panel { display: none; }
.apollo-modal-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: .03em;
}
.apollo-modal-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  background: #fff;
}
.apollo-modal-input:focus {
  outline: none;
  border-color: #1a1a1a;
}
.apollo-modal-note {
  margin-top: 8px;
  font-size: 11px;
  color: #888;
  line-height: 1.5;
}

.apollo-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  background: #fafafa;
}
.apollo-btn {
  padding: 8px 18px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  color: #1a1a1a;
  font-family: inherit;
}
.apollo-btn:hover { background: #f4f4f4; }
.apollo-btn-primary {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}
.apollo-btn-primary:hover { background: #333; }

/* =========================================================
 * Accessibility (a11y)
 * ========================================================= */

/* スクリーンリーダー専用 (視覚的に非表示だが SR は読み上げる) */
.apollo-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* キーボード操作時のフォーカスインジケータ
   :focus-visible でマウスクリック時のフォーカスリングは出さない */
.apollo-tb-btn:focus-visible,
.apollo-search-btn:focus-visible,
.apollo-modal-tab:focus-visible,
.apollo-modal-close:focus-visible,
.apollo-btn:focus-visible,
.apollo-handle:focus-visible {
  outline: 2px solid var(--apollo-accent);
  outline-offset: 2px;
  background: var(--apollo-hover);
}
.apollo-search-input:focus-visible {
  outline: 2px solid var(--apollo-accent);
  outline-offset: 0;
}
.apollo-classic:focus-visible,
.apollo-content:focus-visible,
.apollo-media-caption:focus-visible {
  /* 編集領域は contenteditable のキャレットがあるので outline は控えめに */
  outline: none;
}
/* ブロックモードで編集領域にフォーカスが入ったら左に細い帯を出す */
.apollo-block:focus-within {
  background: rgba(0, 0, 0, 0.015);
}
.apollo-block:focus-within > .apollo-handle {
  opacity: 1;
}

/* 高コントラストモード対応 (Windows ハイコントラスト) */
@media (prefers-contrast: more) {
  .apollo-tb-btn:focus-visible,
  .apollo-handle:focus-visible {
    outline-width: 3px;
  }
}

/* 動きを減らす設定 (前庭障害等への配慮) */
@media (prefers-reduced-motion: reduce) {
  .apollo-block {
    transition: none;
  }
}

/* =========================================================
 * Block: drag & drop reorder
 * ========================================================= */

/* ハンドルにドラッグ中のヒントカーソル */
.apollo-handle {
  cursor: grab;
}
.apollo-handle:active {
  cursor: grabbing;
}
/* readOnly 時はドラッグ不可カーソル */
.apollo-root.apollo-readonly .apollo-handle {
  cursor: default;
}

/* ドラッグ中のブロック (透明度を下げる) */
.apollo-block.apollo-block-dragging {
  opacity: 0.4;
}

/* ドロップ位置インジケータ (上 / 下に細いライン) */
.apollo-block.apollo-drop-above::before,
.apollo-block.apollo-drop-below::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  height: 3px;
  background: var(--apollo-accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
}
.apollo-block.apollo-drop-above::before {
  top: -2px;
}
.apollo-block.apollo-drop-below::after {
  bottom: -2px;
}

/* ブロック D&D 中は editor 全体のファイル D&D ハイライトを抑制
   (画像 D&D の青い枠と並べ替えインジケータが二重に出ないように) */
.apollo-editor.apollo-block-dnd-active {
  outline: none !important;
}
.apollo-editor.apollo-block-dnd-active::before {
  display: none !important;
}
/* ブロック D&D 中は子要素の pointer-events を保証
   (apollo-drag-over の `* { pointer-events: none }` を打ち消す) */
.apollo-editor.apollo-block-dnd-active * {
  pointer-events: auto !important;
}
/* ブロック D&D 中に apollo-drag-over も同時に付いた場合は ::before 表示も抑制 */
.apollo-editor.apollo-block-dnd-active.apollo-drag-over {
  background: transparent !important;
}

/* キーボードでハンドルにフォーカスが来たら opacity:1 を確実に
   (:focus-within での親側からの opacity だけでは間に合わないケースの保険) */
.apollo-handle:focus-visible,
.apollo-handle:focus {
  opacity: 1 !important;
}

/* =========================================================
 * Indent (インデント)
 * ========================================================= */
/* classic モード: 段落要素自体に padding-left が直接スタイル指定されるので
   特別な CSS は不要。data-apollo-indent 属性は将来の拡張用に予約 */
/* block モード: wrap.style.paddingLeft で表現済み。
   ハンドル位置 (left:4px) は wrap 基準で固定だが、wrap 自体が右にずれる
   ため見た目は自動追従する */