* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  font-size: 16px;
  color: #1a1a1a;
  background: #f3f4f6;
}
body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.card {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
  max-width: 420px;
  width: 100%;
}
.card h1 { margin-top: 0; font-size: 1.35rem; }
.card label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }
.card input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}
.card button {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.65rem;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.err { color: #b91c1c; }
.ok { color: #15803d; }
.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
.top nav { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.app-version {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.02em;
  user-select: none;
}
.top a { color: #2563eb; text-decoration: none; }
.top button {
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.top button.secondary { background: #6b7280; }
.wrap { max-width: 800px; margin: 0 auto; padding: 1.5rem; }
.panel {
  background: #fff;
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.inline { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 200px; padding: 0.5rem; border-radius: 8px; border: 1px solid #ccc; }
.inline button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.maplist { list-style: none; padding: 0; margin: 0; }
.maplist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
}
.maplist .maplist-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}
.map-shared-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  white-space: nowrap;
}
.maplist .maplist-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.map-share-settings {
  font-size: 0.85rem;
  font-weight: 600;
}
.maplist time { color: #6b7280; font-size: 0.9rem; }
.top .toolbar-save-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 13em;
  max-width: 13em;
  min-width: 0;
}
.top .editor-toolbar .save-msg {
  width: 100%;
  padding: 0.28rem 0.55rem;
  margin: 0;
  border-radius: 6px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top label.line-style-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}
.top label.line-style-label select {
  padding: 0.28rem 0.45rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  font: inherit;
  cursor: pointer;
}
.top button.danger { background: #dc2626; }
.toolbar-sep { width: 1px; height: 1.2rem; background: #e5e7eb; margin: 0 0.15rem; flex-shrink: 0; }

/* 編輯器頂欄：右邊工具列唔截 72% 寬，盡量同一行排晒（太窄先橫向捲） */
body.editor-page .top {
  flex-wrap: nowrap;
  gap: 0.65rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
body.editor-page .top > a:first-of-type {
  flex-shrink: 0;
}
body.editor-page .top > strong {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}
body.editor-page .top nav.editor-toolbar {
  flex: 0 0 auto;
  flex-shrink: 0;
  max-width: none;
  margin-left: auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.35rem;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}
body.editor-page .top button {
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
  white-space: nowrap;
}
body.editor-page .top .toolbar-save-slot {
  flex: 0 0 auto;
  max-width: 10em;
}
body.editor-page .top label.line-style-label {
  font-size: 0.8rem;
  flex-shrink: 0;
  white-space: nowrap;
}
body.editor-page .top .app-version {
  flex-shrink: 0;
}
body.editor-page .top nav.editor-toolbar > a {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.88rem;
}
.editor-hint {
  margin: 0;
  padding: 0.4rem 1rem;
  font-size: 0.88rem;
  color: #4b5563;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}
.editor-hint strong { color: #111827; }
body.editor-page.mm-node-dragging {
  cursor: grabbing !important;
  user-select: none;
}
body.editor-page.mm-node-dragging jmnode {
  cursor: grabbing !important;
}
body.editor-page .top > .editor-share-link {
  flex-shrink: 0;
  margin-left: 0.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #2563eb;
}

/* 中等寬度以下：工具列另起一行佔滿寬，避免「儲存／登出」永遠擠喺右邊要喺成條 header 先搵到／橫向捲 */
@media (max-width: 1100px) {
  body.editor-page .top {
    flex-wrap: wrap;
    row-gap: 0.45rem;
  }
  body.editor-page .top nav.editor-toolbar {
    flex: 1 1 100%;
    max-width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1px;
  }
}

/* 編輯器：避免 #jsmind_container 用固定 calc(100vh - Npx)；頂部換行／提示變高會同 100vh 打架，第一次改字易整頁錯位捲動。 */
html {
  overflow-x: hidden;
}
body.editor-page {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
body.editor-page > header.top {
  flex-shrink: 0;
  /* 畫布有 transform 時会形成堆疊层；提高 header 避免按键被挡、click 落到下面画布 */
  position: relative;
  z-index: 200;
  isolation: isolate;
  pointer-events: auto;
}
body.editor-page > .editor-hint {
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  isolation: isolate;
  pointer-events: auto;
}
body.editor-page > .editor-appearance {
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  isolation: isolate;
  pointer-events: auto;
}
body.editor-page > #remote-notice {
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  isolation: isolate;
  pointer-events: auto;
}

/* 編輯器：全寬提示（新增失敗等）；頂欄 #save-msg 槽太窄時使用者會「乜提示都睇唔到」 */
body.editor-page > #editor-feedback {
  flex-shrink: 0;
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
  background: #fee2e2;
  color: #991b1b;
  border-bottom: 1px solid #fecaca;
  position: relative;
  z-index: 150;
  isolation: isolate;
  pointer-events: auto;
}
body.editor-page > #editor-feedback[hidden] {
  display: none !important;
}

#jsmind_container {
  width: 100%;
  flex: 1 1 0%;
  min-height: 420px;
  overflow: hidden;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
  isolation: isolate;
}
/* jsMind 預設 .jsmind-inner { height:100% }；父flex 無「指定高度」時 100% 會計成 0 → 節點唔見。改由 flex 拉高內層。 */
body.editor-page #jsmind_container > .jsmind-inner {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  width: 100%;
}
/* 畫布平移由 app.js + translate 處理；關閉 jsMind 內建 scroll pan，唔再用捲軸 */
body.editor-page .jsmind-inner {
  overflow: hidden;
}
.save-msg, .remote-notice {
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.95rem;
}
.remote-notice {
  background: #fef3c7;
  color: #92400e;
}
.remote-notice button {
  margin-left: 0.5rem;
  padding: 0.2rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: #b45309;
  color: #fff;
  cursor: pointer;
}

/* —— 編輯器：節點外觀（字體／框形；字色由 app.js 插入 #mindmap-node-fg-style）—— */
.editor-appearance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding: 0.35rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.85rem;
  color: #374151;
}
.editor-appearance .appearance-title {
  font-weight: 700;
  color: #111827;
  margin-right: 0.25rem;
}
.editor-appearance .appearance-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}
.editor-appearance select {
  padding: 0.24rem 0.4rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  font: inherit;
  cursor: pointer;
  max-width: 11rem;
}
.editor-appearance .appearance-color input[type="color"] {
  width: 2rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  vertical-align: middle;
}

/* 字體（primary 主題節點） */
body.editor-page.mm-font-sys jmnodes.theme-primary jmnode {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", sans-serif !important;
}
body.editor-page.mm-font-tc jmnodes.theme-primary jmnode {
  font-family: "Microsoft JhengHei", "PingFang TC", "Heiti TC", "Noto Sans TC", sans-serif !important;
}
body.editor-page.mm-font-ming jmnodes.theme-primary jmnode {
  font-family: "PMingLiU", "MingLiU", "Noto Serif TC", serif !important;
}
body.editor-page.mm-font-kai jmnodes.theme-primary jmnode {
  font-family: "BiauKai", "KaiTi", "Kaiti SC", "Noto Sans TC", serif !important;
}
body.editor-page.mm-font-noto jmnodes.theme-primary jmnode {
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif !important;
}
body.editor-page.mm-font-mono jmnodes.theme-primary jmnode {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace !important;
}

/* 框形：長方圓角／直角／膠囊（維持橢圓長條，文字單行省略） */
body.editor-page.mm-shape-roundrect jmnodes.theme-primary jmnode {
  border-radius: 10px !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  display: block !important;
  max-width: 400px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
body.editor-page.mm-shape-rect jmnodes.theme-primary jmnode {
  border-radius: 0 !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  display: block !important;
  max-width: 400px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
body.editor-page.mm-shape-pill jmnodes.theme-primary jmnode {
  border-radius: 9999px !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  display: block !important;
  max-width: 400px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
/* 正方形／圓形：固定框，長字會換行／裁切（版面限於方／圓） */
body.editor-page.mm-shape-square jmnodes.theme-primary jmnode {
  border-radius: 0 !important;
  width: 5.25rem !important;
  height: 5.25rem !important;
  min-width: 5.25rem !important;
  min-height: 5.25rem !important;
  max-width: 5.25rem !important;
  padding: 0.28rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: normal !important;
  overflow: hidden !important;
  text-align: center !important;
  font-size: 12px !important;
  line-height: 1.25 !important;
  aspect-ratio: 1 / 1 !important;
}
body.editor-page.mm-shape-circle jmnodes.theme-primary jmnode {
  border-radius: 50% !important;
  width: 5.25rem !important;
  height: 5.25rem !important;
  min-width: 5.25rem !important;
  min-height: 5.25rem !important;
  max-width: 5.25rem !important;
  padding: 0.28rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: normal !important;
  overflow: hidden !important;
  text-align: center !important;
  font-size: 12px !important;
  line-height: 1.25 !important;
  aspect-ratio: 1 / 1 !important;
}
