/* ============================================================
   Redmine Monaco Editor Plugin - Stylesheet
   ============================================================ */

/* エディタ全体のラッパー */
.monaco-editor-wrapper {
  display: flex;
  flex-direction: column;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  margin-bottom: 4px;
  position: relative;
  /* overflow:hidden だと、wrapper内に配置した overflowWidgets(補完の
     詳細パネル等)が wrapper の表示領域(高さ)でクリップされて見えなく
     なる。クリップは内側の .monaco-editor-body（overflow:hidden 済み）に
     任せ、wrapper 自体は visible にしてウィジェットを突き抜けさせる。 */
  overflow: visible;
  min-height: 150px;
  box-sizing: border-box;
}

/* 縦リサイズハンドル（下端） */
.monaco-resize-handle {
  height: 6px;
  flex-shrink: 0;
  cursor: ns-resize;
  background: #f0f0f0;
  border-top: 1px solid #ddd;
  border-radius: 0 0 3px 3px;
  background-image: radial-gradient(circle, #aaa 1px, transparent 1px);
  background-size: 4px 4px;
  background-position: center;
  background-repeat: repeat-x;
}

.monaco-resize-handle:hover {
  background-color: #e0e8f0;
}

/* ============================================================
   単一ツールバー構造（1段）
   左: モードボタン群 (.monaco-toolbar-modes) — 固定で隠れない
   右: 装飾ボタン群   (.monaco-decoration-toolbar) — 幅不足で右から隠れる
   ============================================================ */

/* ツールバー全体 */
.monaco-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #fafafa;
  border-bottom: 1px solid #ddd;
  border-radius: 3px 3px 0 0;
  min-height: 36px;
  flex-shrink: 0;       /* bodyが伸縮してもツールバーは潰れない */
  overflow: hidden;     /* 装飾ボタンが幅を超えたら隠す */
  flex-wrap: nowrap;    /* 折り返さず1段固定 */
}

/* モードボタン群（左・固定幅・縮まない・隠れない） */
.monaco-toolbar-modes {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;       /* 縮小も省略もしない */
}

/* 装飾ボタン群（右・幅が足りなければ右端から見切れる） */
.monaco-decoration-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;    /* 折り返さない（はみ出しは overflow:hidden で切る）*/
  flex-shrink: 1;
  min-width: 0;         /* flexアイテムが縮めるように */
  overflow: hidden;
}

/* 装飾ボタン（アイコンのみ、正方形） */
.monaco-deco-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;       /* Redmineテーマのボタン影を除去（青ぽつぽつ対策） */
  -webkit-appearance: none;
  appearance: none;       /* OS/テーマのデフォルト装飾を無効化 */
  color: #333;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
  flex-shrink: 0;       /* 各ボタンは縮まず、丸ごと見切れる */
}

.monaco-deco-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* H1〜H4 は viewBox が横長（20x16）なので幅を広めに */
.monaco-deco-btn-wide {
  width: 32px;
}

.monaco-deco-btn-wide svg {
  width: 20px;
}

.monaco-deco-btn:hover {
  background: #e8f0fe;
  border-color: #4a90d9;
  color: #1a73e8;
}

.monaco-deco-btn:active {
  background: #d2e3fc;
}

/* 区切り線 */
.monaco-deco-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: #ccc;
  margin: 0 4px;
  flex-shrink: 0;
}

/* モード群と装飾群の境界セパレータ */
.monaco-group-sep {
  margin: 0 6px;
  flex-shrink: 0;
}

/* プレビュー切り替えボタン（モードボタン） */
.monaco-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  gap: 4px;
  height: 28px;            /* 装飾ボタンと高さを統一 */
  padding: 0 10px;
  margin: 0;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid #bbb;
  background: #fff;
  box-shadow: none;        /* Redmineテーマのボタン影を除去 */
  -webkit-appearance: none;
  appearance: none;
  color: #333;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

/* アイコンのみのモードボタン（縦分割・プレビュー・アウトライン） */
.monaco-preview-btn.monaco-icon-only {
  width: 30px;
  padding: 0;
}

.monaco-preview-btn.monaco-icon-only svg {
  margin: 0;
}

.monaco-preview-btn:hover {
  background: #e8f0fe;
  border-color: #4a90d9;
  color: #1a73e8;
}

.monaco-preview-btn.active {
  background: #1a73e8;
  border-color: #1a73e8;
  color: #fff;
}

.monaco-preview-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* エディタ本体エリア（アウトライン | ペインラッパー の横並び） */
.monaco-editor-body {
  display: flex;
  flex-direction: row;   /* 常に横並び。左=アウトライン、右=paneWrap */
  flex: 1 1 auto;
  min-height: 0;         /* wrapperの高さに完全追従（はみ出し防止）*/
  overflow: hidden;
}

