/* ===========================================================================
   app.css — mindmap-saas フロントエンド
   DESIGN.md §8.5「CSS 変数ベースのダーク対応」を踏襲する。
   =========================================================================== */

:root {
  --bg: #f7f8fa;
  --bg-canvas: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d9dde3;
  --border-strong: #b9c0ca;
  --text: #1c2027;
  --text-muted: #6b7480;
  --accent: #2f6fdd;
  --accent-soft: #e5eefc;
  --node-bg: #ffffff;
  --node-border: #ccd3dc;
  --branch: #9aa6b4;
  --xlink: #8a7fb8;
  --hit: #ffd54f;
  --danger: #d5372f;
  --ok: #2e8b57;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .08);
  --radius: 8px;
  --side-w: 248px;
  --detail-w: 348px;
  /* 種別の色（kinds.js と対）。見た目は種別で固定する。 */
  --k-domain: #2f6fdd;
  --k-project: #7a4fd6;
  --k-todo: #c47a00;
  --k-note: #6b7480;
  --k-worklog: #2e8b57;
  --k-host: #c2476b;
  --k-service: #1f8a99;
  --k-link: #8a7fb8;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "Yu Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --bg-canvas: #101317;
    --surface: #1c2128;
    --surface-2: #232931;
    --border: #2e3540;
    --border-strong: #414a57;
    --text: #e4e8ee;
    --text-muted: #949dab;
    --accent: #6da2f5;
    --accent-soft: #1e2b40;
    --node-bg: #232931;
    --node-border: #3a424e;
    --branch: #5c6674;
    --xlink: #9d8fd4;
    --hit: #8a6d1f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
    --k-domain: #6da2f5;
    --k-project: #a98bf0;
    --k-todo: #e0a23a;
    --k-note: #949dab;
    --k-worklog: #5fc08a;
    --k-host: #e57f9d;
    --k-service: #4fb9c7;
    --k-link: #9d8fd4;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 9px;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(.5px); }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.primary:hover { filter: brightness(1.08); }
input, select, textarea {
  font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}

/* --- ツールバー ---------------------------------------------------------- */
#mm-toolbar {
  position: fixed; inset: 0 0 auto 0; height: 46px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-brand { color: var(--accent); font-size: 17px; }
#mm-title {
  font-size: 14px; font-weight: 600; margin: 0;
  max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 6px; border-radius: 5px;
}
#mm-title[contenteditable="true"]:hover { background: var(--surface-2); }
#mm-title:focus { outline: 2px solid var(--accent); background: var(--surface); }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

