/* EdaMap 全体スタイル */
:root {
  --accent: #4a90d9;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e5e8f0;
  --text: #3a3f45;
  --text-dim: #98a1b3;
  --topbar-h: 50px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- トップバー ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}
.brand {
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  font-family: var(--font);
  color: var(--text);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
.brand:hover { background: #eef1f7; }
.map-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.save-status {
  font-size: 11px;
  color: var(--text-dim);
  margin-right: 4px;
}

.icon-btn {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1;
  min-width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: #eef1f7; }
.icon-btn:disabled { color: #c8cdd8; cursor: default; background: transparent; }

/* ---------- キャンバス ---------- */
.canvas-wrap {
  position: relative;
  height: calc(100% - var(--topbar-h));
}
#map-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;           /* ブラウザ既定のジェスチャを無効化してSVG内ズームに一本化 */
  background-image: radial-gradient(circle, #dcdfe8 1px, transparent 1px);
  background-size: 26px 26px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- ノード ---------- */
.node { cursor: pointer; transition: transform 0.18s ease; }
.node .inner {
  animation: pop 0.16s ease-out;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes pop {
  from { transform: scale(0.5); opacity: 0; }
}
.node text {
  font-family: var(--font);
}
.node.selected .node-bg {
  stroke: var(--accent);
  stroke-width: 2.5;
}
.node.depth-0 .node-bg {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.28));
}
.collapse-badge { cursor: pointer; }
.collapse-badge circle { transition: r 0.1s; }
.collapse-badge:hover circle { r: 12; }

/* ---------- 枝 ---------- */
.edges path { transition: d 0.18s ease; }

/* ---------- インライン編集 ---------- */
.editor-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.node-editor {
  position: absolute;
  pointer-events: auto;
  border: 2px solid var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
  resize: none;
  overflow: hidden;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- ズームコントロール ---------- */
.zoom-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.zoom-label {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 38px;
  text-align: center;
}

/* ---------- ヒントバー ---------- */
.hint-bar {
  position: absolute;
  left: 14px;
  bottom: 18px;
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
@media (max-width: 760px) {
  .hint-bar { display: none; }
}

/* ---------- トースト ---------- */
.toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #2f3640;
  color: #fff;
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 86vw;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: #c0392b; }
.toast-update {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  background: #2f3640;
  color: #fff;
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.update-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
}

/* ---------- 画面切替 ---------- */
body[data-screen="list"] .editor-only { display: none; }
@media (max-width: 560px) {
  .brand-name { display: none; } /* スマホは🌿だけ残す（一覧に戻る手段は維持） */
  .save-status { display: none; }
}

/* ---------- マップ一覧 ---------- */
#screen-list {
  height: calc(100% - var(--topbar-h));
  overflow-y: auto;
}
.map-list-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.new-map-btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.35);
}
.new-map-btn:active { transform: scale(0.99); }
.map-cards { display: flex; flex-direction: column; gap: 10px; }
.map-card {
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.map-card-main {
  flex: 1;
  text-align: left;
  padding: 13px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  min-width: 0;
}
.map-card-main:hover { background: #f4f7fc; }
.map-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-card-meta {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-dots { display: inline-flex; gap: 3px; }
.map-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.map-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-left: 1px solid var(--border);
}
.map-list-empty { color: var(--text-dim); text-align: center; padding: 30px 0; }

/* ---------- フローティングツールバー ---------- */
.float-toolbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(80px);
  display: flex;
  gap: 2px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
  z-index: 20;
}
.float-toolbar.show {
  transform: translateX(-50%);
  opacity: 1;
  pointer-events: auto;
}
.float-toolbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 46px;
  padding: 6px 4px;
  border: none;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  font-family: var(--font);
}
.float-toolbar button:hover { background: #eef1f7; }
.float-toolbar button:disabled { opacity: 0.35; cursor: default; }
.ft-icon { font-size: 16px; line-height: 1.2; }
.ft-label { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.ft-danger .ft-label { color: #c0392b; }

/* ---------- 絵文字・色ピッカー ---------- */
.icon-picker {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  width: min(340px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 12px;
  display: none;
  z-index: 21;
}
.icon-picker.show { display: block; }
.ip-heading { font-size: 11px; color: var(--text-dim); margin: 4px 0 6px; }
.ip-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.ip-emoji {
  width: 34px; height: 34px;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.ip-emoji:hover { background: #eef1f7; }
.ip-color {
  width: 26px; height: 26px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  cursor: pointer;
}
.ip-none {
  width: auto;
  padding: 0 10px;
  font-size: 11px;
  font-family: var(--font);
  color: var(--text-dim);
  background: #f0f2f7;
  border-radius: 13px;
  border: none;
  height: 26px;
  cursor: pointer;
}
.ip-section + .ip-section { margin-top: 10px; }

/* ---------- ノートパネル ---------- */
.note-panel {
  position: absolute;
  background: var(--panel);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  display: none;
  flex-direction: column;
  z-index: 22;
}
.note-panel.show { display: flex; }
@media (min-width: 761px) {
  .note-panel {
    top: 0; right: 0; bottom: 0;
    width: 320px;
    border-left: 1px solid var(--border);
  }
}
@media (max-width: 760px) {
  .note-panel {
    left: 0; right: 0; bottom: 0;
    height: 42vh;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }
}
.note-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px 16px;
}
.note-panel-title {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-panel-text {
  flex: 1;
  margin: 0 12px 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
  resize: none;
  outline: none;
}
.note-panel-text:focus { border-color: var(--accent); }

/* ---------- アウトラインモード ---------- */
#outline-view {
  position: absolute;
  inset: 0;
  background: var(--panel);
  overflow-y: auto;
  padding: 18px 14px 120px;
  z-index: 5;
}
.ol-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
  padding-bottom: 2px;
}
.ol-root .ol-input { font-size: 18px; font-weight: 700; }
.ol-chevron {
  width: 20px; height: 20px;
  flex: none;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.ol-chevron-empty { visibility: hidden; }
.ol-bullet { font-size: 9px; flex: none; }
.ol-emoji { flex: none; }
.ol-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  padding: 4px 2px;
  border-radius: 6px;
  min-width: 0;
}
.ol-input:focus { background: #eef4fd; }
.ol-note-mark { font-size: 11px; flex: none; }
.icon-btn.active { background: #e3edfb; color: var(--accent); }

/* ---------- ドラッグ組み替え ---------- */
.drag-ghost { opacity: 0.55; pointer-events: none; }
.drag-ghost .inner { animation: none; }
.drag-source { opacity: 0.3; }
.drop-indicator {
  stroke: var(--accent);
  stroke-width: 3;
  fill: none;
  pointer-events: none;
}
rect.drop-indicator { stroke-dasharray: 7 5; }
line.drop-indicator { stroke-linecap: round; }

/* ---------- オーバーレイ・ダイアログ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 36, 46, 0.45);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
}
/* hidden属性はどんなCSSのdisplay指定よりも優先して隠す（.overlayのdisplay:flex対策） */
[hidden] { display: none !important; }
.dialog {
  background: var(--panel);
  border-radius: 16px;
  width: min(520px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 8px 20px;
  font-weight: 700;
}
.dialog-body { padding: 4px 20px 20px; }
.dialog-note { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; line-height: 1.6; }
.big-btn {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafd;
  cursor: pointer;
  color: var(--text);
}
.big-btn:hover { background: #eef3fa; }
.share-row { display: flex; gap: 10px; flex-wrap: wrap; }
.share-row .big-btn { flex: 1; min-width: 180px; }
.share-url-section { margin-top: 18px; }
.share-url-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.share-notes-label { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.share-url-row { display: flex; gap: 6px; }
#share-url {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font);
  min-width: 0;
}
.share-url-len { font-size: 11px; color: var(--text-dim); margin-top: 5px; }
.share-url-len.warn { color: #c0392b; }
#import-text {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
#import-text:focus { border-color: var(--accent); }
.import-mode-row {
  display: flex;
  gap: 16px;
  margin: 10px 0 14px;
  font-size: 13px;
  flex-wrap: wrap;
}
.import-mode-row label { display: flex; align-items: center; gap: 5px; }
#import-run { width: 100%; background: var(--accent); color: #fff; border: none; }

/* ---------- 検索 ---------- */
.search-box {
  background: var(--panel);
  border-radius: 16px;
  width: min(560px, 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
#search-input {
  width: 100%;
  padding: 16px 20px;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: var(--font);
  border-bottom: 1px solid var(--border);
}
.search-results { max-height: 50vh; overflow-y: auto; }
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  border-bottom: 1px solid #f0f2f7;
}
.search-hit:hover { background: #f4f7fc; }
.search-hit-map {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  background: #e9f1fc;
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 3px;
}
.search-hit-text { display: block; font-size: 14px; color: var(--text); }
.search-hit-path { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.search-empty { padding: 18px 20px; color: var(--text-dim); font-size: 13px; }

/* ---------- 同期 ---------- */
.sync-btn { position: relative; }
.sync-btn.sync-ok::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2ecc71;
}
.sync-btn.sync-warn::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e67e22;
}
.sync-btn.sync-spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-status-line {
  font-size: 13px;
  padding: 8px 0 14px;
  color: var(--text);
}
.sync-connect-btn { width: 100%; background: var(--accent); color: #fff; border: none; }
.sync-config-summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 10px 0 6px;
}
.sync-steps ol { padding-left: 18px; }
.sync-steps li { margin-bottom: 6px; }
.sync-steps code { background: #f0f2f7; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
#sync-client-id {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  min-width: 0;
}

/* ---------- ビューア ---------- */
.open-mine-btn {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  padding: 8px 14px;
  border-radius: 9px;
  text-decoration: none;
  white-space: nowrap;
}
