/* MDPop2 追加コンポーネントのスタイル
   (基本レイアウト・テーマ変数は style.css。本ファイルは新規UI部品のみ) */

/* ---------- メディアビューア ---------- */
#mediaview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  zoom: var(--content-zoom);
}
.media-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.media-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bar-bg);
}
.media-toolbar button { padding: 3px 10px; font-size: 12px; }
.media-toolbar select {
  font-size: 12px;
  padding: 2px 4px;
  color: var(--text);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.media-info { font-size: 11px; color: var(--muted); margin: 0 6px; }
.media-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
.media-error {
  padding: 10px 14px;
  font-size: 12px;
  color: #b42318;
}

/* 画像 */
.img-scroller {
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  /* 中央寄せに align-items/justify-content を使わない:
     画像がコンテナより大きいとき、はみ出した左端・上端がスクロールで到達できなくなる
     (スクロール原点が0のため、開始側のオーバーフローが切り捨てられる)。
     フレックスの auto マージンは「空きが負なら0」と規定されているので、
     中央寄せは .img-view 側の margin:auto に任せると拡大時も端まで動かせる。 */
  background:
    conic-gradient(var(--hover) 0 25%, transparent 0 50%, var(--hover) 0 75%, transparent 0)
    0 0 / 24px 24px; /* 透過画像用の市松模様 */
  cursor: default;
}
/* つかんで動かせるとき(はみ出しがあるとき)だけ手のカーソルにする */
.img-scroller.pannable { cursor: grab; }
.img-scroller.panning { cursor: grabbing; }
.img-view {
  display: block;
  margin: auto;
  /* フレックス既定の flex-shrink:1 だと、拡大しても幅がコンテナまで縮められてしまい
     横方向に一切はみ出さない(=横パンが効かない)。縮小を止めて指定幅を守らせる。 */
  flex: 0 0 auto;
  -webkit-user-drag: none; /* 画像のネイティブドラッグがパンを乗っ取るのを防ぐ */
  user-select: none;
}
.img-view.fit { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 動画 */
.video-view {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #000;
  outline: none;
}

/* 音楽 */
.media-audio { align-items: center; justify-content: flex-start; overflow-y: auto; }
.audio-card {
  width: min(560px, 92%);
  margin: 32px auto 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bar-bg);
}
.audio-art { font-size: 56px; }
.audio-title { font-size: 15px; font-weight: 600; word-break: break-all; text-align: center; }
.audio-card audio { width: 100%; }
.audio-controls { display: flex; align-items: center; gap: 10px; }
.audio-playlist {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  font-size: 12px;
}
.audio-track {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.audio-track:hover { background: var(--hover); }
.audio-track.now { color: var(--focus); font-weight: 600; }

/* PDF / HTMLプレビュー */
.pdf-frame, .html-frame {
  flex: 1 1 auto;
  width: 100%;
  border: none;
  background: #fff;
}

/* その他ファイルの情報カード */
.media-other { align-items: center; justify-content: center; }
.file-card {
  margin: auto;
  width: min(520px, 92%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 32px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bar-bg);
  text-align: center;
}
.file-card-icon { font-size: 52px; }
.file-card-name { font-size: 15px; font-weight: 600; word-break: break-all; }
.file-card-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}
.file-card-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- コード/CSVビューア ---------- */
.code-view {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}
.trunc-note, .csv-note {
  margin: 0 0 10px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.csv-wrap { overflow: auto; }
.csv-table {
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.csv-table th, .csv-table td {
  border: 1px solid var(--border);
  padding: 3px 8px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.csv-table th {
  position: sticky;
  top: 0;
  background: var(--bar-bg);
  font-weight: 600;
  z-index: 1;
}
.csv-table tr:nth-child(even) td { background: var(--hover); }

/* ---------- ページ内検索バー ---------- */
.findbar {
  position: absolute;
  top: 8px;
  right: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.findbar input {
  width: 200px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.findbar input:focus { outline: none; border-color: var(--focus); }
.findbar button { padding: 2px 8px; font-size: 12px; }
.find-count { font-size: 11px; color: var(--muted); min-width: 44px; text-align: center; }
mark.find-hit { background: rgba(255, 200, 0, 0.45); color: inherit; border-radius: 2px; }
mark.find-hit.now { background: #ff9632; color: #1f2328; }

/* ---------- 目次パネル ---------- */
.toc-panel {
  position: absolute;
  top: 8px;
  right: 18px;
  bottom: 16px;
  z-index: 30;
  width: 260px;
  display: flex;
  flex-direction: column;
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}
.toc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 8px 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.toc-head button { padding: 1px 8px; font-size: 13px; }
.toc-list { flex: 1 1 auto; overflow-y: auto; padding: 6px 0 12px; }
.toc-item {
  padding: 3px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.toc-item:hover { background: var(--hover); color: var(--focus); }
.toc-h2 { padding-left: 24px; }
.toc-h3 { padding-left: 36px; color: var(--muted); }
.toc-h4 { padding-left: 48px; color: var(--muted); }
.toc-empty { padding: 14px; font-size: 12px; color: var(--muted); }

/* ---------- クイックオープン ---------- */
.qo-overlay {
  position: fixed;
  inset: 0;
  z-index: 1150;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
  background: rgba(0, 0, 0, 0.25);
}
.qo-box {
  width: min(640px, 92vw);
  max-height: 64vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
#qo-input {
  padding: 12px 14px;
  font-size: 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
#qo-input:focus { outline: none; }
.qo-status { padding: 4px 14px; font-size: 11px; color: var(--muted); }
.qo-list { flex: 1 1 auto; overflow-y: auto; padding: 4px; }
.qo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.qo-item.selected { background: rgba(9, 105, 218, 0.14); }
.qo-name { font-weight: 600; flex: 0 0 auto; }
.qo-rel { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 全文検索パネル(サイドバー内) ---------- */
.search-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.gs-head {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.gs-head input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.gs-head input:focus { outline: none; border-color: var(--focus); }
.gs-head button { padding: 3px 8px; font-size: 12px; }
.gs-opts {
  display: flex;
  gap: 12px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.gs-opts label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.gs-status { padding: 6px 10px; font-size: 11px; color: var(--muted); }
.gs-results { flex: 1 1 auto; overflow-y: auto; padding-bottom: 16px; }
.gs-file {
  padding: 6px 10px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: sticky;
  top: 0;
  background: var(--bar-bg);
}
.gs-file:hover { color: var(--focus); }
.gs-hit {
  display: flex;
  gap: 6px;
  padding: 2px 10px 2px 16px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.gs-hit:hover { background: var(--hover); }
.gs-line { color: var(--muted); min-width: 28px; text-align: right; flex: 0 0 auto; }
.gs-text { overflow: hidden; text-overflow: ellipsis; }

/* ---------- タブドラッグ ---------- */
.tab-ghost {
  position: fixed;
  z-index: 2000;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--focus);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-ghost.detach { border-style: dashed; opacity: 0.9; }
.tab-ghost.detach::after { content: "  ⧉ ドロップで切り離し/結合"; color: var(--muted); font-size: 10px; }
.tab.dragging, .ws-tab.dragging { opacity: 0.4; }
body.tab-dragging { cursor: grabbing; user-select: none; }
body.tab-dragging * { cursor: grabbing !important; }

/* ---------- トースト ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 7px 16px;
  font-size: 12px;
  color: #fff;
  background: rgba(31, 35, 40, 0.92);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.warn { background: rgba(150, 60, 20, 0.95); }

/* ---------- 改善フィードバック ---------- */
.feedback-fab {
  position: fixed;
  right: 16px;
  bottom: 40px;
  z-index: 1400;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
  opacity: 0.55;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.feedback-fab:hover { opacity: 1; }
.feedback-panel {
  position: fixed;
  right: 16px;
  bottom: 84px;
  z-index: 1400;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.fb-title { font-size: 12px; font-weight: 600; }
.feedback-panel textarea {
  height: 90px;
  resize: vertical;
  padding: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.feedback-panel textarea:focus { outline: none; border-color: var(--focus); }
.fb-actions { display: flex; justify-content: flex-end; gap: 6px; }
.fb-actions button { padding: 4px 12px; font-size: 12px; }
.fb-actions .primary { background: var(--focus); border-color: var(--focus); color: #fff; }

/* ---------- ステータスバー拡張 ---------- */
#statusbar { gap: 12px; }
.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}
#status-info { overflow: hidden; text-overflow: ellipsis; }
.status-right { overflow: hidden; }
#status-meta { overflow: hidden; text-overflow: ellipsis; }
.audio-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  max-width: 220px;
}
.audio-chip .chip-title {
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--focus);
}
.audio-chip .chip-pause {
  border: none;
  background: transparent;
  padding: 0 4px;
  font-size: 11px;
  cursor: pointer;
  color: var(--muted);
}

/* ---------- 空状態の最近使ったファイル ---------- */
.empty-recents {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  max-width: 480px;
}
.recents-title { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.recent-item {
  width: 100%;
  text-align: left;
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--focus);
}
.recent-item:hover { background: var(--hover); border-color: var(--border); }

/* トグル状態のボタン共通表示(#btn-comments は個別配色のため上書きされる) */
button.active-toggle {
  background: rgba(9, 105, 218, 0.14);
  border-color: var(--focus);
  color: var(--focus);
}

/* ---------- 分割ビュー(比較ペイン) ---------- */
/* #panewrap が本体(#container)と比較ペイン(#pane-b)を並べる。
   position:relative はブリンク比較で #pane-b を本体に重ねるための基準。 */
#panewrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  position: relative;
}
#panewrap.split-col { flex-direction: column; }
#panewrap > #container { flex: 1 1 auto; min-width: 0; min-height: 0; }

#pane-b {
  flex: 0 0 50%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid var(--border);
}
#panewrap.split-col > #pane-b {
  border-left: none;
  border-top: 1px solid var(--border);
}

#pane-resizer {
  flex: 0 0 4px;
  cursor: col-resize;
  background: transparent;
}
#pane-resizer:hover { background: rgba(9, 105, 218, 0.25); }
#panewrap.split-col > #pane-resizer { cursor: row-resize; }

.pane-b-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px 5px 12px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  user-select: none;
}
#pane-b-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane-b-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.pane-b-actions button { padding: 2px 8px; font-size: 12px; }

#viewer-b {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 24px clamp(16px, 4vw, 40px) 60px;
  zoom: var(--content-zoom);
}
#viewer-b.markdown-body { background: transparent; }

#mediaview-b {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  zoom: var(--content-zoom);
}

/* 変更点ノート(比較ペイン下部の説明ストリップ) */
.pane-notes {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  max-height: 38%;
  border-top: 2px solid var(--focus);
  background: var(--bar-bg);
}
.pane-notes-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.pane-notes-head:hover { color: var(--focus); }
#pane-notes-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane-notes-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 14px 14px;
  font-size: 12.5px;
  background: transparent;
}
.pane-notes-body h1, .pane-notes-body h2, .pane-notes-body h3 {
  font-size: 13px;
  margin: 10px 0 6px;
  padding-bottom: 2px;
}
.pane-notes.collapsed .pane-notes-body { display: none; }
.pane-notes.collapsed { max-height: none; }

/* 本文とコメント一覧を左右に並べる入れ物(一覧を開くと右側に出る) */
.notes-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.pane-notes.collapsed .notes-wrap,
.main-notes.collapsed .notes-wrap { display: none; }
/* 横並びになるため、本文側が縮めるように min-width を解除する */
.notes-wrap > .pane-notes-body { min-width: 0; }
.notes-cclist {
  flex: 0 0 clamp(200px, 34%, 340px);
  min-width: 0;
  overflow-y: auto;
  padding: 6px 8px 10px;
  border-left: 1px solid var(--border);
}
.notes-cclist .cp-empty { padding: 8px 4px; font-size: 11.5px; color: var(--muted); }
/* 帯は狭いのでカードを一段コンパクトに */
.notes-cclist .comment-card { padding: 6px 8px; margin-bottom: 6px; font-size: 11.5px; }
.notes-cclist .cc-quote { font-size: 11px; }
.notes-cc-btn {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0 6px;
  font-size: 12px;
  line-height: 18px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.notes-cc-btn:hover { border-color: var(--border); }
.notes-cc-btn.on { background: rgba(9, 105, 218, 0.14); border-color: var(--focus); }

/* 変更点帯の高さリサイザ(上端の境目をつかんで上下ドラッグ) */
.notes-resizer {
  flex: 0 0 6px;
  margin-bottom: -3px; /* 見た目は細く、掴み判定は6px確保 */
  cursor: row-resize;
  background: transparent;
  z-index: 1;
}
.notes-resizer:hover { background: rgba(9, 105, 218, 0.30); }
.pane-notes.collapsed .notes-resizer,
.main-notes.collapsed .notes-resizer { display: none; }
/* ユーザーが高さを指定したら 38% 上限は解除(JSが .user-sized を付ける) */
.pane-notes.user-sized, .main-notes.user-sized { max-height: none; }

/* メイン側(左ペイン)の変更点ノート。位置は下端固定だが「重ねない」:
   帯の実高さを --notes-h として #container に反映し、viewer/mediaview/editor の
   表示領域をその分だけ縮める(本文が説明帯に隠れない)。 */
#container { --notes-h: 0px; }
#container > #viewer { height: calc(100% - var(--notes-h)); }
#container > #editor { height: calc(100% - var(--notes-h)); }
#container > #mediaview { bottom: var(--notes-h); }

.main-notes {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  max-height: 38%;
  border-top: 2px solid var(--focus);
  background: var(--bar-bg);
}
.main-notes.collapsed .pane-notes-body { display: none; }

.pane-b-empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}

/* タブをメイン領域へドラッグ中、比較ペインになる側を示す */
#panewrap.drop-hint-b::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  background: rgba(9, 105, 218, 0.10);
  border-left: 2px dashed var(--focus);
  pointer-events: none;
  z-index: 40;
}
#panewrap.split-col.drop-hint-b::after {
  left: 0;
  top: auto;
  bottom: 0;
  width: auto;
  height: 50%;
  border-left: none;
  border-top: 2px dashed var(--focus);
}

/* ブリンク比較: 比較ペインを本体に重ね、show-a の有無でA/Bを瞬間切替する */
#panewrap.blink > #pane-b {
  position: absolute;
  inset: 0;
  flex: none;
  border: none;
  z-index: 30;
}
#panewrap.blink > #pane-resizer { display: none; }
#panewrap.blink.show-a > #pane-b { visibility: hidden; }

/* ---------- 日付（仮想フォルダ）表示 ---------- */
#btn-viewmode.on {
  background: rgba(9, 105, 218, 0.14);
  border-color: var(--focus);
}
/* 年/月/日の自動フォルダは通常フォルダと区別して控えめに見せる */
.tree-item.is-vnode .tree-label { font-weight: 600; }
.tree-vcount {
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: 8px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* ファイルが実フォルダのどこにあるかを右端に薄く添える */
.tree-vhint {
  flex: 0 1 auto;
  margin-left: auto;
  padding-left: 10px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl; /* 長い場合は先頭側を省略して末端フォルダ名を残す */
  text-align: right;
}
/* ドラッグ中の投下先 */
.tree-item.vdrop {
  background: rgba(45, 164, 78, 0.18);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- Claude Code に聞くパネル ---------- */
#ask-panel {
  flex: 0 0 auto;
  width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--bar-bg);
  border-left: 1px solid var(--border);
  overflow: hidden;
}
#ask-panel .cp-head { gap: 6px; }
#ask-title { flex: 1 1 auto; }
#ask-new, #ask-hist, #ask-all {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 1px 8px;
}
.ask-context {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.ask-quote {
  margin-top: 4px;
  padding: 4px 6px;
  border-left: 2px solid var(--focus);
  background: rgba(9, 105, 218, 0.06);
  color: var(--fg);
  max-height: 76px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.ask-dirs { margin-top: 4px; }
.ask-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 12.5px;
}
.ask-msg {
  margin-bottom: 10px;
  padding: 7px 9px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.ask-q {
  background: rgba(9, 105, 218, 0.12);
  white-space: pre-wrap;
}
.ask-a { background: var(--bg); border: 1px solid var(--border); }
.ask-a > :first-child { margin-top: 0; }
.ask-a > :last-child { margin-bottom: 0; }
.ask-a pre { overflow-x: auto; }
.ask-msg.pending { color: var(--muted); font-style: italic; }
/* 回答の署名(どのモデル・エフォートが答えたか) */
.ask-sign {
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}
/* 回答を対象mdのコメント+返信として書き残すバー */
.ask-save {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.ask-save button { padding: 2px 8px; font-size: 11px; }
.ask-save-off { font-size: 10px; color: var(--muted); }
/* コメントスレッドの続きを話しているときの表示 */
.ask-thread-tag { margin-top: 4px; font-size: 10px; color: #6f42c1; }
.ask-thread-note {
  margin: 2px 0 10px;
  padding: 4px 0;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  border-top: 1px dashed var(--border);
}
.ask-error { color: #b42318; border-color: #b42318; white-space: pre-wrap; }
.ask-input {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
#ask-text {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  font-family: inherit;
  font-size: 12.5px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}
#ask-send { flex: 0 0 auto; align-self: flex-end; }

/* ---------- 音声読み上げ ---------- */
/* 操作バーは左上(検索バー・目次パネルは右上なので衝突しない) */
.readbar {
  position: absolute;
  top: 8px;
  left: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.readbar button { padding: 2px 8px; font-size: 12px; }
.readbar .rd-play { min-width: 34px; font-size: 13px; }
.readbar select {
  max-width: 150px;
  padding: 2px 4px;
  font-size: 11px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.readbar select:focus { outline: none; border-color: var(--focus); }
.rd-progress { font-size: 11px; color: var(--muted); min-width: 56px; text-align: center; }
.rd-status { font-size: 11px; color: var(--focus); }

/* 読み上げ中の文。CSS Custom Highlight API は DOM を書き換えないため、
   コメントの目印・タスクリスト・レンダリングキャッシュに影響しない。 */
::highlight(mdpop-read) {
  background-color: rgba(255, 212, 0, 0.34);
  color: inherit;
}
::highlight(mdpop-read-word) {
  background-color: rgba(255, 150, 50, 0.55);
  color: inherit;
}
html[data-theme="dark"] ::highlight(mdpop-read) {
  background-color: rgba(120, 170, 255, 0.28);
}
html[data-theme="dark"] ::highlight(mdpop-read-word) {
  background-color: rgba(120, 170, 255, 0.55);
}
/* Custom Highlight API 非対応環境のフォールバック(段落単位の強調) */
.reading-block {
  background-color: rgba(255, 212, 0, 0.18);
  border-radius: 3px;
}
html[data-theme="dark"] .reading-block {
  background-color: rgba(120, 170, 255, 0.16);
}

/* ---------- 印刷時は新規UIも隠す ---------- */
/* ---------- v0.11.1: ツールバーの1行固定とあふれメニュー ---------- */
/* ボタンの文字を折らない。CJK は1文字ごとに折れるため、幅が足りないとボタンが縦長になっていた */
#toolbar button,
.sidebar-actions button { white-space: nowrap; flex: 0 0 auto; }
#toolbar { flex-wrap: nowrap; }
/* ファイル名は読める幅(☰ ⊟ の2ボタン約70px＋約80px)を残し、そこから先はボタン側が退避する。
   既定幅(1020px)で全ボタンが1行に収まるよう、ボタンの左右余白と間隔を少し詰める */
.file-info { flex: 1 1 auto; min-width: 150px; overflow: hidden; }
.actions { flex: 0 0 auto; flex-wrap: nowrap; gap: 4px; }
.actions > button, .actions .edit-group > button:first-child, .actions .save-group > button:first-child { padding-left: 11px; padding-right: 11px; }
#btn-more { padding: 5px 9px; font-weight: 700; }

/* 退避したボタンの受け皿。ボタン要素そのものが移動してくるので、縦並びに整える */
.tb-more {
  position: fixed;
  z-index: 1100;
  min-width: 190px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.tb-more > button,
.tb-more > .edit-group,
.tb-more > .save-group { width: 100%; }
.tb-more > button { text-align: left; }
.tb-more > .edit-group > button:first-child,
.tb-more > .save-group > button:first-child { flex: 1 1 auto; text-align: left; }
/* 絵文字だけのボタンには名前を添える */
.tb-more .icon-btn[data-label]::after {
  content: attr(data-label);
  margin-left: 8px;
  font-size: 12px;
}

/* サイドバー上部: フォルダ名の行を優先し、狭いときは「フォルダ」をアイコンにする */
#sidebar { container-type: inline-size; }
.sidebar-head { min-width: 0; }
#sidebar-root { flex: 1 1 auto; min-width: 0; }
.sidebar-actions { flex: 0 0 auto; }
#btn-folder .sb-ic { display: none; }
@container (max-width: 300px) {
  #btn-folder .sb-lbl { display: none; }
  #btn-folder .sb-ic { display: inline; }
  /* ボタンを詰め、再読み込み(F5・パンくずの ↻ でも同じ)は隠してフォルダ名に幅を回す */
  .sidebar-actions { gap: 2px; }
  .sidebar-actions button { padding: 2px 5px; }
  .sidebar-actions #btn-refresh { display: none; }
}

/* ---------- v0.11.0: 返信の編集 / 複数行モーダル / FABドラッグ / 履歴一覧 ---------- */
.cc-reply-actions { display: flex; gap: 6px; margin-top: 4px; }
.cc-reply-actions button { padding: 1px 6px; font-size: 10px; }

.modal-textarea {
  resize: vertical;
  min-height: 110px;
  font-family: inherit;
  line-height: 1.5;
}

/* FAB はドラッグで移動できる(位置は localStorage に保存) */
.feedback-fab { cursor: grab; touch-action: none; user-select: none; }
.feedback-fab.dragging { cursor: grabbing; opacity: 1; }

/* 履歴一覧(#recentview) */
.rv-box { max-height: 78vh; }
.rv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.rv-title { font-weight: 600; flex: 0 0 auto; }
#rv-filter {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
#rv-filter:focus { outline: none; border-color: var(--focus); }
.rv-head button { flex: 0 0 auto; padding: 3px 8px; font-size: 12px; }
.rv-body { flex: 1 1 auto; overflow-y: auto; padding: 6px 8px 10px; }
.rv-section {
  margin: 10px 4px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.rv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.rv-row:hover { background: rgba(9, 105, 218, 0.10); }
.rv-time {
  flex: 0 0 auto;
  width: 44px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rv-name {
  flex: 0 1 auto;
  max-width: 55%;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-path {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-win { flex-direction: column; align-items: stretch; gap: 2px; cursor: default; }
.rv-win:hover { background: transparent; }
.rv-win-head { display: flex; align-items: center; gap: 8px; }
.rv-win-head .rv-time { width: 80px; }
.rv-win-label { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-win-head button { flex: 0 0 auto; padding: 2px 8px; font-size: 11px; }
.rv-win-files {
  padding-left: 88px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 13px; }

@media print {
  #mediaview, #findbar, #toc-panel, #quickopen, #recentview, #toolbar-more, .toasts,
  .feedback-fab, .feedback-panel, #media-dock, #search-panel,
  #pane-b, #pane-resizer, #ask-panel, #readbar { display: none !important; }
}

/* ---------- md本文の画像ズーム（imgzoom.js） ----------
   画像を枠（span.mdimg-frame）で包み、枠の中だけで拡大・移動する。枠は包む前の画像と同じ位置・大きさ
   （包んだ前後で測って確かめている）。img を block にして枠の下に行の隙間を作らず、transform で拡大する。 */
.markdown-body .mdimg-frame {
  display: inline-block;
  position: relative;
  max-width: 100%;
  overflow: hidden;
  vertical-align: baseline;
}
.markdown-body .mdimg-frame > img {
  display: block;
  transform-origin: 0 0;
}
/* touch-action: 拡大中はタッチのドラッグもページのスクロールではなく画像の移動にする */
.markdown-body .mdimg-frame.is-zoomed { cursor: grab; user-select: none; touch-action: none; }
.markdown-body .mdimg-frame.is-zoomed > img { -webkit-user-drag: none; } /* ネイティブドラッグにパンを奪わせない */
.markdown-body .mdimg-frame.panning { cursor: grabbing; }
/* 右下の小さな札: 拡大中は倍率。カーソルを乗せると操作のヒント（通りがかりでちらつかないよう少し遅れて出す）。
   content の「/ ""」は読み上げソフト向けの代替テキストを空にする指定（札の文字を本文として読ませない） */
.markdown-body .mdimg-frame::after {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
  pointer-events: none;
}
.markdown-body .mdimg-frame.hint:hover:not(.is-zoomed)::after {
  content: "Ctrl+ホイール / ダブルクリックで拡大" / "";
  animation: mdimg-hint-in 0.2s ease-out 0.6s both;
}
/* リンク付きの画像と「表示まま編集」中は、ダブルクリックの1回目がリンク・段落編集へ行くので Ctrl+ホイールだけ案内する */
.markdown-body .mdimg-frame.in-link.hint:hover:not(.is-zoomed)::after,
body.block-editing .markdown-body .mdimg-frame.hint:hover:not(.is-zoomed)::after {
  content: "Ctrl+ホイールで拡大" / "";
}
.markdown-body .mdimg-frame.is-zoomed::after { content: attr(data-zoom-label) / ""; }
.markdown-body .mdimg-frame.is-zoomed.hint:hover::after {
  content: attr(data-zoom-label) "　ドラッグで移動 / ダブルクリックで戻す" / "";
}
@keyframes mdimg-hint-in { from { opacity: 0; } to { opacity: 1; } }
@media print {
  .markdown-body .mdimg-frame > img { transform: none !important; }
  .markdown-body .mdimg-frame::after { content: none !important; }
}

/* ---------- 画像の範囲へのコメント（imgregion.js） ----------
   重ね書きは画像の枠（.mdimg-frame）の中に置き、拡大・移動では画像と同じ transform を掛ける。
   --mdimg-s は拡大倍率。枠線と番号は 1/倍率 で描き、拡大しても太らせない。 */
.markdown-body .mdimg-regions {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  pointer-events: none;
}
.markdown-body .mdimg-region {
  position: absolute;
  box-sizing: border-box;
  border: calc(2px / var(--mdimg-s, 1)) solid #b78113;
  border-radius: calc(3px / var(--mdimg-s, 1));
  background: rgba(227, 179, 65, 0.14);
}
.markdown-body .mdimg-region.resolved { border-style: dashed; background: transparent; opacity: 0.6; }
.markdown-body .mdimg-region.active {
  background: rgba(227, 179, 65, 0.4);
  box-shadow: 0 0 0 calc(3px / var(--mdimg-s, 1)) rgba(227, 179, 65, 0.55);
}
.markdown-body .mdimg-region-badge {
  position: absolute;
  left: 2px;
  top: 2px;
  margin: 0;
  vertical-align: baseline;
  transform: scale(calc(1 / var(--mdimg-s, 1)));
  transform-origin: 0 0;
  pointer-events: auto;
  box-shadow: 0 0 0 1.5px #fff;
}

/* 範囲を選んでいる間の覆い。画像の見えている部分だけ明るく残し、ほかを暗くする */
.mdimg-pick {
  position: fixed;
  inset: 0;
  z-index: 10000;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.mdimg-pick-target {
  position: fixed;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.38);
  outline: 1px dashed rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.mdimg-pick-sel {
  position: fixed;
  box-sizing: border-box;
  border: 2px solid #e3b341;
  background: rgba(227, 179, 65, 0.22);
  pointer-events: none;
}
.mdimg-pick-tip {
  position: fixed;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- コメント・返信に貼った画像（comment-attach.js） ---------- */
.modal-attach { margin: -8px 0 12px; }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.attach-item { position: relative; }
.attach-item img {
  display: block;
  max-width: 120px;
  max-height: 80px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.attach-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  background: var(--bg);
}
.attach-hint { margin: 0; font-size: 11px; color: var(--muted); }
.attach-msg { margin-left: 8px; color: #cf222e; }

.cc-region-crop {
  margin: 6px 0 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-repeat: no-repeat;
  background-color: #fff;
}
.cc-images { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.cc-image {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: zoom-in;
  overflow: hidden;
}
.cc-image img { display: block; max-width: 120px; max-height: 80px; }
.cc-image.missing { opacity: 0.4; cursor: default; }

@media print {
  .markdown-body .mdimg-regions { display: none !important; }
}

/* コメント・返信の本文の出典リンク(linkify.js) */
.cc-body a.cc-link,
.cc-reply-body a.cc-link {
  color: var(--focus);
  text-decoration: underline;
  overflow-wrap: anywhere;
  cursor: pointer;
}

/* ---------- 質問パネル: ファイルごとの会話（ask.js）と、すべての会話の一覧（ask-browser.js） ---------- */
.ask-owner { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.ask-owner + .ask-files { margin-top: 2px; }

#ask-browser {
  width: min(1100px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--bar-bg);
  overflow: hidden;
}
#ask-browser[open] { display: flex; flex-direction: column; }
#ask-browser::backdrop { background: rgba(25, 32, 38, 0.4); }
.ab-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px 10px; border-bottom: 1px solid var(--border); }
.ab-title { margin: 0; font-size: 16px; }
.ab-count { color: var(--muted); font-size: 12px; }
.ab-close { margin-left: auto; }
.ab-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 38%) 1fr; }
.ab-left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.ab-search { margin: 10px 12px 8px; padding: 6px 9px; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.ab-search:focus { outline: none; border-color: var(--focus); }
.ab-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.ab-list:focus { outline: none; }
.ab-group { margin-top: 10px; }
.ab-file { display: flex; align-items: baseline; gap: 6px; padding: 0 6px; }
.ab-file-name { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.ab-badge { padding: 0 6px; border-radius: 8px; font-size: 10px; color: #fff; background: var(--focus); }
.ab-file-count { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.ab-file-dir { padding: 0 6px 4px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.ab-conv { display: block; width: 100%; margin: 2px 0; padding: 6px 8px 6px 14px; text-align: left; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; }
.ab-conv:hover { background: var(--hover); }
.ab-conv.selected { background: var(--bg); border-color: var(--focus); }
.ab-conv.current .ab-conv-title::before { content: "● "; color: var(--focus); }
.ab-conv-title { display: block; font-size: 13px; overflow-wrap: anywhere; }
.ab-conv-meta { display: block; color: var(--muted); font-size: 11px; }
.ab-right { display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--bg); }
.ab-prev-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); }
.ab-prev-title { margin: 0 0 4px; font-size: 15px; overflow-wrap: anywhere; }
.ab-prev-file { font-size: 12px; overflow-wrap: anywhere; }
.ab-prev-date { margin-top: 2px; color: var(--muted); font-size: 11px; }
.ab-prev-head .ask-quote { margin-top: 8px; }
.ab-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.ab-continue { background: var(--focus); border-color: var(--focus); color: #fff; }
.ab-delete.danger { color: #fff; background: #cf222e; border-color: #cf222e; }
.ab-confirm { font-size: 12px; color: #cf222e; }
.ab-log { flex: 1; overflow-y: auto; padding: 12px 18px 18px; }
.ab-empty { margin: 16px; color: var(--muted); font-size: 13px; }
@media (max-width: 720px) {
  .ab-body { grid-template-columns: 1fr; grid-template-rows: 45% 1fr; }
  .ab-left { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* 範囲コメントの枠を隠す(コメント欄の「枠を隠す」・region-hide.js) */
.markdown-body .mdimg-region.is-hidden { display: none; }
.cc-region-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.cc-region-tools button { padding: 1px 8px; font-size: 11px; }
.cc-region-tools button[aria-pressed="true"] { border-color: var(--focus); color: var(--focus); }
