/* =========================================================
   Claude Note Web - マップ機能

   配色は 6 つのテーマ（ダーク 4 / ライト 2）を CSS 変数で切り替える。
   html[data-theme="..."] が唯一の切り替えスイッチで、
   UI の枠だけでなくキャンバス・ノードカード・接続線まで一緒に変わる。
   テーマの一覧と、JS でしか使えない色（世代別カラー）は js/theme.js。
   ========================================================= */

/* ---------- テーマ非依存の形（角丸・余白など） ---------- */
:root {
  --radius: 8px;
  /* チェック済みの色。明暗どちらのテーマでも読めるようテーマ非依存にしている */
  --ok: #3fa66a;
  /* 持ち越し（＝保留）の色。MapNodeStatus.DEFERRED と同じ色にそろえてある */
  --carry: #ff9800;
}

/* ==================== ダーク: ミッドナイト（既定） ==================== */
:root,
html[data-theme="midnight"] {
  /* ブラウザ自前の部品（日付の入力欄と暦の窓・スクロールバー）をこのテーマ側へ寄せる。
     これが無いと、暦の窓とカレンダーの絵柄だけ白いまま出る */
  color-scheme: dark;
  --bg: #14161a;
  --panel: #1b1e23;
  --panel-2: #23272e;
  --border: #333942;
  --text: #e4e7ea;
  --text-dim: #98a1ad;
  --accent: #6ea8ff;
  --accent-soft: rgba(110, 168, 255, 0.18);
  --canvas-bg: #101216;
  --grid: rgba(255, 255, 255, 0.045);
  --grid-strong: rgba(255, 255, 255, 0.085);
  --node-bg: #232830;
  /* 付箋（大きなメモの貼り紙）の下地・枠・コードの地色 */
  --sticky-note-bg: #3b3524;
  --sticky-note-border: #554d33;
  --code-bg: rgba(255, 255, 255, .09);
  --node-border: #3b424c;
  --node-radius: 10px;
  --node-border-width: 1.5px;
  --node-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  --edge: #7d8894;
  --branch: #6d7c8c;
  --selection: #6ea8ff;
  --danger: #ff6b6b;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
  --anchor-ring: #14161a;
  --resizer-bg: #0c0e11;
  --group: #9a7cf0;
  --group-fill: rgba(154, 124, 240, 0.08);
  --group-fill-active: rgba(154, 124, 240, 0.15);
  --hit: #ffb020;
  --ctrl: #ffb020;
  --ctrl-ring: #14161a;
  --link: #6ec8ff;
  --on-accent: #10131a;
}

/* ==================== ダーク: ディープブルー ==================== */
html[data-theme="ocean"] {
  color-scheme: dark;
  --bg: #0a1522;
  --panel: #0f1e30;
  --panel-2: #16293f;
  --border: #23405c;
  --text: #dbe9f7;
  --text-dim: #8ba6c4;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.18);
  --canvas-bg: #071019;
  --grid: rgba(120, 190, 255, 0.05);
  --grid-strong: rgba(120, 190, 255, 0.1);
  --node-bg: #12283d;
  /* 付箋（大きなメモの貼り紙）の下地・枠・コードの地色 */
  --sticky-note-bg: #1d3550;
  --sticky-note-border: #2f4d6e;
  --code-bg: rgba(255, 255, 255, .09);
  --node-border: #27486a;
  --node-radius: 12px;
  --node-border-width: 1.5px;
  --node-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  --edge: #5f89b3;
  --branch: #4d7ba8;
  --selection: #38bdf8;
  --danger: #ff7a85;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
  --anchor-ring: #071019;
  --resizer-bg: #040a10;
  --group: #7dd3fc;
  --group-fill: rgba(125, 211, 252, 0.07);
  --group-fill-active: rgba(125, 211, 252, 0.14);
  --hit: #ffc247;
  --ctrl: #ffc247;
  --ctrl-ring: #071019;
  --link: #7dd3fc;
  --on-accent: #05131f;
}

/* ==================== ダーク: フォレスト ==================== */
html[data-theme="forest"] {
  color-scheme: dark;
  --bg: #101613;
  --panel: #16201a;
  --panel-2: #1d2a22;
  --border: #2c3d32;
  --text: #e2ece4;
  --text-dim: #93a89a;
  --accent: #57c98a;
  --accent-soft: rgba(87, 201, 138, 0.18);
  --canvas-bg: #0c110e;
  --grid: rgba(150, 220, 175, 0.045);
  --grid-strong: rgba(150, 220, 175, 0.09);
  --node-bg: #1a261e;
  /* 付箋（大きなメモの貼り紙）の下地・枠・コードの地色 */
  --sticky-note-bg: #26301f;
  --sticky-note-border: #3d4a33;
  --code-bg: rgba(255, 255, 255, .09);
  --node-border: #31463a;
  --node-radius: 14px;
  --node-border-width: 1.5px;
  --node-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  --edge: #6f8a78;
  --branch: #5d7d68;
  --selection: #57c98a;
  --danger: #f4736b;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
  --anchor-ring: #0c110e;
  --resizer-bg: #070c09;
  --group: #b8a04e;
  --group-fill: rgba(184, 160, 78, 0.08);
  --group-fill-active: rgba(184, 160, 78, 0.16);
  --hit: #e5b04a;
  --ctrl: #e5b04a;
  --ctrl-ring: #0c110e;
  --link: #7fd6b0;
  --on-accent: #08160f;
}

/* ==================== ダーク: 高コントラスト ==================== */
html[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #171717;
  --border: #4f4f4f;
  --text: #ffffff;
  --text-dim: #bcbcbc;
  --accent: #ffd400;
  --accent-soft: rgba(255, 212, 0, 0.22);
  --canvas-bg: #000000;
  --grid: rgba(255, 255, 255, 0.09);
  --grid-strong: rgba(255, 255, 255, 0.17);
  --node-bg: #0d0d0d;
  /* 付箋（大きなメモの貼り紙）の下地・枠・コードの地色 */
  --sticky-note-bg: #1c1600;
  --sticky-note-border: #6b5a00;
  --code-bg: rgba(255, 255, 255, .14);
  --node-border: #7a7a7a;
  --node-radius: 4px;
  --node-border-width: 2px;
  --node-shadow: none;
  --edge: #d2d2d2;
  --branch: #d2d2d2;
  --selection: #ffd400;
  --danger: #ff5252;
  --shadow: 0 2px 14px rgba(255, 255, 255, 0.12);
  --anchor-ring: #000000;
  --resizer-bg: #000000;
  --group: #00e5ff;
  --group-fill: rgba(0, 229, 255, 0.1);
  --group-fill-active: rgba(0, 229, 255, 0.2);
  --hit: #ff8c00;
  --ctrl: #ff8c00;
  --ctrl-ring: #000000;
  --link: #66e0ff;
  --on-accent: #000000;
}

/* ==================== ライト: 既定 ==================== */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f1f4;
  --border: #d8dbe0;
  --text: #1f2328;
  --text-dim: #6a737d;
  --accent: #2f6feb;
  --accent-soft: rgba(47, 111, 235, 0.14);
  --canvas-bg: #fafbfc;
  --grid: rgba(0, 0, 0, 0.055);
  --grid-strong: rgba(0, 0, 0, 0.09);
  --node-bg: #ffffff;
  /* 付箋（大きなメモの貼り紙）の下地・枠・コードの地色 */
  --sticky-note-bg: #fdf1b6;
  --sticky-note-border: #e5d582;
  --code-bg: rgba(0, 0, 0, .07);
  --node-border: #c9ced6;
  --node-radius: 8px;
  --node-border-width: 1.5px;
  --node-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  --edge: #7c8794;
  --branch: #8b96a3;
  --selection: #2f6feb;
  --danger: #d13438;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  --anchor-ring: #ffffff;
  --resizer-bg: #ffffff;
  --group: #9a7cf0;
  --group-fill: rgba(154, 124, 240, 0.07);
  --group-fill-active: rgba(154, 124, 240, 0.13);
  --hit: #ffb020;
  --ctrl: #ffb020;
  --ctrl-ring: #ffffff;
  --link: #0a84c8;
  --on-accent: #ffffff;
}

/* ==================== ライト: セピア ==================== */
html[data-theme="sepia"] {
  color-scheme: light;
  --bg: #efe6d5;
  --panel: #f8f2e6;
  --panel-2: #eae0cd;
  --border: #d3c4a8;
  --text: #3b3226;
  --text-dim: #7d6f5b;
  --accent: #a9683a;
  --accent-soft: rgba(169, 104, 58, 0.16);
  --canvas-bg: #f4ecdb;
  --grid: rgba(90, 70, 40, 0.07);
  --grid-strong: rgba(90, 70, 40, 0.13);
  --node-bg: #fdf8ee;
  /* 付箋（大きなメモの貼り紙）の下地・枠・コードの地色 */
  --sticky-note-bg: #f7e6b0;
  --sticky-note-border: #ddc98a;
  --code-bg: rgba(0, 0, 0, .07);
  --node-border: #cdbb9c;
  --node-radius: 10px;
  --node-border-width: 1.5px;
  --node-shadow: 0 1px 3px rgba(90, 70, 40, 0.2);
  --edge: #99866a;
  --branch: #a4906f;
  --selection: #a9683a;
  --danger: #b1443c;
  --shadow: 0 2px 12px rgba(90, 70, 40, 0.22);
  --anchor-ring: #fdf8ee;
  --resizer-bg: #fdf8ee;
  --group: #8a6a9e;
  --group-fill: rgba(138, 106, 158, 0.09);
  --group-fill-active: rgba(138, 106, 158, 0.16);
  --hit: #c98a1e;
  --ctrl: #c98a1e;
  --ctrl-ring: #fdf8ee;
  --link: #1a6f9e;
  --on-accent: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* ブラウザ自前の「引っ張って更新」「行き過ぎたときの跳ね返り」を止める。
     とくに **iPad の Chrome** はこれらのジェスチャを持っていて、指が触れた拍子に
     ポインタを持っていかれる。持っていかれると走っている pointer が
     `pointercancel` になり、**手書きの線がそこで途切れる**（2026-08-14 に発生）。
     キャンバスの `touch-action: none` だけでは、この経路は塞げない */
  overscroll-behavior: none;
}

body {
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", Meiryo, system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { filter: brightness(1.1); background: var(--accent); }
button.danger { color: var(--danger); }
button.icon-btn { padding: 5px 9px; min-width: 30px; }
button.link-btn { background: none; border: none; color: var(--text-dim); padding: 4px 6px; }
button.link-btn:hover { color: var(--accent); background: none; }
button.has-caret::after { content: " ▾"; opacity: .6; }

/* 文字を打つ入力欄。**型を1つ書き漏らすと、その型だけ読めなくなる。**
   上の `button, input, select, textarea` が `color: var(--text)`（暗いテーマでは明るい字）を
   全部の入力欄へ配るのに対し、地の色を渡すのはここだけなので、漏れた型は
   **ブラウザ既定の白地に明るい字**になり、字が背景と同化する。
   実際 date / month / password が漏れており、気付いた画面が同じ指定を書き足して回っていた
   （conversations.css の date・calendar.css の date/time・login.css と security.css の password）。
   型を増やすときは画面側ではなくここへ足すこと。 */
input[type="text"], input[type="search"], input[type="number"],
input[type="password"], input[type="email"], input[type="url"], input[type="tel"],
input[type="date"], input[type="month"], input[type="week"],
input[type="time"], input[type="datetime-local"],
select, textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="color"] {
  width: 38px; height: 28px; padding: 1px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--panel); cursor: pointer;
}

/* ==================== 画面最上部のメニューバー ====================

   画面をまたぐ移動リンクとテーマ切り替えを、一番上の帯にまとめる。
   サイドバーの見出し行に詰め込むと、幅を狭めたときに右側の 💾 や 🌙 が
   押し出されて見えなくなるため、ここへ逃がしている。
   使う側の <body> に class="has-topbar" を付けること。
   ================================================================= */

/* body を縦並びにして、帯の下に本体（#app / #page）を敷き詰める。
   body は overflow:hidden なので、帯は常に画面の一番上に留まる */
body.has-topbar { display: flex; flex-direction: column; }
body.has-topbar > #app,
body.has-topbar > #page { flex: 1 1 auto; min-height: 0; height: auto; }

/* ==================== 単体表示（マップだけを全画面で出す） ====================

   ⛶ ボタン（または Esc で戻る）で body に .map-solo を付ける。
   隠すのは「別の場所へ行くための部品」だけ＝メニューバーとマップ一覧で、
   ツールバー・ステータスバーは残す（単体表示のまま編集を続けられるようにするため）。
   スマホは画面が狭く、一覧が常に幅を食うのでこの状態が既定に近い使い方になる。
   ========================================================================= */
body.map-solo > .topbar { display: none; }
body.map-solo #sidebar { display: none; }
/* アウトライン・AI パネルは自分で閉じられるので触らない（開いたまま単体表示にできる） */

/* 単体表示に入ると ⛶ が「戻る」の意味になる。押し間違えないよう色を変える */
body.map-solo #btn-solo { background: var(--accent); color: #fff; }

.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}
.topbar .brand {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 14px; font-weight: 600; white-space: nowrap; flex: 0 0 auto;
}
.topbar .brand .page-name { font-size: 12px; font-weight: 400; color: var(--text-dim); }

/* ==================== 共有ページ（/share/<札>） ====================
   ログインしていない相手が見る唯一の画面。編集画面と同じ CSS を使うが、
   「触っても変わらない画面だ」と最初に分かるように印を出す。
   ================================================================= */
.share-badge {
  flex: 0 0 auto;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent);
}
/* 書き込める札。閲覧専用と一目で違って見えるように色を変える */
.share-badge.editable {
  background: var(--ok-soft, var(--accent-soft)); color: var(--ok, var(--accent));
  border-color: var(--ok, var(--accent));
}
/* 「足すだけ」の道具立て。狭い画面では絵文字だけにして帯に収める */
.share-edit-tools { display: inline-flex; gap: 4px; align-items: center; }
@media (max-width: 760px) {
  .share-edit-tools .lbl { display: none; }
}

/* 共有ページのマップ名は帯の主役なので、他の画面の page-name より強く出す */
.share-page .topbar .brand .page-name {
  font-size: 14px; font-weight: 600; color: var(--text);
}
/* 道具は右端へ寄せる（この画面には移動リンクの列が無い） */
.share-page .topbar-tools { margin-left: auto; }

/* 移動リンクの置き場所。中身は ☰ ボタン 1 個だけ（js/nav.js が組み立てる）。
   **ここに overflow を持たせないこと。** ☰ の引き出しは .dropdown（position:absolute）で、
   器がスクロール容器になると開いたメニューが器の高さで切り取られる。
   リンクを横並びにしていた頃は幅が足りず横スクロールさせていたが、
   1 個しか置かないのでもうあふれない */
.topbar-nav {
  display: flex; align-items: center; gap: 4px;
  flex: 0 0 auto;
}

/* 移動リンクの中身は js/nav.js が全画面ぶん組み立てる。
   .topbar を持たない画面（横断検索・しおり・ゴミ箱・バックアップ・セキュリティ）でも
   同じ並びを出すので、器の振る舞いだけをここに置く。
   見た目（色・大きさ）は各画面の .page-head / .trash-head 側の .nav-link が決める */
