/* ====== 一介导图 — 样式表 ====== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #F5F0E8;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ====== 页面加载动画 ====== */
#page-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #F5E6D3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.3s ease;
}

.loader-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #E8D5B7;
  border-top: 3px solid #C8A84E;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-size: 14px;
  color: #A67C4A;
  letter-spacing: 2px;
}

#page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ====== 木纹主题 ====== */
.wood-bg {
  background: linear-gradient(180deg, #DEB887 0%, #D2A56C 40%, #C4955A 100%);
  border-bottom: 2px solid #A67C4A;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.wood-bg-light {
  background: linear-gradient(180deg, #E8D5B7 0%, #DCC7A0 100%);
  border-bottom: 1px solid #C4A87C;
}

/* ====== 头部 ====== */
.header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 52px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
  position: relative;
}

.header-title {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 1px;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 13px;
  opacity: 0.85;
  white-space: nowrap;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ====== 按钮（旧 btn-header 已废弃，由 btn-tool-wood 替代） ====== */

/* ====== 工具栏（统一单行） ====== */
.toolbar {
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 48px;
  gap: 4px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 40;
  transition: height 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
}

.toolbar::-webkit-scrollbar {
  height: 0;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: #C4A87C;
  margin: 0 3px;
  flex-shrink: 0;
}

.toolbar-sep-wood {
  background: rgba(255,255,255,0.35);
}

.toolbar-row-break {
  display: none;
}

.zoom-label {
  font-size: 11px;
  color: #fff;
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* 通用 btn-tool 基础样式 */
.btn-tool {
  padding: 4px 10px;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.92);
  color: #4a4a4a;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.btn-tool:hover {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transform: translateY(-1px);
}

.btn-tool:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

/* 木纹按钮 */
.btn-tool-wood {
  padding: 4px 10px;
  font-size: 13px;
}

/* 删除线按钮 */
.btn-tool-strike {
  position: relative;
}
.btn-tool-strike::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  height: 1.5px;
  background: currentColor;
  pointer-events: none;
}

/* 颜色指示小方块 */
.btn-tool-color::before {
  content: '';
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: currentColor;
  margin-right: 4px;
  vertical-align: middle;
}

/* ====== 工具栏按钮分组配色（优雅方案） ====== */

/* 导航/视图 — 沉稳蓝 */
.tool-group-nav {
  background: #4A7FD6 !important;
  color: #fff !important;
}
.tool-group-nav:hover {
  background: #3D6BC2 !important;
}

/* 缩放 — 玫粉 */
.tool-group-zoom {
  background: #E84393 !important;
  color: #fff !important;
}
.tool-group-zoom:hover {
  background: #D63384 !important;
}

/* 节点操作 — 翠绿 */
.tool-group-node {
  background: #3AA76D !important;
  color: #fff !important;
}
.tool-group-node:hover {
  background: #2E9460 !important;
}

/* 删除 — 朱红 */
.btn-tool-danger {
  background: #D9534F !important;
  color: #fff !important;
}
.btn-tool-danger:hover {
  background: #C9433E !important;
}

/* 折叠/展开 — 紫灰 */
.tool-group-fold {
  background: #6C5CE7 !important;
  color: #fff !important;
}
.tool-group-fold:hover {
  background: #5B4CD6 !important;
}

/* 样式/外观 — 琥珀 */
.tool-group-style {
  background: #D8842C !important;
  color: #fff !important;
}
.tool-group-style:hover {
  background: #C77520 !important;
}

/* 节点颜色 — 朱红 */
.tool-group-nodecolor {
  background: #E74C3C !important;
  color: #fff !important;
}
.tool-group-nodecolor:hover {
  background: #D33A2C !important;
}

/* 文字颜色 — 深蓝 */
.tool-group-textcolor {
  background: #2980B9 !important;
  color: #fff !important;
}
.tool-group-textcolor:hover {
  background: #1F6FA4 !important;
}

/* 图标 — 金色 */
.tool-group-icon {
  background: #D4A017 !important;
  color: #fff !important;
}
.tool-group-icon:hover {
  background: #B88B0E !important;
}

/* 背景 — 天蓝 */
.tool-group-bgcolor {
  background: #87CEEB !important;
  color: #fff !important;
}
.tool-group-bgcolor:hover {
  background: #6CB8D4 !important;
}

/* 文字排版 — 蓝绿 */
.tool-group-text {
  background: #3A9AA5 !important;
  color: #fff !important;
}
.tool-group-text:hover {
  background: #2E8892 !important;
}

/* ====== 返回按钮 ====== */
.btn-back {
  padding: 4px 12px;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  background: #5C6B7A;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.btn-back:hover {
  background: #4A5866;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}



/* ====== 工具栏折叠动画 ====== */
#main-toolbar {
  transition: height 0.25s ease, padding-top 0.25s ease, padding-bottom 0.25s ease, opacity 0.2s ease;
}

#editor-screen.toolbar-collapsed #main-toolbar {
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* 工具栏收起/展开按钮 */
.btn-toggle {
  font-size: 14px;
  padding: 4px 8px;
  flex-shrink: 0;
  font-weight: bold;
}

/* 浮动恢复按钮 */
.toolbar-restore-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 100;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: #5C4B2F;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: opacity 0.2s ease, transform 0.2s ease;
  padding: 0;
  line-height: 1;
}
.toolbar-restore-btn:hover {
  background: #fff;
  transform: scale(1.08);
  box-shadow: 0 3px 12px rgba(0,0,0,0.18);
}