.mm-role {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.mm-role.role-owner { background: var(--accent-soft); color: var(--accent); }

.mm-sync {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.mm-sync.is-synced   { background: #e4f4ea; color: #24704a; }
.mm-sync.is-saving   { background: #fff4d6; color: #8a6516; }
.mm-sync.is-local    { background: var(--surface-2); color: var(--text-muted); }
.mm-sync.is-offline  { background: #e9e9ec; color: #575c66; }
.mm-sync.is-error    { background: #fde7e5; color: #a02a23; }
.mm-sync.is-conflict { background: #e7edfd; color: #2a52a8; }
@media (prefers-color-scheme: dark) {
  .mm-sync.is-synced   { background: #17351f; color: #7fd6a2; }
  .mm-sync.is-saving   { background: #3a2f10; color: #e3c268; }
  .mm-sync.is-error    { background: #3d1c1a; color: #f0938c; }
  .mm-sync.is-conflict { background: #1b2740; color: #8fb3f5; }
}

#mm-banner {
  position: fixed; top: 46px; left: 0; right: 0; z-index: 25;
  display: none; padding: 7px 14px; font-size: 12px;
  background: #fff7e0; color: #7a5b12; border-bottom: 1px solid #e8d9a8;
}
#mm-banner.is-open { display: block; }
@media (prefers-color-scheme: dark) {
  #mm-banner { background: #33290f; color: #e5cf94; border-bottom-color: #4a3d18; }
}

/* --- キャンバス ---------------------------------------------------------- */
#canvas {
  position: fixed; top: 46px; left: var(--side-w); bottom: 26px;
  width: calc(100% - var(--side-w) - var(--detail-w)); height: calc(100% - 72px);
  background: var(--bg-canvas);
  display: block; cursor: default; outline: none;
  touch-action: none;
}
#canvas.is-panning { cursor: grabbing; }
#canvas.is-dragging { cursor: grabbing; }

/* ノード ------------------------------------------------------------------ */
.mm-node { cursor: pointer; }
.mm-node .mm-box {
  fill: var(--node-bg);
  stroke: var(--node-border);
  stroke-width: 1;
  filter: drop-shadow(0 1px 1.5px rgba(16, 24, 40, .10));
}
@media (prefers-color-scheme: dark) {
  .mm-node .mm-box { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
}
.mm-node:hover .mm-box { stroke: var(--border-strong); }
.mm-node .mm-accent { fill: var(--accent); }
.mm-node .mm-label {
  font-family: var(--font); font-size: 13px; fill: var(--text);
  pointer-events: none; dominant-baseline: alphabetic;
}
.mm-node .mm-badge {
  font-size: 11px; fill: var(--text-muted); pointer-events: all; cursor: help;
}
.mm-node .mm-badge-host { font-size: 8px; }
.mm-node.is-selected .mm-box { stroke: var(--accent); stroke-width: 1.6; }
.mm-node.is-focus   .mm-box { stroke-width: 2; }
.mm-node.is-editing .mm-label { opacity: 0; }
.mm-node.is-hit .mm-box { stroke: var(--hit); stroke-width: 2; }
.mm-node.is-link-source .mm-box {
  stroke: var(--xlink); stroke-width: 2; stroke-dasharray: 4 3;
}

/* 折りたたみトグル */
.mm-toggle { cursor: pointer; }
.mm-toggle .mm-toggle-bg {
  fill: var(--surface); stroke: var(--border-strong); stroke-width: 1;
}
.mm-toggle:hover .mm-toggle-bg { fill: var(--accent-soft); stroke: var(--accent); }
.mm-toggle .mm-toggle-icon {
  stroke: var(--text-muted); stroke-width: 1.6; stroke-linecap: round; fill: none;
}
.mm-toggle:hover .mm-toggle-icon { stroke: var(--accent); }
.mm-toggle .mm-toggle-count {
  font-size: 10px; fill: var(--text-muted); font-family: var(--font);
}
.mm-node.is-collapsed .mm-box { stroke-dasharray: 0; stroke: var(--border-strong); }

/* クロスリンク作成ハンドル */
.mm-link-handle {
  fill: var(--xlink); opacity: 0; cursor: crosshair;
  transition: opacity .12s;
}
.mm-node:hover .mm-link-handle,
.mm-node.is-selected .mm-link-handle { opacity: .75; }
.mm-link-handle:hover { opacity: 1; }

/* 枝を足す ＋ -------------------------------------------------------------- */
.mm-add { cursor: pointer; opacity: 0; transition: opacity .12s; }
.mm-add .mm-add-bg { fill: var(--surface); stroke: var(--accent); stroke-width: 1.2; }
.mm-add .mm-add-icon { stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; fill: none; }
.mm-node:hover .mm-add,
.mm-node.is-selected .mm-add { opacity: .85; }
/* 中心は、選んでいなくても薄く出しておく（左にも足せることが見て分かるように） */
.mm-node.is-center .mm-add { opacity: .5; }
.mm-node.is-center:hover .mm-add,
.mm-node.is-center.is-selected .mm-add { opacity: .9; }
.mm-add:hover { opacity: 1 !important; }
.mm-add:hover .mm-add-bg { fill: var(--accent-soft); }
body.is-readonly .mm-add { display: none; }

/* 枝 ---------------------------------------------------------------------- */
.mm-branch {
  fill: none; stroke: var(--branch); stroke-linecap: round;
  pointer-events: none;
}
.mm-branch.is-selected { stroke: var(--accent); }

/* クロスリンク (§8.4) ------------------------------------------------------ */
.mm-xlink {
  fill: none;
  stroke: var(--xlink);
  stroke-width: 1.5;
  opacity: .35;                 /* 通常時: マップ全体の可読性を落とさない */
  pointer-events: none;
  transition: opacity .15s, stroke-width .15s;
}
.mm-xlink-dashed { stroke-dasharray: 6 4; }
.mm-xlink-dotted { stroke-dasharray: 1.5 3.5; }
.mm-xlink-solid  { stroke-dasharray: none; }
.mm-xlink.is-active { opacity: 1; stroke-width: 2.4; }
.mm-xlink.is-selected { stroke-width: 3; }
/* 折りたたみで集約されたリンクは細い破線で「集約」を示す */
.mm-xlink.is-aggregated {
  stroke-width: 1; stroke-dasharray: 2 5; opacity: .28;
}
.mm-xlink.is-aggregated.is-active { opacity: .8; stroke-width: 1.6; }

.mm-xlink-hit {
  fill: none; stroke: transparent; stroke-width: 12;
  pointer-events: stroke; cursor: pointer;
}
.mm-arrow-head { fill: var(--xlink); opacity: .5; }
.mm-arrow-head.is-active { opacity: 1; }
.mm-xlink-label {
  font-family: var(--font); font-size: 10.5px; fill: var(--xlink);
  pointer-events: none;
}
.mm-xlink-label-bg { fill: var(--bg-canvas); opacity: .9; pointer-events: none; }
.mm-link-preview {
  fill: none; stroke: var(--xlink); stroke-width: 2;
  stroke-dasharray: 5 4; opacity: .8; pointer-events: none;
}

/* オーバーレイ ------------------------------------------------------------ */
.mm-sel-ring {
  fill: none; stroke: var(--accent); stroke-width: 1.2;
  stroke-dasharray: 4 3; opacity: .6; pointer-events: none;
}
.mm-sel-ring.is-focus { opacity: .95; stroke-width: 1.6; stroke-dasharray: none; }
.mm-marquee {
  fill: var(--accent); fill-opacity: .08;
  stroke: var(--accent); stroke-width: 1; stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke; pointer-events: none;
}
svg.is-marquee { cursor: crosshair; }
.mm-drop-line {
  stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; pointer-events: none;
}
.mm-drop-parent {
  fill: var(--accent); fill-opacity: .1;
  stroke: var(--accent); stroke-width: 2; pointer-events: none;
}

/* --- インライン編集 ------------------------------------------------------ */
#mm-inline-editor {
  position: fixed; display: none; z-index: 40;
  padding: 6px 9px; font-size: 13px; line-height: 18px;
  border: 2px solid var(--accent); border-radius: 6px;
  background: var(--surface); box-shadow: var(--shadow);
}

/* 待ち受け: ノードを選んでいる間、見えないままフォーカスを持つ（打てばそのまま名前の編集になる） */
#mm-inline-editor.is-standby {
  left: 50% !important; top: 50% !important;
  width: 1px !important; min-height: 0 !important; height: 1px;
  padding: 0; border: 0; opacity: 0; pointer-events: none; box-shadow: none;
}

/* --- ステータスバー ------------------------------------------------------ */
#mm-status {
  position: fixed; inset: auto 0 0 0; height: 26px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; font-size: 11px; color: var(--text-muted);
  background: var(--surface); border-top: 1px solid var(--border);
}
.st-hint { opacity: .75; }
@media (max-width: 720px) { .st-hint { display: none; } }

/* --- 検索 ---------------------------------------------------------------- */
#mm-search {
  position: fixed; top: 58px; right: calc(var(--detail-w) + 14px); z-index: 35;
  display: none; align-items: center; gap: 5px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
#mm-search.is-open { display: flex; }
#mm-search input { width: 210px; }
#mm-search .count { font-size: 11px; color: var(--text-muted); min-width: 42px; text-align: center; }

/* --- ヘルプ / 致命的エラー ---------------------------------------- */
#mm-help, #mm-fatal {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center;
  background: rgba(14, 18, 24, .45); backdrop-filter: blur(2px);
}
#mm-help.is-open, #mm-fatal.is-open { display: flex; }
.help-panel, .fatal-panel {
  width: min(560px, 92vw); max-height: 80vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.help-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.help-head h2 { margin: 0; font-size: 14px; }
.help-body { padding: 14px 16px; }

.help-body h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin: 14px 0 6px;
}
.help-body h3:first-child { margin-top: 0; }
.help-body table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.help-body td { padding: 3px 0; vertical-align: top; }
.help-body td.key { width: 175px; white-space: nowrap; }
.help-body kbd {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 10.5px; padding: 1px 5px; margin-right: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px;
}
.fatal-panel { padding: 24px; text-align: center; }
.fatal-panel h2 { margin: 0 0 8px; font-size: 15px; }
.fatal-panel p { font-size: 13px; color: var(--text-muted); white-space: pre-wrap; }
.fatal-panel a { color: var(--accent); font-size: 12.5px; }

/* --- トースト ------------------------------------------------------------ */
#mm-toast {
  position: fixed; bottom: 42px; left: 50%; transform: translateX(-50%) translateY(8px);
  z-index: 60; padding: 8px 16px; font-size: 12.5px;
  background: #23272e; color: #fff; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  box-shadow: var(--shadow); max-width: 80vw;
}
#mm-toast.is-open { opacity: .95; transform: translateX(-50%) translateY(0); }

/* --- 読み取り専用 -------------------------------------------------------- */
body.is-readonly #btn-undo,
body.is-readonly #btn-redo { display: none; }
body.is-readonly .mm-link-handle { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mm-node, .mm-branch { transition: none !important; }
}

/* ===========================================================================
   三分割の画面（要件定義 v2 §6.1）
   =========================================================================== */
.tb-mid { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; min-width: 0; overflow: hidden; }
.tb-left { flex-shrink: 1; }
.tb-right { flex-shrink: 0; }
#mm-title { max-width: 16vw; }

/* 今見ている場所 */
#mm-crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; }
#mm-crumbs button {
  border: none; background: transparent; padding: 2px 6px; color: var(--text-muted);
  max-width: 14em; overflow: hidden; text-overflow: ellipsis;
}
#mm-crumbs button:hover { color: var(--accent); background: var(--surface-2); }
#mm-crumbs button.is-here { color: var(--text); font-weight: 600; }
#mm-crumbs .sep { color: var(--border-strong); }

/* 種別の絞り込み */
.kf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
}
.kf-chip .g { color: var(--k, var(--text-muted)); }
.kf-chip.is-on { background: color-mix(in srgb, var(--k, var(--accent)) 14%, var(--surface)); border-color: var(--k, var(--accent)); color: var(--text); }

.tb-inbox b { font-weight: 600; margin-left: 2px; }
.tb-inbox.has-items { border-color: var(--k-todo); }
.tb-inbox.has-items b { color: var(--k-todo); }
#sel-depth { padding: 3px 4px; font-size: 12px; }

/* 種別ごとの色。地図・一覧・絞り込みで同じ変数を使う。 */
.kind-domain  { --k: var(--k-domain); }
.kind-project { --k: var(--k-project); }
.kind-todo    { --k: var(--k-todo); }
.kind-note    { --k: var(--k-note); }
.kind-worklog { --k: var(--k-worklog); }
.kind-host    { --k: var(--k-host); }
.kind-service { --k: var(--k-service); }
.kind-link    { --k: var(--k-link); }

/* 種別ごとのノードの見た目 */
.mm-node .mm-kind {
  font-family: var(--font); font-size: 12px; pointer-events: none;
  fill: var(--k, var(--text-muted));
}
.mm-node[class*="kind-"] .mm-box {
  fill: color-mix(in srgb, var(--k) 9%, var(--node-bg));
  stroke: color-mix(in srgb, var(--k) 45%, var(--node-border));
}
.mm-node[class*="kind-"] .mm-accent { fill: var(--k); }
.mm-node.kind-domain .mm-box, .mm-node.kind-project .mm-box {
  fill: color-mix(in srgb, var(--k) 16%, var(--node-bg));
  stroke: var(--k);
}
.mm-node.is-done .mm-label { text-decoration: line-through; opacity: .5; }
.mm-node.is-done .mm-box { opacity: .6; }
.mm-node.is-managed .mm-box { stroke-dasharray: 3 2; }
.mm-node.is-dim { opacity: .22; }
.mm-node.is-selected .mm-box { stroke: var(--accent); stroke-width: 1.8; stroke-dasharray: none; }

/* --- 左: PJ 一覧 ---------------------------------------------------------- */
#mm-side, #mm-detail {
  position: fixed; top: 46px; bottom: 26px; z-index: 22;
  background: var(--surface); overflow-y: auto; overscroll-behavior: contain;
}
#mm-side { left: 0; width: var(--side-w); border-right: 1px solid var(--border); padding: 8px 0 24px; }
#mm-detail { right: 0; width: var(--detail-w); border-left: 1px solid var(--border); }

.sd-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-muted);
  padding: 12px 14px 4px;
}
.sd-head .n { font-weight: 400; }
.sd-row {
  display: flex; align-items: center; gap: 6px; width: 100%;
  border: none; border-radius: 0; background: transparent; text-align: left;
  padding: 5px 14px; font-size: 13px; line-height: 1.35;
}
.sd-row:hover { background: var(--surface-2); }
.sd-row.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sd-row .g { flex: none; width: 1.1em; text-align: center; color: var(--k, var(--text-muted)); }
.sd-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-row .m { flex: none; font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sd-domain { font-weight: 600; margin-top: 4px; }
.sd-pj { padding-left: 26px; }
.sd-pill {
  flex: none; font-size: 10.5px; line-height: 1; padding: 2px 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.sd-pill.is-open { background: color-mix(in srgb, var(--k-todo) 16%, var(--surface)); color: var(--k-todo); }
.sd-pill.is-late { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.sd-empty { font-size: 12px; line-height: 1.6; color: var(--text-muted); padding: 6px 14px 2px; }
.sd-foot { font-size: 11px; color: var(--text-muted); padding: 14px 14px 0; }

/* --- 右: 詳細 ------------------------------------------------------------- */
.dt-empty { padding: 28px 18px; font-size: 12.5px; line-height: 1.7; color: var(--text-muted); }
.dt-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dt-path { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-label {
  width: 100%; margin-top: 6px; font-size: 15px; font-weight: 600;
  border-color: transparent; background: transparent; padding: 4px 6px; margin-left: -6px;
}
.dt-label:hover { border-color: var(--border); }
.dt-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; font-size: 12px; }
.dt-row label { color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.dt-row select, .dt-row input { font-size: 12px; padding: 3px 6px; }
.dt-row input[type="text"] { width: 9.5em; }
.dt-row .sp { flex: 1; }
.dt-row button { font-size: 12px; padding: 3px 8px; }
.dt-managed { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }

.dt-sec { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.dt-sec > h3 {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-muted);
}
.dt-sec > h3 .n { font-weight: 400; }
.dt-note { width: 100%; min-height: 74px; resize: vertical; font-size: 12.5px; line-height: 1.6; }
.dt-hint { font-size: 11.5px; line-height: 1.6; color: var(--text-muted); margin: 0; }

.dt-hand { font-size: 12.5px; line-height: 1.6; }
.dt-hand ul { margin: 0; padding-left: 1.2em; }
.dt-hand .next { margin-top: 6px; padding: 6px 9px; border-radius: 6px; background: var(--accent-soft); }
.dt-hand .next b { color: var(--accent); font-weight: 600; margin-right: 4px; }
.dt-hand .from { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.dt-list { list-style: none; margin: 0; padding: 0; }
.dt-todo { display: flex; align-items: flex-start; gap: 7px; padding: 3px 0; font-size: 12.5px; line-height: 1.45; }
.dt-todo input[type="checkbox"] { margin: 3px 0 0; flex: none; }
.dt-todo .t { flex: 1; min-width: 0; cursor: pointer; overflow-wrap: anywhere; }
.dt-todo .t:hover { color: var(--accent); }
.dt-todo .d { flex: none; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dt-todo.is-late .d { color: var(--danger); font-weight: 600; }
.dt-todo.is-done .t { text-decoration: line-through; color: var(--text-muted); }
.dt-add { display: flex; gap: 4px; margin-top: 8px; }
.dt-add input { flex: 1; min-width: 0; font-size: 12.5px; }
.dt-add button { flex: none; font-size: 12px; }
details.dt-done { margin-top: 6px; font-size: 11.5px; color: var(--text-muted); }
details.dt-done summary { cursor: pointer; }

.dt-week { font-size: 11px; color: var(--text-muted); margin: 10px 0 3px; }
.dt-week:first-child { margin-top: 0; }
.dt-log { display: block; text-align: left; border: none; background: transparent; border-radius: 6px; padding: 5px 6px; margin: 0 -6px; width: calc(100% + 12px); }
.dt-log:hover { background: var(--surface-2); }
.dt-log .h { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.dt-log .h .day { flex: none; color: var(--k-worklog); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.dt-log .h .ttl { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dt-log .h .host { flex: none; font-size: 10.5px; color: var(--text-muted); }
.dt-log .x { font-size: 11.5px; line-height: 1.5; color: var(--text-muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.dt-link { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 12.5px; }
.dt-link a, .dt-link span.t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); text-decoration: none; }
.dt-link a:hover { text-decoration: underline; }
.dt-link span.t { color: var(--text); }
.dt-link button { flex: none; padding: 0 6px; font-size: 11px; border-color: transparent; color: var(--text-muted); }
.dt-skill span.t { display: flex; gap: 8px; align-items: baseline; }
.dt-skill code { font-size: 12px; }
.dt-skill .ag { font-size: 11px; color: var(--text-muted); }
.dt-host span.t { display: flex; gap: 8px; align-items: baseline; }
.dt-host b { font-size: 12.5px; font-weight: 600; flex: none; }
.dt-host .ag { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.dt-host .g { font-size: 9px; color: var(--text-muted); }
.dt-foot { padding: 12px 14px 28px; font-size: 11px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dt-foot .sp { flex: 1; }
.dt-foot button { font-size: 12px; }
.dt-foot button.danger { color: var(--danger); }

body.is-readonly .dt-add, body.is-readonly .dt-foot button { display: none; }

/* --- 狭い画面: 一覧 / 地図 / 詳細 をタブで切り替える ------------------------ */
#mm-tabs { display: none; }
@media (max-width: 860px) {
  :root { --side-w: 0px; --detail-w: 0px; }
  #mm-kindfilter, #sel-depth, #btn-zoom-in, #btn-zoom-out, #btn-undo, #btn-redo,
  #btn-help, .tb-sep, #mm-role, #mm-title { display: none; }
  #mm-status { display: none; }
  #mm-tabs {
    position: fixed; inset: auto 0 0 0; height: 46px; z-index: 30; display: flex;
    background: var(--surface); border-top: 1px solid var(--border);
  }
  #mm-tabs button { flex: 1; border: none; border-radius: 0; background: transparent; font-size: 13px; color: var(--text-muted); }
  body[data-tab="side"] #mm-tabs button[data-tab="side"],
  body[data-tab="map"] #mm-tabs button[data-tab="map"],
  body[data-tab="detail"] #mm-tabs button[data-tab="detail"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }
  #canvas { bottom: 46px; width: 100%; height: calc(100% - 92px); }
  #mm-side, #mm-detail { width: 100%; bottom: 46px; border: none; display: none; }
  body[data-tab="side"] #mm-side { display: block; }
  body[data-tab="detail"] #mm-detail { display: block; }
  .sd-row { padding-top: 10px; padding-bottom: 10px; font-size: 14px; }
  #mm-search { right: 10px; }
  #mm-toast { bottom: 60px; }
}

/* 一覧の ＋（事業・PJ を足す） */
.sd-head { display: flex; align-items: center; }
.sd-head .n { margin-left: auto; }
.sd-line { display: flex; align-items: center; }
.sd-line > .sd-row { flex: 1; min-width: 0; }
.sd-plus {
  flex: none; margin-left: auto; width: 22px; height: 22px; padding: 0;
  border: 1px solid transparent; border-radius: 5px; background: none;
  color: var(--text-muted); font-size: 13px; line-height: 1; cursor: pointer;
}
.sd-line > .sd-plus { margin: 4px 6px 0 2px; }
.sd-plus:hover { background: var(--surface-2); border-color: var(--border, #d5d9e0); color: var(--text, inherit); }
@media (max-width: 860px) { .sd-plus { width: 32px; height: 32px; font-size: 16px; } }

/* 上の帯の ◈ はマップの一覧へ戻るリンク */
a.tb-brand { text-decoration: none; }
/* 詳細: 地図での側 */
.dt-side .dt-row { display: flex; gap: 6px; flex-wrap: wrap; }
.dt-side button.is-on { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

/* ドラッグ中に地図の文字が選択されないようにする */
#canvas { -webkit-user-select: none; user-select: none; }