.cn-nav {
  display: flex; align-items: center; gap: 4px;
  /* 伸びない・縮まない。☰ はどの画面でも帯／見出し行の**先頭（左上）**に置く
     （HTML で最初の子にしてある）。画面ごとに「アプリ名の右」「題の右」「右端寄り」と
     ばらばらだと、画面を移るたびに ☰ を探し直すことになる。右へ寄せる役は
     .topbar-tools の margin-left:auto と見出し行の .spacer が持つ */
  flex: 0 0 auto;
  /* overflow は持たせない（.topbar-nav 側の但し書きと同じ理由） */
}
.cn-nav > * { flex: 0 0 auto; }

/* ☰ の入口。各画面の .nav-link（.topbar / .page-head / .trash-head / .backup-head /
   .sec-head の 5 種）の見た目をそのまま借りるので、ボタン固有の地色と字だけ落とす。
   hover の地色を消しているのは、上の帯以外では隣の <a> と揃えるため
   （.topbar .nav-link:hover のほうが詳しいので、帯では今までどおり地色が付く） */
button.nav-link {
  cursor: pointer;
  font: inherit; line-height: inherit;
  background: none;
}
button.nav-link:hover { background: none; }

/* ☰ を押す／乗せると開く引き出し（移動リンク一式）。
   .dropdown の見た目は共通のものを使い、ここでは中の項目だけを決める。
   **絵文字と名前を必ず両方出す**——帯に横並びだった頃は幅 900px 以下で名前が消え、
   絵文字だけの列から行き先を当てさせる形になっていた */
.cn-nav-menu { min-width: 210px; }
.cn-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 5px;
  font-size: 13px; color: var(--text); text-decoration: none;
  white-space: nowrap; cursor: pointer;
}
.cn-nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.cn-nav-item-icon { width: 18px; text-align: center; flex: 0 0 auto; }
.cn-nav-item-label { flex: 1 1 auto; }
/* いま開いている画面。押しても動かないことが見て分かるようにする */
.cn-nav-item.current { color: var(--accent); }
.cn-nav-item-here {
  flex: 0 0 auto;
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.cn-nav-item-edit { color: var(--text-dim); font-size: 12px; }

/* ---- 第2・第3階層（js/nav.js の renderNode） ----
   乗せて開ける端末では親の右へ飛び出す引き出し、それ以外（指・幅 760px 以下）では
   .cn-nav-menu.inline になり、その場で下に開く。
   子の引き出しに .dropdown を使わないのは、幅 760px 以下の .dropdown が
   画面下の帯（position:fixed）になる規則に巻き込まれないため */
.cn-nav-sub { position: relative; }
.cn-nav-sub-head { display: flex; align-items: center; }
.cn-nav-sub-head > .cn-nav-item { flex: 1 1 auto; min-width: 0; }
.cn-nav-folder {
  width: 100%; background: none; border: none; text-align: left; font: inherit;
}
.cn-nav-caret, .cn-nav-caret-mark { color: var(--text-dim); font-size: 11px; flex: 0 0 auto; }
.dropdown button.cn-nav-caret { padding: 6px 8px; }
.cn-nav-sub.open > .cn-nav-sub-head > .cn-nav-item,
.cn-nav-sub.open > .cn-nav-sub-head > .cn-nav-caret { background: var(--accent-soft); color: var(--accent); }
/* 自分の画面がこの枝の下にある */
.cn-nav-sub.has-current > .cn-nav-sub-head .cn-nav-item-label { color: var(--accent); }

.cn-nav-flyout {
  display: none;
  position: absolute; left: 100%; top: -5px; z-index: 61;
  margin-left: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; min-width: 190px;
  flex-direction: column;
}
.cn-nav-sub.open > .cn-nav-flyout { display: flex; }
/* 右に出すと窓からはみ出すときは左へ */
.cn-nav-sub.flip > .cn-nav-flyout { left: auto; right: 100%; margin-left: 0; margin-right: 2px; }

/* その場で下に開く形。▸ を ▾ 向きに回して、開いていることを見せる */
.cn-nav-menu.inline .cn-nav-flyout {
  position: static; margin: 0 0 2px 14px; padding: 0 0 0 6px;
  border: none; border-left: 1px solid var(--border); border-radius: 0;
  box-shadow: none; background: none; min-width: 0;
}
.cn-nav-menu.inline .cn-nav-sub.open .cn-nav-caret,
.cn-nav-menu.inline .cn-nav-sub.open .cn-nav-caret-mark { display: inline-block; transform: rotate(90deg); }

.topbar .nav-link {
  color: var(--text-dim); text-decoration: none; font-size: 12px;
  padding: 4px 9px; border-radius: 6px; border: 1px solid transparent;
  white-space: nowrap; flex: 0 0 auto;
}
.topbar .nav-link:hover {
  color: var(--accent); border-color: var(--border); background: var(--panel-2);
}
.topbar .nav-link.current {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}

/* 右端へ寄せる役はここが持つ（☰ を先頭へ移したので、伸びて押しやる器が無い） */
.topbar-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; margin-left: auto; }
/* 右端に置くメニューは画面外へはみ出さないよう右揃えで開く */
.topbar-tools .dropdown { left: auto; right: 0; }

/* 幅が狭いときにリンクの文字を畳んで絵文字だけにする規則は、
   移動リンクを ☰ 1 個へ畳んだ時点で不要になったので外した（.nav-text 自体が無くなった）。
   狭い画面の見え方は、引き出しが画面下の帯になる @media (max-width:760px) 側が受け持つ */

/* ==================== レイアウト ==================== */

#app { display: flex; height: 100%; }

#sidebar {
  position: relative;      /* 右端の #sidebar-resizer を置くため */
  width: 250px;
  min-width: 190px;
  flex: 0 0 auto;          /* 幅はドラッグで決めた値をそのまま使う */
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

/* サイドバー右端の掴み手（js/sidebar-resize.js が差し込む） */
#sidebar-resizer {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: ew-resize; z-index: 6;
}
#sidebar-resizer:hover, #sidebar-resizer.dragging { background: var(--accent); opacity: .35; }

/* ドラッグ中は本文の選択を止めて、どこでも矢印カーソルにする */
body.col-resizing { cursor: ew-resize; user-select: none; }

.sidebar-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.sidebar-head h1 { font-size: 15px; margin: 0; flex: 1; }
/* マップ画面 ⇔ メモ画面 の行き来 */
.sidebar-head .nav-link {
  color: var(--text-dim); text-decoration: none; font-size: 12px;
  padding: 3px 7px; border-radius: 6px; border: 1px solid transparent; white-space: nowrap;
}
.sidebar-head .nav-link:hover { color: var(--accent); border-color: var(--border); }

.sidebar-tools { display: flex; gap: 6px; padding: 8px 10px; }
.sidebar-tools input { flex: 1; min-width: 0; }

.map-list { list-style: none; margin: 0; padding: 0 6px; overflow-y: auto; flex: 1; }
.map-list li {
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.map-list li:hover { background: var(--panel-2); }
.map-list li.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.map-list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-list .meta { font-size: 11px; color: var(--text-dim); }
.map-list.trash { flex: 0 0 auto; max-height: 180px; border-top: 1px solid var(--border); }

.sidebar-foot { display: flex; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border); }
/* 同じ並びを上に置く場合（メモ画面）。境目の線を下側にし、一覧に押し潰されないようにする */
.sidebar-foot.at-top {
  border-top: none; border-bottom: 1px solid var(--border); flex: 0 0 auto; flex-wrap: wrap;
}

/* ==================== サイドバーの会話検索 ==================== */

/* 折りたたみ節（会話画面・メモ画面の .side-section と同じ見た目） */
.side-section { border-top: 1px solid var(--border); flex: 0 0 auto; }
.side-section > summary {
  padding: 6px 10px; cursor: pointer; color: var(--text-dim); font-size: 12px; user-select: none;
}
.side-section > summary:hover { color: var(--accent); }
.side-section-body { padding: 0 10px 8px; max-height: 260px; overflow-y: auto; }
.side-section-body > input[type="search"] { width: 100%; margin-bottom: 6px; }

.conv-hits { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-hit {
  padding: 5px 7px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.conv-hit:hover { background: var(--panel-2); border-color: var(--border); }

.conv-hit-head { display: flex; align-items: center; gap: 4px; }
.conv-hit-name {
  flex: 1; min-width: 0; font-weight: 600; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-hit-head button { padding: 2px 6px; min-width: 0; font-size: 11px; }

.conv-hit-sub { font-size: 11px; color: var(--text-dim); }
.conv-hit-snippet {
  font-size: 11px; color: var(--text-dim); line-height: 1.5; margin-top: 3px;
  padding-left: 6px; border-left: 2px solid var(--border);
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}

/* ==================== カテゴリ（プロジェクト） ==================== */

.cat-tools { padding-top: 0; align-items: center; }
/* 検索欄が上の帯へ移り、この行が一覧のいちばん上に来た場合（マップ画面） */
.cat-tools.first { padding-top: 8px; }
.cat-tools select { flex: 1; min-width: 0; }

/* マップ一覧のカテゴリ見出し */
.map-list li.cat-head {
  flex-direction: row; align-items: center; gap: 6px;
  margin-top: 6px; padding: 5px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--text-dim); text-transform: none;
  border-left: 3px solid var(--border); border-radius: 0 6px 6px 0;
  background: var(--panel-2);
}
.map-list li.cat-head:first-child { margin-top: 0; }
.map-list li.cat-head .caret { width: 10px; flex: 0 0 auto; }
.map-list li.cat-head .cname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-list li.cat-head .ccount {
  flex: 0 0 auto; padding: 0 6px; border-radius: 9px;
  background: var(--bg); color: var(--text-dim); font-weight: 600;
}
.map-list li.in-cat { margin-left: 8px; }
.map-list li.placeholder { cursor: default; }
.map-list li.placeholder:hover { background: none; }

/* カテゴリ管理ダイアログ */
.cat-manager { min-width: 420px; }
.cat-manager-tools { display: flex; gap: 6px; margin-bottom: 10px; }
.cat-rows { display: flex; flex-direction: column; gap: 2px; }
.cat-rows.trash { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
}
.cat-row:hover { background: var(--panel-2); }
.cat-row .cdot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.cat-row .cname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .ccount { color: var(--text-dim); font-size: 11px; }
.cat-row .link-btn.danger { color: var(--danger); }

/* ==================== アウトラインパネル ==================== */

#outline {
  position: relative;
  width: 260px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-width: 0;
}
#outline[hidden] { display: none; }

.outline-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 6px 8px 12px; border-bottom: 1px solid var(--border);
}
.outline-title { font-size: 13px; font-weight: 600; flex: 1; }
.outline-count { font-size: 11px; color: var(--text-dim); }

.outline-tools { display: flex; gap: 4px; padding: 6px 8px; }
.outline-tools button { flex: 1; font-size: 11px; padding: 4px 2px; }

.outline-tree { flex: 1; overflow: auto; padding: 2px 4px 10px; }
.outline-empty { color: var(--text-dim); font-size: 12px; padding: 10px 8px; }

.outline-row {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px 3px 0; border-radius: 5px;
  cursor: pointer; user-select: none;
  border-top: 2px solid transparent; border-bottom: 2px solid transparent;
}
.outline-row:hover { background: var(--panel-2); }
.outline-row.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.outline-row.dragging { opacity: 0.45; }

/* ドロップ位置の目印: 上下＝兄弟として割り込む / 枠＝その子にする */
.outline-row.drop-before { border-top-color: var(--accent); }
.outline-row.drop-after { border-bottom-color: var(--accent); }
.outline-row.drop-child { box-shadow: inset 0 0 0 2px var(--accent); }