/* ====== 画布容器 ====== */
#canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #FDFAF3;
}

#mindmap-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#mindmap-canvas:active {
  cursor: grabbing;
}

/* ====== 全局布局 ====== */
.hidden {
  display: none !important;
}

/* ====== 首页文件列表 ====== */
#home-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#empty-hint {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#file-list {
  flex: 1;
  list-style: none;
  padding: 8px 16px;
  overflow-y: auto;
}

#file-list li {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  margin: 4px 0;
  background: #FFFEF9;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  gap: 10px;
}

#file-list li:hover {
  background: #F5E6D0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.file-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.file-name {
  flex: 1;
  font-size: 14px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-date {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
}

.file-delete {
  border: none;
  background: none;
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.file-delete:hover {
  color: #C0392B;
  background: rgba(192,57,43,0.08);
}

/* ====== 市场卡片 ====== */
.market-entry-card {
  background: linear-gradient(135deg, #FDF8F0 0%, #F8EDD8 100%) !important;
  border: 2px solid #D4A96A !important;
  border-radius: 10px !important;
  padding: 14px 16px !important;
  margin-bottom: 8px !important;
  position: relative;
  overflow: hidden;
}
.market-entry-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #C4955A, #A67C4A);
  border-radius: 4px 0 0 4px;
}
.market-entry-card:hover {
  background: linear-gradient(135deg, #F5E6D0 0%, #ECD8B0 100%) !important;
  box-shadow: 0 3px 12px rgba(180,130,70,0.2) !important;
}

.market-badge {
  font-size: 12px;
  color: #A67C4A;
  background: rgba(196,149,90,0.12);
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
  font-weight: 500;
}

/* ====== 编辑页 ====== */
#editor-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

#editor-screen.hidden {
  display: none !important;
}

/* ====== 节点编辑框 ====== */
.node-editor {
  font-family: inherit;
}

/* ====== 颜色选择器 ====== */
#color-picker-popup {
  animation: popIn 0.15s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ====== 背景色选择面板 ====== */
#bg-color-picker-popup {
  animation: popIn 0.15s ease;
}

