/* 相関図メーカー：エンタメパンダ ツールズと同じ白・墨・パンダ朱 */
:root {
  --ink: #1F1D1B;
  --sub: #66615C;
  --line: #E8E3DD;
  --surface: #F6F3EF;
  --blush: #FDF0EB;
  --shu: #E5452B;
  --shu-deep: #C93A22;
  --shu-text: #C93A22;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --shadow: 0 12px 32px rgba(31, 29, 27, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: #FFFFFF; color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.6; letter-spacing: .02em;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
/* 朱の細い線（エンタメパンダ本体のヘッダーと同じ） */
body::before { content: ""; display: block; flex-shrink: 0; height: 4px; background: var(--shu); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2 { margin: 0; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; }

/* サイト共通ヘッダー */
.hd { flex-shrink: 0; display: flex; align-items: center; gap: 8px 32px; height: 60px; padding: 0 40px; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-right: auto; min-width: 0; }
.logo img { width: 34px; height: 34px; object-fit: contain; }
.logo b { display: block; font-size: 19px; font-weight: 900; line-height: 1.1; letter-spacing: .04em; white-space: nowrap; }
.logo b span { color: var(--shu-text); }
.logo small { display: block; margin-top: 1px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--sub); line-height: 1.4; }
.nav { display: flex; align-items: center; gap: 28px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 6px; min-height: 44px; transition: color .2s; }
.nav a:hover { color: var(--shu-text); }
.nav svg { width: 13px; height: 13px; }

/* ボタン */
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: #FFFFFF; font-size: 13px; font-weight: 700; white-space: nowrap; }
.tbtn svg { width: 16px; height: 16px; }
.tbtn:hover { border-color: var(--ink); }
.tbtn.primary { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }
.tbtn[aria-pressed="true"], .tbtn[aria-expanded="true"] { border-color: var(--shu-deep); background: var(--blush); color: var(--shu-text); }
#savePng.primary { border-color: var(--shu-deep); background: var(--shu-deep); }
#savePng.primary:hover { border-color: var(--ink); background: var(--ink); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #FFFFFF; }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.text-btn { min-height: 44px; padding: 0; border: 0; background: none; font-size: 13px; font-weight: 700; color: var(--sub); text-decoration: underline; }

/* ツールの操作列 */
.rm-bar { position: relative; z-index: 20; flex-shrink: 0; display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 6px 40px; border-bottom: 1px solid var(--line); background: #FFFFFF; }
.rm-name { font-size: 15px; font-weight: 900; white-space: nowrap; }
.top-actions { position: relative; display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top-actions .icon-btn { width: 44px; height: 44px; border-color: transparent; }
.top-actions .icon-btn:hover { border-color: var(--line); }
.more-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: #FFFFFF; box-shadow: var(--shadow); }
.more-menu button { display: block; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: #FFFFFF; font-size: 14px; font-weight: 700; text-align: left; }
.more-menu button:hover { background: var(--surface); }

/* 作業面 */
.workspace { flex: 1; min-height: 0; padding: 12px 16px; background: #FFFFFF; }
.board-shell { position: relative; height: 100%; max-width: 1400px; margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background-color: var(--surface); background-image: radial-gradient(#DDD5CB 1.2px, transparent 1.2px); background-size: 22px 22px; }
.board-scroller { position: absolute; inset: 34px 0 0; overflow: auto; overscroll-behavior: contain; }
/* 2026-12-01監査修正：スクロール端のフェードはキャンバス領域だけに掛け、上端の操作帯（ボタン類）には重ねない。幅と濃さも抑え、端のノードが黒帯に見えないようにする */
.board-shell::before, .board-shell::after { content: ""; position: absolute; z-index: 12; top: 34px; bottom: 0; width: 16px; pointer-events: none; opacity: 0; transition: opacity .15s; }
.board-shell::before { left: 0; background: linear-gradient(to right, rgba(31, 29, 27, .12), transparent); }
.board-shell::after { right: 0; background: linear-gradient(to left, rgba(31, 29, 27, .12), transparent); }
.board-shell.more-left::before, .board-shell.more-right::after { opacity: 1; }
.board-spacer { position: absolute; top: 0; left: 0; width: 1px; pointer-events: none; }
.board-stage { position: absolute; width: 1000px; height: 650px; transform-origin: 0 0; }
.board-stage > svg { display: block; width: 1000px; height: 650px; touch-action: none; user-select: none; }
/* 画面では作業面の点線を通しで見せる。PNGには図側の背景が入る。 */
#graph > .graph-bg, #graph > rect[fill="url(#dots)"] { display: none; }

/* 図の操作表示（色・書体は renderer.js の GRAPH_STYLE と共通） */
.edge { cursor: pointer; outline: none; }
.edge.selected .edge-line { stroke-width: 5; }
.edge:focus-visible .edge-label rect, .edge.selected .edge-label rect { stroke: var(--ink); stroke-width: 2; }
.edge-label text { pointer-events: none; }
.node { cursor: grab; outline: none; }
.node:active { cursor: grabbing; }
.avatar-placeholder { pointer-events: none; }
.node-name, .node-description { cursor: text; }
.node-remove { opacity: 0; transition: opacity .15s; pointer-events: none; }
.node.selected .node-remove { opacity: 1; pointer-events: auto; }
/* 削除の×は、選んでいる人物にだけ出す（ほかの人物にマウスを載せただけでは出さない。押せる範囲は44px）。2026-11-03、レビュー指摘B7 */
.node.selected .avatar-ring { stroke: var(--ink); stroke-width: 6; }
.node.selected .name-card { stroke: var(--ink); stroke-width: 2.5; }
/* 見えない当たり判定（実寸44px以上）。見た目の×より大きく取る。 */
.node-remove .remove-hit { fill: transparent; stroke: none; }
.node.fresh .avatar-ring { stroke: var(--shu-deep); stroke-width: 7; animation: fresh-pulse 1.4s ease-out; }
@keyframes fresh-pulse { from { stroke-width: 16; opacity: .4; } to { stroke-width: 7; opacity: 1; } }
.node-remove circle { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.5; cursor: pointer; }
.node-remove text { font-size: 20px; fill: var(--ink); pointer-events: none; }
.node.selected .avatar-ring, .node:focus-visible .avatar-ring { stroke: var(--ink); stroke-width: 5; }
.node.connect-selected .avatar-ring { stroke: var(--shu-deep); stroke-width: 6; stroke-dasharray: 9 5; }
.inline-editor { position: absolute; z-index: 12; transform: translate(-50%, -50%); }
.inline-editor input { width: 200px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 10px; background: #FFFFFF; box-shadow: var(--shadow); font-weight: 700; text-align: center; outline: none; }

/* テンプレート */
.templates { position: absolute; z-index: 10; top: 12px; left: 12px; width: 280px; max-height: calc(100% - 24px); overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; box-shadow: var(--shadow); }
.panel-heading, .inspector-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading { padding: 6px 6px 6px 16px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .inspector-head h2 { font-size: 15px; font-weight: 900; }
.panel-heading .icon-btn, .inspector-head .icon-btn { border-color: transparent; }
.panel-heading .icon-btn:hover, .inspector-head .icon-btn:hover { border-color: var(--line); }
.template-list { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.template-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 8px 10px; border: 1px solid transparent; border-radius: 12px; background: #FFFFFF; text-align: left; }
.template-card:hover { background: var(--surface); }
.template-card.active { border-color: var(--shu-deep); background: var(--blush); }
.template-card > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.template-card strong { font-size: 14px; font-weight: 700; }
.template-card.active strong { color: var(--shu-text); }
.template-card small { font-size: 12px; color: var(--sub); }
.template-icon { position: relative; display: block; flex: 0 0 76px; height: 48px; }
.template-icon i { position: absolute; display: block; width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 50%; background: #FFFFFF; }
.triangle::before { content: ""; position: absolute; inset: 10px 17px 6px; border: 1.5px solid var(--sub); border-top: 0; transform: perspective(20px) rotateX(-12deg); }
.triangle i:nth-child(1) { top: 0; left: 29px; border-color: var(--shu); background: var(--blush); }
.triangle i:nth-child(2) { bottom: 0; left: 4px; }
.triangle i:nth-child(3) { bottom: 0; right: 4px; }
.four::before, .family::before { content: ""; position: absolute; inset: 9px 15px; border: 1.5px solid var(--sub); }
.four i:nth-child(1) { top: 0; left: 6px; border-color: var(--shu); background: var(--blush); }
.four i:nth-child(2) { top: 0; right: 6px; }
.four i:nth-child(3) { bottom: 0; left: 6px; }
.four i:nth-child(4) { bottom: 0; right: 6px; }
.org::before { content: ""; position: absolute; top: 18px; left: 10px; right: 10px; height: 14px; border: 1.5px solid var(--sub); border-bottom: 0; }
.org i { border-radius: 5px; }
.org i:nth-child(1) { top: 0; left: 29px; border-color: var(--shu); background: var(--blush); }
.org i:nth-child(2) { bottom: 0; left: 2px; }
.org i:nth-child(3) { bottom: 0; left: 29px; }
.org i:nth-child(4) { bottom: 0; right: 2px; }
.family::before { top: 19px; border-bottom: 0; }
.family i:nth-child(1) { top: 0; left: 29px; border-color: var(--shu); background: var(--blush); }
.family i:nth-child(2) { bottom: 0; left: 2px; }
.family i:nth-child(3) { bottom: 0; left: 29px; }
.family i:nth-child(4) { bottom: 0; right: 2px; }
.blank { display: grid; place-items: center; border: 1.5px dashed var(--sub); border-radius: 10px; font-size: 24px; color: var(--sub); }

/* 関係・グループの設定 */
.edge-inspector, .group-inspector { position: absolute; z-index: 13; top: 12px; right: 12px; width: 260px; max-height: calc(100% - 24px); overflow: auto; padding: 6px 16px 12px; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; box-shadow: var(--shadow); }
.inspector-head { margin: 0 -10px 4px 0; }
.edge-inspector label, .edge-inspector legend, .group-inspector label, .group-inspector legend { display: block; font-size: 12px; font-weight: 700; color: var(--sub); }
.edge-inspector label, .group-inspector label { margin: 10px 0; }
.edge-inspector input, .edge-inspector select, .group-inspector input { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #FFFFFF; font-size: 15px; color: var(--ink); }
.edge-inspector input:focus-visible, .edge-inspector select:focus-visible, .group-inspector input:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.edge-inspector fieldset, .group-inspector fieldset { min-width: 0; min-inline-size: 0; margin: 10px 0; padding: 0; border: 0; }
.color-options { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.color-chip { position: relative; width: 30px; height: 30px; padding: 0; border: 3px solid #FFFFFF; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.color-chip.active { box-shadow: 0 0 0 2px var(--ink); }
.danger { color: var(--shu-text); }

/* 関係をつなぐ案内 */
.connect-hint { position: absolute; z-index: 14; top: 12px; left: 50%; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px); padding: 4px 4px 4px 18px; border-radius: 999px; background: var(--ink); color: #FFFFFF; font-size: 13px; transform: translateX(-50%); white-space: nowrap; }
.connect-hint .tbtn { min-height: 36px; border-color: #FFFFFF; color: var(--ink); }

/* 下部バー */
.bottom-bar { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 6px 40px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #FFFFFF; }
.title-area { display: flex; align-items: center; gap: 12px; min-width: 0; margin-right: auto; }
.title-area button { display: inline-flex; align-items: center; gap: 6px; min-width: 0; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; }
.title-area button:hover { background: var(--surface); }
.title-area strong { overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.title-area svg { width: 16px; height: 16px; color: var(--sub); }
.history-actions { display: flex; gap: 8px; }
.history-actions .icon-btn { border-color: transparent; }
.history-actions .icon-btn:hover { border-color: var(--line); }
.history-actions .icon-btn:disabled { opacity: .35; cursor: default; border-color: transparent; }
.zoom-actions { display: flex; align-items: center; margin-left: 8px; padding: 0 2px; border: 1px solid var(--line); border-radius: 999px; }
.zoom-actions button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
.zoom-actions button:hover { background: var(--surface); }
.zoom-actions svg { width: 18px; height: 18px; }
.zoom-actions output { width: 52px; font-size: 13px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-actions #fitView { border-left: 1px solid var(--line); border-radius: 0 999px 999px 0; }

/* トースト・ダイアログ */
.toast { position: fixed; z-index: 50; top: auto; right: auto; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); margin: 0; border: 0; overflow: visible; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 32px); padding: 6px 14px; border-radius: 999px; background: var(--ink); color: #FFFFFF; font-size: 13px; font-weight: 700; transform: translateX(-50%); }
.toast[hidden] { display: none; }
.toast button { min-width: 44px; min-height: 44px; margin: -6px -8px -6px 0; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: #FFFFFF; font-size: 13px; font-weight: 900; text-decoration: underline; white-space: nowrap; }
.toast button[hidden] { display: none; }
.toast button:focus-visible { outline: 3px solid #FFFFFF; outline-offset: -3px; }
.new-doc { width: 100%; min-height: 44px; margin-bottom: 8px; justify-content: center; gap: 6px; }
.new-doc svg { width: 16px; height: 16px; }
.preview { width: min(860px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 0; border-radius: 16px; background: #FFFFFF; color: var(--ink); box-shadow: 0 16px 48px rgba(31, 29, 27, .25); }
.preview[open] { display: flex; flex-direction: column; }
.preview::backdrop { background: rgba(31, 29, 27, .55); }
.preview-head, .preview-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 12px 10px 20px; }
.preview-head { border-bottom: 1px solid var(--line); }
.preview-head h2 { margin: 0; font-size: 16px; font-weight: 900; }
.preview-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px; background: var(--surface); }
.preview-body img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(31, 29, 27, .12); }
.preview-foot { flex-wrap: wrap; border-top: 1px solid var(--line); }
.preview-brand-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; font-weight: 700; color: var(--ink); cursor: pointer; user-select: none; }
.preview-brand-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--shu-deep); flex-shrink: 0; cursor: pointer; }
.preview-actions { display: flex; gap: 8px; margin-left: auto; }
.preview-actions .tbtn { min-height: 44px; padding: 0 18px; }
.app-dialog { width: min(400px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; color: var(--ink); box-shadow: 0 20px 48px rgba(31, 29, 27, .16); }
.app-dialog::backdrop { background: rgba(31, 29, 27, .2); }
.app-dialog form { padding: 20px; }
.app-dialog p { margin: 0 0 16px; font-size: 15px; font-weight: 700; line-height: 1.7; white-space: pre-line; }
.app-dialog input { display: block; width: 100%; min-height: 44px; margin: -4px 0 16px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
.app-dialog input:focus-visible { border-color: var(--ink); outline: 3px solid var(--ink); outline-offset: 1px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .tbtn { min-height: 44px; padding: 0 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media (max-width: 1020px) {
  .hd, .rm-bar, .bottom-bar { padding-left: 28px; padding-right: 28px; }
}
/* PCでは操作列・下部バー・注記の左右を、作業面（最大1400px）の端に揃える。 */
@media (min-width: 761px) {
  .rm-bar, .bottom-bar { padding-left: max(16px, calc((100% - 1400px) / 2)); padding-right: max(16px, calc((100% - 1400px) / 2)); }
}

/* はじめに選ぶテンプレート */
.start-dialog { width: min(560px, calc(100% - 32px)); }
.start-options { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
.start-options legend { padding: 0; font-size: 19px; font-weight: 900; }
.start-lead { margin: 4px 0 14px !important; font-size: 13px !important; font-weight: 500 !important; color: var(--sub); }
.start-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.start-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 0 0 10px; border: 1px solid var(--line); border-radius: 14px; background: #FFFFFF; overflow: hidden; cursor: pointer; }
.start-card input, .start-blank input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.start-thumb { display: flex; align-items: center; justify-content: center; height: 92px; margin-bottom: 8px; background: var(--surface); }
.start-thumb .template-icon { flex: none; width: 76px; transform: scale(1.35); }
.start-card strong { padding: 0 12px; font-size: 15px; font-weight: 700; }
.start-card small { padding: 0 12px; font-size: 12px; color: var(--sub); }
.start-card:has(input:checked) { border: 2px solid var(--ink); }
.start-card:has(input:focus-visible), .start-blank:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.start-blank { position: relative; display: flex; margin-top: 10px; cursor: pointer; }
.start-blank span { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 48px; border: 1px dashed #C9C1B6; border-radius: 12px; font-size: 14px; font-weight: 700; }
.start-blank:has(input:checked) span { border: 2px solid var(--ink); border-style: solid; }
.start-dialog .dialog-actions .primary { flex: 1; }
@media (max-width: 760px) {
  .rm-bar { gap: 8px; min-height: 56px; padding: 6px 12px; }
  .rm-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top-actions { flex: 1; justify-content: space-between; gap: 3px; margin: 0; }
  .top-actions .tbtn { flex: 1; min-width: 0; min-height: 50px; padding: 3px 1px; flex-direction: column; gap: 0; border-radius: 10px; }
  .top-actions .tbtn svg { width: 19px; height: 19px; }
  .top-actions .lbl { display: block; font-size: 10px; line-height: 1.3; letter-spacing: 0; white-space: nowrap; }
  .top-actions .icon-btn { width: 44px; height: 44px; }
  .workspace { padding: 8px; }
  .board-shell { border-radius: 12px; }
  #graph .graph-title { display: none; }
  .templates { top: 8px; left: 8px; width: min(280px, calc(100% - 16px)); }
  /* 関係・グループの設定は低い下部シート。閉じるを右上へ重ね、2列に詰めて高さを抑える。 */
  .edge-inspector, .group-inspector { top: auto; right: 0; bottom: 0; left: 0; width: auto; padding: 6px 12px 8px; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 16px rgba(31, 29, 27, .12); }
  .edge-inspector, .group-inspector { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 8px; align-items: end; }
  .edge-inspector[hidden], .group-inspector[hidden] { display: none !important; }
  .edge-inspector label:first-of-type, .group-inspector > label { grid-column: 1 / -1; margin-right: 48px; }
  .edge-inspector fieldset, .group-inspector fieldset, .group-size-fields { grid-column: 1 / -1; }
  .edge-inspector .danger, .group-inspector .danger { justify-self: end; margin-bottom: 4px; }
  .group-inspector .danger { grid-column: 1 / -1; }
  .edge-inspector .inspector-head, .group-inspector .inspector-head { position: absolute; top: 2px; right: 4px; margin: 0; }
  .edge-inspector .inspector-head h2, .group-inspector .inspector-head h2 { display: none; }
  .edge-inspector legend, .group-inspector legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .edge-inspector label, .edge-inspector fieldset, .group-inspector label, .group-inspector fieldset { margin: 4px 0; }
  .edge-inspector input, .edge-inspector select, .group-inspector input { margin-top: 2px; }
  .edge-inspector .color-options, .group-inspector .color-options { margin-top: 0; }
  .bottom-bar { gap: 2px; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
  .title-area { gap: 0; }
  .title-area button { padding: 0 8px; }
  .title-area strong { font-size: 14px; }
  .preview-actions { width: 100%; }
  .preview-actions .tbtn { flex: 1; justify-content: center; }
  .history-actions { gap: 0; }
  .zoom-actions { margin-left: 2px; padding: 0; }
  .zoom-actions button { width: 44px; height: 44px; }
  .zoom-actions output { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .hd { padding: 0 16px; gap: 16px; }
  .logo b { font-size: 16px; }
  .logo img { width: 30px; height: 30px; }
  .logo small { display: none; }
  .nav { gap: 16px; font-size: 13px; }
  .nav .hide-sp, .nav .ext { display: none; }
}

.node-color { cursor: pointer; }
.node-color:focus-visible circle:not(.color-hit) { stroke: #1F1D1B; stroke-width: 3; }
.layout-notice { margin: 4px 14px; color: #9D351F; font-size: 12px; }
#canvasForm label { display: block; margin: 10px 0; }
#canvasForm input { width: 100%; min-height: 44px; margin-top: 4px; padding: 6px 10px; }

/* 操作画面の下に置く静的な使い方・FAQ */
.tool-guide { box-sizing: border-box; width: min(100% - 32px, 900px); margin: 40px auto; padding: 24px 0 48px; color: #1F1D1B; font-size: 15px; line-height: 1.9; }
.tool-guide h2 { font-size: 22px; margin: 28px 0 12px; }
.tool-guide h3 { font-size: 17px; margin: 20px 0 8px; }
.tool-guide p { margin: 0 0 14px; }
.tool-guide ul, .tool-guide ol { padding-left: 1.5em; }
.tool-guide li { margin: 0 0 6px; }
.tool-guide a { text-decoration: underline; text-underline-offset: .2em; }
.tool-screen { display: flex; flex-direction: column; flex: none; height: 100vh; height: 100dvh; min-height: 500px; }
html, body { height: auto; overflow: auto; }
body { display: block; }

.edit-hint { position: absolute; z-index: 2; top: 3px; left: 8px; display: flex; align-items: center; gap: 8px; margin: 0; padding: 2px 6px; border-radius: 6px; background: #fff; font-size: 12px; }
.edit-hint button { border: 0; background: transparent; color: #a8321d; text-decoration: underline; font: inherit; font-weight: 700; }
.edit-hint button:disabled { color: var(--sub); text-decoration: none; }
.mobile-hint { display: none; }
.person-inspector { display: none; }
@media (max-width: 760px) {
  .edit-hint { font-size: 11px; pointer-events: none; }
  .desktop-hint, .edit-hint button { display: none; }
  .mobile-hint { display: inline; }
  .node-color, .node-remove { display: none; }
  .person-inspector, .edge-inspector, .group-inspector { position: fixed; z-index: 30; top: calc(var(--ep-viewport-top, 0px) + var(--ep-viewport-height, 100dvh)); bottom: auto; left: 0; right: 0; width: auto; max-height: calc(var(--ep-viewport-height, 100dvh) - 12px); transform: translateY(-100%); overflow: auto; overscroll-behavior: contain; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); border: 1px solid var(--line); border-radius: 16px 16px 0 0; background: #fff; box-shadow: 0 -4px 16px rgba(31,29,27,.12); }
  .person-inspector { display: block; }
  .person-inspector { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 8px; padding-top: 4px; }
  .person-inspector .inspector-head, .person-actions { grid-column: 1 / -1; }
  .person-inspector label { display: block; margin: 2px 0; font-size: 12px; font-weight: 700; }
  .edge-inspector, .group-inspector { padding: 6px 12px calc(8px + env(safe-area-inset-bottom)); }
  .person-inspector input, .edge-inspector input, .edge-inspector select, .group-inspector input { display: block; width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
  .person-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .person-actions .tbtn { flex: 1; padding: 0 8px; }
  .person-inspector .inspector-head { display: flex; justify-content: space-between; align-items: center; }
  .person-inspector .inspector-head h2 { display: block; font-size: 15px; }
  .app-dialog { max-height: calc(var(--ep-viewport-height, 100dvh) - 16px); overflow: auto; }
  html.ep-keyboard-open .app-dialog[open] { position: fixed; top: var(--ep-viewport-top, 0px); bottom: auto; margin: 8px auto; }
}

.wide-canvas { display: none; }
@media (max-width: 760px) {
  /* 図に重ならないよう、上端の帯（ヒントと同じ行）に置く。 */
  .board-scroller { inset: 44px 0 0; }
  .board-shell::before, .board-shell::after { top: 44px; }
  .wide-canvas { display: block; position: absolute; z-index: 3; right: 6px; top: 2px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 700; font-size: 13px; }
  .preview-foot { flex-wrap: wrap; }
  .preview-foot p { width: 100%; margin: 0; font-size: 13px; }
}

/* 共通操作バー（スマホ）：理由文は保存ボタンの真上に1行、下に「共有」「画像を保存」。「プレビュー」は図の編集画面と同じなので隠す。 */
[data-ep-shell="diagram"] .ep-shell-actions { flex-wrap: wrap; }
[data-ep-shell="diagram"] .ep-shell-actions > button:not(.ep-shell-primary):not([data-ep-custom]) { display: none; }
[data-ep-shell="diagram"] .ep-shell-actions > [data-ep-custom] { flex: 0 0 112px; }
[data-ep-shell="diagram"] .ep-shell-actions > .ep-shell-primary { flex: 1 1 0; }
.ep-save-reason { order: -1; flex: 0 0 100%; min-width: 0; color: #9A2412; font: 700 12.5px/1.4 var(--font); }
@media (max-width: 760px) {
  body:has(.ep-save-reason:not([hidden])) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  /* 理由文の1行ぶん（25px）だけ操作バーが高くなるので、画面もその分縮める */
  body:has(.ep-save-reason:not([hidden])) .tool-screen { height: calc(100vh - var(--ep-chrome-h, 64px) - 86px - env(safe-area-inset-bottom)); height: calc(100dvh - var(--ep-chrome-h, 64px) - 86px - env(safe-area-inset-bottom)); }
}
/* 無効ボタンの共通の見た目（赤系を薄くせず、灰みの面にする） */
[data-ep-shell="diagram"] .ep-shell-actions button:disabled, .panel-save-btn:disabled, .panel-share-btn:disabled, .tbtn.primary:disabled {
  border: 0; background: #E6E0D7; color: #5f5852; box-shadow: none; opacity: 1; cursor: not-allowed;
}
html[data-theme="dark"] [data-ep-shell="diagram"] .ep-shell-actions button:disabled, html[data-theme="dark"] .panel-save-btn:disabled, html[data-theme="dark"] .panel-share-btn:disabled, html[data-theme="dark"] .tbtn.primary:disabled { background: #2C2832; color: #B5AEA6; }
.more-menu button:disabled { color: var(--sub); cursor: default; }
.more-menu button:disabled:hover { background: #FFFFFF; }
.menu-hint { display: block; padding: 0 12px 6px; color: var(--sub); font-size: 12px; line-height: 1.4; }

/* 色の選択と関係ラベルは指で押せる大きさ（44px以上・間隔8px）にする */
.color-options { gap: 8px; padding: 4px; }
.color-chip { width: 44px; height: 44px; border-width: 6px; box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .14), 0 0 0 1px var(--line); }
.color-chip.active { box-shadow: inset 0 0 0 1px rgba(31, 29, 27, .14), 0 0 0 2px var(--ink); }
.color-chip-custom { display: inline-grid; place-items: center; overflow: hidden; flex: none; background: conic-gradient(#F8BBD0, #FFF0A6, #B8EBD4, #B3E5FC, #D8C2F5, #F8BBD0); color: #2B2326; cursor: pointer; }
.color-chip-custom:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.edge-inspector .color-picker-input, .group-inspector .color-picker-input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.color-custom-mark { pointer-events: none; font-size: 16px; font-weight: 900; line-height: 1; }
.label-hit { cursor: pointer; }

@media (max-width: 760px) {
  .top-actions { gap: 3px; }
  .top-actions .lbl { font-size: 10px; }
  /* 色は1行で横にスクロール（44pxの丸を8px間隔で並べると360pxに収まらないため）。シートの高さを抑える。 */
  .edge-inspector .color-options, .group-inspector .color-options { flex-wrap: nowrap; gap: 8px; padding: 4px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .edge-inspector .color-chip, .group-inspector .color-chip { flex: none; scroll-snap-align: start; }
  /* 下の共通操作バー（画像を保存）を隠さないよう、シートはその上に出す */
  .person-inspector, .edge-inspector, .group-inspector { transform: translateY(calc(-100% - var(--ep-sheet-bottom, 0px))); max-height: calc(var(--ep-viewport-height, 100dvh) - var(--ep-sheet-bottom, 0px) - 12px); }
  .person-inspector .inspector-head #closePerson { min-width: 88px; border-color: var(--ink); background: var(--ink); color: #FFFFFF; }
  /* タイトルは3行まで折り返す（既定の「無題の相関図」は省略しない） */
  .bottom-bar { gap: 8px; }
  .history-actions { gap: 8px; }
  .title-area { flex: 1; min-width: 0; margin-right: 0; }
  .title-area button { width: 100%; justify-content: flex-start; padding: 0 8px; border: 1px dashed var(--line); }
  .title-area svg { display: none; }
  .title-area strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; font-size: 13px; line-height: 1.25; text-align: left; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
}

/* ===== PC（761px以上）：新しいメーカーと同じ「タイトル行＋主パネルの見出し行」 =====
   上の操作列は使わず、タイトル行（ツール名・説明・自動保存・「…」）と、主パネルの見出し行（タイトル・画像を保存）に分ける。
   図の道具（追加・ズーム・元に戻す）は見出し行の下の道具列に置く。移し替えは app.js の placeLayout()。 */
.board-panel { display: contents; }
.panel-head, .panel-tools, .rm-meta { display: none; }
@media (min-width: 761px) {
  .top-actions, .bottom-bar { display: none; }
  /* 共通の操作バー（tool-shell）はPCでは使わない。画像を保存は主パネルの見出し行にある（#savePng は共通バー用に残す）。 */
  [data-ep-slug="relationship-maker"] .ep-shell-actions { display: none; }
  .rm-bar { flex-wrap: wrap; gap: 0 14px; min-height: 44px; padding: 2px max(12px, calc((100% - 1400px) / 2)); border-bottom: 0; }
  .rm-bar .ep-shell-heading { display: flex; flex: 1 1 0; align-items: baseline; gap: 0 12px; min-width: 0; }
  .rm-bar .rm-name { flex: none; font-size: 18px; font-weight: 900; line-height: 1.35; letter-spacing: 0; }
  .rm-bar .ep-shell-heading .ep-shell-description { margin: 0; min-width: 0; overflow: hidden; font-size: 13px; color: var(--sub); text-overflow: ellipsis; white-space: nowrap; }
  .rm-meta { position: relative; display: flex; flex: none; align-items: center; gap: 12px; }
  .rm-meta .icon-btn { border-radius: 10px; }
  .more-menu .menu-danger { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; color: var(--shu-text); }
  .workspace { padding: 0 12px 10px; }
  .board-panel { display: flex; flex-direction: column; height: 100%; max-width: 1400px; margin: 0 auto; padding: 8px 14px 12px; border-radius: 16px; background: #F5F2ED; }
  .panel-head, .panel-tools { display: flex; flex: none; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
  .panel-head { margin-bottom: 6px; }
  .panel-tools { margin-bottom: 8px; }
  .panel-head-main { min-width: 0; }
  .panel-head .title-area { margin: 0; }
  .panel-head .title-area button { max-width: 100%; border: 1px dashed #CFC6BA; border-radius: 10px; background: #FFFFFF; }
  .panel-head .title-area strong { max-width: min(46vw, 520px); font-size: 16px; font-weight: 900; }
  .panel-save { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; }
  .panel-reason { color: #9A2412; font-size: 13px; font-weight: 700; line-height: 1.4; text-align: right; }
  .panel-save-btn { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border: 1.5px solid var(--shu-deep); border-radius: 10px; background: var(--shu-deep); color: #FFFFFF; font-size: 14px; font-weight: 700; line-height: 1.4; }
  .panel-save-btn svg { width: 16px; height: 16px; }
  .panel-save-btn:hover:not(:disabled) { border-color: var(--ink); background: var(--ink); }
  .panel-share-btn { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #FFFFFF; color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.4; }
  .panel-share-btn svg { width: 16px; height: 16px; }
  .panel-share-btn:hover:not(:disabled) { border-color: var(--ink); }
  .panel-reason { max-width: 24em; }
  .tools-main, .tools-side { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
  .tools-side { margin-left: auto; }
  .panel-tools .history-actions { gap: 4px; }
  .panel-tools .history-actions .icon-btn, .panel-tools .history-actions .icon-btn:disabled { border-color: var(--line); }
  .panel-tools .zoom-actions { margin-left: 4px; background: #FFFFFF; }
  .board-shell { flex: 1 1 0; height: auto; min-height: 0; max-width: none; margin: 0; border-radius: 12px; background-color: #FFFFFF; background-image: radial-gradient(#E4DDD3 1.2px, transparent 1.2px); }
  .layout-notice { margin: 0 max(12px, calc((100% - 1400px) / 2)) 8px; }
  /* PCの「関係・グループの設定」は2列グリッドで高さを抑え、768px級ノートPCでもスクロールせず全体を見渡せるようにする */
  .edge-inspector { top: 10px; right: 10px; width: 280px; max-height: calc(100% - 20px); padding: 6px 12px 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8px; row-gap: 6px; align-items: end; overflow-y: auto; }
  .group-inspector { top: 10px; right: 10px; width: 280px; max-height: calc(100% - 20px); padding: 6px 12px 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8px; row-gap: 6px; align-items: end; }
  .edge-inspector[hidden], .group-inspector[hidden] { display: none !important; }
  .edge-inspector .inspector-head, .edge-inspector .edge-endpoints, .group-inspector .inspector-head { grid-column: 1 / -1; margin: 0 -6px 0 0; }
  .edge-inspector label, .edge-inspector fieldset, .group-inspector label, .group-inspector fieldset { margin: 0; min-width: 0; }
  .edge-inspector label:first-of-type, .edge-inspector fieldset, .group-inspector > label, .group-inspector fieldset, .group-size-fields { grid-column: 1 / -1; }
  .edge-inspector input, .group-inspector input { margin-top: 2px; padding: 0 8px; font-size: 14px; }
  .edge-inspector .color-options, .group-inspector .color-options { gap: 6px; padding: 4px; margin-top: 2px; }
  .edge-inspector .danger, .group-inspector .danger { justify-self: end; white-space: nowrap; }
}
/* 広いPC画面（1180px以上）は見出し行と道具列を1行にまとめ、ボタンの44pxタップ高を保ったまま作業面をさらに広げる */
@media (min-width: 1180px) {
  .board-panel:not(:has(.panel-reason:not([hidden]))) {
    display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto auto; grid-template-rows: auto minmax(0, 1fr);
    align-items: center; column-gap: 8px; row-gap: 8px;
  }
  .board-panel:not(:has(.panel-reason:not([hidden]))) > .panel-head,
  .board-panel:not(:has(.panel-reason:not([hidden]))) > .panel-tools { display: contents; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-head-main { grid-column: 1; grid-row: 1; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-head .title-area strong { max-width: 150px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .tools-main { grid-column: 2; grid-row: 1; flex-wrap: nowrap; gap: 4px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .tools-main .tbtn { padding: 0 8px; gap: 4px; font-size: 12px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .tools-side { grid-column: 3; grid-row: 1; flex-wrap: nowrap; margin-left: 0; gap: 4px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-tools .zoom-actions { margin-left: 0; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-tools .zoom-actions output { width: 42px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-save { grid-column: 4; grid-row: 1; margin-left: 0; gap: 6px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-share-btn { padding: 0 10px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .panel-save-btn { padding: 0 14px; }
  .board-panel:not(:has(.panel-reason:not([hidden]))) .board-shell { grid-column: 1 / -1; grid-row: 2; height: 100%; }
}
/* 900px以下（タブレット縦など）は道具列が1行に収まるよう、余白とボタンの幅を詰める */
@media (min-width: 761px) and (max-width: 900px) {
  .board-panel { padding: 8px 12px 10px; }
  .panel-tools .tbtn { padding: 0 9px; gap: 4px; font-size: 12px; }
  .tools-main, .tools-side { gap: 4px; }
  .panel-tools .history-actions { gap: 2px; }
  .panel-tools .zoom-actions { margin-left: 0; }
  .panel-tools .zoom-actions output { width: 42px; }
}

/* 共有ダイアログ：ガチャ系（result-actions.css）と同じクラス名・見た目 */
/* スマホの配置（〜760px）では、トーストを下部の行（タイトル・元に戻す・拡大）と共通操作バーの上に出す。
   --ep-sheet-bottom は app.js が共通操作バーの実際の高さ（理由文・安全領域を含む）から入れる */
@media (max-width: 760px) {
  .toast { bottom: calc(var(--ep-sheet-bottom, 61px) + 64px); }
}

/* 操作方法は使い方にまとめ、選択時の編集操作だけを残す。 */
.edit-hint .desktop-hint, .edit-hint .mobile-hint, .edit-hint button:disabled { display: none; }
.edit-hint:has(button:disabled) { display: none; }

/* 背景テーマ（きなり・白・薄ピンク・ダーク） */
.board-shell[data-graph-theme="cream"] {
  background-color: #F6F3EF;
  background-image: radial-gradient(#DDD5CB 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.board-shell[data-graph-theme="white"] {
  background-color: #FFFFFF;
  background-image: radial-gradient(#E4E1DC 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.board-shell[data-graph-theme="pastel"] {
  background-color: #FFF3F7;
  background-image: radial-gradient(#F2C8D8 1.3px, transparent 1.3px);
  background-size: 22px 22px;
  border-color: #F0CEDB;
}
.board-shell[data-graph-theme="pastel"] .node.selected .avatar-ring,
.board-shell[data-graph-theme="pastel"] .node:focus-visible .avatar-ring,
.board-shell[data-graph-theme="pastel"] .node.selected .name-card { stroke: #5A2A3E; }
.board-shell[data-graph-theme="dark"] {
  background-color: #161822;
  background-image: radial-gradient(#3E4668 1.2px, transparent 1.2px), radial-gradient(#7E8AC4 .9px, transparent .9px);
  background-size: 28px 28px;
  background-position: 0 0, 14px 12px;
  border-color: #2E344D;
}
.board-shell[data-graph-theme="dark"]::before { background: linear-gradient(to right, rgba(10, 12, 20, .55), transparent); }
.board-shell[data-graph-theme="dark"]::after { background: linear-gradient(to left, rgba(10, 12, 20, .55), transparent); }
.board-shell[data-graph-theme="dark"] .node.selected .avatar-ring,
.board-shell[data-graph-theme="dark"] .node:focus-visible .avatar-ring,
.board-shell[data-graph-theme="dark"] .node.selected .name-card,
.board-shell[data-graph-theme="dark"] .edge:focus-visible .edge-label rect,
.board-shell[data-graph-theme="dark"] .edge.selected .edge-label rect { stroke: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .node-remove circle { fill: #222638; stroke: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .node-remove text { fill: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .edit-hint { background: #222638; color: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .edit-hint button { color: #FF8F7A; }
.board-shell[data-graph-theme="dark"] .wide-canvas { background: #222638; border-color: #4B5378; color: #F4F6FF; }

/* 配置エリア・背景テーマダイアログの背景テーマ切替（44px以上のタップ高） */
.theme-picker { margin: 12px 0 14px; padding: 0; border: 0; }
.theme-picker legend { margin-bottom: 8px; padding: 0; font-size: 13px; font-weight: 700; color: var(--sub); }
.theme-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.theme-card { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #FFFFFF; color: var(--ink); font-size: 14px; font-weight: 700; text-align: left; }
.theme-card:hover { border-color: var(--ink); }
.theme-card[aria-pressed="true"], .theme-card.active { border-color: var(--shu-deep); background: var(--blush); color: var(--shu-text); }
.theme-swatch { flex: none; width: 22px; height: 22px; border: 1px solid rgba(31, 29, 27, .22); border-radius: 50%; }
.theme-swatch-cream { background-color: #F6F3EF; background-image: radial-gradient(#C8BDB0 1px, transparent 1px); background-size: 6px 6px; }
.theme-swatch-white { background-color: #FFFFFF; background-image: radial-gradient(#D5D0C8 1px, transparent 1px); background-size: 6px 6px; }
.theme-swatch-pastel { background-color: #FFF3F7; background-image: radial-gradient(#E89EB9 1px, transparent 1px); background-size: 6px 6px; border-color: #E89EB9; }
.theme-swatch-dark { background-color: #161822; background-image: radial-gradient(#7E8AC4 1px, transparent 1px); background-size: 7px 7px; border-color: #4B5378; }

/* 関係プリセット */
.preset-options { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.preset-chip { flex: none; min-height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: #FFFFFF; font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.preset-chip:hover { border-color: var(--ink); background: var(--surface); }
.preset-chip.active { border-color: var(--shu-deep); background: var(--blush); color: var(--shu-text); }

/* 関係インスペクタのアイコンSegmented Button＆始点・終点バッジ */
.edge-endpoints { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: 8px; background: var(--surface); font-size: 12px; font-weight: 700; color: var(--ink); }
.edge-endpoints span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edge-endpoints button { flex: none; min-height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; background: #FFF; font-size: 11px; font-weight: 700; color: var(--ink); cursor: pointer; }
.edge-endpoints button:hover { border-color: var(--ink); }
.rm-seg-field { margin: 0; padding: 0; border: 0; }
.rm-seg { display: flex; gap: 4px; margin-top: 2px; }
.rm-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: #FFF; color: var(--ink); cursor: pointer; }
.rm-seg button:hover { border-color: var(--ink); background: var(--surface); }
.rm-seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #FFF; }
.rm-seg svg { width: 18px; height: 18px; pointer-events: none; }

/* PC用人物ミニ操作バー */
.pc-person-bar { position: absolute; z-index: 6; left: 50%; bottom: 14px; display: flex; align-items: center; gap: 4px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .96); box-shadow: 0 8px 24px rgba(31, 29, 27, .14); transform: translateX(-50%); }
.pc-person-bar[hidden] { display: none !important; }
.pc-person-bar .tbtn { min-height: 36px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; font-size: 12px; font-weight: 700; }
.pc-person-bar .tbtn:hover:not(:disabled) { background: var(--surface); }
.pc-person-bar .tbtn.danger { color: var(--shu-text); }
.pc-person-bar svg { width: 15px; height: 15px; flex: none; }
@media (max-width: 760px) {
  .pc-person-bar { display: none !important; }
}

/* グループ枠の編集・リサイズ・削除 */
.group { outline: none; }
.group-tag-wrap, .group-edge-hit, .group-body-hit { cursor: grab; }
.group-tag-wrap:active, .group-edge-hit:active, .group-body-hit:active { cursor: grabbing; }
.group-label { cursor: text; }
.group-remove, .group-resize { opacity: 0; transition: opacity .15s; pointer-events: none; }
.group.selected .group-remove, .group.selected .group-resize { opacity: 1; pointer-events: auto; }
.group.selected .group-box, .group:focus-visible .group-box { stroke-width: 3; }
.group.selected .group-tag, .group:focus-visible .group-tag { stroke: var(--ink); stroke-width: 2; }
.group-remove .remove-hit { fill: transparent; stroke: none; cursor: pointer; }
.group-remove circle:not(.remove-hit) { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.5; cursor: pointer; }
.group-remove text { font-size: 18px; fill: var(--ink); pointer-events: none; }
.group-resize { cursor: nwse-resize; }
.group-resize .resize-knob { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.8; }
.group-resize path { stroke: var(--ink); }
.board-shell[data-graph-theme="dark"] .group.selected .group-tag,
.board-shell[data-graph-theme="dark"] .group:focus-visible .group-tag { stroke: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .group-remove circle:not(.remove-hit),
.board-shell[data-graph-theme="dark"] .group-resize .resize-knob { fill: #222638; stroke: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .group-remove text { fill: #F4F6FF; }
.board-shell[data-graph-theme="dark"] .group-resize path { stroke: #F4F6FF; }

.group-size-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) {
  .group-remove, .group-resize { display: none; }
  .group.selected .group-resize { display: block; opacity: 1; pointer-events: auto; }
}

/* 人物一括追加ダイアログ */
.bulk-dialog { width: min(460px, calc(100% - 32px)); }
.bulk-dialog h2 { margin: 0 0 8px; font-size: 18px; font-weight: 900; }
.bulk-lead { margin: 0 0 12px !important; font-size: 13px !important; font-weight: 500 !important; color: var(--sub); }
.bulk-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
.bulk-dialog textarea { display: block; width: 100%; min-height: 150px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #FFFFFF; font: inherit; font-size: 15px; line-height: 1.5; resize: vertical; }
.bulk-dialog textarea:focus-visible { border-color: var(--ink); outline: 3px solid var(--ink); outline-offset: 1px; }
.bulk-status { margin: 8px 0 14px !important; min-height: 1.5em; font-size: 13px !important; font-weight: 700 !important; color: var(--sub); }
.bulk-status.is-warn { color: var(--shu-text); }

.edge-inspector .edge-people-toggle { position: relative; display: block; margin: 0; cursor: pointer; }
.edge-inspector .edge-people-toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.edge-people-pill { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.edge-people-pill svg { width: 18px; height: 18px; flex: none; }
.toggle-track { position: relative; width: 32px; height: 18px; margin-left: auto; flex: none; border: 1px solid currentColor; border-radius: 999px; }
.toggle-track::before { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.edge-people-toggle:hover .edge-people-pill { border-color: var(--ink); }
.edge-people-toggle input:checked + .edge-people-pill { border-color: var(--ink); background: var(--ink); color: #fff; }
.edge-people-toggle input:checked + .edge-people-pill .toggle-track::before { transform: translateX(14px); }
.edge-people-toggle input:focus-visible + .edge-people-pill { outline: 2px solid var(--ink); outline-offset: 2px; }

.membership-field { grid-column: 1 / -1; min-width: 0; margin: 3px 0; padding: 0; border: 0; }
.membership-field legend { font-size: 12px; font-weight: 700; }
.membership-chips { display: flex; gap: 6px; overflow-x: auto; padding: 3px; }
.membership-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.membership-chip[aria-pressed="true"], #multiSelect[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.membership-dot { width: 11px; height: 11px; flex: none; border: 1px solid #747078; border-radius: 50%; box-shadow: 0 0 0 1px #fff; }
.pc-membership summary { display: flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 700; }
.pc-membership summary:hover, .pc-membership[open] summary { background: var(--surface); }
.pc-membership .membership-chips { position: absolute; left: 50%; bottom: calc(100% + 6px); width: max-content; max-width: min(480px, 80vw); padding: 6px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 4px 16px rgba(31,29,27,.14); }
.board-select-tools { position: absolute; top: 6px; right: 6px; z-index: 4; }
@media (max-width: 760px) { .board-select-tools { top: 2px; right: auto; left: 6px; } }
#multiSelect { width: 44px; height: 44px; flex: none; background-color: #fff; }
#multiSelect[aria-pressed="true"] { background-color: var(--ink); }
.multi-group-bar { position: absolute; z-index: 13; left: 50%; bottom: 12px; width: max-content; max-width: calc(100% - 24px); transform: translateX(-50%); padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 4px 16px rgba(31,29,27,.14); }
.multi-group-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; font-size: 13px; }
.multi-group-head .tbtn { min-height: 44px; }
.node.multi-selected .avatar-ring, .node.multi-selected .name-card { stroke: #99476A; stroke-width: 5px; }
.board-shell[data-graph-theme="dark"] .node.multi-selected .avatar-ring,
.board-shell[data-graph-theme="dark"] .node.multi-selected .name-card { stroke: #F9AED0; }