.oc-caret {
  width: 13px; flex: 0 0 13px; text-align: center;
  color: var(--text-dim); font-size: 10px;
}
.oc-caret:hover { color: var(--accent); }
.oc-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; }
.oc-title {
  flex: 1; min-width: 0; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oc-title.empty { color: var(--text-dim); font-style: italic; }
.oc-title[contenteditable="true"] {
  outline: 2px solid var(--accent); border-radius: 4px;
  background: var(--panel-2); text-overflow: clip; cursor: text;
}
.oc-badge {
  font-size: 10px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 8px; padding: 0 5px;
}
.oc-badge.session { color: var(--accent); border-color: var(--accent); }
.oc-badge.weight { color: var(--accent); border-color: var(--accent); }
.oc-badge.check { font-variant-numeric: tabular-nums; }
.oc-badge.check.done { color: var(--ok); border-color: var(--ok); }

/* 行のチェックボックス */
.oc-check {
  width: 13px; height: 13px; flex: 0 0 13px; margin-right: 1px;
  border: 1.5px solid var(--border); border-radius: 4px;
  font-size: 10px; line-height: 10px; text-align: center;
  color: transparent;
}
.oc-check:hover { border-color: var(--ok); }
.oc-check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.outline-row.checked .oc-title { text-decoration: line-through; color: var(--text-dim); }

/* ---------- ✓ リスト（アウトラインを ToDo として見る） ---------- */

.outline-modes { display: flex; gap: 4px; padding: 6px 8px 0; }
.outline-modes button { flex: 1; font-size: 11px; padding: 4px 2px; }
.outline-modes button.toggled { background: var(--accent-soft); border-color: var(--accent); }
.outline-count.done { color: var(--ok); }

/* リストの行は 2 段（1 段目＝やること／2 段目＝どの枝の話だったか） */
.outline-row.list { align-items: flex-start; padding: 5px 6px 5px 2px; gap: 6px; }
.outline-row.list .oc-check,
.outline-row.list .oc-dot { margin-top: 3px; }
.oc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.oc-text .oc-title { white-space: normal; overflow: visible; text-overflow: clip; }
.oc-trail {
  font-size: 10.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.outline-row.list.checked .oc-trail { opacity: .6; }
.oc-badge.carried { color: var(--carry); border-color: var(--carry); }

/* 「済み N 件」の区切り。ここから下は片づいたもの */
.outline-sep {
  font-size: 10.5px; color: var(--text-dim);
  padding: 10px 6px 4px; margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* まとめて書く（js/todo.js）。左に打ち込み、下に「こうなる」を出す */
.todo-bulk-text {
  width: 100%; margin-top: 8px; padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.6;
  white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.todo-bulk-root { display: flex; align-items: center; gap: 6px; margin: 8px 0 4px; font-size: 12px; }
.todo-bulk-root input[type="text"] { flex: 1; min-width: 0; }
.todo-bulk-count { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.todo-bulk-preview {
  margin: 4px 0 0; padding: 8px 10px; max-height: 28vh; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55; white-space: pre;
}

/* 前の日の残りを選ぶダイアログ（js/todo.js） */
.todo-pick-tools { display: flex; gap: 6px; margin: 8px 0 6px; }
.todo-pick-tools button { font-size: 11px; padding: 3px 8px; }
.todo-pick-list { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.todo-pick-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 9px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.todo-pick-row:last-child { border-bottom: 0; }
.todo-pick-row:hover { background: var(--panel-2); }
.todo-pick-row input { margin-top: 2px; flex: 0 0 auto; }
.todo-pick-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.todo-pick-title { font-size: 13px; }
.todo-pick-trail { font-size: 10.5px; color: var(--text-dim); }

/* 思考フレームの階層番号（1-1-2） */
.oc-no {
  font-size: 10.5px; color: var(--text-dim); flex: 0 0 auto;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}

#outline-resizer {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: ew-resize; z-index: 5;
}

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.current-map { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sep { width: 1px; height: 18px; background: var(--border); }
.spacer { flex: 1; }
.save-state { font-size: 11px; color: var(--text-dim); min-width: 60px; text-align: right; }

.menu-wrap { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; min-width: 170px;
  display: flex; flex-direction: column;
}
.dropdown button { background: none; border: none; text-align: left; border-radius: 5px; }
.dropdown button:hover { background: var(--accent-soft); }
.dropdown .dd-title {
  font-size: 11px; color: var(--text-dim); padding: 5px 9px 3px;
}
.dropdown .dd-divider { height: 1px; background: var(--border); margin: 4px 2px; }
.dropdown .dd-hint {
  font-size: 11px; color: var(--text-dim); padding: 4px 9px;
  line-height: 1.6; white-space: pre-line;
}
/* 項目名が長いメニュー（思考フレーム） */
.dropdown.wide { min-width: 270px; }

/* チェック付きメニュー項目（マインドマップの ON/OFF） */
.dropdown button.check::before {
  content: "✓"; display: inline-block; width: 14px; opacity: 0;
}
.dropdown button.check.on::before { opacity: 1; color: var(--accent); }

/* 押し込み表示のツールバーボタン */
button.toggled { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* ==================== テーマ選択メニュー ==================== */

#menu-theme { min-width: 200px; left: auto; right: 0; }
.theme-item {
  display: flex !important; align-items: center; gap: 9px;
  padding: 6px 8px !important;
}
.theme-item.on { background: var(--accent-soft); }
.theme-item .tswatch {
  flex: 0 0 auto; width: 34px; height: 18px; border-radius: 4px;
  border: 1px solid var(--border); overflow: hidden; display: flex;
}
.theme-item .tswatch i { flex: 1; }
.theme-item .tname { flex: 1; }
.theme-item .tkind { font-size: 10px; color: var(--text-dim); }

#findbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--panel-2); border-bottom: 1px solid var(--border);
}
#find-count { font-size: 11px; color: var(--text-dim); min-width: 70px; }

/* ==================== マップ検索（上の帯 ＋ 大きな結果） ====================
   検索欄は左の一覧の上から上の帯へ移した。結果は左を絞らず、
   キャンバスの上に重ねた #map-search-panel に大きく並べる（js/map-search.js）。
   ========================================================================== */

.map-search-wrap { position: relative; display: flex; align-items: center; }
.map-search-wrap input[type="search"] {
  width: 190px;
  /* ✕ のぶんだけ右を空ける */
  padding-right: 26px;
}
#map-search-clear {
  position: absolute; right: 1px;
  background: none; border: none; color: var(--text-dim);
  padding: 3px 5px; min-width: 0; font-size: 12px;
}
#map-search-clear:hover { color: var(--text); background: none; }

/* 結果パネル。#viewport の子として上に重ねる（キャンバスは隠さない。
   隠すと幅も高さも 0 になり、帯に残る「全体表示」がその 0 で計算してしまう） */
#map-search-panel {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--panel);
  /* #viewport の touch-action: none を打ち消す（結果を指で送れるように） */
  touch-action: auto;
  cursor: default;
}

.msp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: var(--panel-2); border-bottom: 1px solid var(--border);
}
.msp-title { font-weight: 600; }
.msp-count { font-size: 12px; color: var(--text-dim); }

.msp-body { flex: 1; overflow-y: auto; padding: 14px; overscroll-behavior: contain; }

.msp-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
}

.msp-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.msp-card:hover { background: var(--accent-soft); border-color: var(--accent); }
/* いま開いているマップ（探した先が今のマップだった、が分かるように） */
.msp-card.current { box-shadow: inset 0 0 0 1px var(--accent); }

.msp-name { font-size: 15px; font-weight: 600; word-break: break-word; }
.msp-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
}
/* 当たった語。ブラウザ既定の黄色はテーマに合わないので上書きする */
.msp-name mark, .msp-desc mark {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 0 2px;
}

.msp-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.msp-cat {
  font-size: 11px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}
.msp-date { font-size: 11px; color: var(--text-dim); }

.msp-empty { padding: 40px 20px; text-align: center; color: var(--text-dim); }
.msp-empty-title { font-size: 14px; margin-bottom: 8px; }
.msp-empty-note { font-size: 12px; line-height: 1.7; }

/* 浮くパレット（選んだカードのそば）は結果の上に出てしまうので畳む。
   選択そのものは触らない（閉じれば元のまま戻る） */
body.map-search-open .palette { display: none; }

/* ==================== キャンバス ==================== */


#viewport {
  position: relative; flex: 1; overflow: hidden;
  background-color: var(--canvas-bg);
  cursor: default;
  touch-action: none;
}
#viewport.panning { cursor: grabbing; }
#viewport.connecting { cursor: crosshair; }

/* will-change を常時付けると、ブラウザが world を「一度描いた絵」として保持し、
   拡大縮小はその絵の引き伸ばしになるため文字がかすれる。
   ドラッグ・ズーム中だけ .transforming を付け、止まったら外して描き直させる。 */
#world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
#world.transforming { will-change: transform; }

#edge-layer, #handle-layer {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: visible;
}
/* 接続の線は #node-layer の子。z-index を持たせると（正の値は）カードより必ず手前、
   （負の値は）必ず奥になってしまい、DOM の並びで決めている重ね順に混ざれない。
   どこへ挟むかは Canvas.orderLayers が決める */
#handle-layer { z-index: 4; pointer-events: none; }
#handle-layer .hit { pointer-events: auto; }
#group-layer { position: absolute; top: 0; left: 0; z-index: 1; }
#node-layer { position: absolute; top: 0; left: 0; z-index: 3; }

.empty-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); pointer-events: none; font-size: 14px;
}

#rubber {
  position: absolute; z-index: 50;
  border: 1px dashed var(--selection);
  background: var(--accent-soft);
  pointer-events: none;
}

/* ---- ノードカード ---- */
.node {
  position: absolute;
  background: var(--node-bg);
  border: var(--node-border-width) solid var(--node-border);
  border-radius: var(--node-radius);
  overflow: visible;
  cursor: move;
  user-select: none;
  display: flex; flex-direction: column;
  box-shadow: var(--node-shadow);
}
.node.selected { border-color: var(--selection); box-shadow: 0 0 0 2px var(--accent-soft), var(--node-shadow); }
.node.search-hit { outline: 2px solid var(--hit); outline-offset: 1px; }
.node.search-current { outline: 3px solid var(--selection); outline-offset: 2px; }
.node.dimmed { opacity: .35; }

.node-inner { padding: 6px 8px; overflow: hidden; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.node-badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; min-height: 0; }
.node-badge {
  font-size: 9px; line-height: 1.4; padding: 0 5px; border-radius: 8px;
  color: #fff; white-space: nowrap;
}
.node-badge.type { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.node-badge.project {
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}

/* ---- 思考フレーム（階層番号・比率・MECE の注意） ---- */
.node-badge.no {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.node-badge.weight {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.node-badge.mece {
  background: var(--hit); color: #1f2328; font-size: 10px; font-weight: 700;
  cursor: help;
}

/* ---- チェック（枝の進み具合） ---- */
.node-badge.check {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums; cursor: help;
}
.node-badge.check.done { color: var(--ok, #3fa66a); border-color: currentColor; }

/* ---- ロック（位置・大きさの固定） ---- */
.node-badge.lock {
  background: transparent; border: 1px solid var(--border);
  font-size: 10px; line-height: 1.3; padding: 0 3px; cursor: help;
}
.node-title { font-weight: 600; word-break: break-word; white-space: pre-wrap; }
.node-title[contenteditable="true"] {
  outline: 2px solid var(--accent); border-radius: 4px; cursor: text; background: var(--panel);
  user-select: text; -webkit-user-select: text;
}
.node-content { color: var(--text-dim); word-break: break-word; white-space: pre-wrap; overflow: hidden; flex: 1; }
.node-image { max-width: 100%; min-height: 0; flex: 1 1 auto; border-radius: 4px; object-fit: contain; }
.node.collapsed .node-content,
.node.collapsed .node-image { display: none; }

/* ---- 文字の縦位置（TOP / MIDDLE / BOTTOM）----
   横の寄せ（text-align）はインラインで当てるが、縦は「カードの中の一段」ではなく
   **中身の塊をどこへ置くか**なので、.node-inner の justify-content で決める。

   .node-content と .node-image は既定で余白を吸う（flex: 1）ので、そのままだと
   塊が必ず高さいっぱいに伸びて justify-content が効かない。真ん中・下に寄せる
   ときだけ、伸びるのをやめさせて中身の高さに縮める。
   図形（.shape-node）は shape_data の tv が正で、下の方に専用の規則がある。 */
.node.text-middle > .node-inner { justify-content: center; }
.node.text-bottom > .node-inner { justify-content: flex-end; }
.node.text-middle > .node-inner > .node-content,
.node.text-bottom > .node-inner > .node-content,
.node.text-middle > .node-inner > .node-image,
.node.text-bottom > .node-inner > .node-image,
.node.text-middle > .node-inner > .sticky-note-body,
.node.text-bottom > .node-inner > .sticky-note-body { flex: 0 1 auto; }

.node-strip {
  height: 4px; flex: 0 0 auto;
  border-radius: calc(var(--node-radius) - 2px) calc(var(--node-radius) - 2px) 0 0;
}
.node-session-mark {
  position: absolute; right: 4px; top: -8px; font-size: 10px;
  background: var(--accent); color: var(--on-accent); border-radius: 8px; padding: 0 6px;
}

/* 内容テキスト内のリンク（URL / claudenote://session/...） */
.node-content a.node-link { color: var(--link); text-decoration: underline; cursor: pointer; }
.node-content a.node-link:hover { filter: brightness(1.2); }

/* ==========================================================================
   付箋（大きなメモの貼り紙 / js/sticky-note.js）

   ふつうのノードと同じ .node の上に .sticky-note を足したもの。
   ・敷物として使うので、ほかのカードより奥に描く。奥行きは z-index ではなく
     **DOM の並び順**で付ける（Canvas.orderStickyNotes）。全ノードに z-index を振ると
     カードごとに重ね合わせの箱ができて、枠からはみ出す −/＋ や ☐ が
     隣のカードの下に潜ってしまうため
   ・本文は Markdown を整形した HTML。はみ出したぶんはカードの中でスクロールする
   ・色を指定していないときは、テーマに合わせた「紙」の色を当てる
   ========================================================================== */
/* 色を指定していない付箋の下地。背景色を選んだ付箋は
   updateNodeEl が inline style を書くので、そちらが勝つ */
.node.sticky-note {
  border-radius: 3px;
  background: var(--sticky-note-bg, #fdf6c8);
  border-color: var(--sticky-note-border, rgba(0, 0, 0, .12));
  box-shadow: 2px 3px 10px rgba(0, 0, 0, .18);
}
.node.sticky-note > .node-inner { padding: 10px 12px; gap: 6px; }
.node.sticky-note .node-title { font-weight: 700; flex: 0 0 auto; }

/* 選んでいる付箋の本文は、**ふつうの文字として選んでコピーできる**。
   選ぶ前は今までどおり掴んで動かせる（画像のカードと同じ作法。rejected #206）ので、
   「押してそのまま動かす」いちばん多い操作は変わらない。
   指の端末では文字選択に入れない（なぞる操作が画面を送るのと見分けが付かない）ので、
   掴めるままにする。指から本文を持ち出すのは右クリック（長押し）の「📋 本文をコピー」 */
.node.sticky-note.selected .sticky-note-body {
  user-select: text; -webkit-user-select: text; cursor: text;
}
@media (pointer: coarse) {
  .node.sticky-note.selected .sticky-note-body {
    user-select: none; -webkit-user-select: none; cursor: move;
  }
}

/* ==================== 手書き領域（INK） ==================== */

/* 手書き層（マップに1枚。`node_type='INK'`）。

   **これはカードではなく「地に引いた線」そのもの。**
   枠も下地も持たず、掴めもしない（見えている範囲を丸ごと覆っているので、
   触れるようにすると上のカードが何も押せなくなる）。
   当たり判定は Canvas.nodeAt でも外してある。 */
.node.ink-note {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
}

body.ink-drawing #viewport { cursor: crosshair; }

/* 手書きに文字はふつう入らない。見出しを打ったときだけ出す */
.node.ink-note .node-content,
.node.ink-note .node-image,
.node.ink-note .sticky-note-body { display: none !important; }
.node.ink-note > .node-inner { padding: 0; pointer-events: none; }
.node.ink-note .node-title {
  pointer-events: auto;
  padding: 2px 6px;
  opacity: .75;
}
.node.ink-note .node-title:empty { display: none; }

.node-ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* 紙からはみ出した線は見せない。紙を広げれば出てくる（データは消していない） */
  overflow: hidden;
  pointer-events: none;
  display: none;   /* 手書き領域のときだけ Canvas.updateInk が出す */
}
/* 表示・非表示は Canvas.updateInk が決める（線を持つカードなら種類を問わず出す） */

/* ---- 図形（四角・円・矢印…／js/shape.js・js/map-shape.js） ----

   図形のカードは「入れ物」でしかない。下地・枠・影はすべて図形自身が SVG で描くので、
   カードからは全部取り去る。選択中だけ、どこが箱かが分かるように薄い枠を出す。

   触れるのは**実際に描かれたところだけ**にする（pointer-events は継承する
   プロパティなので、カードで none にしてから中の図形にだけ戻す）。
   こうすると、塗っていない四角の内側はクリックが素通りして、下にあるカードや
   キャンバスのパン・範囲選択がそのまま使える —— 作図ソフトと同じ規則。
   細い線は当たり判定が針になるので、shape.js が透明な太い線（.shape-hit）を重ねている。 */
.node.shape-node {
  background: none !important;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
}
.node.shape-node.selected {
  border-color: var(--selection);
  border-style: dashed;
  box-shadow: none;
}
.node.shape-node .node-shape * { pointer-events: visiblePainted; }
/* 道具は常に押せる（つまみ・接続点・折りたたみ・回す） */
.node.shape-node .anchor,
.node.shape-node .resizer,
.node.shape-node .rotator,
.node.shape-node .collapse-btn { pointer-events: auto; }
/* 図形に「見た・済ませた」の印は要らない（`State.structuralNodes` が数えないので、
   押しても何も起きない札だった）。左上が空くので、そこを回すつまみが使う */
.node.shape-node .check-btn { display: none !important; }
/* 図形の中の文字は真ん中に置く（囲みのラベル・ワイヤーフレームの見出し）。
   位置指定（relative）が要る: 図形の SVG は position:absolute なので、
   **位置指定していない中身は必ず SVG の下に潜る**。塗った図形では
   文字が塗りに隠れて完全に見えなくなる（塗っていない図形では透けるので気づけない）。
   兄弟どうしが両方 position 付きになれば、あとは DOM の並び順で前後が決まる */
.node.shape-node > .node-inner {
  position: relative;
  padding: 4px 8px;
  justify-content: center;
  pointer-events: none;
}
/* 文字の縦の位置（図形ごとに選べる）。大きな囲みは中央だと中のカードと重なる */
.node.shape-node.text-top > .node-inner { justify-content: flex-start; }
.node.shape-node.text-bottom > .node-inner { justify-content: flex-end; }
/* 左右の寄せは MapShape.create が textAlignment='CENTER' で持たせる
   （updateNodeEl がインラインで当てるので、ここで指定しても勝てない） */
.node.shape-node .node-title,
.node.shape-node .node-content { pointer-events: auto; }
.node.shape-node .node-image,
.node.shape-node .sticky-note-body { display: none !important; }

.node-shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* 回した図形は箱からはみ出す。切らずに見せる（箱＝当たり判定は回さない） */
  overflow: visible;
  display: none;   /* 図形のときだけ Canvas.updateShape が出す */
}
.node.shape-node .node-shape { display: block; }

/* 矢印・直線を引いている間の下見（handle-layer に出す。置くものと同じ形）。
   薄くして「まだ置いていない」ことを示す。handle-layer 自体が pointer-events:none
   なので、下見が下のカードの操作を邪魔することはない */
.shape-ghost { opacity: .55; }
/* 向き待ちの始点の印（2 点目を押すまで出る） */
#handle-layer circle.shape-aim-start {
  fill: var(--accent); stroke: var(--node-bg); stroke-width: 2;
}

/* 接続先待ち（接続点をクリック / 🔗 つなぐ を押した後）の、線の出どころの印。
   指の端末では仮の線が指を追わない（触れていないので pointermove が来ない）ため、
   これが「1 枚目を受け取った」ことを示す唯一の目印になる */
#handle-layer circle.connect-start {
  fill: var(--accent); stroke: var(--node-bg); stroke-width: 2;
}

/* 図形ツールを構えている間。どこを触っても「描く」ので、カーソルで知らせる */
#viewport.shape-armed { cursor: crosshair; }
#viewport.shape-armed .node { cursor: crosshair; }
#rubber.shape-draw { border-style: solid; border-width: 2px; }

/* 種類を選ぶ格子（上の帯の ▾ から開くメニューの中） */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 2px 6px 6px;
}
.shape-pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 2px;
  background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: 6px;
  font-size: 10px; line-height: 1.2; cursor: pointer;
}
.shape-pick:hover { background: var(--accent-soft); border-color: var(--border); }
.shape-pick.on { background: var(--accent-soft); border-color: var(--accent); }
.shape-pick .shape-preview { display: block; }
.shape-dashes { display: flex; gap: 4px; padding: 2px 6px 6px; }
.shape-dash {
  flex: 1; padding: 4px 2px; font-size: 11px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.shape-dash:hover { background: var(--accent-soft); }
.shape-dash.on { background: var(--accent-soft); border-color: var(--accent); }
/* 構えている間は上の帯のボタンを点灯させる（手書きの ▾ と同じ考え方） */
#btn-shape.on { background: var(--accent-soft); border-color: var(--accent); }
@media (pointer: coarse) {
  .shape-pick { padding: 8px 2px; }
}

/* 隅の道具（ペン ⇄ 消しゴム／▾）。ペンを持ったまま押せる大きさにする */
.ink-tools {
  position: absolute;
  top: 3px; right: 3px;
  display: flex; gap: 3px;
  z-index: 3;
}
.ink-tool {
  width: 34px; height: 30px;
  padding: 0; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  cursor: pointer;
}
.ink-tool.eraser { background: var(--accent-soft); border-color: var(--accent); }
@media (pointer: coarse) {
  .ink-tool { width: 40px; height: 36px; font-size: 17px; }
}


/* 手書きが入のときは、ボタン自体が押されたままに見えるようにする */
#btn-ink.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
/* ▾ の枠にいまのペンの色を出す。メニューを開かなくても何色か分かる */
#btn-ink-menu { border-left-width: 3px; border-left-style: solid; }

/* 👆 送るだけ（触っても動かない）。入のときはボタンが押されたままに見える */
#btn-freeze.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
/* 掴めないことを、カーソルの形でも伝える（どこを触っても画面を送るだけ） */
body.frozen #viewport,
body.frozen #viewport .node { cursor: grab; }
body.frozen #viewport.panning,
body.frozen #viewport.panning .node { cursor: grabbing; }

/* 引き出しの中の説明書き（押せない案内文） */
.dd-note {
  padding: 4px 10px 8px; font-size: 11px; line-height: 1.5;
  color: var(--text-dim); max-width: 260px; white-space: normal;
}

.ink-swatches, .ink-widths {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px 8px 6px;
}
.ink-swatch {
  width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--border); border-radius: 5px;
  cursor: pointer;
}
.ink-swatch.on { outline: 2px solid var(--selection); outline-offset: 1px; }
.ink-width {
  width: 30px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); border-radius: 5px;
  cursor: pointer;
}
.ink-width i { display: block; border-radius: 50%; background: currentColor; }
.ink-width.on { outline: 2px solid var(--selection); outline-offset: 1px; }

