/* md_outline.css - v55 テキストエディタの階層 (折りたたみ) / 目次 / その場で編集できるストリーム */

/* ===== 行 (1 行 1 ブロック) と折りたたみ ===== */
.mdx-l { position: relative; }
.mdx-fold, .mdx-more { cursor: pointer; }
.mdx-fold {
  position: absolute; left: -20px; top: 0;
  width: 18px; height: calc(1em * var(--mdx-lh)); height: 1lh;
  display: flex; align-items: center; justify-content: center;
  font-weight: 400;
  color: var(--fg-mute); opacity: .5;
  border-radius: 4px;
  transition: opacity .12s, background .12s, color .12s;
}
.mdx-fold::before { content: '\25BE'; font-size: 12px; line-height: 1; }                 /* ▾ */
.mdx-l.is-folded > .mdx-fold { opacity: 1; color: var(--accent); }
.mdx-l.is-folded > .mdx-fold::before { content: '\25B8'; } /* ▸ */
.mdx-fold:hover { opacity: 1; color: var(--fg); background: var(--bg-sunk); }
.mdx-more {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  white-space: nowrap;
  font-size: 11px; line-height: 1.5; letter-spacing: 0; font-weight: 400;
  padding: 0 7px; border-radius: 9px;
  color: var(--fg-mute); background: var(--bg-sunk);
}
.mdx-more::before { content: '\22EF  ' attr(data-n) ' 行'; }
.mdx-more:hover { color: var(--accent); }

/* Ctrl / ⌘ を押しているあいだ、タグ・リンクは「押せる」見た目に */
.mdx--mod .mdx-tag, .mdx--mod .mdx-wiki, .mdx--mod .mdx-link { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* 集中: いま書いている段落以外を薄く */
.mdx--focus .mdx-l { opacity: .32; transition: opacity .18s; }
.mdx--focus .mdx-l.is-near { opacity: 1; }

/* 静的表示 (ストリームで画面に入る前の仮表示) */
.mdx--static .mdx-ce { cursor: default; }

/* ===== ズーム (その項目だけを表示) ===== */
.mdx-crumbs { display: none; }
.mdx--zoomed .mdx-crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px;
  padding: 2px 2px 8px 22px; margin-bottom: 4px;
  font-size: 12px; color: var(--fg-mute);
  border-bottom: 1px dashed var(--border);
}
.mdx-crumb { color: var(--fg-mute); text-decoration: none; padding: 1px 6px; border-radius: 5px; }
a.mdx-crumb:hover { background: var(--bg-sunk); color: var(--fg); }
.mdx-crumb.is-here { color: var(--fg); font-weight: 700; }
.mdx-crumb-sep { color: var(--fg-dim); }
.mdx--zoomed .mdx-ce > .mdx-l:first-child:not(.mdx-l--h) { font-size: 1.35em; font-weight: 700; line-height: 1.5; margin-bottom: .3em; }
.mdx--zoomed .mdx-ce > .mdx-l:first-child .mdx-li { display: none; }
.mdx--zoomed .mdx-ce > .mdx-l:first-child.is-cur .mdx-li { display: inline; }

/* ===== 目次つきレイアウト ===== */
.mdx.mdx--toc {
  max-width: 1010px;
  display: grid;
  grid-template-columns: minmax(0, 760px) 210px;
  gap: 28px;
  align-items: start;
}
.mdx-body { min-width: 0; }
.mdx-toc {
  position: sticky; top: 4px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding: 2px 0 8px 14px;
  border-left: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.5;
  color: var(--fg-mute);
}
.mdx-toc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.mdx-toc-title { font-size: 11px; letter-spacing: .14em; color: var(--fg-dim); }
.mdx-toc-stat { font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.mdx-toc-tools { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.mdx-toc .mdx-toc-btn {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--border); background: transparent; color: var(--fg-mute);
  cursor: pointer; line-height: 1.5;
}
.mdx-toc .mdx-toc-btn:hover { color: var(--fg); border-color: var(--fg-dim); }
.mdx-toc .mdx-toc-btn.is-on { color: var(--accent-fg, #fff); background: var(--accent); border-color: var(--accent); }
.mdx-toc-list { display: flex; flex-direction: column; }
.mdx-toc-i {
  display: block; padding: 3px 8px; border-radius: 5px;
  color: var(--fg-mute); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 2px solid transparent;
}
.mdx-toc-i:hover { background: var(--bg-sunk); color: var(--fg); }
.mdx-toc-i.is-active { color: var(--fg); border-left-color: var(--accent); }
.mdx-toc-tag { font-size: 12px; color: var(--fg-dim); }
.mdx-toc-empty { font-size: 11.5px; color: var(--fg-dim); padding: 4px 0; }
.mdx-toc-keys {
  margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 10.5px; color: var(--fg-dim); line-height: 1.8;
}
/* 幅が狭いときは目次を本文の上へ */
.mdx--narrow .mdx-toc {
  position: static; max-height: none;
  border-left: 0; border-bottom: 1px solid var(--border);
  padding: 0 0 8px; margin-bottom: 10px;
}
.mdx--narrow .mdx-toc-list { max-height: 132px; overflow-y: auto; }
.mdx--narrow .mdx-toc-keys { display: none; }
.mdx.mdx--toc.mdx--narrow { display: flex; flex-direction: column; align-items: stretch; }
.mdx--narrow .mdx-toc { order: -1; }

/* 目次ぶん、メモ詳細の横幅を広げる */
.memo-editor:has(.mdx--toc) { max-width: 1060px; }
.memo-pane--detail .memo-pane-edit:has(.mdx--toc) { max-width: 1140px; }

/* ===== その場で編集できるストリーム ===== */
.memo-stream--edit { gap: 14px; }
.tag-stream-card--edit { padding: 10px 14px 8px; }
.tag-stream-card--edit .tag-stream-meta { justify-content: flex-start; gap: 10px; margin-bottom: 4px; }
.tag-stream-card--edit .tag-stream-meta .ghost { margin-left: auto; }
.tag-stream-title-inline { font-size: 13px; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-stream-scope { font-size: 10.5px; color: var(--fg-dim); border: 1px solid var(--border); border-radius: 9px; padding: 0 7px; white-space: nowrap; }
.tag-stream-body--edit { white-space: normal; font-size: inherit; line-height: inherit; }
.tag-stream-body--edit .mdx { max-width: none; }
.tagfrag .mdx { --mdx-pad: 2px 2px 2px 22px; }
.tagfrag + .tagfrag { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.tagfrag-crumb { font-size: 11px; color: var(--fg-dim); padding-left: 22px; }
.tagfrag-crumb::before { content: '\203A  '; }
.memo-stream-head .memo-stream-add { margin-left: auto; }
.memo-stream-head .memo-stream-add + .ghost { margin-left: 0; }

/* 折りたたみボタンのぶん (22px) だけ左へ出し、本文の左端をタイトルやタグ欄とそろえる */
.dmemo-ol-area.mdx .mdx-body, .memo-ol-host.mdx .mdx-body { margin-left: -20px; }

/* ===== メニューの並び替え (ドラッグ) ===== */
.sbnav .sni { touch-action: none; }
.sbnav.is-sorting .sni { cursor: grabbing; transition: none; }
.sbnav .sni.is-dragging { background: var(--bg-sunk); color: var(--fg); box-shadow: 0 4px 14px rgba(0,0,0,.18); opacity: .92; }
