:root{
  --bg:#f4efe1;        /* 薄いクリーム（キャンバス背景） */
  --panel:#ffffff;     /* 枠内 白 */
  --line:#d9d3c4;      /* 枠線・区切り */
  --text:#333a40;      /* 濃い灰色（文字） */
  --muted:#8b8578;
  --accent:#3b82f6;    /* 主要ボタン（子・兄弟）＝青 */
  --danger:#d64545;
  --node:#d3c6a6;      /* デフォルト枠内 */
  --node-border:#c9c2b1; /* 枠線は中心枠と同じ色で統一 */
  --sel:#264653;       /* 選択した枠内＝濃い青緑 */
  --sel-text:#f4efe1;  /* 選択枠は濃色なので文字は明るく */
}
*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ margin:0; height:100%; overflow:hidden; background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Hiragino Sans","Yu Gothic",sans-serif;
  -webkit-font-smoothing:antialiased; }
.screen{ position:fixed; inset:0; display:flex; flex-direction:column; }
.hidden{ display:none !important; }

/* ---- 一覧画面 ---- */
.listHeader{ padding:calc(env(safe-area-inset-top) + 14px) 18px 12px; }
.listHeader h1{ margin:0; font-size:20px; font-weight:700; letter-spacing:.02em; }
.mapList{ flex:1; overflow:auto; padding:6px 14px 100px; }
.mapRow{ display:flex; align-items:center; gap:12px; padding:14px 14px; margin:8px 0;
  background:var(--panel); border:1px solid var(--line); border-radius:14px; }