/* 既定を block にしておくのは、updateNodeEl が付箋のとき style.display = '' で
   インラインの指定を外すため（'none' を書いてあると付箋の本文が消える）。
   ふつうのノードでは JS が 'none' を書いて隠す */
.sticky-note-body {
  /* 本文の中の罫線（表・引用・見出しの下線・区切り線）の色。
     テーマの --border ではなく**その付箋の文字色**から作る。付箋の下地は
     --sticky-note-bg か利用者が選んだカード色で、テーマの面とは別物のため、
     --border だとダークテーマで表の罫線がほとんど見えなくなる（2026-08-12 実描画で確認）。
     currentColor 基準なので、下地に濃い色を選んでも薄い色を選んでも見える。 */
  --sticky-note-rule: color-mix(in srgb, currentColor 30%, transparent);
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  word-break: break-word;
  line-height: 1.6;
  /* 本文の上でも「掴んで動かす」。文字を選んでコピーするのは編集中（textarea）に行う。
     ここだけ選択できるようにすると、ドラッグが選択に化けて付箋が動かせなくなる */
}
.sticky-note-body.raw { white-space: pre-wrap; }
.sticky-note-body.empty { display: flex; align-items: center; justify-content: center; }
.sticky-note-hint { color: var(--text-dim); font-size: 11px; opacity: .8; text-align: center; }

/* ---- 付箋の中の Markdown（メモ画面より詰めた寸法にする） ---- */
.sticky-note-body > :first-child { margin-top: 0; }
.sticky-note-body > :last-child { margin-bottom: 0; }
.sticky-note-body h1, .sticky-note-body h2, .sticky-note-body h3,
.sticky-note-body h4, .sticky-note-body h5, .sticky-note-body h6 {
  margin: .7em 0 .35em; line-height: 1.3; font-weight: 700;
}
.sticky-note-body h1 { font-size: 1.5em; border-bottom: 1px solid var(--sticky-note-rule); padding-bottom: .15em; }
.sticky-note-body h2 { font-size: 1.3em; border-bottom: 1px solid var(--sticky-note-rule); padding-bottom: .12em; }
.sticky-note-body h3 { font-size: 1.15em; }
.sticky-note-body h4, .sticky-note-body h5, .sticky-note-body h6 { font-size: 1em; }
.sticky-note-body p { margin: .45em 0; }
.sticky-note-body ul, .sticky-note-body ol { margin: .4em 0; padding-left: 1.4em; }
.sticky-note-body li { margin: .12em 0; }
/* チェックボックスは <li> ではなく段落の中に <br> 区切りで並ぶ
   （NoteMarkdownService が CommonMark より先に HTML 化するため） */
.sticky-note-body input.todo-check { margin: 0 .4em 0 0; vertical-align: -1px; cursor: pointer; }
.sticky-note-body blockquote {
  margin: .5em 0; padding: .1em .8em;
  border-left: 3px solid var(--sticky-note-rule); opacity: .85;
}
.sticky-note-body code {
  font-family: Consolas, 'Courier New', monospace; font-size: .92em;
  background: var(--code-bg, rgba(127, 127, 127, .16)); border-radius: 3px; padding: .05em .3em;
}
.sticky-note-body pre {
  margin: .5em 0; padding: .5em .7em; border-radius: 5px; overflow-x: auto;
  background: var(--code-bg, rgba(127, 127, 127, .16));
}
.sticky-note-body pre code { background: none; padding: 0; }
.sticky-note-body table { border-collapse: collapse; margin: .5em 0; font-size: .95em; }
.sticky-note-body th, .sticky-note-body td { border: 1px solid var(--sticky-note-rule); padding: .25em .6em; }
.sticky-note-body th { background: rgba(127, 127, 127, .12); font-weight: 700; }
.sticky-note-body hr { border: none; border-top: 1px solid var(--sticky-note-rule); margin: .7em 0; }
.sticky-note-body img { max-width: 100%; border-radius: 4px; cursor: zoom-in; }
.sticky-note-body a.node-link { color: var(--link); text-decoration: underline; cursor: pointer; }
.sticky-note-body a.node-link:hover { filter: brightness(1.2); }

/* ---- 本文の編集（カードにかぶせる textarea） ---- */
.node.sticky-note.editing { z-index: 20; }
.sticky-note-edit {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%; margin: 0;
  padding: 10px 12px 26px;
  box-sizing: border-box; resize: none;
  border: 2px solid var(--accent); border-radius: 3px;
  background: var(--panel); color: var(--text);
  font-family: Consolas, 'Courier New', monospace; font-size: 12px; line-height: 1.6;
  white-space: pre-wrap;
  user-select: text; -webkit-user-select: text; cursor: text;
}
.sticky-note-edit:focus { outline: none; }
.sticky-note-edit-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: center; gap: 5px;
  padding: 2px 8px; font-size: 10px; line-height: 1.6;
  color: var(--text-dim); background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 0 0 3px 3px;
  pointer-events: none;
}
.sticky-note-edit-bar .key {
  border: 1px solid var(--border); border-radius: 3px; padding: 0 4px;
  font-family: Consolas, monospace; color: var(--text);
}

/* 折りたたみボタン（子ノードを持つノードの右上）。
   チェック（下の .check-btn）と対なので、外へ出す量も同じにする */
.collapse-btn {
  position: absolute; right: -12px; top: -8px; z-index: 7;
  width: 18px; height: 18px; padding: 0; line-height: 1;
  border-radius: 50%; border: 1px solid var(--node-border);
  background: var(--panel); color: var(--text);
  font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.collapse-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---- チェックボックス（カード左上） ----
   既定ではホバー・選択中・チェック済みのときだけ出る。
   「表示」メニューの「チェックボックスを常に表示」で #viewport.show-checks が付く。
   **横へ出す量は「文字の箱に掛からないところまで」**——.node-inner の左の余白は 8px なので、
   18px の丸を left:-12px（＝カードの中へ 6px）まで出せば、題名の1文字目に絶対に重ならない。
   下げるのではなく**左へ**逃がすのは、上は編集パレットの居場所だから
   （js/palette.js は カードの上端から 10px しか空けない。8px より上へ出すとバーの下に潜る）。 */
.check-btn {
  position: absolute; left: -12px; top: -8px; z-index: 7;
  width: 18px; height: 18px; padding: 0; line-height: 1;
  border-radius: 5px; border: 1.5px solid var(--node-border);
  background: var(--panel); color: transparent;
  font-size: 12px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .1s linear;
}
.node:hover .check-btn,
.node.selected .check-btn,
#viewport.show-checks .check-btn,
.check-btn.on { opacity: 1; }
.check-btn:hover { border-color: var(--ok); color: var(--ok); }
.check-btn.on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* チェック済みのカード: タイトルに取り消し線、枠を確認色に */
.node.checked { border-color: var(--ok); }
.node.checked .node-title { text-decoration: line-through; text-decoration-thickness: 1.5px; }
#viewport.dim-checked .node.checked { opacity: .55; }
#viewport.dim-checked .node.checked.selected { opacity: 1; }

/* 接続先の候補（ドラッグ中／スティッキー接続中のハイライト） */
.node.connect-target { border-color: var(--hit); box-shadow: 0 0 0 3px var(--accent-soft); }
/* 繋ぎ替え候補では、吸着先が分かるよう接続点を強調する */
.node.connect-target .anchor { background: var(--hit); }

/* スティッキー接続中のヒント */
#sticky-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 55;
  padding: 5px 14px; border-radius: 16px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--accent); color: var(--text);
  box-shadow: var(--shadow); pointer-events: none;
}

/* 描画モードの道具パネル（js/map-ink.js ＋ js/ui.js buildInkPanel）。

   **どちらのモードかは、押した本人にしか分からない状態を作らない。**
   ボタンの押下表示だけだと、狭い画面で帯が畳まれたときに手がかりが消える。
   キャンバスの上に出しっぱなしにして、抜ける手段（✕）も同じ場所に置く。

   帯だったものを 2026-08-26 にパネルへ広げた —— ペンと消しゴムの持ち替えが
   上の帯の ▾ を開き直す（＝描いている手を画面の端まで往復させる）作業だったため。
   道具は**描いている場所のそば**に置けることが要点なので、掴んで動かせるようにし、
   置き場所は端末ごとに覚える。畳めば見出しだけになる。 */
#ink-panel {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 56;
  display: flex; flex-direction: column; gap: 6px;
  max-width: calc(100% - 16px);
  padding: 6px; border-radius: 12px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--accent); color: var(--text);
  box-shadow: var(--shadow);
  /* 掴んで動かすのに、ブラウザの既定のジェスチャへ譲らない。
     文字が選ばれると、なぞったときに青い選択が走って掴めなくなる */
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
#ink-panel-head {
  display: flex; align-items: center; gap: 7px;
  padding: 1px 2px 1px 3px;
  cursor: grab;
}
#ink-panel-head:active { cursor: grabbing; }
#ink-panel-grip { color: var(--text-dim); font-size: 13px; line-height: 1; flex-shrink: 0; }
/* いま描く色をそのまま見せる（何色で描くかも、ここで分かる） */
#ink-hint-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid var(--border); flex-shrink: 0;
}
/* 狭い画面では説明から先に削る。**「✕ 終わる」は絶対に残す**
   （抜ける手段が消えると、触るたびに線が増えるだけの状態から出られない） */
#ink-hint-text {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#ink-panel-fold {
  padding: 2px 6px; font-size: 11px; line-height: 1.4;
  border-radius: 8px; min-height: 0;
}
#ink-hint-exit {
  padding: 2px 8px; font-size: 11px; line-height: 1.5;
  border-radius: 10px; min-height: 0;
}

#ink-panel-body { display: flex; flex-direction: column; gap: 5px; }
.ink-panel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

/* ペン ⇄ 消しゴム。**押した瞬間に切り替わる**ことが目的なので、
   引き出しの中の項目ではなく、常に出ている大きな 2 択にする */
