/* InfraAcademy Diagram — エディターとツールのページで共通の見た目 */
:root {
  --font: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic UI', 'Yu Gothic', Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ink: #0f172a;
  --sub: #526077;
  --muted: #64748b;
  --line: #e2e8f0;
  --line2: #cbd5e1;
  --panel: #ffffff;
  --bg: #f1f5f9;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-bg: #eff6ff;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --r: 4px;
}

/* ---------- エディター ---------- */
.dg-editor { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 13px; -webkit-font-smoothing: antialiased; }
.dg-editor *, .dg-editor *::before, .dg-editor *::after { box-sizing: border-box; }
.dg-editor [hidden] { display: none !important; }
.dg-editor button, .dg-editor input, .dg-editor select, .dg-editor textarea { font: inherit; color: inherit; }
#app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; height: 100dvh; }
/* お知らせ（banner）が隠れていても、作業領域が残りの高さを使うように行を固定する */
#app > .tb { grid-row: 1; }
#app > .banner { grid-row: 2; }
#app > .ws { grid-row: 3; }

.tb { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.tb-logo { display: flex; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 15px; letter-spacing: .01em; white-space: nowrap; margin-right: 6px; }
.tb-logo { font-family: "Poppins", system-ui, sans-serif; color: #020617; }
.tb-logo .tb-name { font-weight: 800; }
.tb-logo .tb-infra { color: #0000ff; font-weight: 800; }
.tb-logo span { color: var(--sub); font-weight: 600; }
.tb-title { display: flex; align-items: center; min-width: 80px; flex: 0 1 280px; }
.tb-title input { width: 100%; border: 1px solid transparent; background: transparent; padding: 6px 8px; border-radius: var(--r); font-weight: 700; font-size: 14px; text-overflow: ellipsis; }
.tb-title input:hover { border-color: var(--line); }
.tb-title input:focus { border-color: var(--accent); background: #fff; outline: none; }
.tb-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.tb-spacer { flex: 1; }
.tb-btn { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 10px; border: 1px solid transparent; background: transparent; border-radius: var(--r); cursor: pointer; white-space: nowrap; color: var(--ink); }
.tb-btn:hover:not(:disabled) { background: var(--bg); }
.tb-btn:disabled { opacity: .35; cursor: default; }
.tb-btn.primary { background: var(--accent); color: #fff; font-weight: 700; }
.tb-btn.primary:hover { background: var(--accent-ink); }
.tb-btn .badge { margin-left: 2px; }
/* 右上のアカウント：未ログインは「ログイン」、ログイン後は頭文字のアイコン。ホバー・フォーカス・クリックでメニュー */
.tb-btn.acct-login { border-color: var(--line2); text-decoration: none; font-weight: 700; margin-left: 2px; }
.acct { position: relative; margin-left: 4px; }
.acct .acct-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; }
.acct .acct-btn:hover, .acct.open .acct-btn { border-color: var(--line2); }
.acct-ic { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); border: 1px solid #bfdbfe; }
.acct-menu { display: none; position: absolute; right: 0; top: 100%; padding-top: 6px; z-index: 70; min-width: 200px; }
.acct:hover .acct-menu, .acct:focus-within .acct-menu, .acct.open .acct-menu { display: block; }
.acct.closed .acct-menu { display: none; }
.acct-box { background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(15,23,42,.12); overflow: hidden; }
.acct-head { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.acct-head strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.acct-head span { font-size: 11px; color: var(--muted); }
.acct-menu a { display: block; padding: 8px 14px; font-size: 13px; color: var(--ink); text-decoration: none; }
.acct-menu a:hover, .acct-menu a:focus-visible { background: var(--bg); outline: none; }
.acct-menu a.acct-out { color: var(--danger); border-top: 1px solid var(--line); }
.tb-btn.on { background: var(--accent-bg); color: var(--accent-ink); border-color: #bfdbfe; font-weight: 700; }
.tb-btn.on:hover:not(:disabled) { background: #dbeafe; }
.save-status { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 6px; }
.save-status[data-state="saved"]::before { content: '✓ '; color: var(--ok); }
.save-status[data-state="error"] { color: var(--danger); font-weight: 700; }
.save-status[data-state="dirty"] { color: var(--sub); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; color: #fff; background: var(--muted); }
.badge.warning { background: #d97706; }
.badge.error { background: var(--danger); }
.only-narrow { display: none !important; }

.banner { display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-size: 13px; border-bottom: 1px solid var(--line); background: #fffbeb; color: #78350f; }
.banner.error { background: #fef2f2; color: #7f1d1d; }
.banner > span { flex: 1; }
.banner.info { background: var(--accent-bg); color: #1e3a8a; }
/* 閲覧のみ（共有リンク・閲覧だけを許可された図面）：編集の道具を隠す */
.read-only .lp, .read-only #btn-left, .read-only #btn-undo, .read-only #btn-redo, .read-only #btn-connect, .read-only #btn-display, .read-only #btn-layout,
.read-only .cv-tools [data-tool="pen"], .read-only .cv-tools [data-tool="marker"], .read-only .cv-tools [data-tool="eraser"], .read-only .cv-tools [data-tool="delete"], .read-only .cv-tools [data-add], .read-only .cv-tools-sep,
.read-only #empty-hint, .read-only .cv-coach, .read-only .cv-ink { display: none !important; }
@media (min-width: 900px) {
  .read-only .ws { grid-template-columns: minmax(0, 1fr) var(--rw, 344px); }
}

.ws { display: grid; grid-template-columns: var(--lw, 236px) minmax(0, 1fr) var(--rw, 344px); min-height: 0; position: relative; overflow: hidden; } /* 画面外に隠した引き出しでページが横に広がらないように */
.lp, .rp { background: var(--panel); min-height: 0; min-width: 0; display: flex; flex-direction: column; position: relative; }
/* 横幅の変更（内側の端をドラッグ）と、たたむボタン。狭い画面（引き出し）では使わない */
.side-rz { position: absolute; top: 0; bottom: 0; width: 7px; z-index: 6; cursor: col-resize; touch-action: none; }
.lp > .side-rz { right: -4px; }
.rp > .side-rz { left: -4px; }
.side-rz::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: transparent; transition: background .12s; }
.side-rz:hover::after, .side-rz.on::after { background: var(--accent); width: 2px; left: 2.5px; }
.resizing, .resizing * { cursor: col-resize !important; user-select: none; }
.side-hide { position: absolute; top: 10px; z-index: 5; width: 30px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: var(--r); cursor: pointer; }
.side-hide:hover { background: var(--bg); color: var(--ink); border-color: var(--line); }
.lp > .side-hide { right: 8px; }
.rp > .side-hide { right: 6px; top: 6px; }
.lp .lib-search { margin-right: 42px; }
.rp .rp-tabs { padding-right: 40px; }
.side-rail { display: none; flex: 1; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; border: 0; background: transparent; color: var(--sub); cursor: pointer; font-size: 12px; font-weight: 700; }
.side-rail:hover { background: var(--bg); color: var(--ink); }
.side-rail span { writing-mode: vertical-rl; letter-spacing: .12em; }
@media (min-width: 900px) {
  .ws.lp-hidden { --lw: 36px !important; }
  .ws.rp-hidden { --rw: 36px !important; }
  .ws.lp-hidden .lp > :not(.side-rail), .ws.rp-hidden .rp > :not(.side-rail) { display: none; }
  .ws.lp-hidden .lp > .side-rail, .ws.rp-hidden .rp > .side-rail { display: flex; }
}
.lp { border-right: 1px solid var(--line); }
.rp { border-left: 1px solid var(--line); }

/* 素材 */
.lib-search { display: flex; align-items: center; gap: 6px; margin: 10px; padding: 0 8px; border: 1px solid var(--line2); border-radius: var(--r); color: var(--muted); }
.lib-search input { flex: 1; border: 0; outline: none; padding: 7px 0; background: transparent; min-width: 0; }
.lib-search:focus-within { border-color: var(--accent); }
.lib-list { flex: 1; overflow: auto; padding: 0 10px 10px; }
.lib-list h3 { margin: 0; font-size: 12px; }
.lib-sec, .lib-grp { display: flex; align-items: center; gap: 5px; width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; border-radius: var(--r); }
.lib-list .lib-sec { padding: 5px 2px; margin-top: 2px; font-size: 11px; font-weight: 600; color: var(--muted); }
.lib-list .lib-grp { padding: 9px 2px 7px; font-size: 12px; font-weight: 700; color: var(--ink); }
.lib-list > h3 ~ h3 .lib-grp { border-top: 1px solid var(--line); border-radius: 0; }
.lib-list > h3 ~ h3 .lib-grp { margin-top: 4px; }
.lib-grp-body { padding-bottom: 4px; }
.lib-grp-body .lib-sec { padding-left: 10px; }
.lib-sec:hover, .lib-grp:hover { color: var(--ink); background: var(--bg); }
.lib-sec svg, .lib-grp svg { transition: transform .15s; flex: none; }
.lib-sec[aria-expanded="false"] svg, .lib-grp[aria-expanded="false"] svg { transform: rotate(-90deg); }
.lib-sec .lbl, .lib-grp .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-sec .n, .lib-grp .n { margin-left: auto; font-weight: 400; font-size: 10.5px; color: var(--muted); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 4px; }
.lib-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border: 1px solid transparent; background: transparent; border-radius: var(--r); cursor: grab; min-width: 0; }
.lib-item:hover, .lib-item:focus-visible { background: var(--bg); border-color: var(--line); }
.lib-ic { display: flex; }
.lib-label { font-size: 10.5px; line-height: 1.25; text-align: center; color: var(--sub); word-break: keep-all; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-foot { padding: 10px; border-top: 1px solid var(--line); }

/* キャンバス */
.cv-wrap { position: relative; overflow: hidden; outline: none; touch-action: none; user-select: none; -webkit-user-select: none; background-color: #f7f9fc; background-image: radial-gradient(circle, var(--dot, #d4dbe6) 1.1px, transparent 1.3px); background-size: 20px 20px; }
.cv-wrap.grab, .cv-wrap.grab * { cursor: grab !important; }
.cv-wrap:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cv .dn, .cv .dg, .cv .de { cursor: pointer; }
/* ポートの丸は、線をつないでいる間だけ出す */
.cv .dp { cursor: crosshair; display: none; }
.cv .dp.show { display: inline; }
.cv .dp:hover { fill: #dbeafe; stroke-width: 2.6; }
.cv .dc { cursor: crosshair; }
.cv .dc .dc-line { stroke-opacity: .55; }
.cv .dc .dc-glow, .cv .dc .dc-tip { display: none; }
/* 枠に合わせたら、選択の青と区別できるよう緑にし、破線を流して光らせる */
.cv .dc:hover .dc-line { stroke: #16a34a; stroke-opacity: 1; stroke-width: 2.5px; vector-effect: non-scaling-stroke; stroke-dasharray: 7 5; animation: dc-march .7s linear infinite; }
.cv .dc:hover .dc-glow { display: inline; stroke-width: 12px; vector-effect: non-scaling-stroke; animation: dc-pulse 1.1s ease-in-out infinite; }
.cv .dc:hover .dc-tip { display: inline; }
@keyframes dc-march { to { stroke-dashoffset: -12; } }
@keyframes dc-pulse { 0%, 100% { stroke-opacity: .1; } 50% { stroke-opacity: .32; } }
@media (prefers-reduced-motion: reduce) {
  .cv .dc:hover .dc-line, .cv .dc:hover .dc-glow { animation: none; }
  .cv .dc:hover .dc-glow { stroke-opacity: .2; }
}
.cv .rh { cursor: nwse-resize; }
.cv text { pointer-events: none; }
/* 重ね描き（接続の枠・サイズ変更以外）はクリックを通す。接続先の判定を邪魔しないため */
.cv .ly-overlay { pointer-events: none; }
.cv .ly-overlay .dc, .cv .ly-overlay .rh, .cv .ly-overlay .eb, .cv .ly-overlay .ea { pointer-events: auto; }
.cv .eb, .cv .ea { cursor: move; }
.cv .ea:hover circle + circle { fill: #2563eb; stroke-opacity: 1; }
.cv .dn:hover .dn-hit:not([stroke]) { fill: rgba(37,99,235,.045); }
.cv .de:hover .de-hit { stroke: rgba(37,99,235,.14); }
.cv-wrap.tool-connect .dn:hover .dn-hit:not([stroke]) { fill: rgba(22,163,74,.07); }
.cv-wrap.dark .dn:hover .dn-hit:not([stroke]) { fill: rgba(147,197,253,.08); }

/* つなぐモードの案内（キャンバスの上） */
.cv-mode { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: max-content; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; background: var(--ink); color: #fff; border-radius: var(--r); font-size: 13px; box-shadow: 0 6px 20px rgba(15,23,42,.18); max-width: calc(100% - 24px); z-index: 5; }
.cv-mode .btn.small { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); white-space: nowrap; }
.cv-mode .btn.small:hover { background: rgba(255,255,255,.1); }
/* 最初の一度だけの、つなぎ方の案内（キャンバスの上） */
.cv-coach { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; width: min(620px, calc(100% - 24px)); background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r); box-shadow: 0 6px 20px rgba(15,23,42,.08); z-index: 4; }
.cv-coach p { margin: 0; flex: 1; font-size: 12.5px; line-height: 1.7; color: var(--sub); }
.cv-coach b { color: var(--ink); }
.cv-coach-fig { flex: none; }
.cv-coach-act { display: flex; align-items: center; gap: 4px; flex: none; }
.cv-coach .for-touch { display: none; }
@media (hover: none) {
  .cv-coach .for-touch { display: inline; }
  .cv-coach .for-mouse { display: none; }
}
.cv-wrap.dark .cv-coach { background: #152033; border-color: #2c3a52; border-left-color: #60a5fa; }
.cv-wrap.dark .cv-coach p { color: #c7d2e3; }
.cv-wrap.dark .cv-coach b { color: #fff; }

/* その場で名前を変える入力欄 */
.cv-note-edit { position: fixed; z-index: 40; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: #fff8db; border: 1.5px solid var(--accent); border-radius: var(--r); box-shadow: 0 6px 20px rgba(15,23,42,.16); }
.cv-note-edit input, .cv-note-edit textarea { width: 100%; border: 1px solid #e5c95c; border-radius: 4px; background: #fff; padding: 5px 8px; font: 13px var(--font); color: var(--ink); outline: none; resize: vertical; }
.cv-note-edit input { font-weight: 700; }
.cv-note-edit input:focus, .cv-note-edit textarea:focus { border-color: var(--accent); }
.cv-note-edit p { margin: 0; font-size: 11px; color: var(--muted); }
.cv-inline { position: fixed; z-index: 40; height: 28px; padding: 3px 8px; border: 1.5px solid var(--accent); border-radius: var(--r); background: #fff; font: 700 13px var(--font); color: var(--ink); box-shadow: 0 4px 14px rgba(15,23,42,.14); outline: none; }

/* 機器を選んで追加する窓 */
.pick { position: fixed; z-index: 50; width: 320px; max-width: calc(100vw - 16px); background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 12px 32px rgba(15,23,42,.16); padding: 10px; font-family: var(--font); font-size: 13px; color: var(--ink); }
.pick-head { font-size: 12px; font-weight: 700; color: var(--sub); margin: 0 2px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick input[type="search"] { width: 100%; border: 1px solid var(--line2); border-radius: var(--r); padding: 6px 8px; margin-bottom: 8px; background: #fff; }
.pick input[type="search"]:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--accent); }
.pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; max-height: 280px; overflow: auto; }
.pick-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 2px 6px; border: 1px solid transparent; background: transparent; border-radius: var(--r); cursor: pointer; min-width: 0; font-size: 11px; line-height: 1.25; color: var(--sub); }
.pick-item span:last-child { word-break: keep-all; overflow-wrap: anywhere; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pick-item:hover, .pick-item:focus-visible { background: var(--bg); border-color: var(--line); outline: none; }
.pick-ic { display: flex; }
.pick-none { grid-column: 1 / -1; margin: 8px 2px; color: var(--muted); font-size: 12px; }

/* 操作とショートカット */
.kb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-table th, .kb-table td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.6; }
.kb-table th { font-weight: 400; color: var(--sub); width: 44%; }
.kb-table td { font-weight: 700; }
.cv-empty { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 24px; max-width: 380px; width: calc(100% - 32px); }
.cv-empty h2 { margin: 0 0 6px; font-size: 16px; }
.cv-empty p { margin: 0 0 14px; color: var(--sub); line-height: 1.7; }
.cv-empty .btn-row { justify-content: center; }
.cv-zoom { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.cv-zoom button { border: 0; background: transparent; height: 32px; min-width: 32px; padding: 0 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.cv-zoom button:hover { background: var(--bg); }
.cv-zoom #zoom-level { min-width: 52px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cv-zoom button[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); }
.cv .ly-drawings { pointer-events: none; }
/* 下の道具（選択・移動・手書き） */
.cv-tools { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 3px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 4px 14px rgba(15,23,42,.08); z-index: 4; }
.cv-tools button { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px 0 8px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; color: var(--sub); font-size: 12px; font-weight: 600; white-space: nowrap; }
.cv-tools button:hover { background: var(--bg); color: var(--ink); }
.cv-tools button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.cv-tools-sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
/* アイコンだけのボタン。名前はマウスを合わせたとき（キーボードで選んだとき）に上に出す */
.cv-tools button { position: relative; }
.cv-tools button:has(> svg + .cv-tip) { padding: 0 8px; }
.cv-tools .cv-tip { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); padding: 4px 8px; border-radius: 4px; background: #0f172a; color: #fff; font-size: 11px; font-weight: 600; line-height: 1.3; white-space: nowrap; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .12s; }
.cv-tools button:hover .cv-tip, .cv-tools button:focus-visible .cv-tip { opacity: 1; visibility: visible; }
/* 消す道具（消しゴム・削除）は赤で見分ける */
.cv-tools [data-tool="eraser"], .cv-tools [data-tool="delete"] { color: var(--danger); }
.cv-tools [data-tool="eraser"]:hover, .cv-tools [data-tool="delete"]:hover { background: #fef2f2; color: var(--danger); }
.cv-tools [data-tool="eraser"][aria-pressed="true"], .cv-tools [data-tool="delete"][aria-pressed="true"] { background: var(--danger); color: #fff; }
.cv-wrap.dark .cv-tools [data-tool="eraser"], .cv-wrap.dark .cv-tools [data-tool="delete"] { color: #f87171; }
.cv-wrap.dark .cv-tools [data-tool="eraser"]:hover, .cv-wrap.dark .cv-tools [data-tool="delete"]:hover { background: rgba(248,113,113,.12); }
.cv-wrap.dark .cv-tools [data-tool="eraser"][aria-pressed="true"], .cv-wrap.dark .cv-tools [data-tool="delete"][aria-pressed="true"] { background: #dc2626; color: #fff; }
.cv-ink { position: absolute; left: 50%; bottom: 56px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 4px 14px rgba(15,23,42,.08); z-index: 4; }
.cv-ink-sw { display: flex; gap: 4px; }
.cv-ink-sw[hidden] { display: none; }
.cv-sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; padding: 0; }
.cv-sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.cv-ink-sep { width: 1px; height: 20px; background: var(--line); }
.cv-ink-sep[hidden], .cv-ink-sz[hidden] { display: none; }
.cv-ink-sz { display: flex; gap: 2px; }
.cv-ink .cv-sz { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; }
.cv-ink .cv-sz:hover { background: #f1f5f9; }
.cv-ink .cv-sz[aria-pressed="true"] { border-color: var(--ink); background: #fff; }
.cv-sz-dot { width: var(--d); height: var(--d); border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(15,23,42,.15); }
.cv-wrap.dark .cv-ink .cv-sz[aria-pressed="true"] { background: #1e2a40; }
.cv-ink-clear { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--danger); white-space: nowrap; }
.cv-ink-clear:hover:not(:disabled) { background: #fef2f2; }
.cv-ink-clear:disabled { color: var(--muted); cursor: default; }
/* キャンバスの幅に合わせる（左下の拡大・縮小と重ならないように） */
.cv-wrap { container-type: inline-size; }
@container (max-width: 919px) {
  .cv-tools { left: 12px; transform: none; bottom: 54px; }
  .cv-ink { left: 12px; transform: none; bottom: 98px; }
}
@container (max-width: 419px) {
  .cv-tools button span:not(.cv-tip) { display: none; }
  .cv-tools button { padding: 0 8px; }
}
@container (max-width: 739px) {
  .cv-tools { left: 12px; transform: none; bottom: 54px; }
  .cv-ink { left: 12px; transform: none; bottom: 98px; }
}
.cv-wrap.dark .cv-tools, .cv-wrap.dark .cv-ink { background: #152033; border-color: #2c3a52; }
.cv-wrap.dark .cv-tools button { color: #c7d2e3; }
.cv-wrap.dark .cv-tools button[aria-pressed="true"] { color: #fff; }
/* 道具ごとのカーソル */
.cv-wrap.tool-hand, .cv-wrap.tool-hand .cv * { cursor: grab !important; }
.cv-wrap.tool-hand.grabbing, .cv-wrap.tool-hand.grabbing .cv * { cursor: grabbing !important; }
.cv-wrap.tool-pen .cv, .cv-wrap.tool-pen .cv *, .cv-wrap.tool-marker .cv, .cv-wrap.tool-marker .cv * { cursor: crosshair !important; }
.cv-wrap.tool-eraser .cv, .cv-wrap.tool-eraser .cv *, .cv-wrap.tool-delete .cv, .cv-wrap.tool-delete .cv * { cursor: none !important; }
.minimap { position: absolute; right: 12px; bottom: 61px; width: 168px; height: 108px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; overflow: hidden; }
.minimap svg { width: 100%; height: 100%; display: block; }
/* 右下の Powered by バッジ（サイトのヘッダーと同じロゴの書き方） */
.cv-badge { position: absolute; right: 12px; bottom: 12px; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 16px 7px; box-shadow: 0 2px 8px rgba(15,23,42,.06); background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; line-height: 1.1; }
.cv-badge:hover { border-color: var(--accent); }
.cv-badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cv-badge-by { font-size: 8.5px; color: var(--muted); letter-spacing: .03em; }
.cv-badge-name { font-family: "Poppins", system-ui, sans-serif; font-weight: 800; font-size: 13px; letter-spacing: .01em; color: #020617; }
.cv-badge-name .tb-infra { color: #0000ff; font-weight: 800; }
.cv-wrap.dark .cv-badge { background: #152033; border-color: #2c3a52; }
.cv-wrap.dark .cv-badge-by { color: #94a3b8; }
.cv-wrap.dark .cv-badge-name { color: #e5ecf6; }
.cv-wrap.dark .cv-badge-name .tb-infra { color: #60a5fa; }
.cv-wrap.dark .cv-zoom, .cv-wrap.dark .minimap { background: #152033; border-color: #2c3a52; color: #e5ecf6; }

/* 右パネル */
.rp-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.rp-tabs button { flex: 1; border: 0; background: transparent; padding: 12px 6px 10px; cursor: pointer; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.rp-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.rp-body { flex: 1; overflow: auto; padding-bottom: 40px; }
.sec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sec h3 { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--sub); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span, .label { font-size: 12px; color: var(--sub); }
.field small { font-size: 11px; }
.dg-editor input[type="email"], .dg-editor input[type="text"], .dg-editor input[type="number"], .dg-editor input[type="search"]:not(.lib-search input):not(.tp-search input), .dg-editor select, .dg-editor textarea,
.tool-page .fi { width: 100%; border: 1px solid var(--line2); border-radius: var(--r); padding: 6px 8px; background: #fff; min-width: 0; }
.dg-editor textarea { resize: vertical; line-height: 1.6; }
/* セレクトの矢印：ブラウザ既定の矢印は端に寄りすぎるので、自前の矢印を余白つきで置く */
.dg-editor select, .tool-page select.fi { appearance: none; -webkit-appearance: none; padding-right: 30px; background-color: #fff; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23526077' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 12px; }
.dg-editor input:focus, .dg-editor select:focus, .dg-editor textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--accent); }
/* 枠つきの箱に入れた検索欄は、箱のほうで枠とフォーカスを見せる（欄そのものに枠を重ねない） */
.dg-editor .tp-search input:focus, .dg-editor .lib-search input:focus { outline: none; }
.dg-editor .mono, .dg-editor .ports input, .dg-editor .routes input { font-family: var(--mono); font-size: 12px; }
.dg-editor .invalid { border-color: var(--danger) !important; background: #fef2f2 !important; }
.check { display: flex; align-items: center; gap: 7px; margin: 2px 0 6px; cursor: pointer; line-height: 1.4; }
.check input { margin: 0; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.checks { display: flex; flex-direction: column; }
.checks.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.6; }
.pad { padding: 10px 14px; margin: 0; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }
.ports { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.port { border: 1px solid var(--line); border-radius: var(--r); padding: 7px; display: flex; flex-direction: column; gap: 6px; background: #fbfcfe; }
.port-head { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; }
.port-row2 { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 6px; }
.routes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.route { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 4px; align-items: center; }
.arrow { color: var(--muted); }
.edge-ends { margin: 0 0 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 32px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--r); background: #fff; cursor: pointer; white-space: nowrap; color: var(--ink); text-decoration: none; font-size: 13px; }
.btn:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
/* サイト共通の Tailwind の .block（display: block）に負けないように、2 クラスで flex を指定する */
.btn.block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.btn-grid.two { grid-template-columns: 1fr 1fr; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; background: transparent; border-radius: var(--r); cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
.icon-btn:disabled { opacity: .3; }
.ic { display: inline-flex; }

/* クイック操作 */
.qa-list { display: flex; flex-direction: column; padding: 8px; gap: 4px; }
.qa-list > .sec { padding: 10px 6px; border: 0; }
.qa-title { margin: 6px 6px 8px; }
.qa { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; }
.qa:hover { border-color: var(--line2); background: #fbfcfe; }
.qa.open { border-color: var(--accent); background: var(--accent-bg); }
.qa.primary { border-color: var(--accent); }
.qa.primary .qa-label { color: var(--accent-ink); }
.qa-label { font-weight: 700; }
.qa-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.qa-wrap { display: flex; flex-direction: column; }
.qa-form { border: 1px solid var(--accent); border-top: 0; padding: 10px; margin-top: -2px; background: #fff; border-radius: 0 0 var(--r) var(--r); }
.qa-form[hidden] { display: none; }
.qa-list > .qa-form { border-top: 1px solid var(--line); margin: 0; border-color: var(--line); }
.order, .deps { margin: 0 0 8px; padding: 0; list-style: none; }
.order li, .deps li { display: flex; align-items: center; gap: 4px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.order li span, .deps li span { flex: 1; }

/* ドロワー（狭い画面） */
.drawer-backdrop { display: none; }
.nf { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 5; padding: 20px; }
.nf[hidden] { display: none; }
.nf-box { max-width: 460px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.nf-box h2 { margin: 0 0 8px; font-size: 17px; }
.nf-box p { color: var(--sub); line-height: 1.8; }

/* ダイアログ */
.dlg { border: 1px solid var(--line); border-radius: 6px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); color: var(--ink); font-family: var(--font); font-size: 13px; box-shadow: 0 20px 50px rgba(15,23,42,.18); display: flex; flex-direction: column; }
.dlg:not([open]) { display: none; }
.dlg.wide { width: min(1040px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(15,23,42,.42); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 15px; }
.dlg-body { padding: 16px 18px; overflow: auto; flex: 1; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-text { line-height: 1.8; margin: 0; }
.dlg h3 { font-size: 13px; margin: 14px 0 8px; }
.dlg .field { margin-bottom: 12px; }
/* 共有 */
.sh h3:first-child, .sh .sh-title + h3 { margin-top: 0; }
.sh-title { margin: 0 0 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-link, .sh-add { display: flex; gap: 6px; margin: 4px 0 6px; }
.sh-link input, .sh-add input { flex: 1; }
.sh-add .sh-role, .sh-members .sh-role { width: auto; flex: none; }
.sh .small { margin: 0 0 8px; }
.sh-members { list-style: none; margin: 8px 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.sh-members li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.sh-members li + li { border-top: 1px solid var(--line); }
.sh-members .sh-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sh-members .sh-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-members .sh-state { font-size: 11px; color: var(--warn); }
.sh-members .sh-state.on { color: var(--ok); }
.sh-members .btn { height: 28px; padding: 0 9px; }
.preview { border: 1px solid var(--line); border-radius: var(--r); background: #fff; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.preview svg { width: 100%; height: auto; max-height: inherit; display: block; }
.preview.checker { background-color: #fff; background-image: linear-gradient(45deg, #eef2f7 25%, transparent 25%), linear-gradient(-45deg, #eef2f7 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eef2f7 75%), linear-gradient(-45deg, transparent 75%, #eef2f7 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; max-height: 52vh; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 10px; }
.tpl-card { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; }
.tpl-card:hover, .tpl-card:focus-visible { border-color: var(--accent); }
.tpl-card .preview { height: 120px; }
.tpl-card strong { font-size: 13px; line-height: 1.5; }
.tpl-meta { display: flex; gap: 4px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 3px; background: var(--bg); color: var(--sub); border: 1px solid var(--line); }
.tag.blue { background: var(--accent-bg); color: var(--accent-ink); border-color: #bfdbfe; }
.tpl-wizard { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.tpl-wizard.static { grid-template-columns: 260px minmax(0, 1fr); }
.tpl-side h3 { font-size: 15px; margin: 0 0 6px; }
.tpl-form { margin-top: 12px; }
.tpl-preview { position: sticky; top: 0; }
.errors p { margin: 0 0 6px; color: var(--danger); font-size: 12px; line-height: 1.6; }
.errors p::before { content: '・'; }
.modes { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; margin: 12px 0 0; }
.modes legend { font-size: 12px; color: var(--sub); padding: 0 4px; }
.radio { display: flex; gap: 7px; align-items: center; margin: 4px 0; cursor: pointer; }
.radio input { accent-color: var(--accent); margin: 0; }
table.mini { border-collapse: collapse; font-size: 12px; width: 100%; }
table.mini th, table.mini td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.mini th { color: var(--sub); font-weight: 700; white-space: nowrap; }
table.mini td.num input { width: 56px; }
table.mini td input[type="text"] { min-width: 90px; }
td.before { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(100,116,139,.5); font-family: var(--mono); }
td.after { color: var(--ok); font-weight: 700; font-family: var(--mono); }
td.arrow { color: var(--muted); }
.steps { margin-bottom: 12px; }
.diff-sum { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 3px; background: var(--bg); border: 1px solid var(--line); }
.chip.add { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.chip.del { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.chip.chg { background: #eff6ff; border-color: #bfdbfe; color: var(--accent-ink); }
.diff-list { margin: 0; padding: 0; list-style: none; }
.diff-list > li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.diff-list.add > li > span::before { content: '＋ '; color: var(--ok); font-weight: 700; }
.diff-list.del > li > span::before { content: '－ '; color: var(--danger); font-weight: 700; }
.diff-list table { margin-top: 4px; }
.ip-dialog { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; }
.ip-targets { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; margin-bottom: 10px; }
.ip-targets small { margin-left: 4px; }
.export { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; }
.opt-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--r); padding: 8px 10px; line-height: 1.7; font-size: 12px; color: #78350f; }
pre.json { margin: 0; max-height: 52vh; overflow: auto; font-family: var(--mono); font-size: 11px; background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: var(--r); white-space: pre-wrap; word-break: break-all; }
.check h3.lv-error { color: var(--danger); }
.check h3.lv-warning { color: var(--warn); }
.check h3.lv-notice { color: var(--sub); }
.issues { list-style: none; padding: 0; margin: 0; }
.issue { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 8px 4px; cursor: pointer; line-height: 1.6; }
.issue:hover:not(:disabled) { background: var(--bg); }
.issue.lv-error::before { content: '● '; color: var(--danger); }
.issue.lv-warning::before { content: '● '; color: #d97706; }
.issue.lv-notice::before { content: '● '; color: var(--muted); }
.ok { color: var(--ok); font-weight: 700; }

.menu { position: fixed; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 30px rgba(15,23,42,.14); padding: 4px; min-width: 220px; font-family: var(--font); font-size: 13px; }
.menu button { display: flex; justify-content: space-between; align-items: center; gap: 24px; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 3px; cursor: pointer; color: var(--ink); white-space: nowrap; }
.menu kbd { font: 11px var(--font); color: var(--muted); }
.menu button:hover, .menu button:focus-visible { background: var(--bg); outline: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .18s; background: #0f172a; color: #fff; padding: 9px 16px; border-radius: var(--r); font-size: 13px; z-index: 100; max-width: calc(100vw - 32px); font-family: var(--font); line-height: 1.6; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #991b1b; }

@media (max-width: 1180px) {
  .ws { grid-template-columns: var(--lw, 200px) minmax(0, 1fr) var(--rw, 312px); }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .tb-label { display: none; }
  #btn-connect .tb-label { display: inline; }
}
@media (max-width: 899px) {
  .minimap { display: none !important; }
  .only-narrow { display: inline-flex !important; }
  .hide-narrow { display: none !important; }
  .ws { grid-template-columns: minmax(0, 1fr); }
  .side-rz, .side-hide, .side-rail { display: none !important; }
  .lp .lib-search { margin-right: 10px; }
  .rp .rp-tabs { padding-right: 8px; }
  .lp, .rp { position: absolute; top: 0; bottom: 0; z-index: 20; width: min(88vw, 360px); transition: transform .2s ease; box-shadow: 0 10px 40px rgba(15,23,42,.2); }
  .lp { left: 0; transform: translateX(-105%); }
  .rp { right: 0; transform: translateX(105%); }
  .open-left .lp, .open-right .rp { transform: none; }
  .open-left .drawer-backdrop, .open-right .drawer-backdrop { display: block; position: absolute; inset: 0; z-index: 15; background: rgba(15,23,42,.3); }
  .lib-grid { grid-template-columns: repeat(4, 1fr); }
  .tb { gap: 2px; padding: 0 6px; }
  .tb-logo { font-size: 0; margin-right: 0; }
  .tb-logo::before { content: 'IA'; font-size: 14px; font-weight: 800; color: #0000ff; }
  .tb-logo span, .tb-logo .tb-infra { display: none; }
  .save-status { font-size: 11px; padding: 0 2px; }
  .tb-btn { padding: 0 7px; }
  .tpl-wizard, .tpl-wizard.static, .ip-dialog, .export { grid-template-columns: minmax(0, 1fr); }
  .tpl-preview { position: static; }
}
@media (max-width: 520px) {
  #btn-connect .tb-label { display: none; }
  .cv-coach-fig { display: none; }
  .cv-coach { flex-wrap: wrap; gap: 6px 8px; }
  .cv-coach p { flex: 1 1 100%; }
  .cv-coach-act { margin-left: auto; }
  .cv-mode { font-size: 12px; }
  .save-status { display: none; }
  .tb-title { flex: 1 1 60px; min-width: 50px; }
  .tb-label { display: none; }
  .tb-btn { padding: 0 6px; }
  /* 右上のアカウントが見切れないよう、出力はアイコンだけにする */
  .tb-out { display: none; }
  .acct { margin-left: 0; }
  .acct .acct-btn { width: 30px; }
  .tb-btn.acct-login { padding: 0 6px; font-size: 12px; }
}

/* ---------- ツールのページ（ホーム・テンプレート・マイ図面・ヘルプ） ---------- */
.tool-page { font-family: var(--font); color: var(--ink); }
.tool-page .wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.tp-hero { padding: 120px 0 36px; background: #fff; border-bottom: 1px solid var(--line); }
.tp-hero .eyebrow { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .08em; margin: 0 0 10px; }
.tp-hero h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.35; margin: 0 0 10px; font-weight: 800; letter-spacing: .01em; }
.tp-hero .lead { color: var(--sub); line-height: 1.9; margin: 0 0 22px; max-width: 720px; }
.tp-search { display: flex; align-items: center; gap: 10px; border: 2px solid var(--ink); border-radius: var(--r); padding: 0 14px; background: #fff; max-width: 720px; }
.tp-search input { flex: 1; border: 0; outline: none; padding: 14px 0; font-size: 16px; background: transparent; min-width: 0; font-family: inherit; }
.tp-search:focus-within { border-color: var(--accent); }
.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.tp-chip { border: 1px solid var(--line2); background: #fff; border-radius: 3px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--sub); font-family: inherit; }
.tp-chip:hover, .tp-chip.on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-bg); }
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.tp-actions .btn { height: 42px; padding: 0 18px; font-size: 14px; }
.tp-sec { padding: 40px 0; }
.tp-sec h2 { font-size: 20px; margin: 0 0 6px; font-weight: 800; }
.tp-sec .sub { color: var(--sub); margin: 0 0 18px; line-height: 1.8; }
.tp-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tp-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: #fff; text-decoration: none; color: var(--ink); overflow: hidden; }
.tp-card:hover { border-color: var(--accent); }
.tp-card .thumb { aspect-ratio: 16 / 10; background: #f7f9fc; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tp-card .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tp-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tp-card h3 { font-size: 15px; margin: 0; line-height: 1.5; }
.tp-card p { font-size: 13px; color: var(--sub); margin: 0; line-height: 1.7; }
.tp-card .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 4px; }
.tp-empty { color: var(--sub); padding: 20px 0; }
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.recent-card { border: 1px solid var(--line); border-radius: var(--r); background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.recent-card a.open { display: block; text-decoration: none; color: var(--ink); }
.recent-card .thumb { aspect-ratio: 16 / 10; background: #f7f9fc; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.recent-card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.recent-card .thumb .none { color: var(--muted); font-size: 12px; }
.recent-card .info { padding: 10px 12px 4px; }
.recent-card .info strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-card .info span { font-size: 12px; color: var(--muted); }
.recent-card .info .who { display: block; color: var(--accent-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-card .ops { flex-wrap: wrap; }
.pj-sub { font-size: 15px; margin: 28px 0 6px; }
.pj-login { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r); background: #fff; padding: 12px 16px; margin: 0 0 18px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pj-login p { margin: 0; flex: 1 1 320px; color: var(--sub); line-height: 1.7; font-size: 14px; }
.pj-count { font-variant-numeric: tabular-nums; }
.pj-note-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pj-note-row .sub { flex: 1; min-width: 0; }
.pj-note-row .btn { flex: none; }
/* 図面カードの操作：小さい枠つきボタン。先頭（開く・復元）は主ボタン、削除系は右端に赤字 */
.recent-card .ops { display: flex; gap: 4px; padding: 4px 10px 12px; align-items: center; }
.recent-card .ops button { font-size: 12px; line-height: 1.4; border: 1px solid var(--line2); background: #fff; color: var(--ink); padding: 3px 6px; cursor: pointer; border-radius: 4px; font-family: inherit; white-space: nowrap; }
.recent-card .ops button:hover { border-color: var(--accent); color: var(--accent); }
.recent-card .ops button:first-child { background: var(--accent); border-color: var(--accent); color: #fff; }
.recent-card .ops button:first-child:hover { filter: brightness(.92); color: #fff; }
.recent-card .ops button.danger { margin-left: auto; border-color: transparent; color: var(--danger); padding: 3px 4px; }
.recent-card .ops button.danger:hover { border-color: transparent; text-decoration: underline; }
.recent-card .ops button.icon-op { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; color: var(--muted); }
.recent-card .ops button.icon-op .ic { display: inline-flex; }
.recent-card .ops button.icon-op.danger:hover { color: var(--danger); background: #fef2f2; text-decoration: none; }
.notice-box { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: #fff; padding: 12px 16px; font-size: 13px; line-height: 1.8; color: var(--sub); border-radius: var(--r); }
.drop-zone.drag { outline: 2px dashed var(--accent); outline-offset: 6px; }
.tool-page .crumbs { font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.tool-page .crumbs a { color: var(--muted); }
.td-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.td-preview { margin: 0; border: 1px solid var(--line); border-radius: var(--r); background: #fff; padding: 12px; }
.td-preview img { width: auto; max-width: 100%; height: auto; max-height: 760px; display: block; margin: 0 auto; }
.td-preview figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }
.td-body ol.td-steps { padding-left: 1.5em; list-style: decimal; }
.td-body ul.td-others { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.td-others li { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 12px; line-height: 1.6; background: #fff; }
.td-others li a { display: block; font-weight: 700; font-size: 14px; }
.td-others li span { font-size: 12px; color: var(--muted); }
.td-side { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 12px; }
.td-box { border: 1px solid var(--line); border-radius: var(--r); background: #fff; padding: 16px; }
.td-box h2, .td-box h3 { font-size: 14px; margin: 0 0 10px; }
.td-body h2 { font-size: 18px; margin: 30px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.td-body p, .td-body li { line-height: 1.95; color: #1e293b; }
.td-body ul { padding-left: 1.3em; }
.td-body table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0 16px; background: #fff; }
.td-body th, .td-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.td-body th { background: #f8fafc; white-space: nowrap; }
.td-body code { font-family: var(--mono); font-size: 13px; background: #f1f5f9; padding: 1px 5px; border-radius: 3px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit; font-size: 14px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tm-tabs { margin-bottom: 12px; }
.tm-sub { font-size: 14px; margin: 20px 0 8px; }
.tm-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 8px; }
.tm-grid .recent-card .info { padding-bottom: 10px; }
.tm-grid .recent-card.current { border-color: var(--accent); }
.recent-card .info .tm-now { display: inline-block; margin-left: 6px; color: var(--accent-ink); font-weight: 700; }
.help-body h2 { font-size: 18px; margin: 32px 0 10px; }
.help-body p, .help-body li { line-height: 1.95; }
.help-body table { border-collapse: collapse; font-size: 14px; background: #fff; }
.help-body th, .help-body td { border: 1px solid var(--line); padding: 6px 12px; text-align: left; }
.help-body kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: #fff; }
.tool-page [hidden] { display: none !important; }
.tool-page .tp-sec a:not(.btn):not(.tp-card):not(.open) { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.tp-hero.compact { padding-bottom: 28px; }
.tp-sec .sub.after { margin-top: 16px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: #fff; }
.feature { padding: 18px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.feature h3 { font-size: 15px; margin: 0 0 6px; }
.feature p { font-size: 13px; color: var(--sub); margin: 0; line-height: 1.85; }
.btn.big { height: 46px; font-size: 15px; }
.td-note { font-size: 12px; color: var(--muted); line-height: 1.7; margin: 10px 0 0; }
.td-link { display: block; font-weight: 700; font-size: 14px; }
.td-related { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.storage-note { font-size: 12px; color: var(--muted); margin-top: 18px; }
.help-body table th { white-space: nowrap; background: #f8fafc; }
.help-body ul { padding-left: 1.3em; list-style: disc; }
.help-faq { margin: 0; border-top: 1px solid var(--line); }
.help-faq dt { font-weight: 700; padding: 14px 0 4px; }
.help-faq dd { margin: 0; padding: 0 0 14px; line-height: 1.9; color: #1e293b; border-bottom: 1px solid var(--line); }
.td-body ul { list-style: disc; }
.tool-page .tabs button[aria-selected] { font-family: inherit; }
@media (max-width: 860px) {
  .td-grid { grid-template-columns: minmax(0, 1fr); }
  .td-side { position: static; }
  .tp-hero { padding-top: 96px; }
}
@media (max-width: 600px) {
  .help-body table th { white-space: normal; }
  .feature-grid { grid-template-columns: minmax(0, 1fr); }
}
/* 図面への招待 */
.invite-box { max-width: 640px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r); background: #fff; padding: 16px 20px; margin: 6px 0 10px; line-height: 1.8; }
.invite-box p { margin: 0 0 8px; }
.invite-box .invite-title { font-size: 17px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.invite-box .tp-actions { margin: 14px 0 0; }
.pj-notice { margin: 0 0 16px; }

/* ---------- エディターの上のポップアップ（ツールのトップ・マイ図面） ---------- */
.start { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 28px; background: rgba(15,23,42,.42); }
.start-box { position: relative; width: min(1040px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 20px 50px rgba(15,23,42,.18); padding: 30px 34px 34px; font-size: 14px; line-height: 1.7; outline: none; }
.start-box a { color: var(--accent); }
.start-box a.btn { color: var(--ink); text-decoration: none; }
.start-box a.btn.primary { color: #fff; }
.start-box a.tp-card { color: inherit; text-decoration: none; }
.start-close { position: absolute; top: 12px; right: 12px; }
.start-head .eyebrow { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .08em; margin: 0 0 8px; }
.start-head .eyebrow a { text-decoration: none; }
.start-head h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.35; margin: 0 0 8px; font-weight: 800; }
.start-head .lead { color: var(--sub); margin: 0 0 18px; max-width: 760px; }
.start-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.start-actions .btn { padding: 0 18px; }
.start-sec { margin-top: 30px; }
.start-sec h2 { font-size: 17px; margin: 0 0 6px; }
.start-sec .sub { color: var(--sub); margin: 0 0 12px; }
.start-sec .sub:last-child { margin: 12px 0 0; }
.start-sec .tp-search { margin: 0 0 10px; }
.start-sec .tp-cats { margin-bottom: 14px; }
@media (max-width: 640px) {
  .start { padding: 0; }
  .start-box { max-height: 100%; height: 100%; border-radius: 0; border: 0; padding: 22px 16px 28px; }
}

/* ログイン・新規登録のポップアップ（InfraAcademy のログイン画面 templates/auth と同じ見た目） */
.dlg.au-dlg { width: min(448px, calc(100vw - 24px)); max-width: none; padding: 0; border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; box-shadow: 0 24px 80px rgba(8,24,255,.10), 0 10px 30px rgba(15,23,42,.12); color: #0f172a; }
.au-dlg .dlg-head, .au-dlg .dlg-foot { display: none; }
.au-dlg .dlg-body { padding: 0; overflow: auto; }
.au { position: relative; padding: 40px; font-size: 14px; }
.au .au-close { position: absolute; top: 14px; right: 14px; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: #94a3b8; cursor: pointer; }
.au .au-close:hover { background: #f1f5f9; color: #0f172a; }
.au-logo { margin: 0; font-family: 'Poppins', 'Helvetica Neue', Arial, sans-serif; font-size: 14px; font-weight: 700; color: #020617; letter-spacing: 0; }
.au-logo-infra { color: #0000ff; }
.au-h1 { margin: 12px 0 0; font-size: 24px; line-height: 1.33; font-weight: 900; color: #020617; letter-spacing: 0; }
.au-sub { margin: 8px 0 0; font-size: 14px; line-height: 24px; color: #64748b; }
.au-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 24px; padding: 4px; border-radius: 8px; background: #f1f5f9; }
.au .au-tab { border: 0; border-radius: 6px; padding: 8px 0; background: transparent; font-size: 14px; font-weight: 700; color: #64748b; cursor: pointer; transition: color .15s, background .15s; }
.au .au-tab:hover { color: #0818ff; }
.au .au-tab.on { background: #fff; color: #020617; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.au-form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.au-row[hidden] { display: none; }
.au-label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 700; color: #334155; }
.au input.au-input { display: block; width: 100%; box-sizing: border-box; height: auto; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 16px; line-height: 24px; color: #0f172a; outline: none; transition: border-color .15s, box-shadow .15s; }
.au input.au-input::placeholder { color: #94a3b8; }
.au input.au-input:focus { border-color: #0818ff; box-shadow: 0 0 0 3px #dbeafe; outline: none; }
.au input.au-input[aria-invalid="true"] { border-color: #dc2626; }
.au-pw-wrap { position: relative; }
.au input.au-input.au-pw { padding-right: 40px; }
.au .au-eye { position: absolute; top: 0; bottom: 0; right: 0; display: flex; align-items: center; justify-content: center; width: 40px; border: 0; border-radius: 0 6px 6px 0; background: transparent; color: #94a3b8; cursor: pointer; }
.au .au-eye:hover { color: #0818ff; }
.au .au-submit { width: 100%; padding: 10px 0; border: 0; border-radius: 6px; background: #0818ff; color: #fff; font-size: 16px; font-weight: 700; line-height: 24px; cursor: pointer; transition: background .15s; }
.au .au-submit:hover:not(:disabled) { background: #0000cc; }
.au .au-submit:disabled, .au .au-outline:disabled { opacity: .6; cursor: default; }
.au-err { padding: 10px 12px; border: 1px solid #fecaca; border-radius: 6px; background: #fef2f2; color: #b91c1c; font-size: 14px; font-weight: 700; line-height: 1.6; }
.au-err[hidden] { display: none; }
.au .au-outline { display: flex; width: 100%; box-sizing: border-box; align-items: center; justify-content: center; gap: 8px; padding: 10px 0; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #334155; font-size: 14px; font-weight: 700; line-height: 20px; text-decoration: none; cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.au .au-outline:hover:not(:disabled) { border-color: #0818ff; background: #eff6ff; color: #0818ff; }
.au-pk { margin-top: 12px; }
.au-pk[hidden], .au-forgot[hidden], .au-terms[hidden] { display: none; }
.au-pk-err { margin: 8px 0 0; font-size: 14px; font-weight: 700; color: #b91c1c; }
.au-forgot { margin-top: 16px; text-align: right; }
.au-forgot a { font-size: 14px; font-weight: 700; color: #0818ff; text-decoration: none; }
.au-forgot a:hover { text-decoration: underline; }
.au-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 12px; color: #94a3b8; }
.au-or::before, .au-or::after { content: ''; flex: 1; height: 1px; background: #e2e8f0; }
.au-terms { margin: 20px 0 0; text-align: center; font-size: 11px; line-height: 20px; color: #64748b; }
.au-terms a { color: #0818ff; text-decoration: none; }
.au-terms a:hover { text-decoration: underline; }
.au-legal { margin-top: 24px; padding-top: 20px; border-top: 1px solid #f1f5f9; text-align: center; font-size: 12px; color: #94a3b8; }
.au-legal span { margin: 0 4px; }
.au-legal a { color: inherit; text-decoration: none; }
.au-legal a:hover { color: #0818ff; text-decoration: underline; }
@media (max-width: 520px) {
  .au { padding: 32px 22px 24px; }
}