.bg-color-swatch {
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bg-color-swatch:hover {
  transform: scale(1.08);
}

/* ====== 滚动条 ====== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* 文件列表中的 md 图标样式 */
li[data-type="md"] .file-icon {
  color: #5a8a5a;
}

/* ====== 内联格式工具栏 ====== */
.inline-format-toolbar {
  position: fixed;
  z-index: 20001;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.13);
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  white-space: nowrap;
  border: 1px solid #E0E0E0;
}
.inline-format-toolbar.visible {
  opacity: 1;
  pointer-events: auto;
}
.inline-tool-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #333;
  transition: background 0.12s;
  font-family: inherit;
}
.inline-tool-btn:hover {
  background: #F0F0F0;
}
.inline-tool-btn.active {
  background: #D6E9FF;
  color: #309EFF;
}
.inline-tool-sep {
  width: 1px;
  height: 20px;
  background: #E0E0E0;
  margin: 0 3px;
}
.inline-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid #ddd;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.inline-color-dot:hover {
  transform: scale(1.25);
  border-color: #999;
}
.inline-font-btn {
  width: auto;
  min-width: 24px;
  padding: 0 4px;
  height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: #555;
  transition: background 0.12s;
  font-family: inherit;
}
.inline-font-btn:hover {
  background: #F0F0F0;
  color: #309EFF;
}
.format-toolbar-row-break {
  display: none;
}

/* ====== 笔记编辑器模态框 ====== */
.note-editor-overlay {
  position: fixed;
  z-index: 10000;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}
.note-editor-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
  animation: gufengFadeIn 0.12s ease;
}
.note-editor-overlay.hidden {
  display: none;
}
.note-editor-dialog {
  background: #F5EDE0;
  border: 2px solid #C8A84E;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: max(900px, 68vw);
  max-width: 92vw;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.note-editor-textarea {
  width: 100%;
  height: max(300px, 30vh);
  border: 1px solid #C8A84E;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.8;
  outline: none;
  box-sizing: border-box;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 140px;
  background: #FFFBF5;
  color: #4A3728;
}
.note-editor-textarea:empty::before {
  content: "输入备注内容...";
  color: #B8A898;
}
.note-editor-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.note-editor-btn {
  padding: 8px 28px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: inherit;
}
.note-editor-btn-cancel {
  background: #E8DCC8;
  color: #6B5D4F;
  border: 1px solid #C8A84E;
}
.note-editor-btn-cancel:hover {
  background: #DCCCB0;
}
.note-editor-btn-save {
  background: #C8A84E;
  color: #FFFBF5;
}
.note-editor-btn-save:hover {
  background: #B8922E;
}

/* ====== 搜索框 ====== */
.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#search-input {
  width: 220px;
  padding: 5px 28px 5px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
  color: #333;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-weight: 400;
}

#search-input:focus {
  border-color: #5B8DEF;
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.15);
}

#search-input::placeholder {
  color: #aaa;
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #ccc;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
  line-height: 1;
}
.search-clear-btn:hover {
  background: #999;
}

.search-dropdown {
  position: fixed;
  max-height: 400px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 2000;
  width: 100vw;
  left: 0 !important;
  right: 0 !important;
  border-radius: 0 0 8px 8px;
}

.search-dropdown-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.12s;
  user-select: none;
  -webkit-user-select: none;
  width: 100%;
  box-sizing: border-box;
}

.search-dropdown-item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.search-dropdown-item:last-child {
  border-bottom: none;
}

.search-dropdown-item:hover {
  background: #F0F5FF;
}

#search-dropdown {
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
}

.search-item-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-text mark {
  background: #FFC107;
  color: #000;
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: bold;
  box-shadow: 0 1px 4px rgba(255, 140, 0, 0.4);
  border: 1px solid #FF9800;
}

.search-item-path {
  display: block;
  font-size: 11px;
  color: #999;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-dropdown-empty {
  padding: 16px 12px;
  font-size: 13px;
  color: #999;
  text-align: center;
}

/* 搜索清除按钮 */
.search-clear-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: none;
  padding: 0;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.search-clear-btn:hover {
  background: rgba(255, 255, 255, 0.7);
  color: #333;
}