.ink-p-mode {
  flex: 1 1 0; min-width: 88px;
  padding: 7px 8px; font-size: 12px; line-height: 1.2;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
}
.ink-p-mode.on {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.ink-p-act {
  padding: 4px 8px; font-size: 11px; line-height: 1.4;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
}
.ink-p-act:disabled { opacity: .4; cursor: default; }

/* パネルの中の色・太さは、引き出しの中より一回り大きくする（指で押す） */
#ink-panel .ink-swatch { width: 27px; height: 27px; }
#ink-panel .ink-width { width: 33px; height: 27px; }
@media (pointer: coarse) {
  #ink-panel .ink-swatch { width: 33px; height: 33px; }
  #ink-panel .ink-width { width: 40px; height: 33px; }
  .ink-p-mode { padding: 10px 8px; font-size: 13px; }
  .ink-p-act { padding: 7px 10px; font-size: 12px; }
}
/* 狭い画面。パネルの幅を画面いっぱいまで許して、色を 2 段に折り返させる */
@media (max-width: 760px) {
  #ink-panel { max-width: calc(100% - 12px); }
}
/* 描画モードの間は、キャンバスの縁を色で囲う（帯を見ていなくても気づける） */
body.ink-drawing #viewport::after {
  content: ''; position: absolute; inset: 0; z-index: 54;
  border: 2px solid var(--accent); border-radius: 2px;
  pointer-events: none;
}

/* 重ねて親子にする（カードを他のカードへ落とす）ときの落とし先。
   接続先候補（.connect-target）と紛れないよう、色ではなく**太い枠**で示す */
.node.drop-parent {
  border-color: var(--ok);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--node-shadow);
}
#drop-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 55;
  padding: 5px 14px; border-radius: 16px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--ok); color: var(--text);
  box-shadow: var(--shadow); pointer-events: none;
}

/* ---- 指で枝を伸ばす道具（js/map-touch.js） ----

   ＋ハンドルはカードの中ではなく**画面に貼る**。カードの中に入れると
   world の transform に乗って倍率ぶん縮み、縮小して全体を見ているときに
   指では押せない大きさになる（チェックボックス・折りたたみと同じ事情）。 */
.quick-add { position: fixed; inset: 0; z-index: 185; pointer-events: none; }
.quick-add[hidden] { display: none; }
.qa-btn {
  position: fixed; pointer-events: auto;
  padding: 0 10px; height: 30px; min-height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; white-space: nowrap;
  background: var(--panel); color: var(--accent);
  border: 1.5px solid var(--accent); border-radius: 15px;
  box-shadow: var(--shadow); cursor: pointer;
  /* 押している間に iOS が文字を選び始めると、そのまま指を持っていかれる */
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.qa-btn:hover { background: var(--accent); color: var(--on-accent); }
/* .qa-btn が display を持つので、hidden 属性だけでは消えない（.quick-add[hidden] と同じ） */
.qa-btn[hidden] { display: none; }

/* 入力中の帯（画面キーボードのすぐ上）。Tab / Shift+Enter の代わり */
.edit-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 195;
  display: flex; gap: 4px; padding: 5px 6px;
  max-width: calc(100vw - 12px); overflow-x: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.edit-bar[hidden] { display: none; }
.eb-btn {
  padding: 0 11px; height: 34px; min-height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; white-space: nowrap;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.eb-btn.primary { border-color: var(--accent); color: var(--accent); }
.eb-btn:hover { background: var(--accent-soft); }

/* 帯の中の説明文（押せないただの文字）。接続先を待っている間に出す */
.eb-note {
  display: inline-flex; align-items: center;
  padding: 0 6px; font-size: 12px; color: var(--text-dim); white-space: nowrap;
}

/* 接続点（アンカー）: 未選択ノードのホバー時、またはエッジ選択時に表示。
   ★ ホバーの無い端末（タブレット・スマホ）ではここが一度も真にならない。
   指での接続は「🔗 つなぐ」→ 相手を押す（js/map-touch.js）が受け持つ */
.node .anchor { display: none; }
.node:hover:not(.selected) .anchor,
.node.connect-target .anchor,
.node.show-anchors .anchor { display: block; }

/* リサイズハンドル: 選択中のみ表示 */
.node .resizer { display: none; }
.node.selected .resizer { display: block; }

/* ロック中: カード自体は動かないが、掴むと画面のほうが動く（＝パン）ので ✋ を出す。
   サイズ変更つまみは止める（接続点は残す。ロックが縛るのは位置と大きさだけ） */
.node.locked { cursor: grab; }
.node.locked .resizer { display: none !important; }

/* パンの最中は、カードの上に来ても握った手のまま（.node の move / grab に勝たせる） */
#viewport.panning .node { cursor: grabbing; }

.anchor {
  position: absolute; width: 9px; height: 9px; margin: -5px 0 0 -5px;
  background: var(--accent); border: 1.5px solid var(--anchor-ring); border-radius: 50%;
  cursor: crosshair; z-index: 6;
}
.anchor:hover { transform: scale(1.45); }

/* リサイズハンドル */
.resizer {
  position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  background: var(--resizer-bg); border: 1.5px solid var(--selection); z-index: 6;
}

/* 回すつまみ（図形を選んでいるときだけ出る）。**左上の角のつまみの、さらに外側**に置く。
   上辺の真ん中は編集パレット（.palette）の指定席で、そこに置くとバーの下に潜って掴めなかった
   （パレットは position:fixed / z-index 190 なので、カードの中のつまみでは前に出られない）。
   角なら四隅のリサイズつまみのすぐ外側で、どのつまみとも重ならない。
   図形にはチェックの札を出さないので左上は空いている。
   パレットが上に来るときは Palette.position() がこのつまみのぶんだけ余白を足す */
.rotator {
  position: absolute; left: 0; top: 0; margin: -25px 0 0 -25px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--panel); border: 1.5px solid var(--selection); color: var(--selection);
  font-size: 12px; line-height: 1; display: none;
  align-items: center; justify-content: center;
  cursor: grab; z-index: 7; user-select: none;
}
.node.shape-node.selected:not(.locked) .rotator { display: flex; }
.rotator:hover { background: var(--selection); color: #fff; }
#viewport.rotating, #viewport.rotating .node { cursor: grabbing; }

/* グループ枠 */
.group-frame {
  position: absolute;
  border: 1.5px dashed var(--group);
  border-radius: 12px;
  background: var(--group-fill);
  pointer-events: none;
}
.group-frame.active { border-style: solid; background: var(--group-fill-active); }
.group-frame.selected { border-color: var(--selection); background: var(--accent-soft); }
/* 枝（サブツリー）のグループは実線寄りにして、手で束ねたグループと見分ける */
.group-frame.branch { border-style: solid; border-width: 1.5px; }
.group-frame .group-name {
  position: absolute; top: -9px; left: 10px; font-size: 10px;
  background: var(--canvas-bg); padding: 0 6px; color: var(--group);
  pointer-events: auto; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.group-frame .group-name.branch::before { content: '⌥'; opacity: .75; }
.group-frame .group-name:hover { color: var(--accent); text-decoration: underline; }
.group-frame.selected .group-name { color: var(--selection); }

/* 枠の縁だけを掴めるようにする帯（中はクリックが素通りしてノードに届く） */
.group-frame .group-edge { position: absolute; pointer-events: auto; }
.group-frame .group-edge.top { left: 0; right: 0; top: -5px; height: 11px; cursor: move; }
.group-frame .group-edge.bottom { left: 0; right: 0; bottom: -5px; height: 11px; cursor: move; }
.group-frame .group-edge.left { top: 0; bottom: 0; left: -5px; width: 11px; cursor: move; }
.group-frame .group-edge.right { top: 0; bottom: 0; right: -5px; width: 11px; cursor: move; }

/* 折りたたみ / 展開ボタン（枠の右上・たたんだカードの右端） */
.group-collapse-btn {
  position: absolute; top: -10px; right: 8px; width: 18px; height: 18px; padding: 0;
  border-radius: 50%; border: 1px solid var(--group);
  background: var(--canvas-bg); color: var(--group);
  font-size: 12px; line-height: 1; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
}
.group-collapse-btn:hover { background: var(--group); color: var(--canvas-bg); }

/* 折りたたんだグループ（1 枚のカードにまとまる） */
.group-collapsed {
  position: absolute; display: flex; flex-direction: column; justify-content: center;
  gap: 2px; padding: 4px 26px 4px 12px; border-radius: 10px;
  border: 1.5px solid var(--group); background: var(--group-fill-active);
  color: var(--group); cursor: move; user-select: none; pointer-events: auto;
  box-sizing: border-box; overflow: hidden;
}
.group-collapsed.selected { border-color: var(--selection); box-shadow: 0 0 0 2px var(--accent-soft); }
.group-collapsed .group-collapsed-name {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.group-collapsed .group-collapsed-count { font-size: 10px; opacity: .75; }
.group-collapsed .group-collapse-btn { top: 50%; right: 6px; margin-top: -9px; }

/* エッジ */
#edge-layer path.edge-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
#edge-layer path.edge-line { fill: none; stroke-linecap: round; pointer-events: none; }
#edge-layer path.edge-line.selected { stroke: var(--selection) !important; }
#edge-layer .edge-label {
  font-size: 11px; fill: var(--text); paint-order: stroke;
  stroke: var(--canvas-bg); stroke-width: 3px; stroke-linejoin: round;
  pointer-events: none; user-select: none;
}
#edge-layer path.arrow { pointer-events: none; }
/* ラベルを線から離して置いたときの引き出し線（どの線のものか分かるように） */
#edge-layer line.edge-label-leader {
  stroke-width: 1; stroke-dasharray: 2 3; opacity: .55; pointer-events: none;
}
/* ラベルを掴む枠。選んでいる線にだけ出る（文字は pointer-events: none のまま） */
#handle-layer rect.label-hit {
  fill: transparent; stroke: var(--ctrl); stroke-width: 1; stroke-dasharray: 3 3;
  cursor: move;
}
#handle-layer rect.label-hit:hover { stroke: var(--accent); stroke-dasharray: none; }
#handle-layer circle.ctrl { fill: var(--ctrl); stroke: var(--ctrl-ring); stroke-width: 1.5; cursor: move; }
/* 端点ハンドル: 始点は白抜き・終点は塗りつぶしで向きが分かるようにする */
#handle-layer circle.endpoint { fill: var(--danger); stroke: var(--ctrl-ring); stroke-width: 2; cursor: grab; }
#handle-layer circle.endpoint.source { fill: var(--ctrl-ring); stroke: var(--danger); }
#handle-layer circle.endpoint:hover { stroke-width: 3; }
#handle-layer circle.endpoint-preview {
  fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 3; pointer-events: none;
}
#handle-layer line.ctrl-line { stroke: var(--ctrl); stroke-dasharray: 3 3; stroke-width: 1; }
#handle-layer path.temp-edge { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }

/* ==================== ステータスバー ==================== */

#statusbar {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 12px; font-size: 11px; color: var(--text-dim);
  background: var(--panel); border-top: 1px solid var(--border);
  /* **高さを絶対に変えないこと。** 長い知らせを入れるとバーが2行になり、
     その分 #viewport が縮んでマップ全体がずれる。手書きの最中にこれが起きると
     紙が指の下から逃げる（2026-08-14）。折り返さず、はみ出しは … で切る */
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
#statusbar > * { flex: 0 0 auto; }
#status-msg { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* チェックの進み具合（クリックで次の未チェックへ） */
.check-state {
  padding: 1px 7px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.check-state:hover { border-color: var(--ok); color: var(--ok); }
.check-state.done { color: var(--ok); border-color: var(--ok); }

/* グリッド吸着が有効なときだけ出る目印 */
.grid-state {
  padding: 1px 7px; border-radius: 9px;
  border: 1px solid var(--border);
  color: var(--accent); white-space: nowrap;
}

/* ==================== 右クリックメニュー ==================== */

.ctxmenu {
  position: fixed; z-index: 200; min-width: 190px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px;
}
.ctxmenu .item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 9px; border-radius: 5px; cursor: pointer; position: relative;
  white-space: nowrap;
}
.ctxmenu .item:hover { background: var(--accent-soft); }
.ctxmenu .item.danger { color: var(--danger); }
.ctxmenu .item .sub-caret { margin-left: auto; opacity: .6; }
.ctxmenu .divider { height: 1px; background: var(--border); margin: 4px 2px; }
.ctxmenu .submenu { position: fixed; z-index: 201; }
.ctxmenu .swatch { width: 13px; height: 13px; border-radius: 3px; border: 1px solid var(--border); }

/* ==================== 浮くパレット（編集道具） ====================
   選択したカード・接続のそばに出るツールバー。
   バー（アイコンの並び）＋引き出し（押した道具の中身）の 2 段構え。
   右クリックメニュー（.ctxmenu, z-index 200）より下、モーダル（300）より下。 */

.palette {
  position: fixed; z-index: 190;
  display: flex; flex-direction: column; gap: 6px;
  max-width: min(94vw, 560px);
  /* バーの真上に引き出しを出したいので、下寄せ配置が既定 */
  align-items: flex-start;
}
/* display:flex は [hidden] の display:none より強いので、明示的に消す */
.palette[hidden] { display: none; }
/* カードの下に回り込んだときは、バー → 引き出し の順に並べる */
.palette.below { flex-direction: column; }
.palette:not(.below) { flex-direction: column-reverse; }

.palette-bar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 4px 5px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.pal-btn {
  min-width: 28px; height: 28px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--text); cursor: pointer;
}
.pal-btn:hover { background: var(--accent-soft); }
.pal-btn.on { background: var(--accent-soft); border-color: var(--accent); }
.pal-btn.danger { color: var(--danger); }
.pal-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

.palette-drawer {
  min-width: 240px; max-width: min(94vw, 560px); max-height: 46vh; overflow-y: auto;
  padding: 6px 9px 9px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.pal-drawer-head {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.pal-drawer-title { font-size: 12px; font-weight: 600; }
.pal-x {
  margin-left: auto; background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 12px; padding: 0 2px;
}
.pal-x:hover { color: var(--text); }

.pal-sec { margin-bottom: 7px; }
.pal-sec:last-child { margin-bottom: 0; }
.pal-sec-t { font-size: 10.5px; color: var(--text-dim); margin-bottom: 4px; }
/* 引き出しの中の補足文（ボタンではないので折り返す） */
.pal-note { font-size: 10.5px; color: var(--text-dim); line-height: 1.5; max-width: 260px; }
.pal-sec-b { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.pal-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; font-size: 11.5px; line-height: 1.5;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 13px;
  color: var(--text); cursor: pointer; white-space: nowrap;
}
.pal-chip:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.pal-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.pal-chip.danger { color: var(--danger); }
.pal-chip:disabled { opacity: .4; cursor: default; }
.pal-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--border); }

.pal-swatches { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.pal-sw {
  width: 20px; height: 20px; border-radius: 5px;
  border: 1px solid var(--border); cursor: pointer; padding: 0;
}
.pal-sw:hover { transform: scale(1.12); }
.pal-sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ==================== モーダル ==================== */

#modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  /* ★ スマホで「いま見えている高さ」に合わせる。vh は URL バーが隠れたときの高さを
     指すので、これが無いと真ん中に置いた #modal の下端 —— 記録する・取り込むが並ぶ
     .modal-foot —— が画面の外へ出て、押せなくなる（お金 → 📷 レシートを「品目ごと」に
     切り替えて中身が伸びたときに出る。dvh を解さないブラウザは今までどおり inset: 0） */
  height: 100dvh;
  background: rgba(0, 0, 0, .42);
  display: flex; align-items: center; justify-content: center;
}
#modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  min-width: 340px; max-width: min(760px, 92vw); max-height: 88vh;
  max-height: 88dvh;   /* 上の 88vh は dvh を解さないブラウザ向けの控え */
  display: flex; flex-direction: column;
}
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