/* ペインラッパー（エディタ＋スプリッター＋プレビューを内包） */
/* アウトラインの右側を占有し、分割方向はここで制御する */
.monaco-pane-wrap {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Monacoコンテナ */
.monaco-editor-container {
  flex: 1;
  min-width: 0;
  min-height: 0;     /* wrapperの高さに追従（はみ出し防止）*/
  overflow: hidden;
}

/* プレビューペイン */
.monaco-preview-pane {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  overflow-y: auto;
  border-left: 1px solid #ddd;
  display: none; /* デフォルトは非表示 */
}

/* 分割スプリッター（デフォルト非表示。分割時のみ表示） */
.monaco-splitter {
  display: none;
  flex-shrink: 0;
  background: #e8e8e8;
  position: relative;
  z-index: 1;
}

/* 左右分割時: 縦バー（左右ドラッグ）。判定は body、見た目適用は paneWrap 内 */
.monaco-editor-body.split-view .monaco-splitter {
  display: block;
  width: 6px;
  cursor: col-resize;
  background-image: radial-gradient(circle, #999 1px, transparent 1px);
  background-size: 4px 4px;
  background-position: center;
  background-repeat: repeat-y;
}

/* 縦分割時: 横バー（上下ドラッグ） */
.monaco-editor-body.split-view.split-vertical .monaco-splitter {
  width: auto;
  height: 6px;
  cursor: row-resize;
  background-image: radial-gradient(circle, #999 1px, transparent 1px);
  background-size: 4px 4px;
  background-position: center;
  background-repeat: repeat-x;
}

.monaco-splitter:hover {
  background-color: #c8d4e0;
}

/* サイドバイサイド表示時（左右に並べる） */
.monaco-editor-body.split-view .monaco-preview-pane {
  display: block;
}

/* 縦分割（上下に並べる。画面幅に依存しない）。
   paneWrap だけを column 方向にする。bodyは row のままなので
   アウトラインは左に固定され、スプリッターの割合計算も安定する。 */
.monaco-editor-body.split-view.split-vertical .monaco-pane-wrap {
  flex-direction: column;
}
.monaco-editor-body.split-view.split-vertical .monaco-editor-container {
  flex: 1 1 50%;
  min-height: 100px;
}
.monaco-editor-body.split-view.split-vertical .monaco-preview-pane {
  flex: 1 1 50%;
  min-height: 100px;
  border-left: none;
  border-top: 1px solid #ddd;
}

/* プレビューのみ表示時（編集エリアを隠す） */
.monaco-editor-body.preview-only .monaco-editor-container {
  display: none;
}

.monaco-editor-body.preview-only .monaco-preview-pane {
  display: block;
  border-left: none;
  flex: 1;
}

/* ------------------------------------------------------------
   狭い画面（768px以下）: 分割表示を縦並び（上:エディタ / 下:プレビュー）に
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  .monaco-editor-body.split-view .monaco-pane-wrap {
    flex-direction: column;
  }
  .monaco-editor-body.split-view .monaco-editor-container {
    /* 上半分をエディタに */
    flex: 1 1 50%;
    min-height: 0;
  }
  .monaco-editor-body.split-view .monaco-preview-pane {
    /* 下半分をプレビューに。境界線を左→上に変更 */
    flex: 1 1 50%;
    min-height: 0;
    border-left: none;
    border-top: 1px solid #ddd;
  }
  /* 狭い画面の縦並び時もスプリッターを横バーに */
  .monaco-editor-body.split-view .monaco-splitter {
    width: auto;
    height: 6px;
    cursor: row-resize;
    background-repeat: repeat-x;
  }
}

/* プレビュー内の見た目は Redmineテーマの .wiki / .wiki-preview に委譲する。
   （章番号の自動採番・フォント・テーブル等はテーマCSSがそのまま効く）
   ここでは独自装飾を一切当てない。 */

/* ローディング表示 */
.monaco-preview-loading {
  color: #999;
  font-style: italic;
  padding: 8px 0;
}

/* 元のtextareaは隠す */
textarea.wiki-edit.monaco-replaced {
  display: none !important;
}

/* ============================================================
   #1010 キャレット連動ツールチップ（自前DOM）
   ============================================================ */
.monaco-issue-tooltip {
  position: absolute;
  z-index: 10000;
  max-width: 600px;
  padding: 5px 10px;
  background: #2b2b2b;
  color: #f0f0f0;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none; /* ツールチップ自体はマウス操作を奪わない */
}

.monaco-issue-tooltip .tip-id {
  font-weight: bold;
  color: #6cb6ff;
}

.monaco-issue-tooltip .tip-meta {
  color: #c8c8c8;
}

/* ============================================================
   画像記法ホバー時のサムネイルツールチップ
   ============================================================ */
.monaco-image-tooltip {
  position: absolute;
  z-index: 10000;
  width: 160px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none; /* ツールチップ自体はマウス操作を奪わない */
}

.monaco-image-tooltip-img {
  width: 100%;
  max-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  overflow: hidden;
}

.monaco-image-tooltip-img img {
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  display: block;
}

.monaco-image-tooltip-name {
  font-size: 12px;
  color: #333;
  padding: 4px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
  border-top: 1px solid #eee;
  line-height: 1.4;
}

.monaco-image-tooltip-date {
  font-size: 10px;
  color: #888;
  padding: 0 7px 4px;
  background: #fff;
  line-height: 1.3;
}

/* ============================================================
   （旧）Monaco標準Hoverの余白詰め。キャレット方式に移行したが念のため残置
   ============================================================ */
.monaco-hover {
  line-height: 1.4 !important;
  max-width: 600px !important;
  white-space: normal !important;
}
.monaco-hover .hover-row,
.monaco-hover .hover-contents,
.monaco-hover .markdown-hover {
  padding: 4px 8px !important;
}
.monaco-hover p,
.monaco-hover .hover-contents p {
  margin: 0 0 2px 0 !important;
  line-height: 1.4 !important;
  white-space: normal !important;
}
.monaco-hover p:last-child {
  margin-bottom: 0 !important;
}

/* ============================================================
   アウトラインパネル（左側・トグル表示）
   ============================================================ */
.monaco-outline-pane {
  display: none;           /* デフォルト非表示 */
  flex: 0 0 220px;         /* 固定幅220px */
  min-width: 120px;
  overflow-y: auto;
  border-right: 1px solid #ddd;
  background: #fafafa;
  font-size: 12px;
  padding: 4px 0;
}

/* アウトライン表示時のみパネルを出す */
.monaco-editor-body.outline-visible .monaco-outline-pane {
  display: block;
}

.monaco-outline-item {
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
  border-left: 2px solid transparent;
}

.monaco-outline-item:hover {
  background: #e8f0fe;
  border-left-color: #4a90d9;
}

/* 見出しレベルごとの見た目（H1は太め、深いほど薄く） */
.monaco-outline-item.level-1 { font-weight: 600; color: #1a1a1a; }
.monaco-outline-item.level-2 { font-weight: 500; color: #333; }
.monaco-outline-item.level-3 { color: #555; }
.monaco-outline-item.level-4,
.monaco-outline-item.level-5,
.monaco-outline-item.level-6 { color: #777; font-size: 11px; }

.monaco-outline-empty {
  padding: 10px 8px;
  color: #999;
  font-style: italic;
}

/* ============================================================
   @メンション補完候補（suggest-widget）の配色
   ============================================================ */
/* Monaco本体が
     .suggest-widget .monaco-list .monaco-list-row > .contents > .main ...
   という深い階層＋高詳細度で色を指定しているため、こちらも同等以上の
   詳細度で指定しないと上書きできない。DOM構造に沿って深く書く。
   背景: 非選択行=明るいグレー / 選択行(focused)=濃い青 */

/* 非選択行（明るいテーマ時）→ 濃い文字 */
.monaco-editor .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-icon-label,
.monaco-editor .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-icon-label .label-name,
.monaco-editor .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-highlighted-label {
  color: #1a1a1a !important;
}

/* 非選択行のあいまい一致ハイライト → 青で強調 */
.monaco-editor .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-highlighted-label .highlight {
  color: #0a66c2 !important;
  font-weight: bold !important;
}

/* 選択行(focused・濃い青背景) → 白文字 */
.monaco-editor .suggest-widget .monaco-list .monaco-list-row.focused > .contents > .main .monaco-icon-label,
.monaco-editor .suggest-widget .monaco-list .monaco-list-row.focused > .contents > .main .monaco-icon-label .label-name,
.monaco-editor .suggest-widget .monaco-list .monaco-list-row.focused > .contents > .main .monaco-highlighted-label {
  color: #ffffff !important;
}

/* 選択行のあいまい一致ハイライト → 白＋下線 */
.monaco-editor .suggest-widget .monaco-list .monaco-list-row.focused > .contents > .main .monaco-highlighted-label .highlight {
  color: #ffffff !important;
  font-weight: bold !important;
  text-decoration: underline !important;
}

/* あいまい一致ハイライトの黄色っぽい背景を消す（文字色だけで強調する） */
.monaco-editor .suggest-widget .monaco-list .monaco-list-row > .contents > .main .monaco-highlighted-label .highlight {
  background: transparent !important;
}

/* 説明（メンション） */
.monaco-editor .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main > .right > .details-label {
  color: #666 !important;
}
.monaco-editor .suggest-widget .monaco-list .monaco-list-row.focused > .contents > .main > .right > .details-label {
  color: #e0e0e0 !important;
}

/* ============================================================
   表グリッド選択ピッカー
   ============================================================ */
.monaco-table-picker {
  position: absolute;
  z-index: 10001;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  padding: 8px;
  user-select: none;
}

.monaco-table-label {
  font-size: 11px;
  color: #666;
  text-align: center;
  margin-bottom: 6px;
  min-height: 14px;
  font-weight: 500;
}

.monaco-table-grid {
  display: grid;
  gap: 3px;
}

.monaco-table-cell {
  width: 18px;
  height: 18px;
  border: 1px solid #ccc;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  transition: background 0.08s, border-color 0.08s;
}

.monaco-table-cell.selected {
  background: #b8d4f5;
  border-color: #4a90d9;
}

.monaco-table-cell:hover {
  border-color: #4a90d9;
}

/* ============================================================
   画像挿入ピッカー
   ============================================================ */
.monaco-image-picker {
  position: absolute;
  z-index: 10001;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  padding: 10px;
  min-width: 300px;
  max-width: 520px;
  max-height: 460px;
  overflow-y: auto;
  user-select: none;
}

.monaco-image-picker-title {
  font-size: 11px;
  font-weight: 600;
  color: #444;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

.monaco-image-picker-sep {
  font-size: 10px;
  color: #999;
  margin: 8px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* サムネイルグリッド */
.monaco-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.monaco-image-thumb {
  width: 120px;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
  background: #fafafa;
}

.monaco-image-thumb:hover {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px #d2e3fc;
}

.monaco-image-thumb-img {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  overflow: hidden;
}

.monaco-image-thumb-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.monaco-image-thumb-name {
  font-size: 13px;
  color: #333;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
  border-top: 1px solid #eee;
  line-height: 1.4;
}

/* 非画像ファイル行 */
.monaco-image-file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.monaco-image-file-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: #333;
  transition: background 0.1s;
}

.monaco-image-file-row:hover {
  background: #e8f0fe;
  color: #1a73e8;
}

.monaco-image-file-icon {
  flex-shrink: 0;
  color: #888;
  display: flex;
  align-items: center;
}

.monaco-image-file-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* フォールバック入力欄 */
.monaco-image-fallback {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.monaco-image-input {
  flex: 1;
  font-size: 12px;
  padding: 4px 7px;
  border: 1px solid #ccc;
  border-radius: 3px;
  outline: none;
  color: #333;
}

.monaco-image-input:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px #d2e3fc;
}

.monaco-image-insert-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #4a90d9;
  border-radius: 3px;
  background: #1a73e8;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}

.monaco-image-insert-btn:hover {
  background: #1557b0;
}

/* ============================================================
   装飾ツールバー：プレビューのみモード時の無効化
   ============================================================ */
.monaco-decoration-toolbar--disabled {
  opacity: 0.4;
  pointer-events: none;  /* クリック・ホバーを完全に無効化 */
}

/* ============================================================
   ファイルリンク挿入ピッカー
   ============================================================ */
.monaco-filelink-picker {
  min-width: 300px;
  max-width: 460px;
}

.monaco-filelink-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 4px;
}

.monaco-filelink-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.monaco-filelink-row:hover {
  background: #e8f0fe;
}

.monaco-filelink-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  width: 18px;
  height: 18px;
}

.monaco-filelink-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.monaco-filelink-name {
  font-size: 13px;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monaco-filelink-desc {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   全画面トグル
   ============================================================ */
/* 装飾群と全画面ボタンの間を押し広げ、全画面ボタンを右端へ寄せる */
.monaco-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 0;
}

/* 全画面ボタン自体は縮まない（常に表示） */
.monaco-fullscreen-btn {
  flex-shrink: 0;
}

/* 擬似全画面: wrapper を画面いっぱいに固定配置する */
/* wrapper には高さがインラインstyleで入るため !important で上書きする */
.monaco-editor-wrapper.monaco-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  box-sizing: border-box;
}

/* 全画面中はツールバー以外の領域（body）が残り全部を埋めるようにする。
   wrapper が flex column なので、ツールバー(固定高)以外を body が占める。 */
.monaco-editor-wrapper.monaco-fullscreen .monaco-editor-body {
  flex: 1 1 auto;
  min-height: 0;
}

/* 全画面中は下端リサイズハンドルを隠す（画面いっぱいのため不要） */
.monaco-editor-wrapper.monaco-fullscreen .monaco-resize-handle {
  display: none;
}

/* 全画面中は背面（body）のスクロールを抑止 */
body.monaco-fullscreen-active {
  overflow: hidden;
}

/* ============================================================
   サムネイル ライトボックス（プレビュー内 {{thumbnail}} 拡大表示）
   ============================================================
   プレビュー内のサムネイルクリックで、ページ遷移せず画面内に
   原寸（ビューポート内に収まる範囲）で拡大表示するためのオーバーレイ。 */
.monaco-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  /* クリックで閉じられることを示すカーソル */
  cursor: zoom-out;
  padding: 24px;
  box-sizing: border-box;
}

.monaco-lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  /* 画像本体はクリックしても閉じない（既定カーソルに戻す） */
  cursor: default;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  background: #fff;
  border-radius: 2px;
}

.monaco-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  line-height: 34px;
  text-align: center;
  font-size: 24px;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.monaco-lightbox-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* プレビュー内サムネイルにズームカーソルを出して、拡大できることを示す */
.monaco-preview-pane img.thumbnail,
.monaco-preview-pane a img.thumbnail {
  cursor: zoom-in;
}

/* ============================================================
   補完候補リスト（suggest-widget）の文字色 — テーマ別
   ============================================================
   背景はテーマ（vs / vs-dark）で変わるため、文字色もテーマで切り替える。
   ライトテーマ(vs)の濃い文字は上の既定ルールが担当し、ここでは
   ダークテーマ(vs-dark)のときだけ明るい文字に上書きする。
   実テキストは .monaco-highlighted-label に入る（.label-name は親）。 */

/* ダークテーマ: 非選択行 → 明るい文字 #E1E4E8 */
.monaco-editor.vs-dark .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-icon-label,
.monaco-editor.vs-dark .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-icon-label .label-name,
.monaco-editor.vs-dark .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-highlighted-label {
  color: #E1E4E8 !important;
}

/* ダークテーマ: 非選択行のあいまい一致ハイライト → 青系のまま強調
   （明るい文字の上で映えるよう、やや明るめの青にする） */
.monaco-editor.vs-dark .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main .monaco-highlighted-label .highlight {
  color: #6cb6ff !important;
  font-weight: bold !important;
}

/* ダークテーマ: 説明(detail) → やや明るいグレー */
.monaco-editor.vs-dark .suggest-widget .monaco-list .monaco-list-row:not(.focused) > .contents > .main > .right > .details-label {
  color: #9DA5B4 !important;
}

/* ============================================================
   オーバーフローウィジェットの配置先ルート
   ============================================================
   overflowWidgetsDomNode に指定した固定コンテナ。
   コンテナ自体は pointer-events:none で背面操作を妨げないが、
   中に入る実際のウィジェット（補完・ホバー・詳細パネル）は
   操作できる必要があるので pointer-events を復活させる。 */
.monaco-overflow-widgets-root {
  /* コンテナは入力を透過（下のUIを触れるように） */
  pointer-events: none;
  /* monaco-editor クラス由来の背景・枠・サイズの影響を打ち消す。
     このノードは「座標系の基準点」だけを提供し、見た目は持たない。 */
  background: transparent !important;
  border: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: visible !important;
}
.monaco-overflow-widgets-root > * {
  /* 実際のウィジェットはクリック/ホバー可能に戻す */
  pointer-events: auto;
}
@keyframes mteTbFlash {
  0%   { background: #7fd1a3; }
  100% { background: transparent; }
}

/* glyph margin 自体が幅0に潰れるのを防ぐ（行番号offでも領域を確保）。 */
.monaco-editor .glyph-margin { width: 22px !important; }
.monaco-editor .margin-view-overlays .cgmr { width: 22px !important; }

/* Monaco ホバー（.monaco-hover）の余白・行間を詰めて統一 */
.monaco-hover {
  padding: 2px 4px !important;
  min-width: 0 !important;
  /* Redmine の継承(line-height/font-size)を断ち、説明欄/コメント欄を統一 */
  font-size: 12px !important;
  line-height: 1.4 !important;
}
.monaco-hover .monaco-hover-content,
.monaco-hover .hover-row,
.monaco-hover .hover-contents,
.monaco-hover .rendered-markdown {
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
}
.monaco-hover .rendered-markdown p,
.monaco-hover .rendered-markdown ul,
.monaco-hover .rendered-markdown ol,
.monaco-hover .rendered-markdown pre {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.4 !important;
}
.monaco-hover .rendered-markdown p {
  margin: 2px 0 !important;
  /* Redmine の .tabular p:170px 漏れを潰す */
  padding: 0 !important;
}

/* 補完候補のドキュメントペイン（.details）の幅確保と余白詰め */
.monaco-editor .suggest-widget .details {
  min-width: 360px;
}
.monaco-editor .suggest-widget .details .docs {
  padding: 6px 10px !important;
  /* Redmine の継承を断ち、説明欄/コメント欄を統一 */
  font-size: 12px !important;
  line-height: 1.45 !important;
}
/* docs 内ブロック要素の継承余白・170px インデントをリセット */
.monaco-editor .suggest-widget .details .docs p,
.monaco-editor .suggest-widget .details .docs ul,
.monaco-editor .suggest-widget .details .docs ol,
.monaco-editor .suggest-widget .details .docs pre,
.monaco-editor .suggest-widget .details .docs blockquote,
.monaco-editor .suggest-widget .details .rendered-markdown p,
.monaco-editor .suggest-widget .details .rendered-markdown ul,
.monaco-editor .suggest-widget .details .rendered-markdown ol,
.monaco-editor .suggest-widget .details .rendered-markdown pre {
  margin: 0 !important;
  padding: 0 !important;
  text-indent: 0 !important;
  line-height: 1.45 !important;
}
.monaco-editor .suggest-widget .details .docs p,
.monaco-editor .suggest-widget .details .rendered-markdown p {
  margin: 2px 0 !important;
}
/* 使用例のコードブロック（```）を等幅・詰めて表示 */
.monaco-editor .suggest-widget .details .docs pre,
.monaco-editor .suggest-widget .details .rendered-markdown pre {
  padding: 4px 6px !important;
  margin: 2px 0 !important;
  text-indent: 0 !important;
  font-size: 11px !important;
  line-height: 1.4 !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
}
.monaco-editor .suggest-widget .details .docs pre code,
.monaco-editor .suggest-widget .details .docs code,
.monaco-editor .suggest-widget .details .rendered-markdown pre code,
.monaco-editor .suggest-widget .details .rendered-markdown code {
  padding: 0 !important;
  font-size: inherit !important;
  line-height: inherit !important;
  background: transparent !important;
}
/* 候補リスト側の .docs（インラインで出る短い説明）も詰める */
.monaco-editor .suggest-widget .monaco-list-row .docs {
  padding: 2px 6px !important;
}

/* 行頭余白対策: opale.css の .tabular p:170px が説明欄(tabular内)の
   補完パネル p に漏れるのを潰す。コメント欄は tabular 外なので元々正常 */
.monaco-editor .suggest-widget p,
.monaco-editor .suggest-widget pre,
.monaco-editor .suggest-widget li,
.monaco-editor .suggest-widget h1,
.monaco-editor .suggest-widget h2,
.monaco-editor .suggest-widget h3,
/* .tabular 直撃（opale.css の .tabular p:170px を確実に上書き） */
.tabular .monaco-editor .suggest-widget p,
.tabular .suggest-widget p,
.tabular .monaco-overflow-widgets-root .suggest-widget p,
/* 詳細パネルは fixedOverflowWidgets で .suggest-details 配下に出る
   （.suggest-widget 経由ではない）ため、こちらを起点に余白を潰す */
.monaco-editor .suggest-details p,
.monaco-editor .suggest-details pre,
.monaco-editor .suggest-details li,
.monaco-editor .suggest-details h1,
.monaco-editor .suggest-details h2,
.monaco-editor .suggest-details h3,
.suggest-details p,
.suggest-details-container p,
.monaco-overflow-widgets-root .suggest-details p,
.monaco-overflow-widgets-root p.type,
.monaco-overflow-widgets-root p.auto-wrap,
.tabular .suggest-details p {
  padding-left: 0 !important;
  margin-left: 0 !important;
  text-indent: 0 !important;
  /* 行間も Redmine 継承で間延びするため Monaco 標準相当に詰める */
  line-height: 1.4 !important;
}
/* 詳細パネルのコンテナ自体にも行間を固定（子の継承元を断つ） */
.monaco-editor .suggest-details,
.monaco-editor .suggest-details .body,
.monaco-editor .suggest-details .header,
.suggest-details,
.suggest-details-container,
.monaco-overflow-widgets-root .suggest-details {
  line-height: 1.4 !important;
}
/* Monaco が詳細パネル本文に付ける標準クラス（実測で class="type auto-wrap"）
   への直撃指定。padding-left:5px の出所はここ。詳細度を上げて確実に勝たせる。 */
.monaco-editor .suggest-widget .details p.type,
.monaco-editor .suggest-widget .details p.auto-wrap,
.monaco-editor .suggest-widget p.type,
.monaco-editor .suggest-widget p.auto-wrap {
  padding: 0 !important;
  margin: 2px 0 !important;
  text-indent: 0 !important;
}

/* ============================================================
   表ビルダー: 既存表の glyph margin アイコン
   ------------------------------------------------------------
   本文中の表ブロック先頭行の glyph margin に表示する「表ビルダーで
   編集」アイコン。クリックでその表を表ビルダー (textgrid) へ読み込む。
   この CSS は textgrid ライブラリの一部ではなく、Redmine プラグイン
   固有の Monaco 連携 UI なので、ここに置く。
   ============================================================ */
.mte-tb-glyph {
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'><rect x='1.5' y='2.5' width='13' height='11' rx='1.2' stroke='%234a7' stroke-width='1.2'/><line x1='1.5' y1='6' x2='14.5' y2='6' stroke='%234a7' stroke-width='1.2'/><line x1='6' y1='2.5' x2='6' y2='13.5' stroke='%234a7' stroke-width='1'/><line x1='10.5' y1='2.5' x2='10.5' y2='13.5' stroke='%234a7' stroke-width='1'/></svg>");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 16px 16px;
  width: 18px !important;
  height: 18px !important;
  margin-left: 2px;
  opacity: 0.6;
  transition: opacity 0.12s ease;
}
.mte-tb-glyph:hover { opacity: 1; }

/* ============================================================
   表ビルダー: コピー完了などの軽量トースト通知
   ------------------------------------------------------------
   textgrid 外部の表示なので Redmine プラグイン側で定義。
   ============================================================ */
.mte-tb-toast {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 100001;
  max-width: 360px;
  background: #2e8b57;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.mte-tb-toast.mte-tb-toast-show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   編集差分マーカー（gutter）
   ------------------------------------------------------------
   開いた時点の本文を基準に、編集中の差分を行装飾マージンへ出す。
     追加行   → 緑の縦線
     変更行   → 青の縦線
     削除位置 → 赤い三角（行を塗らず、行の上端＝行間に出す）
   glyph margin（表ビルダーのアイコン）とは別レーンなので競合しない。
   ============================================================ */
.monaco-editor .mte-diff-added,
.monaco-editor .mte-diff-modified {
  width: 3px !important;
  margin-left: 2px;
  cursor: pointer;
}
.monaco-editor .mte-diff-added {
  background-color: #2ea043; /* 緑（追加） */
}
.monaco-editor .mte-diff-modified {
  background-color: #0969da; /* 青（変更） */
}

/* 削除マーカー: VS Code 流の行間三角。行は塗らず、対象行の上端に
   小さな左向き赤三角を ::before で描く（行高には影響しない）。
   要素本体には透明な幅を持たせて、クリック判定領域を確保する
   (::before は pointer events を受けないため、親要素でクリックを受ける)。 */
.monaco-editor .mte-diff-removed {
  position: relative;
  width: 8px !important;        /* クリック判定の幅(背景は透明) */
  background: transparent;
  overflow: visible;
  cursor: pointer;
}
.monaco-editor .mte-diff-removed::before {
  content: '';
  position: absolute;
  left: 1px;
  top: -4px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent #cf222e; /* 赤 */
  pointer-events: none;          /* 親要素にクリックを伝える */
}

/* ダークテーマ調整 */
.monaco-editor.vs-dark .mte-diff-added,
.monaco-editor.mte-github-dark .mte-diff-added {
  background-color: #3fb950;
}
.monaco-editor.vs-dark .mte-diff-modified,
.monaco-editor.mte-github-dark .mte-diff-modified {
  background-color: #58a6ff;
}
.monaco-editor.vs-dark .mte-diff-removed::before,
.monaco-editor.mte-github-dark .mte-diff-removed::before {
  border-left-color: #f85149;
}

/* ============================================================
   編集差分マーカー — Peek パネル (クリックで変更前を表示)
   ------------------------------------------------------------
   gutter の色付き要素をクリックすると、その変更箇所の上に展開される
   読み取り専用パネル。view zone の domNode として直接挿入される。
   ============================================================ */
.monaco-editor .mte-diff-peek {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-left: 3px solid #cf222e; /* 変更前=削除色のアクセント */
  border-radius: 3px;
  /* 完全左寄せ。エディタの左端から右端まで使い、×ボタンが必ず画面内に入るようにする。 */
  margin: 2px 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.monaco-editor .mte-diff-peek-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  /* 右側は Monaco の縦スクロールバー(約14px)を避けるため余白を多めに。 */
  padding: 0 24px 0 8px;
  background: #eaeef2;
  border-bottom: 1px solid #d0d7de;
  font-size: 11px;
  color: #57606a;
  user-select: none;
  /* スクロールバーより前面に出す(ヘッダ全体)。 */
  position: relative;
  z-index: 10;
}
.monaco-editor .mte-diff-peek-title {
  font-weight: 500;
}
/* ヘッダ右側のアクション群(戻す・閉じる)。同じサイズ感で並べる。 */
.monaco-editor .mte-diff-peek-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 11;
}
.monaco-editor .mte-diff-peek-action {
  background: none;
  border: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: #57606a;
  cursor: pointer;
  border-radius: 3px;
}
.monaco-editor .mte-diff-peek-action:hover {
  background: #d0d7de;
  color: #1f2328;
}
.monaco-editor .mte-diff-peek-revert {
  font-size: 16px; /* ↶ は小さめに見えるので少し大きく */
}
.monaco-editor .mte-diff-peek-close {
  font-size: 18px; /* × は線が細いので少し大きく */
}
.monaco-editor .mte-diff-peek-body {
  /* 左 padding はエディタの文字開始位置と揃える狙い。
     Monaco の行装飾レーン+行番号幅で合計 60〜70px 前後。
     折り返し有効なエディタでも違和感がないように 66px 固定にしておく。 */
  padding: 4px 12px 4px 66px;
  background: #ffeef0; /* 「削除側」を表す薄い赤背景 (GitHub diff の旧側色相当) */
  color: #1f2328;
  white-space: pre;
  overflow-x: auto;
}
.monaco-editor .mte-diff-peek-line {
  white-space: pre;
}
.monaco-editor .mte-diff-peek-empty {
  color: #57606a;
  font-style: italic;
  background: transparent;
}

/* ダークテーマ */
.monaco-editor.vs-dark .mte-diff-peek,
.monaco-editor.mte-github-dark .mte-diff-peek {
  background: #161b22;
  border-color: #30363d;
  border-left-color: #f85149;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.monaco-editor.vs-dark .mte-diff-peek-header,
.monaco-editor.mte-github-dark .mte-diff-peek-header {
  background: #21262d;
  border-bottom-color: #30363d;
  color: #8b949e;
}
.monaco-editor.vs-dark .mte-diff-peek-action,
.monaco-editor.mte-github-dark .mte-diff-peek-action {
  color: #8b949e;
}
.monaco-editor.vs-dark .mte-diff-peek-action:hover,
.monaco-editor.mte-github-dark .mte-diff-peek-action:hover {
  background: #30363d;
  color: #e6edf3;
}
.monaco-editor.vs-dark .mte-diff-peek-body,
.monaco-editor.mte-github-dark .mte-diff-peek-body {
  background: #67060c33; /* 薄い赤 */
  color: #e6edf3;
}
.monaco-editor.vs-dark .mte-diff-peek-empty,
.monaco-editor.mte-github-dark .mte-diff-peek-empty {
  color: #8b949e;
}

/* ============================================================
   変更履歴ドロップダウン（モードバーの「変更履歴」ボタン配下）
   ============================================================ */
/* ボタンの親(モードバー or その親)は position: relative であってほしい。
   既存の monaco-preview-mode-bar が relative になっていない場合に備え、
   念のため指定する。 */
.monaco-preview-mode-bar,
.monaco-mode-group {
  position: relative;
}

.monaco-history-menu {
  position: absolute;
  z-index: 50;
  display: none;
  min-width: 320px;
  max-width: 560px;
  max-height: 60vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  padding: 4px 0;
  font-size: 12px;
  color: #1f2328;
}
.monaco-history-menu-header {
  padding: 6px 12px 4px;
  font-size: 11px;
  color: #57606a;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-bottom: 1px solid #eaeef2;
  margin-bottom: 4px;
}
.monaco-history-menu-trunc {
  padding: 2px 12px 6px;
  font-size: 11px;
  color: #8b949e;
  font-style: italic;
}
.monaco-history-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.monaco-history-menu-item:hover,
.monaco-history-menu-item:focus {
  background: #ddeefd; /* 視認性が出る青系ハイライト */
  color: #0a3069;
  outline: none;
}

/* ダーク */
.monaco-editor.vs-dark ~ .monaco-history-menu,
.monaco-editor.mte-github-dark ~ .monaco-history-menu,
body.theme-mte-github-dark .monaco-history-menu {
  background: #161b22;
  border-color: #30363d;
  color: #e6edf3;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
}
body.theme-mte-github-dark .monaco-history-menu-header {
  color: #8b949e;
  border-bottom-color: #21262d;
}
body.theme-mte-github-dark .monaco-history-menu-trunc {
  color: #6e7681;
}
body.theme-mte-github-dark .monaco-history-menu-item:hover,
body.theme-mte-github-dark .monaco-history-menu-item:focus {
  background: #1f4068;
  color: #cae6ff;
}

/* ============================================================
   diff モード(変更履歴の左右並列表示)
   ============================================================ */
/* body.diff-mode の時は split-view レイアウトを流用しつつ、
   プレビューペインは表示しない(diff コンテナがその場所を使う)。 */
.monaco-editor-body.diff-mode .monaco-preview-pane {
  display: none;
}
.monaco-editor-body.diff-mode .monaco-splitter {
  display: none;
}

/* diff コンテナ自体。paneWrap の中で全幅を占める。 */
.monaco-diff-container {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #ffffff;
}
.monaco-diff-container .monaco-diff-pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #d0d7de;
}
.monaco-diff-container .monaco-diff-pane:first-child {
  border-left: none;
}
.monaco-diff-container .monaco-diff-header {
  flex: 0 0 auto;
  height: 26px;
  background: #eaeef2;
  border-bottom: 1px solid #d0d7de;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #57606a;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.monaco-diff-container .monaco-diff-header-title {
  overflow: hidden;
  text-overflow: ellipsis;
}
.monaco-diff-container .monaco-diff-host {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.monaco-diff-container .monaco-diff-close {
  background: none;
  border: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: #57606a;
  cursor: pointer;
  border-radius: 3px;
  padding: 0;
}
.monaco-diff-container .monaco-diff-close:hover {
  background: #d0d7de;
  color: #1f2328;
}

/* 行装飾: 左=旧=赤背景、右=新=緑背景 */
.monaco-editor .mte-diff-side-removed {
  background-color: rgba(207, 34, 46, 0.12); /* 薄い赤 */
}
.monaco-editor .mte-diff-side-added {
  background-color: rgba(46, 160, 67, 0.14); /* 薄い緑 */
}
/* 行内の濃い色ハイライト (実際に変わった文字に当てる)。
   行全体の薄い背景の上に重なるため、こちらは濃いめの背景を当てる。 */
.monaco-editor .mte-diff-token-removed {
  background-color: rgba(207, 34, 46, 0.12) !important; /* 濃い赤 */
}
.monaco-editor .mte-diff-token-added {
  background-color: rgba(46, 160, 67, 0.14) !important; /* 濃い緑 */
}
/* 行頭の -/+ マーカー。glyphMargin に出す。 */
.monaco-editor .mte-diff-glyph-minus,
.monaco-editor .mte-diff-glyph-plus {
  display: inline-block;
  text-align: center;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: inherit;
}
.monaco-editor .mte-diff-glyph-minus::before {
  content: '-';
  color: #cf222e;
}
.monaco-editor .mte-diff-glyph-plus::before {
  content: '+';
  color: #1a7f37;
}

/* ダークテーマ */
.monaco-editor.vs-dark .mte-diff-side-removed,
.monaco-editor.mte-github-dark .mte-diff-side-removed {
  background-color: rgba(248, 81, 73, 0.16);
}
.monaco-editor.vs-dark .mte-diff-side-added,
.monaco-editor.mte-github-dark .mte-diff-side-added {
  background-color: rgba(63, 185, 80, 0.16);
}
/* 行内ハイライト (ダーク) */
.monaco-editor.vs-dark .mte-diff-token-removed,
.monaco-editor.mte-github-dark .mte-diff-token-removed {
  background-color: rgba(248, 81, 73, 0.16) !important;
}
.monaco-editor.vs-dark .mte-diff-token-added,
.monaco-editor.mte-github-dark .mte-diff-token-added {
  background-color: rgba(63, 185, 80, 0.12) !important;
}
.monaco-editor.vs-dark .mte-diff-glyph-minus::before,
.monaco-editor.mte-github-dark .mte-diff-glyph-minus::before {
  color: #f85149;
}
.monaco-editor.vs-dark .mte-diff-glyph-plus::before,
.monaco-editor.mte-github-dark .mte-diff-glyph-plus::before {
  color: #3fb950;
}

body.theme-mte-github-dark .monaco-diff-container,
.monaco-editor-body.diff-mode.theme-mte-github-dark .monaco-diff-container {
  background: #0d1117;
}
body.theme-mte-github-dark .monaco-diff-container .monaco-diff-header,
.monaco-editor-body.diff-mode.theme-mte-github-dark .monaco-diff-container .monaco-diff-header {
  background: #161b22;
  border-bottom-color: #30363d;
  color: #8b949e;
}
body.theme-mte-github-dark .monaco-diff-container .monaco-diff-pane,
.monaco-editor-body.diff-mode.theme-mte-github-dark .monaco-diff-container .monaco-diff-pane {
  border-left-color: #30363d;
}
body.theme-mte-github-dark .monaco-diff-container .monaco-diff-close,
.monaco-editor-body.diff-mode.theme-mte-github-dark .monaco-diff-container .monaco-diff-close {
  color: #8b949e;
}
body.theme-mte-github-dark .monaco-diff-container .monaco-diff-close:hover,
.monaco-editor-body.diff-mode.theme-mte-github-dark .monaco-diff-container .monaco-diff-close:hover {
  background: #30363d;
  color: #e6edf3;
}

/* ============================================================
   行末 Blame ヒント (カーソル行に薄く著者・日付・#注記を出す)
   ------------------------------------------------------------
   Monaco の Content Widget で描画される div。textContent に
   ラベル文字列が入る。位置はカーソル行末。
   line-height は JS 側で動的に設定する(エディタの実 lineHeight に
   追従させ、フォントサイズ変更にも対応するため)。 */
.monaco-editor .mte-blame-hint {
  color: rgba(120, 120, 120, 0.55);
  font-style: italic;
  font-weight: normal;
  font-size: 0.92em;
  white-space: pre;
  pointer-events: auto; /* ホバー検知のため auto。クリックは bubble させる */
  user-select: none;
  padding-left: 3em;
  display: inline-block;
  vertical-align: middle;
  cursor: default;
}
.monaco-editor.vs-dark .mte-blame-hint,
.monaco-editor.mte-github-dark .mte-blame-hint {
  color: rgba(180, 180, 180, 0.55);
}

/* ============================================================
   Blame ツールチップ (ホバー1秒で出すカード)
   ------------------------------------------------------------
   Monaco の Content Widget として描画されるため、position や
   z-index はここでは指定しない(Monaco が overflow-widgets-root
   配下に配置する。フルスクリーンでも追従する)。
   ============================================================ */
.mte-blame-tooltip {
  background: #ffffff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  font-size: 12px;
  color: #1f2328;
  min-width: 240px;
  max-width: 420px;
  line-height: 1.5;
}
.mte-blame-tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mte-blame-tooltip-author {
  font-weight: 600;
}
.mte-blame-tooltip-date {
  color: #57606a;
  font-size: 11px;
}
.mte-blame-tooltip-note {
  background: #eaeef2;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  color: #1f2328;
}
.mte-blame-tooltip-summary {
  margin-top: 6px;
  display: flex;
  gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
.mte-blame-tooltip-added {
  color: #1a7f37;
}
.mte-blame-tooltip-removed {
  color: #cf222e;
}
.mte-blame-tooltip-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}
.mte-blame-tooltip-jump {
  background: #0969da;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 11px;
  cursor: pointer;
}
.mte-blame-tooltip-jump:hover {
  background: #0860c4;
}

/* ダーク (mte-blame-tooltip--dark クラスが付いてるとき、または body のテーマで) */
body.theme-mte-github-dark .mte-blame-tooltip,
.mte-blame-tooltip.mte-blame-tooltip--dark {
  background: #0d1117;
  border-color: #30363d;
  color: #e6edf3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}
body.theme-mte-github-dark .mte-blame-tooltip-date,
.mte-blame-tooltip.mte-blame-tooltip--dark .mte-blame-tooltip-date {
  color: #8b949e;
}
body.theme-mte-github-dark .mte-blame-tooltip-note,
.mte-blame-tooltip.mte-blame-tooltip--dark .mte-blame-tooltip-note {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
}
body.theme-mte-github-dark .mte-blame-tooltip-added,
.mte-blame-tooltip.mte-blame-tooltip--dark .mte-blame-tooltip-added {
  color: #3fb950;
}
body.theme-mte-github-dark .mte-blame-tooltip-removed,
.mte-blame-tooltip.mte-blame-tooltip--dark .mte-blame-tooltip-removed {
  color: #f85149;
}
body.theme-mte-github-dark .mte-blame-tooltip-jump,
.mte-blame-tooltip.mte-blame-tooltip--dark .mte-blame-tooltip-jump {
  background: #1f6feb;
  color: #ffffff;
}
body.theme-mte-github-dark .mte-blame-tooltip-jump:hover,
.mte-blame-tooltip.mte-blame-tooltip--dark .mte-blame-tooltip-jump:hover {
  background: #388bfd;
}