/* 搜索结果计数 */
.search-result-count {
  padding: 6px 12px;
  font-size: 12px;
  color: #888;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  font-weight: normal;
}

/* 搜索下拉活跃项 */
.search-dropdown-item.active {
  background: #D6EAFF;
  border-left: 3px solid #309EFF;
  font-weight: 500;
}

/* ====== 长按弹出菜单（首页导图卡片） ====== */
.longpress-menu {
  position: fixed;
  z-index: 30000;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  min-width: 130px;
  animation: menuFadeIn 0.12s ease;
}

.longpress-menu.hidden {
  display: none;
}

.longpress-menu-item {
  padding: 11px 22px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.12s;
  white-space: nowrap;
}

.longpress-menu-item:hover {
  background: #F0F5FF;
  color: #309EFF;
}

.longpress-menu-item:active {
  background: #E0EBFF;
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* ====== 古风模态对话框 ====== */
.gufeng-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: gufengFadeIn 0.2s ease;
}

@keyframes gufengFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gufeng-modal-dialog {
  background: linear-gradient(180deg, #F5E6CC 0%, #E8D5B0 40%, #DCC7A0 100%);
  border: 2px solid #C8A84E;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255,255,255,0.4);
  min-width: 320px;
  max-width: 420px;
  padding: 28px 32px 24px;
  animation: gufengPopIn 0.25s ease;
}

@keyframes gufengPopIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

.gufeng-modal-title {
  font-size: 18px;
  font-weight: bold;
  color: #C8A84E;
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(200,168,78,0.3);
  padding-bottom: 10px;
}

.gufeng-modal-message {
  font-size: 14px;
  color: #5C3D2E;
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: center;
  white-space: pre-wrap;
}

.gufeng-modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #C8A84E;
  border-radius: 8px;
  background: rgba(255,255,255,0.7);
  color: #5C3D2E;
  font-size: 14px;
  margin-bottom: 20px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.gufeng-modal-input:focus {
  border-color: #B8963E;
  box-shadow: 0 0 0 3px rgba(200,168,78,0.2);
}

.gufeng-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.gufeng-modal-btn {
  padding: 8px 28px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s;
  letter-spacing: 1px;
}

.gufeng-modal-btn-cancel {
  background: rgba(255,255,255,0.5);
  border-color: #B8A080;
  color: #8B7355;
}

.gufeng-modal-btn-cancel:hover {
  background: rgba(255,255,255,0.75);
  border-color: #A08060;
}

.gufeng-modal-btn-confirm {
  background: linear-gradient(180deg, #D4B060 0%, #C8A84E 100%);
  border-color: #A08830;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.gufeng-modal-btn-confirm:hover {
  background: linear-gradient(180deg, #DEC470 0%, #D0B058 100%);
  border-color: #B09840;
}

/* ====== MD 导入编辑器（古风风格） ====== */
.md-import-editor-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: gufengFadeIn 0.2s ease;
}

.md-import-editor-dialog {
  background: linear-gradient(180deg, #F5E6CC 0%, #E8D5B0 40%, #DCC7A0 100%);
  border: 2px solid #C8A84E;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255,255,255,0.4);
  width: 80vw;
  height: 70vh;
  min-width: 400px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  padding: 24px;
  box-sizing: border-box;
  animation: gufengPopIn 0.25s ease;
}

.md-import-editor-title {
  font-size: 18px;
  font-weight: bold;
  color: #C8A84E;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(200,168,78,0.3);
  padding-bottom: 10px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.md-import-editor-textarea {
  flex: 1;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #C8A84E;
  border-radius: 8px;
  background: rgba(255,255,255,0.7);
  color: #5C3D2E;
  font-size: 14px;
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  line-height: 1.8;
  resize: none;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.md-import-editor-textarea:focus {
  border-color: #B8963E;
  box-shadow: 0 0 0 3px rgba(200,168,78,0.2);
}

.md-import-editor-textarea::placeholder {
  color: #B8A080;
  font-style: italic;
}

.md-import-editor-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  flex-shrink: 0;
}

.md-import-editor-btn {
  padding: 10px 32px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s;
  letter-spacing: 2px;
}

.md-import-editor-btn-cancel {
  background: rgba(255,255,255,0.5);
  border-color: #B8A080;
  color: #8B7355;
}

.md-import-editor-btn-cancel:hover {
  background: rgba(255,255,255,0.75);
  border-color: #A08060;
}

.md-import-editor-btn-confirm {
  background: linear-gradient(180deg, #D4B060 0%, #C8A84E 100%);
  border-color: #A08830;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.md-import-editor-btn-confirm:hover {
  background: linear-gradient(180deg, #DEC470 0%, #D0B058 100%);
  border-color: #B09840;
}

/* ====== 文件夹选择列表（古风对话框内，移动导图/文件夹） ====== */
.folder-picker-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid rgba(200,168,78,0.3);
  border-radius: 8px;
  background: rgba(255,255,255,0.5);
  padding: 6px 0;
}

.folder-picker-item {
  padding: 9px 14px;
  font-size: 14px;
  color: #5C3D2E;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  -webkit-user-select: none;
  border-bottom: 1px solid rgba(200,168,78,0.12);
}

.folder-picker-item:last-child {
  border-bottom: none;
}

.folder-picker-item:hover {
  background: rgba(200,168,78,0.15);
}

.folder-picker-item.selected {
  background: rgba(200,168,78,0.22);
  color: #3D2A16;
  font-weight: 500;
}

.folder-picker-item.selected::before {
  content: '☑️ ';
  margin-right: 4px;
}

.expand-arrow {
  display: inline-block;
  width: 16px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  color: #C8A84E;
  font-size: 12px;
  flex-shrink: 0;
}
.expand-arrow:hover {
  color: #A08830;
}

.expand-arrow-placeholder {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
}

.folder-picker-children {
  /* 由 JS 控制 display:none/block */;
}

/* ====== 导入格式选择对话框（古风风格） ====== */
.import-format-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: gufengFadeIn 0.2s ease;
}

.import-format-dialog {
  background: linear-gradient(180deg, #F5E6CC 0%, #E8D5B0 40%, #DCC7A0 100%);
  border: 2px solid #C8A84E;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255,255,255,0.4);
  padding: 28px 32px 24px;
  animation: gufengPopIn 0.25s ease;
  min-width: 400px;
  max-width: 500px;
}

.import-format-title {
  font-size: 18px;
  font-weight: bold;
  color: #C8A84E;
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(200,168,78,0.3);
  padding-bottom: 10px;
}

.import-format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.import-format-card {
  background: rgba(255, 255, 255, 0.55);
  border: 1.5px solid rgba(200, 168, 78, 0.35);
  border-radius: 10px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.import-format-card:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: #C8A84E;
  box-shadow: 0 4px 16px rgba(200, 168, 78, 0.25);
  transform: translateY(-2px);
}

.import-format-card:active {
  transform: scale(0.96);
}

.import-format-icon {
  font-size: 28px;
  line-height: 1;
}

.import-format-name {
  font-size: 13px;
  font-weight: 600;
  color: #5C3D2E;
}

.import-format-ext {
  font-size: 11px;
  color: #B8963E;
  font-family: monospace;
}

.import-format-cancel-btn {
  display: block;
  margin: 0 auto;
  padding: 8px 36px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid #B8A080;
  background: rgba(255,255,255,0.5);
  color: #8B7355;
  letter-spacing: 1px;
  transition: all 0.15s;
}

.import-format-cancel-btn:hover {
  background: rgba(255,255,255,0.75);
  border-color: #A08060;
}

/* ================================================================
   移动端适配
   ================================================================ */

/* ---- 平板 & 小屏 (≤768px) ---- */
@media (max-width: 768px) {

  /* --- 全局触摸优化 --- */
  button, .btn-tool, .btn-back, .btn-header,
  .gufeng-modal-btn, .note-editor-btn, .md-import-editor-btn,
  .import-format-card, .import-format-cancel-btn,
  .longpress-menu-item, .search-dropdown-item,
  .folder-picker-item, .file-delete {
    min-height: 44px;
    min-width: 44px;
  }

  /* --- 首页头部 --- */
  .header {
    height: 44px;
    padding: 0 10px;
    gap: 8px;
  }
  .header-title {
    font-size: 15px;
  }
  .header-subtitle {
    font-size: 11px;
  }
  .header-actions {
    gap: 4px;
  }
  .header-actions .btn-header {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 5px;
  }

  /* --- 首页文件列表 --- */
  #file-list {
    padding: 4px 8px;
  }
  #file-list li {
    padding: 12px 12px;
    margin: 3px 0;
    gap: 8px;
  }
  .file-icon {
    font-size: 20px;
  }
  .file-name {
    font-size: 13px;
  }
  .file-date {
    font-size: 10px;
  }

  /* --- 工具栏 --- */
  .toolbar {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    height: auto;
    padding: 6px 8px;
    gap: 3px 4px;
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-bottom: 2px solid #A67C4A;
    border-top: none;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  }
  .toolbar-row-break {
    display: block;
    flex-basis: 100%;
    height: 0;
  }
  .btn-tool {
    padding: 6px 10px;
    font-size: 15px;
    border-radius: 6px;
    flex-shrink: 0;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn-back {
    padding: 6px 12px;
    font-size: 15px;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .toolbar-sep {
    height: 14px;
    margin: 0 2px;
  }
  .zoom-label {
    font-size: 10px;
    min-width: 28px;
  }
  .btn-toggle {
    font-size: 12px;
    padding: 4px 8px;
  }
  .toolbar-restore-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
    top: 6px;
    right: 8px;
  }

  /* --- 搜索框 --- */
  #search-input {
    width: 120px;
    padding: 5px 24px 5px 10px;
    font-size: 11px;
  }
  .search-clear-btn {
    width: 16px;
    height: 16px;
    font-size: 9px;
    right: 6px;
  }
  .search-dropdown {
    max-height: 280px;
  }
  .search-dropdown-item {
    padding: 10px 14px;
    font-size: 12px;
  }

  /* --- 笔记编辑器 --- */
  .note-editor-dialog {
    width: max(94vw, 320px);
    max-width: 96vw;
    padding: 14px 12px;
    gap: 10px;
  }
  .note-editor-textarea {
    height: max(270px, 28vh);
    min-height: 140px;
    padding: 10px;
    font-size: 13px;
  }
  .note-editor-buttons {
    gap: 8px;
  }
  .note-editor-btn {
    padding: 8px 22px;
    font-size: 14px;
    min-height: 44px;
  }

  /* --- 古风模态对话框 --- */
  .gufeng-modal-dialog {
    min-width: auto;
    max-width: 90vw;
    width: 90vw;
    padding: 22px 20px 18px;
  }
  .gufeng-modal-title {
    font-size: 16px;
    margin-bottom: 12px;
  }
  .gufeng-modal-message {
    font-size: 13px;
  }
  .gufeng-modal-input {
    padding: 10px 10px;
    font-size: 14px;
  }
  .gufeng-modal-btn {
    padding: 10px 24px;
    font-size: 14px;
  }

  /* --- MD 导入编辑器 --- */
  .md-import-editor-dialog {
    width: 95vw;
    min-width: auto;
    height: 80vh;
    padding: 18px;
  }
  .md-import-editor-title {
    font-size: 16px;
  }
  .md-import-editor-textarea {
    font-size: 13px;
    padding: 10px 12px;
  }
  .md-import-editor-btn {
    padding: 10px 24px;
    font-size: 14px;
  }

  /* --- 导入格式选择对话框 --- */
  .import-format-dialog {
    min-width: auto;
    max-width: 92vw;
    width: 92vw;
    padding: 22px 18px 18px;
  }
  .import-format-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .import-format-card {
    padding: 12px 6px;
    gap: 4px;
  }
  .import-format-icon {
    font-size: 24px;
  }
  .import-format-name {
    font-size: 12px;
  }

  /* --- 文件夹选择列表 --- */
  .folder-picker-list {
    max-height: 240px;
  }
  .folder-picker-item {
    padding: 11px 14px;
    font-size: 13px;
  }

  /* --- 长按菜单 --- */
  .longpress-menu {
    min-width: 120px;
    border-radius: 8px;
  }
  .longpress-menu-item {
    padding: 13px 22px;
    font-size: 14px;
  }

  /* --- 内联格式工具栏 --- */
  .inline-format-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    gap: 2px 4px;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 0;
    border: none;
    border-bottom: 2px solid #A67C4A;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    z-index: 20001;
    white-space: normal;
  }
  .format-toolbar-row-break {
    display: block;
    flex-basis: 100%;
    height: 0;
  }
  .inline-tool-btn {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  /* --- 颜色选择器弹窗 --- */
  #color-picker-popup {
    max-width: 88vw;
    padding: 10px;
    gap: 6px;
  }
  #color-picker-popup > div {
    width: 36px;
    height: 36px;
  }

  /* --- 背景色选择面板 --- */
  #bg-color-picker-popup {
    padding: 12px;
    max-width: 90vw;
  }
  #bg-color-picker-popup [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* --- 形状选择器 --- */
  #shape-picker-popup {
    padding: 10px;
    max-width: 90vw;
  }
  #shape-picker-popup [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* --- 图标选择器 --- */
  #icon-picker-popup {
    max-width: 94vw !important;
    padding: 10px !important;
  }
  #icon-picker-popup [style*="grid-template-columns:repeat(10,1fr)"] {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 3px !important;
  }

  /* --- 画布 --- */
  #canvas-wrapper {
    position: absolute;
    top: 90px; /* 为顶部两行工具栏留空间 */
    left: 0;
    right: 0;
    bottom: 0;
    /* 在移动端确保画布不被工具栏遮挡时仍可操作 */
    touch-action: manipulation;
  }
  #mindmap-canvas {
    touch-action: none;
  }

  /* --- 缩放按钮隐藏 --- */
  .tool-group-zoom {
    display: none;
  }

  /* --- 导出图片按钮方块 --- */
  [data-action="export-png"] {
    width: 36px;
    height: 36px;
    padding: 0;
    min-width: 36px;
    font-size: 0;
    overflow: hidden;
  }
  [data-action="export-png"]::before {
    content: '📷';
    font-size: 16px;
  }

  /* --- 市场卡片 --- */
  .market-entry-card {
    padding: 12px 14px !important;
  }
  .market-badge {
    font-size: 11px;
    padding: 2px 8px;
  }
}