.form-grid { display: grid; grid-template-columns: auto 1fr; gap: 9px 12px; align-items: center; }
.form-grid label { color: var(--text-dim); white-space: nowrap; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid textarea { width: 100%; min-height: 110px; resize: vertical; }
.form-grid input[type="text"], .form-grid input[type="search"], .form-grid select { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { font-size: 11px; color: var(--text-dim); }

.session-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.session-list div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.session-list div:last-child { border-bottom: none; }
.session-list div:hover { background: var(--accent-soft); }
.session-list .sub { font-size: 11px; color: var(--text-dim); }

/* ==================== MECE チェック ==================== */
.mece-body { min-width: 460px; max-width: 620px; }
.mece-ok { padding: 18px 4px; color: var(--accent); font-weight: 600; }
.mece-list {
  margin-top: 8px; max-height: 380px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
}
.mece-row {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 7px 10px; cursor: pointer; font-size: 12.5px; line-height: 1.5;
  border-bottom: 1px solid var(--border);
}
.mece-row:last-child { border-bottom: none; }
.mece-row:hover { background: var(--accent-soft); }
.mece-icon { flex: 0 0 16px; font-weight: 700; }
.mece-row.error .mece-icon { color: var(--danger); }
.mece-row.warn .mece-icon { color: var(--hit); }

.help-body { line-height: 1.75; white-space: pre-wrap; font-size: 12px; max-height: 62vh; }
.help-body b { color: var(--accent); }

/* CSV 取り込みダイアログ */
.csv-import { min-width: min(70vw, 460px); display: flex; flex-direction: column; gap: 9px; }
.csv-info { white-space: pre-line; font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.csv-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.csv-check input[type="text"] { flex: 1; }
.csv-modes {
  display: flex; flex-direction: column; gap: 5px;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.csv-preview {
  margin: 0; padding: 8px 10px; max-height: 240px; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  font-size: 11.5px; line-height: 1.65; white-space: pre;
}

/* 構造の書き出しダイアログ（CSV の見た目を引き継ぐ） */
.struct-dlg { min-width: min(80vw, 620px); }
.struct-opts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.struct-opts .csv-check { flex: none; }
.struct-out {
  width: 100%; min-height: 240px; max-height: 46vh; resize: vertical; box-sizing: border-box;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 12px; line-height: 1.6; white-space: pre; overflow: auto;
}
/* HTML 形式の「見たまま」。貼り付け先と同じ白地で出す（テーマの色を混ぜない） */
.struct-html {
  min-height: 240px; max-height: 46vh; overflow: auto; box-sizing: border-box;
  background: #fff; color: #222; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 13px; line-height: 1.7;
}
.struct-html ul { margin: 0; }

/* Markdown 取り込みダイアログ（CSV の見た目を引き継ぐ） */
.md-import { min-width: min(80vw, 580px); }
.md-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.md-tabs button {
  border: none; background: none; color: var(--text-dim);
  padding: 6px 12px; border-radius: 6px 6px 0 0; font-size: 12.5px;
}
.md-tabs button:hover { background: var(--accent-soft); }
.md-tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.md-pane { display: flex; flex-direction: column; gap: 7px; }
.md-paste {
  width: 100%; min-height: 160px; resize: vertical; box-sizing: border-box;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 12px; line-height: 1.6;
}
.md-file { display: flex; align-items: center; gap: 10px; }
.md-file .name { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.md-notes {
  max-height: 190px; overflow: auto;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2);
}
.md-notes > div {
  padding: 5px 9px; font-size: 12.5px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.md-notes > div:last-child { border-bottom: none; }
.md-notes > div:hover { background: var(--accent-soft); }
.md-notes > div.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.md-notes > div.dim { color: var(--text-dim); cursor: default; }
.md-notes > div.dim:hover { background: none; }
.md-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.md-opts .csv-check { flex: none; }

/* ==================== ノードのひな形 ==================== */

/* ツールバーの「ノード追加 ▾」（本体ボタン＋ ▾ ボタン） */
.split-btn { display: flex; }
.split-btn > button:first-of-type { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn > .caret-btn {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left: none; padding: 5px 7px; color: var(--text-dim);
}
.split-btn > .caret-btn:hover { color: var(--text); }

/* 一覧・メニューに出す色見本 */
.tpl-swatch {
  display: inline-block; width: 11px; height: 11px; margin-right: 7px;
  border-radius: 3px; border: 1px solid var(--border); vertical-align: -1px;
  flex: 0 0 auto;
}

.tpl-manager { display: flex; gap: 14px; min-width: min(76vw, 660px); }

.tpl-side { width: 190px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.tpl-list {
  list-style: none; margin: 0; padding: 4px; flex: 1; min-height: 180px; max-height: 52vh;
  overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2);
}
.tpl-list li {
  display: flex; align-items: center; padding: 6px 8px; border-radius: 5px; cursor: pointer;
}
.tpl-list li:hover { background: var(--accent-soft); }
.tpl-list li.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.tpl-list li.empty { color: var(--text-dim); font-size: 11.5px; cursor: default; }
.tpl-list li.empty:hover { background: none; }
.tpl-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-side-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.tpl-side-tools button { padding: 4px 8px; font-size: 12px; }

.tpl-edit { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tpl-preview {
  position: relative; overflow: auto;
  border: 1px solid var(--border); border-radius: 6px;
  background-color: var(--canvas-bg);
}
/* プレビューではドラッグしないので、接続点・リサイズ枠・カーソルは出さない */
.tpl-preview .node { cursor: default; }
.tpl-preview .anchor, .tpl-preview .resizer,
.tpl-preview .collapse-btn, .tpl-preview .check-btn { display: none !important; }

/* 画像ビューア */
/* ダイアログの内側に収める（はみ出させると align-items:center が左右へ均等にあふれ、左側が出てこない） */
#modal:has(.image-viewer) { max-width: min(1180px, 96vw); }
.image-viewer { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 100%; }
.image-viewer img { max-width: 100%; max-height: 68vh; border-radius: 6px; }


/* 共有リンクのダイアログ（発行・確認・停止） */
.share-dialog { min-width: min(78vw, 620px); }
.share-new { display: flex; gap: 8px; margin: 10px 0 14px; }
.share-new input { flex: 1 1 auto; min-width: 0; }
.share-list { display: flex; flex-direction: column; gap: 10px; max-height: 48vh; overflow-y: auto; }
.share-row {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
/* 停止した札は薄く。消さずに残すのは「いつ止めたか」を追えるようにするため */
.share-row.off { opacity: .6; }
.share-row-head { display: flex; align-items: center; gap: 8px; }
.share-label { font-weight: 600; }
.share-state {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.share-row.off .share-state { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
/* 書ける札。閲覧のみの札と並ぶので色で分ける */
.share-state.rw { background: var(--ok-soft, var(--accent-soft)); color: var(--ok, var(--accent)); }
/* 発行のときのチェック（既定は切）。押し間違えないよう行を独立させる */
.share-can-edit { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.share-url { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.share-row-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.share-info { color: var(--text-dim); font-size: 11px; margin-left: auto; }

/* 会話ビューア */
.session-view { max-height: 66vh; min-width: min(70vw, 720px); }
.session-view-head { margin-bottom: 10px; }
.session-view-head .name { font-weight: 600; font-size: 14px; }
.session-view-head .sub { font-size: 11px; color: var(--text-dim); }
.session-view .msg {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 10px; background: var(--panel-2);
}
.session-view .role { font-size: 11px; color: var(--text-dim); margin: 4px 0 2px; }
.session-view .text { white-space: pre-wrap; word-break: break-word; }

/* ==================== AI アシスタントパネル ==================== */
/* 色はすべてテーマ変数から取るので、6 テーマすべてでそのまま馴染む */

#ai-panel {
  position: relative;
  width: 340px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  min-width: 0;
}
#ai-panel[hidden] { display: none !important; }
#ai-panel.busy { opacity: .75; }

#ai-resizer {
  position: absolute; top: 0; left: -3px; width: 6px; height: 100%;
  cursor: ew-resize; z-index: 5;
}

#btn-ai.active { background: var(--accent-soft); border-color: var(--accent); }

.ai-head {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 6px 8px 12px; border-bottom: 1px solid var(--border);
}
.ai-title { font-size: 13px; font-weight: 600; }
.ai-model {
  flex: 1; min-width: 0; font-size: 10.5px; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-model.off { color: var(--danger); }

.ai-tasks { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 4px; }
.ai-task { font-size: 11.5px; padding: 3px 8px; }
.ai-task.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.ai-desc { padding: 2px 12px 6px; font-size: 11px; color: var(--text-dim); line-height: 1.45; }

.ai-input {
  margin: 0 10px; resize: vertical; min-height: 62px;
  font-size: 12.5px; line-height: 1.5;
}

.ai-check {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 12px 3px; font-size: 11.5px; color: var(--text-dim);
}
.ai-check input { margin: 0; }
.ai-sel-count { color: var(--text-dim); }
.ai-sel-count.warn { color: var(--danger); }

.ai-run-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px 8px; }
.ai-run-row .primary { flex: 1; }
.ai-run-row .hint { font-size: 10.5px; color: var(--text-dim); }

.ai-status {
  margin: 0 10px 8px; padding: 6px 8px; border-radius: 6px;
  background: var(--panel-2); font-size: 11.5px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
}
.ai-status.error { color: var(--danger); border: 1px solid var(--danger); }

.ai-result { flex: 1; overflow: auto; padding: 0 10px 14px; }
.ai-summary { font-size: 12.5px; line-height: 1.6; margin-bottom: 8px; }
.ai-answer {
  font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 4px;
}
.ai-warn { font-size: 11px; color: var(--hit); margin: 3px 0; line-height: 1.45; }
.ai-empty { font-size: 12px; color: var(--text-dim); padding: 8px 2px; }
.ai-meta { font-size: 10px; color: var(--text-dim); text-align: right; margin-top: 10px; }

.ai-proposal {
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--panel-2); padding: 8px 10px; margin-bottom: 8px;
}
.ai-proposal.done { opacity: .6; border-color: var(--accent); }
.ai-p-title { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; }
.ai-p-detail { font-size: 11.5px; color: var(--text-dim); line-height: 1.55; }
.ai-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ai-actions .primary { font-size: 11.5px; padding: 4px 10px; }
.ai-nops { font-size: 11px; color: var(--text-dim); }

.ai-ops { margin: 6px 0 0; padding-left: 16px; }
.ai-ops li {
  font-size: 11px; color: var(--text-dim); line-height: 1.55;
  word-break: break-word; margin-bottom: 2px;
}

/* 実行履歴ダイアログ */
.ai-history { max-height: 60vh; min-width: min(70vw, 560px); overflow: auto; }
.ai-hrow { border-bottom: 1px solid var(--border); padding: 8px 2px; }
.ai-hhead { display: flex; align-items: center; gap: 6px; }
.ai-htask { font-size: 12px; font-weight: 600; }
.ai-hdate { flex: 1; font-size: 11px; color: var(--text-dim); }
.ai-hbadge {
  font-size: 10px; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 8px; padding: 0 6px;
}
.ai-hbadge.err { color: var(--danger); border-color: var(--danger); }
.ai-hinst { font-size: 11.5px; margin-top: 3px; word-break: break-word; }
.ai-hsum { font-size: 11px; color: var(--text-dim); margin-top: 2px; word-break: break-word; }

/* 設定ダイアログ */
.ai-settings { min-width: min(70vw, 480px); }
.ai-srow { display: flex; gap: 10px; padding: 4px 0; font-size: 12px; }
.ai-skey { width: 120px; flex: 0 0 120px; color: var(--text-dim); }
.ai-sval { flex: 1; word-break: break-all; }
.ai-sval.ok { color: var(--accent); }
.ai-sval.warn { color: var(--danger); }
.ai-help {
  margin-top: 10px; padding: 9px 11px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.6; white-space: pre-wrap;
}
.ai-help.warn { border-color: var(--danger); color: var(--danger); }
/* 入力欄の見出し（状態の一覧と設定欄の境目） */
.ai-sform-head {
  margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
}
.ai-settings .form-grid input { width: 100%; }
/* 保存・接続テストの結果 */
.ai-sresult {
  margin-top: 10px; padding: 8px 11px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2);
  font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.ai-sresult.ok { border-color: var(--accent); }
.ai-sresult.warn { border-color: var(--danger); color: var(--danger); }

/* ==================== トースト ==================== */

#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  z-index: 400; padding: 9px 18px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
}
#toast.error { border-color: var(--danger); color: var(--danger); }

/* ==================== 📥 バージョンアップ ====================

   新しいビルドが配信されたことを知らせる帯と、その確認ダイアログ。
   配線は js/app-version.js（全ページが最後に読む）。
   全画面が app.css を読むので、ここに置けば .topbar 系（マップ・メモ・会話）と
   .page-head 系（横断検索・しおり・ゴミ箱・バックアップ）の両方に効く。
   ============================================================ */

/* 帯を出している間だけ body を縦フレックスにして、本体を帯のぶん縮める。
   body は overflow:hidden で #app / #page は height:100% なので、
   .topbar と同じ方式にしないと下端がはみ出して切れる */
body.cn-has-update-banner, body.cn-has-mail-banner { display: flex; flex-direction: column; }
body.cn-has-update-banner > #app, body.cn-has-mail-banner > #app,
body.cn-has-update-banner > #page, body.cn-has-mail-banner > #page { flex: 1 1 auto; min-height: 0; height: auto; }

.cn-update-banner {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px; padding: 6px 12px;
  background: var(--accent-soft);
  border-bottom: 2px solid var(--accent);
  font-size: 12px;
  z-index: 60;
}
.cn-update-banner .cn-update-msg { font-weight: 600; white-space: nowrap; }
.cn-update-banner .cn-update-when { color: var(--text-dim); white-space: nowrap; }
.cn-update-banner button { font-size: 12px; }
.cn-update-banner button.cn-update-later { background: none; color: var(--text-dim); }

/* 📥 ボタン。更新があるときだけ右肩に NEW を出す */
.cn-update-btn { position: relative; overflow: visible; }
.cn-update-btn.has-update { border-color: var(--accent); }
.cn-update-badge {
  position: absolute; top: -7px; right: -9px;
  padding: 0 4px; border-radius: 7px;
  background: var(--accent); color: var(--on-accent);
  font-size: 9px; font-weight: 700; line-height: 14px;
  pointer-events: none;
}

/* ==================== 📬 Web メールの新着（js/mail-notice.js） ====================
   帯を出すときの body の縦フレックスは、上の 📥 と同じ規則に相乗りしている。
   ★ 📥（バージョンアップ）より**控えめに**する。メールは毎日何通も来るので、
   📥 と同じ青い帯・青いバッジでは画面の上が常に光り、本当に見てほしい 📥 が埋もれる。
   色は付けず（パネルの地・灰色の文字・細い線）、気づける程度に留める */
.cn-mail-banner {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px; padding: 2px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  z-index: 60;
}
.cn-mail-banner-msg { white-space: nowrap; }
.cn-mail-banner-who {
  min-width: 0; max-width: min(520px, 100%);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cn-mail-banner a.cn-mail-banner-open {
  display: inline-flex; align-items: center; padding: 1px 6px; border-radius: var(--radius);
  color: var(--accent); text-decoration: none; font-size: 11.5px;
}
.cn-mail-banner a.cn-mail-banner-open:hover { background: var(--accent-soft); }
.cn-mail-banner button.cn-mail-banner-close { font-size: 11.5px; padding: 1px 6px; background: none; border: none; color: var(--text-dim); }

.cn-mail-btn { position: relative; overflow: visible; }
.cn-mail-badge {
  position: absolute; top: -6px; right: -8px;
  min-width: 13px; padding: 0 3px; border-radius: 7px;
  background: var(--border); color: var(--text);
  font-size: 9px; font-weight: 600; line-height: 13px; text-align: center;
  pointer-events: none;
}
/* 右端の道具なので右に揃えて開く（左揃えだと画面の外へはみ出す） */
.dropdown.cn-mail-menu {
  left: auto; right: 0; width: min(340px, calc(100vw - 24px));
  /* アカウントが増えるほど縦に伸びるので、画面からはみ出す前に中で送る */
  max-height: min(75vh, 620px); overflow-y: auto;
}
.cn-mail-head, .cn-mail-empty { padding: 6px 10px; font-size: 12px; color: var(--text-dim); }
.cn-mail-menu a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.cn-mail-menu a:hover { background: var(--accent-soft); }
.cn-mail-item-top { display: flex; gap: 8px; font-size: 12px; }
.cn-mail-from {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}
.cn-mail-when { flex: none; color: var(--text-dim); }
.cn-mail-subject {
  font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cn-mail-menu a.cn-mail-all { font-size: 12.5px; color: var(--accent); }
.cn-mail-menu a.cn-mail-account { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 10px; }
.cn-mail-account-name {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 3px solid transparent; padding-left: 6px;
}
.cn-mail-account-count { flex: none; font-weight: 700; }
.cn-mail-account-count.zero { font-weight: 400; color: var(--text-dim); }
.cn-mail-account-count.failing { font-weight: 400; color: var(--danger); }
/* アカウントごとの区切り。見出し（アドレスと未読数）の下にそのアカウントのメールが並ぶ */
.cn-mail-section + .cn-mail-section { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.cn-mail-menu a.cn-mail-account { font-weight: 600; }
.cn-mail-menu a.cn-mail-item { padding-left: 22px; }
.cn-mail-none { padding: 2px 10px 6px 22px; }
.cn-mail-item.fresh .cn-mail-when::before { content: 'NEW '; color: var(--accent); font-weight: 700; font-size: 10px; }
.cn-mail-banner-per { color: var(--text-dim); white-space: nowrap; }
/* 既読は控えめに、未読は太字で（Web メールの一覧と同じ見分け方） */
.cn-mail-item:not(.unread) .cn-mail-from { font-weight: 400; }
.cn-mail-item:not(.unread) .cn-mail-subject { color: var(--text-dim); }

/* ダイアログ。各画面の #modal は画面ごとの状態に結びついているため、
   どのページからでも同じように出せるよう専用の器を持つ */
.cn-update-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, .42);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.cn-update-modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  width: min(520px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
}
.cn-update-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--accent);
}
.cn-update-body { padding: 14px 16px; overflow-y: auto; line-height: 1.7; }
.cn-update-lead { margin: 0 0 10px; }
.cn-update-table { border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.cn-update-table th {
  text-align: left; font-weight: 400; color: var(--text-dim);
  padding: 2px 16px 2px 0; white-space: nowrap;
}
.cn-update-table td { padding: 2px 0; }
.cn-update-table td.is-new { font-weight: 700; color: var(--accent); }
.cn-update-note {
  padding: 9px 11px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.6; color: var(--text-dim);
}
.cn-update-note.warn {
  border-color: var(--danger); color: var(--danger); background: none;
}
.cn-update-foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--border);
}

/* ==================== 👤 利用者メニューとログイン切れの帯（js/auth.js） ====================

   全画面が読む js/auth.js が動的に挿すので、CSS も全画面が読む app.css に置く。
   ログイン画面そのものの見た目は css/login.css。
   ==================================================================== */

/* ---------- ログインが切れたときの帯 ---------- */

/* 帯は body の先頭に入る。上部メニューバーのある画面は body が縦フレックスなので
   そのまま最上段に積まれ、無い画面でも通常フローの先頭に出る */
.auth-notice {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--text);
  font-size: 12.5px;
}
.auth-notice-text { flex: 1 1 auto; min-width: 0; }
.auth-notice-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 13px; line-height: 1; padding: 5px 7px; border-radius: 5px; cursor: pointer;
}
.auth-notice-close:hover { color: var(--text); background: var(--panel-2); }

/* ---------- 👤 メニュー ---------- */

.auth-menu { min-width: 210px; left: auto; right: 0; }
.auth-menu-head {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 9px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.auth-menu-head strong { font-size: 12.5px; }
.auth-menu-dim { font-size: 10.5px; color: var(--text-dim); }

/* a と button が混ざるので、見た目をここで揃える */
.auth-menu-item {
  display: block; text-align: left;
  padding: 6px 9px; border-radius: 5px;
  font-size: 12.5px; color: var(--text); text-decoration: none;
  background: none; border: none; cursor: pointer;
}
.auth-menu-item:hover { background: var(--accent-soft); color: var(--text); }

/* ==================== 狭い画面（スマホ・小さいタブレット） ====================

   境目は 760px。**js/mobile.js が同じ値を持っているので片方だけ変えないこと**
   （CSS が並べ替えを、JS が開け閉め = body.nav-open / body.tools-open を持つ）。

   考え方:
   - 幅を食う常設の柱（マップ一覧・アウトライン・AI）は「重ねる引き出し」にする
   - ツールバーは既定でよく使う数個だけ出し、残りは ⋯ で開く
     （20 個超が折り返すと縦を 4 段食い、キャンバスが残らない）
   - 引き出しメニュー・右クリックメニューは画面下の帯に置く
     （ボタンの真下だと画面外へはみ出し、指も届きにくい）
   - 指で押す大きさは幅ではなく入力装置（pointer: coarse）で決める。
     マウスの繋がった小さい窓まで太らせない
   ========================================================================= */

/* ---------- 指で押す前提の大きさ ---------- */
@media (pointer: coarse) {
  button { min-height: 34px; }
  button.icon-btn { min-width: 36px; }
  .dropdown button { padding: 9px 10px; }
  /* ☰ の引き出しの項目は <a> と <button> が混ざる。指の端末では両方を同じ高さにする */
  .cn-nav-item { padding: 9px 10px; }
  .ctxmenu .item { padding: 10px 11px; }
  .pal-btn { min-width: 34px; height: 34px; font-size: 16px; }
  .pal-chip { padding: 6px 11px; }
  .pal-sw { width: 26px; height: 26px; }
  /* 一覧の行は長押しでメニューを出す（js/mobile.js）。押している間に
     iOS が文字を選び始めたり「コピー」の吹き出しを出すと取り合いになる */
  .map-list li, .outline-row {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  /* カードに貼った画像は「見るための絵」。指を置いたときに iOS が
     「画像を保存」の吹き出しを出したり画像そのものを引きずり始めると、
     走っている pointer を持っていかれて**画面のパンも長押しメニューも止まる** */
  .node-image {
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    user-select: none;
  }
  /* カードの隅の小さな丸（☐ と −/＋）は 18px では指で押せない。
     カードの中にあるので倍率ぶん縮む＝縮めているときはさらに小さい */
  .check-btn, .collapse-btn {
    width: 24px; height: 24px; font-size: 14px;
  }
  /* 大きくしたぶん横へも余分に逃がす（24px で中へ 6px＝ left/right:-18px）。
     -11px のままだと文字の箱へ 13px 食い込み、題名の1文字目が丸ごと隠れる */
  .check-btn { left: -18px; top: -8px; }
  .collapse-btn { right: -18px; top: -8px; }
  .map-list li { padding: 10px 9px; }
  .outline-row { padding: 7px 6px 7px 0; }
  .oc-check { width: 18px; height: 18px; flex: 0 0 18px; line-height: 15px; font-size: 12px; }
  .conv-hit { padding: 8px 7px; }
}

/* ---------- 画面の幅で変えるもの ---------- */

/* ☰（一覧）・⋯（ほかの道具）・✕（引き出しを閉じる）は狭い画面専用。
   js/mobile.js が差し込むので、広い画面では出さない。
   ☰ と ⋯ は帯ごとに複数あり得る（data-mobile-bar="own" のお金のタブ・本の画面）ので class で引く */
.nav-btn, .tools-btn, #sidebar-close { display: none; }

@media (max-width: 760px) {
  /* iOS は URL バーの出入りで 100% の高さが伸び縮みする。dvh があればそちらを使う */
  html, body { height: 100dvh; }

  /* 16px 未満の入力欄に触れると iOS が勝手に画面を拡大する */
  input, select, textarea { font-size: 16px; }

  .nav-btn, .tools-btn, #sidebar-close {
    display: inline-flex; align-items: center; justify-content: center;
  }

  /* ---- 上の帯 ----

     狭い画面では**この帯だけが他の画面（メモ・会話・検索…）への入口**なので、
     何があっても消さない。実際に消えていた経路が 2 つあった:

     1. 単体表示（⛶）。広い画面では「一覧とメニューバーを畳んで場所を作る」道具だが、
        狭い画面では一覧が元々引き出しなので、稼げるのは帯の 40px だけ。
        引き換えにメモ・会話へ行く手段が全部消え、しかも localStorage に
        記憶されるので開き直しても直らない。
        → 帯は出したままにし、意味の無くなった ⛶ 自体を隠す（後段）
        → **記憶も捨てる**（js/mobile.js → UI.dropSolo）。⛶ を隠しただけでは
          解除できない状態が残り、画面を広げるたび一覧が消える
          （狭める → 出る → 広げる → 消える、が終わらない）
     2. 移動リンクのはみ出し。390px では 7 本で 73px あふれ、
        右端の 🔖 🗑 💾 が切れる（横スクロールできるが掴み手を隠してあるので気付けない）。
        → 「Claude Note」の字を落とし、リンクの内側の余白を詰めて収める */
  .topbar { padding: 5px 8px; gap: 6px; }
  .topbar .brand { min-width: 0; overflow: hidden; }
  .topbar .brand .page-name { overflow: hidden; text-overflow: ellipsis; }
  /* アプリ名は畳んで、いまどの画面かを示す名前だけ残す。
     共有ページは移動リンクを持たない（あふれない）ので、名乗りをそのまま出す */
  body:not(.share-page) .topbar .brand .brand-name { display: none; }
  .topbar .nav-link { padding: 4px 5px; }

  /* 単体表示にしても帯は消さない（上のコメント 1 の理由）。
     .map-solo の規則より後に書いて勝たせる */
  body.map-solo > .topbar { display: flex; }
  /* 消せるものが無くなるので ⛶ 自体を出さない。
     すでに単体表示のまま保存されている端末でも、上の規則で帯は戻る */
  #btn-solo { display: none; }

  /* ---- マップ一覧: 左から出る引き出しにする ---- */
  #sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 120;
    /* 幅ドラッグで覚えたインライン幅を打ち消す（指では掴めない部品なので使わない） */
    width: min(86vw, 320px) !important;
    transform: translateX(-101%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open #sidebar { transform: none; }
  /* 単体表示でも引き出しは使えるようにする（でないとマップを替えられない）。
     .map-solo が #sidebar を消す規則より強く書く。
     いまは狭い画面へ入った時点で UI.dropSolo が状態を捨てるので、ここが効くのは
     JS が走る前の一瞬だけ。それでも消さない——CSS だけで一覧に辿り着けるように */
  body.is-mobile.map-solo #sidebar { display: flex; }
  #sidebar-resizer { display: none; }

  /* 引き出しの足元の並び（ゴミ箱・タグ管理…）は折り返させる。
     折り返さないと幅からはみ出し、閉じている引き出し（左へ 101% ずらしてある）の
     はみ出した部分が画面の左端に貼り付いて見える（会話画面の4個で実際に出た） */
  .sidebar-foot { flex-wrap: wrap; }

  #drawer-backdrop { position: fixed; inset: 0; z-index: 119; background: rgba(0, 0, 0, .42); }

  /* ---- アウトライン・AI パネル: 画面いっぱいに重ねる（自前の ✕ で閉じる） ---- */
  #outline, #ai-panel, #project-panel {
    position: fixed; inset: 0; z-index: 118;
    width: auto !important; border: none;
  }
  #outline-resizer, #ai-resizer { display: none; }

  /* ---- 上の帯: よく使う数個 ＋ ⋯ ----
     どの帯を畳むかは HTML の data-mobile-bar が決める
     （マップは #toolbar、メモは題名の行）。js/mobile.js が同じ印を見る。

     隠す側だけを書き、⋯ を開いた状態では**何も指定しない**のが要点。
     display:revert で出し直すと .menu-wrap の inline-flex まで巻き戻って
     ボタンの並びが縦積みになる。[hidden] の要素も隠れたままにできる */
  #toolbar { gap: 5px; padding: 5px 7px; }
  body:not(.tools-open) [data-mobile-bar] > *:not([data-m="keep"]) { display: none; }
  /* 帯の外にあって ⋯ で一緒に出す部品（メモのタグ行など）。
     .editor-row 等より詳しく書いて、後から読む notes.css にも勝たせる */
  body:not(.tools-open) [data-m="fold"] { display: none; }
  body.tools-open [data-mobile-bar] { max-height: 46vh; overflow-y: auto; }
  .current-map { max-width: 26vw; font-size: 12.5px; }

  /* マップ検索。帯に残す（keep）ので、入力欄は指で押せる範囲まで詰める。
     iOS が勝手に拡大しないよう字は 16px のまま（上の input 指定） */
  .map-search-wrap { flex: 1 1 110px; min-width: 90px; }
  .map-search-wrap input[type="search"] { width: 100%; min-width: 0; }
  /* 結果は 1 列。カードは指で押しやすいよう少し高くする */
  .msp-grid { grid-template-columns: 1fr; }
  .msp-body { padding: 10px; }

  /* ---- 引き出しメニュー（▾）と右クリックメニューは画面下の帯にする ----
     #menu-theme のように id で位置を決めている規則や、
     JS が付ける left/top（インライン）を上書きするため !important を使う
     （作者スタイルの !important はインラインより強い） */
  .dropdown:not([hidden]) {
    position: fixed !important;
    left: 8px !important; right: 8px !important;
    top: auto !important; bottom: 8px !important;
    max-height: 62vh; overflow-y: auto; z-index: 210;
  }
  .ctxmenu {
    left: 8px !important; right: 8px !important;
    top: auto !important; bottom: 8px !important;
    max-height: 66vh; overflow-y: auto; min-width: 0;
  }
  .ctxmenu .item { white-space: normal; }

  /* ---- 浮くパレット・モーダル ---- */
  .palette { max-width: calc(100vw - 16px); }
  .palette-drawer { min-width: 0; max-width: calc(100vw - 16px); }
  #modal { min-width: 0; width: 96vw; max-width: 96vw; max-height: 92vh; }
  #modal { max-height: 92dvh; }   /* 同上（URL バーが出ているぶんを差し引く） */
  .cat-manager, .mece-body, .csv-import, .md-import, .struct-dlg, .tpl-manager,
  .share-dialog, .session-view, .ai-history, .ai-settings {
    min-width: 0; max-width: none;
  }
  .tpl-manager { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { white-space: normal; }

  /* 案内文は1行に収まらないので、端で折り返させる */
  .empty-hint { padding: 0 24px; text-align: center; }

  /* ---- 検索バー・ステータスバー ---- */
  #findbar { flex-wrap: wrap; }
  #find-input { flex: 1 1 auto; min-width: 0; }
  #statusbar { gap: 8px; padding: 4px 8px; }
  #status-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ============================================================
   🔗 リンクの編集（全画面共通 / js/nav.js）

   各画面のモーダル（#modal / .ctxmenu）はその画面の状態に結びついていて
   全画面には無いので、この画面だけは自前で持つ。見た目は #modal に寄せてある。
   ============================================================ */

.cn-nav-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.cn-nav-editor {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  width: min(720px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
  color: var(--text);
}

.cn-nav-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.cn-nav-title { font-weight: 600; flex: 1; }
.cn-nav-close {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 15px; cursor: pointer; padding: 2px 6px;
}
.cn-nav-close:hover { color: var(--text); }

.cn-nav-body { padding: 14px 16px; overflow-y: auto; }
.cn-nav-hint { margin: 0 0 12px; font-size: 12px; color: var(--text-dim); line-height: 1.6; }

.cn-nav-list { display: flex; flex-direction: column; gap: 6px; }

.cn-nav-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
/* 非表示にしたリンクは薄くする（消えたのではなく「今は出していない」） */
.cn-nav-row.off { opacity: 0.45; }
.cn-nav-row.dragging { opacity: 0.4; }
.cn-nav-row.over { border-color: var(--accent); }

.cn-nav-grip { cursor: grab; color: var(--text-dim); user-select: none; flex: 0 0 auto; }
.cn-nav-grip:active { cursor: grabbing; }

.cn-nav-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cn-nav-name { font-size: 13px; white-space: nowrap; }
.cn-nav-badge {
  font-size: 10px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.cn-nav-url {
  font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.cn-nav-icon { width: 46px; text-align: center; flex: 0 0 auto; }
.cn-nav-label { width: 150px; flex: 0 0 auto; }
.cn-nav-url-input { flex: 1 1 180px; min-width: 0; }
.cn-nav-tab { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }

.cn-nav-rowtools { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.cn-nav-rowtools button {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  border-radius: 6px; padding: 3px 6px; cursor: pointer; font-size: 12px;
}
.cn-nav-rowtools button:hover:not(:disabled) { color: var(--text); border-color: var(--border); }
.cn-nav-rowtools button:disabled { opacity: 0.25; cursor: default; }
.cn-nav-del:hover { color: var(--danger) !important; }

.cn-nav-add {
  margin-top: 10px;
  background: transparent; border: 1px dashed var(--border); color: var(--text-dim);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; width: 100%;
}
.cn-nav-add:hover { color: var(--accent); border-color: var(--accent); }

.cn-nav-error {
  margin-top: 10px; padding: 8px 10px;
  border: 1px solid var(--danger); border-radius: 6px;
  color: var(--danger); font-size: 12px;
}

.cn-nav-foot {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.cn-nav-spacer { flex: 1; }
.cn-nav-reset { color: var(--text-dim); }

/* スマホ・タブレット。掴んでの並べ替えが効かない端末でも ↑↓ で並べ替えられるので、
   ☰ は出さない（押せない道具を置かない） */
@media (max-width: 760px) {
  .cn-nav-backdrop { padding: 0; align-items: stretch; }
  .cn-nav-editor { width: 100%; max-height: 100%; border-radius: 0; border: none; }
  .cn-nav-row { flex-wrap: wrap; }
  .cn-nav-main { width: 100%; }
  .cn-nav-label, .cn-nav-url-input { flex: 1 1 100%; width: auto; }
  .cn-nav-grip { display: none; }
}

[hidden] { display: none !important; }

/* ==================== ◇ 図形の設定パネル（js/shape-panel.js） ====================

   図形の見た目を変える道具を 1 枚にまとめた**閉じない**編集画面。
   ドロップダウン（.dropdown）と違い、外を押しても・選択が変わっても消えない。
   置き場所は人がつかんで動かせる（端末に覚える）ので、図の上に居座らない。
   ================================================================================ */
.shape-panel {
  position: fixed;
  /* 既定は右上。位置を動かしたら left/top がインラインで上書きされる */
  right: 16px; top: 68px;
  z-index: 200;
  width: 320px;
  max-height: min(78vh, 720px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px; color: var(--text);
}
.shape-panel[hidden] { display: none; }
/* 位置を持ったら（つかんで動かした・前回の位置）右上寄せをやめる */
.shape-panel[style*="left"] { right: auto; }

.sp-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: move; touch-action: none;
}
.sp-head-text { flex: 1 1 auto; min-width: 0; }
.sp-title { font-weight: 600; font-size: 13px; }
.sp-sub { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.sp-x {
  flex: 0 0 auto; width: 26px; height: 26px;
  background: transparent; color: var(--text-dim);
  border: 1px solid transparent; border-radius: 7px; cursor: pointer;
}
.sp-x:hover { background: var(--accent-soft); color: var(--text); }

.sp-body { flex: 1 1 auto; overflow-y: auto; padding: 6px 4px 8px; }
.sp-sec { padding: 4px 6px 8px; }
.sp-sec + .sp-sec { border-top: 1px solid var(--border); }
.sp-sec-t { font-size: 11px; color: var(--text-dim); margin: 4px 0 4px 2px; }
.sp-group { font-size: 10px; color: var(--text-dim); margin: 4px 0 2px 4px; }
.sp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 0; }
.sp-lab { font-size: 11px; color: var(--text-dim); margin-right: 2px; }

.sp-chip {
  padding: 4px 8px; font-size: 11px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
}
.sp-chip:hover:not(:disabled) { background: var(--accent-soft); }
.sp-chip.on { background: var(--accent-soft); border-color: var(--accent); }
.sp-chip:disabled { opacity: .45; cursor: default; }

.sp-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 2px 0; }
.sp-sw {
  height: 20px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border);
}
.sp-sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }

.sp-range { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.sp-range input[type="range"] { flex: 1 1 auto; min-width: 0; }
.sp-range-l { font-size: 11px; color: var(--text-dim); width: 30px; flex: 0 0 auto; }
.sp-range-v { font-size: 11px; width: 42px; text-align: right; flex: 0 0 auto; }
.sp-num {
  width: 64px; padding: 3px 6px; font-size: 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
}

.sp-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
}
.sp-hint { flex: 1 1 auto; font-size: 11px; color: var(--text-dim); }
.sp-ok {
  padding: 5px 18px; font-size: 12px; font-weight: 600;
  border-radius: 8px; cursor: pointer;
}
/* パネルの中の形の格子は、引き出しより 1 列多く並べる（幅が広いので） */
.shape-panel .shape-grid { grid-template-columns: repeat(5, 1fr); padding: 0 2px 2px; }

/* メニューの中の「強い」項目（設定パネルを開く・最初から発表） */
.dd-strong { font-weight: 600; }
.dd-slide { text-align: left; }

/* 狭い画面ではパネルを画面下の帯にする（.dropdown と同じ考え方） */
@media (max-width: 760px) {
  .shape-panel {
    left: 0 !important; right: 0 !important; top: auto !important;
    bottom: 0; width: auto; max-height: 62vh;
    border-radius: 14px 14px 0 0;
  }
  .shape-panel .shape-grid { grid-template-columns: repeat(4, 1fr); }
  .sp-head { cursor: default; }
}

/* ==================== ▶ 発表モード（js/present.js） ====================

   スライド枠（kind='FRAME'）を 1 枚ずつ画面いっぱいに映す。
   映すのは本物のキャンバスなので、隠すのは「編集のための部品」だけ。
   単体表示（.map-solo）がメニューバーと一覧だけを畳むのに対し、
   こちらは**ツールバーもステータスバーも畳む**（発表中は編集しないため）。
   ===================================================================== */
body.presenting > .topbar,
body.presenting #sidebar,
body.presenting #sidebar-resizer,
body.presenting #toolbar,
body.presenting #statusbar,
body.presenting #findbar,
body.presenting #ai-panel,
body.presenting #project-panel,
body.presenting #outline,
body.presenting .palette,
body.presenting .shape-panel { display: none !important; }

/* 枠そのものは映さない —— 消すのは**枠線と番号の札だけ**。
   塗り（ノードの color）はスライドの下地なので残す。
   CSS の宣言は SVG の属性（stroke="…"）より強いので、これで線だけが消える */
body.presenting .node-shape .frame-outline { stroke: none !important; }
body.presenting .node-shape .frame-tag { display: none !important; }

/* 発表中は掴めない（Canvas.readOnly も立てているが、カーソルでも分かるようにする） */
body.presenting #viewport .node { cursor: default; }

/* マス目は消す（スライドに方眼紙は要らない）。
   マス目は canvas.js が #viewport の style へ直に書くので、!important でだけ勝てる。
   発表が終われば class が外れて、書いてある値がそのまま効き直す */
body.presenting #viewport { background-image: none !important; }

/* B キー: 話の途中で画面を暗くする（板書やデモへ目を移すとき） */
body.present-blank #viewport::after {
  content: ''; position: absolute; inset: 0; background: #000; z-index: 300;
}

.present-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 400;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow);
  opacity: 1; transition: opacity .35s;
}
/* しばらく触らないと薄くなる（映している画面に道具を残さない）。
   消さずに薄くするのは、次に押す場所が分からなくならないため */
.present-bar.idle { opacity: .3; }
.present-bar:hover { opacity: 1; }
.pb-btn {
  min-width: 30px; height: 28px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
  background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: 999px; cursor: pointer;
}
.pb-btn:hover { background: var(--accent-soft); }
.pb-exit { color: var(--text-dim); }
.pb-label { padding: 0 8px; font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ==================== 🖨 印刷（js/map-print.js） ==================== */
.print-dlg { display: flex; flex-direction: column; gap: 10px; }
.print-range { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.print-range label, .print-check { color: var(--text); white-space: nowrap; cursor: pointer; }
.print-range label:has(input[disabled]) { opacity: .5; cursor: default; }
.print-opts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.print-info { min-height: 1.4em; }
/* 用紙の実寸で組んだ iframe を transform で縮めて見せる。枠は縮めたあとの大きさ */
.print-preview {
  position: relative; overflow: hidden; margin: 0 auto;
  border: 1px solid var(--border); box-shadow: var(--shadow); background: #fff;
}
.print-preview iframe {
  position: absolute; top: 0; left: 0; border: 0; background: #fff;
  transform-origin: 0 0; pointer-events: none;
}
/* 範囲を囲っている間だけキャンバスに被せる（押す・動かすをキャンバスへ渡さない） */
.print-pick {
  position: absolute; inset: 0; z-index: 60; cursor: crosshair; touch-action: none;
  background: rgba(0, 0, 0, .06);
}
.print-pick-hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 6px 12px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 12px; pointer-events: none;
}
.print-pick-rect {
  position: absolute; pointer-events: none;
  border: 2px dashed var(--accent); background: var(--accent-soft);
}

/* ==================== 📁 プロジェクトの枠（js/map-project.js） ==================== */
#project-panel {
  position: relative;
  width: 320px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  min-width: 0;
}
#project-panel[hidden] { display: none !important; }
#btn-project.active { background: var(--accent-soft); border-color: var(--accent); }

.pj-head {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 6px 8px 12px; border-bottom: 1px solid var(--border);
}
.pj-head select { flex: 1 1 auto; min-width: 0; }
.pj-tabs { display: flex; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.pj-tabs button { flex: 1 1 0; }
.pj-tabs button.active { background: var(--accent-soft); border-color: var(--accent); }
.pj-body { flex: 1 1 auto; overflow-y: auto; padding: 8px 10px 16px; font-size: 13px; }

.pj-empty { color: var(--text-dim); line-height: 1.6; }
.pj-hint { color: var(--text-dim); font-size: 11px; line-height: 1.5; margin: 2px 0 6px; }
.pj-make { margin-top: 8px; }
.pj-none { color: var(--text-dim); padding: 8px 0; }

.pj-progress { padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.pj-prog-head { display: flex; align-items: baseline; gap: 8px; }
.pj-name { font-weight: 600; color: var(--text); text-decoration: none; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-name:hover { text-decoration: underline; }
.pj-count { color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pj-bar { height: 6px; border-radius: 3px; background: var(--border); margin: 6px 0; overflow: hidden; }
.pj-bar-fill { height: 100%; background: var(--ok); border-radius: 3px; }
.pj-prog-foot { display: flex; align-items: flex-end; gap: 8px; }
.pj-spark { display: flex; align-items: flex-end; gap: 2px; height: 24px; }
.pj-spark-col { width: 7px; background: var(--ok); border-radius: 2px 2px 0 0; }
.pj-spark-col.zero { background: var(--border); }
.pj-week { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

.pj-day { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; font-weight: 600; }
.pj-day-sum { color: var(--text-dim); font-weight: normal; font-size: 11px; }
.pj-day-map, .pj-rel-row {
  display: flex; align-items: baseline; gap: 6px;
  color: var(--text-dim); font-size: 11px; text-decoration: none; padding: 1px 0;
}
.pj-day-map:hover, .pj-rel-row:hover { color: var(--accent); }
.pj-day-map.here, .pj-rel-row.here { color: var(--accent); }
.pj-map-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.pj-rel-row { font-size: 12px; color: var(--text); padding: 3px 0; }
.pj-rel-meta { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.pj-rel-head { margin: 12px 0 4px; font-weight: 600; }

.pj-item {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 4px 4px; border-radius: 6px; cursor: pointer;
}
.pj-item:hover { background: var(--accent-soft); }
.pj-item input { margin-top: 2px; flex: 0 0 auto; }
.pj-item-text { flex: 1 1 auto; min-width: 0; }
.pj-item-title { word-break: break-word; }
.pj-item.checked .pj-item-title { color: var(--text-dim); text-decoration: line-through; }
.pj-item-trail { color: var(--text-dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-item-when { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.pj-done { margin-top: 12px; }
.pj-done summary { color: var(--text-dim); cursor: pointer; }

.pj-log-row { display: flex; gap: 6px; padding: 2px 4px; border-radius: 4px; cursor: pointer; }
.pj-log-row:hover { background: var(--accent-soft); }
.pj-log-mark { flex: 0 0 1.2em; color: var(--text-dim); text-align: center; }
.pj-log-row.done .pj-log-mark { color: var(--ok); }
.pj-log-row.head { color: var(--text-dim); }
.pj-log-title { flex: 1 1 auto; min-width: 0; word-break: break-word; }