.mapRow .mi{ flex:1; min-width:0; }
.mapRow .mname{ font-size:16px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mapRow .mmeta{ font-size:12px; color:var(--muted); margin-top:3px; }
.mapRow .mopen{ color:var(--muted); font-size:22px; }
.emptyList{ color:var(--muted); text-align:center; margin-top:60px; font-size:15px; line-height:1.7; }
.fab{ position:fixed; right:20px; bottom:calc(env(safe-area-inset-bottom) + 22px);
  width:62px; height:62px; border-radius:50%; border:none; background:var(--accent); color:#fff;
  font-size:32px; font-weight:300; box-shadow:0 6px 18px rgba(0,0,0,.4); }

/* ---- 編集画面 ---- */
.editHeader{ display:flex; align-items:center; gap:6px; justify-content:space-between;
  padding:calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background:var(--bg); border-bottom:1px solid var(--line); z-index:5; }
.hleft{ display:flex; align-items:center; gap:2px; min-width:0; flex:0 1 auto; }  /* 戻る＋タイトルは左に一体 */
.hbtn{ background:none; border:none; color:var(--text); font-size:16px; padding:8px 10px; font-weight:600; }
.mapTitle{ flex:0 1 auto; min-width:0; text-align:left; font-size:16px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.canvas{ position:relative; flex:1; overflow:hidden; touch-action:none; background:
  radial-gradient(circle at 1px 1px, rgba(0,0,0,.06) 1px, transparent 0) 0 0/26px 26px, var(--bg); }
.world{ position:absolute; left:0; top:0; transform-origin:0 0; will-change:transform; }
.links{ position:absolute; left:0; top:0; overflow:visible; pointer-events:none; }
.xlinks{ position:absolute; left:0; top:0; overflow:visible; }  /* つなぐ線。ヒット用の太い透明線をタップで削除 */
.nodes{ position:absolute; left:0; top:0; }

.node{ position:absolute; max-width:180px; padding:9px 13px; border-radius:12px;
  background:var(--node); border:none; color:var(--text);
  font-size:15px; line-height:1.35; writing-mode:horizontal-tb;
  white-space:pre; width:max-content; width:-webkit-max-content;
  /* 枠線なし・左上に光源＝右下に影で背景からわずかに浮かせる */
  box-shadow:2px 3px 5px rgba(0,0,0,.20), -1px -1px 2px rgba(255,255,255,.6);
  user-select:none;
  touch-action:none; -webkit-touch-callout:none; }  /* 枠上の指ドラッグをJSで扱う（iOSにスクロール解釈させない） */
.node.root{ background:var(--node); font-weight:700; font-size:16px; border-radius:16px; }
.node.sel{ background:var(--sel); color:var(--sel-text);
  box-shadow:2px 3px 6px rgba(0,0,0,.28); }   /* 選択は濃色なので影のみ（白ハイライトなし） */
.node.sel .ed{ color:var(--sel-text); }
.node.dragging{ opacity:.9; z-index:20; }                                   /* ドラッグ中の枠 */
.node.dropTarget{ box-shadow:0 0 0 3px var(--accent), 2px 3px 6px rgba(0,0,0,.25); }  /* 落とし先＝この子になる */
.node.collapsedMark::after{ content:"⋯"; position:absolute; right:-22px; top:50%; transform:translateY(-50%);
  color:var(--muted); font-weight:700; font-size:18px; }
.node .ed{ background:transparent; border:none; outline:none; color:var(--text);
  font:inherit; line-height:1.35; display:block; width:1.2em; max-width:100%;
  white-space:pre-wrap; overflow-wrap:anywhere; word-break:normal;
  resize:none; overflow:hidden; padding:0; margin:0; }  /* 幅はJSで内容ぴったりに実測（1文字ずつ広がる） */

.fitBtn{ position:absolute; right:16px; bottom:calc(env(safe-area-inset-bottom) + 16px);
  width:46px; height:46px; border-radius:50%; border:1px solid var(--line);
  background:rgba(255,255,255,.92); color:var(--text); font-size:20px; z-index:4;
  box-shadow:0 1px 4px rgba(0,0,0,.12); }
.hint{ position:absolute; left:50%; bottom:calc(env(safe-area-inset-bottom) + 20px); transform:translateX(-50%);
  color:var(--muted); font-size:12.5px; background:rgba(255,255,255,.92); padding:7px 12px; border-radius:20px;
  border:1px solid var(--line); white-space:nowrap; z-index:4; box-shadow:0 1px 4px rgba(0,0,0,.12); }

/* ---- ツールバー ---- */
/* テーマ名の横に並ぶ操作ボタン（子・兄弟・⋯・完了） */
.nodeActions{ display:flex; align-items:center; gap:4px; flex:none; }  /* space-betweenで左グループ・操作群・☰を均等配置 */
.abtn{ border:1px solid var(--line); background:#efe9db; color:var(--text);
  font-size:12px; font-weight:600; padding:6px 10px; border-radius:10px; }
.abtn.primary{ background:var(--accent); border-color:var(--accent); color:#fff;
  min-width:46px; text-align:center; }  /* 子・兄弟を同じ幅に */
/* 枝ボタン（兄弟＝分ける／子＝伸ばす）＝参考アプリ通りのモノクロ線画アイコン（キーの囲みなし） */
.abtn.ibtn{ display:inline-flex; align-items:center; justify-content:center;
  width:auto; height:36px; padding:0 3px; background:none; border:none; box-shadow:none;
  color:var(--text); border-radius:8px; }
.abtn.ibtn svg{ width:21px; height:26px; display:block; pointer-events:none; }
.abtn.ibtn:active{ opacity:.45; }
#moreBtn{ background:none; border:none; box-shadow:none; padding:4px 6px; font-size:19px; color:var(--text); line-height:1; }  /* ⋯は枠なしコンパクトに */
.connectHint{ position:fixed; left:50%; transform:translateX(-50%);
  top:calc(env(safe-area-inset-top) + 52px); z-index:7;
  background:var(--accent); color:#fff; font-size:14px; font-weight:600;
  padding:10px 16px; border-radius:20px; box-shadow:0 6px 20px rgba(0,0,0,.45); }

/* ---- メニューシート ---- */
.sheet{ position:fixed; inset:0; z-index:30; display:flex; align-items:flex-end; }
.sheetBg{ position:absolute; inset:0; background:rgba(0,0,0,.5); }
.sheetCard{ position:relative; width:100%; background:var(--panel); border-radius:20px 20px 0 0;
  padding:10px 12px calc(env(safe-area-inset-bottom) + 12px); }
.menuItem{ display:block; width:100%; text-align:center; background:none; border:none; color:var(--text);
  font-size:16px; padding:15px; border-bottom:1px solid var(--line); }
.menuItem:last-child{ border-bottom:none; }
.menuItem.danger{ color:var(--danger); }
.menuItem.cancel{ color:var(--muted); font-weight:600; }