/* ---- 手机 (≤480px) ---- */
@media (max-width: 480px) {

  /* --- 首页头部 --- */
  .header {
    height: 40px;
    padding: 0 8px;
    gap: 6px;
  }
  .header-title {
    font-size: 14px;
  }
  .header-subtitle {
    display: none;
  }
  .header-actions {
    gap: 3px;
  }
  .header-actions .btn-header {
    padding: 3px 6px;
    font-size: 10px;
    border-radius: 4px;
  }

  /* --- 文件列表 --- */
  #file-list {
    padding: 2px 4px;
  }
  #file-list li {
    padding: 10px 10px;
    margin: 2px 0;
    gap: 6px;
  }
  .file-icon {
    font-size: 18px;
  }
  .file-name {
    font-size: 12px;
  }
  .file-date {
    font-size: 9px;
  }
  .file-delete {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* --- 工具栏 --- */
  .toolbar {
    height: auto;
    padding: 4px 6px;
    gap: 2px 3px;
  }
  .btn-tool {
    padding: 5px 8px;
    font-size: 14px;
    border-radius: 5px;
    min-width: 36px;
    min-height: 36px;
  }
  .btn-back {
    padding: 5px 10px;
    font-size: 14px;
    min-width: 36px;
    min-height: 36px;
  }
  .toolbar-sep {
    height: 12px;
    margin: 0 1px;
  }
  .zoom-label {
    font-size: 9px;
    min-width: 24px;
  }
  .btn-toggle {
    font-size: 11px;
    padding: 3px 6px;
  }

  /* --- 画布 --- */
  #canvas-wrapper {
    top: 80px; /* 为顶部两行工具栏留空间 */
    bottom: 0;
  }

  /* --- 缩放按钮隐藏 --- */
  .tool-group-zoom {
    display: none;
  }

  /* --- 导出图片按钮方块 --- */
  [data-action="export-png"] {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0;
    overflow: hidden;
  }
  [data-action="export-png"]::before {
    content: '📷';
    font-size: 14px;
  }

  /* --- 内联格式工具栏 --- */
  .inline-format-toolbar {
    padding: 4px 6px;
    gap: 2px 3px;
  }

  /* --- 搜索 --- */
  #search-input {
    width: 80px;
    padding: 4px 22px 4px 8px;
    font-size: 10px;
  }
  .search-dropdown {
    max-height: 240px;
  }
  .search-dropdown-item {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* --- 笔记编辑器 --- */
  .note-editor-dialog {
    width: max(96vw, 280px);
    padding: 14px 10px;
    gap: 10px;
  }
  .note-editor-textarea {
    height: max(220px, 22vh);
    min-height: 120px;
    padding: 10px;
    font-size: 12px;
  }
  .note-editor-buttons {
    flex-direction: column;
    gap: 8px;
  }
  .note-editor-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
  }

  /* --- 古风模态 --- */
  .gufeng-modal-dialog {
    width: 94vw;
    padding: 18px 14px 14px;
  }
  .gufeng-modal-buttons {
    flex-direction: column;
    gap: 8px;
  }
  .gufeng-modal-btn {
    width: 100%;
    padding: 12px;
  }

  /* --- MD 导入编辑器 --- */
  .md-import-editor-dialog {
    width: 98vw;
    height: 85vh;
    padding: 14px;
  }
  .md-import-editor-buttons {
    flex-direction: column;
    gap: 8px;
  }
  .md-import-editor-btn {
    width: 100%;
    padding: 12px;
  }

  /* --- 导入格式选择 --- */
  .import-format-dialog {
    width: 94vw;
    padding: 16px 12px 14px;
  }
  .import-format-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .import-format-card {
    padding: 10px 4px;
  }
  .import-format-icon {
    font-size: 22px;
  }
  .import-format-name {
    font-size: 11px;
  }
  .import-format-ext {
    font-size: 10px;
  }
  .import-format-cancel-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
  }

  /* --- 文件夹选择 --- */
  .folder-picker-list {
    max-height: 200px;
  }
  .folder-picker-item {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* --- 颜色选择器 --- */
  #color-picker-popup {
    max-width: 94vw;
    padding: 8px;
    gap: 5px;
  }
  #color-picker-popup > div {
    width: 32px;
    height: 32px;
  }

  /* --- 背景色面板 --- */
  #bg-color-picker-popup [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* --- 形状选择器 --- */
  #shape-picker-popup [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* --- 图标选择器 --- */
  #icon-picker-popup {
    max-width: 98vw !important;
  }
  #icon-picker-popup [style*="grid-template-columns:repeat(10,1fr)"] {
    grid-template-columns: repeat(5, 1fr) !important;
  }

  /* --- 长按菜单 --- */
  .longpress-menu {
    min-width: 100px;
    border-radius: 6px;
  }
  .longpress-menu-item {
    padding: 12px 20px;
    font-size: 13px;
  }

  /* --- 市场卡片 --- */
  .market-entry-card {
    padding: 10px 12px !important;
  }
}
