/* ==========================================================================
   块记 · 第 1 步样式
   风格：极简、纸感 / 白板感、圆角、柔和阴影、低饱和配色
   主题：浅色 + 深色，跟随系统；变量集中在这里，方便以后加“主题切换”
   ========================================================================== */

:root {
  /* 纸感底色 */
  --bg: #f7f5f2;
  --bg-soft: #efebe6;
  --surface: #ffffff;
  --surface-soft: #fbfaf8;
  /* 低饱和墨色 */
  --ink: #2f2c28;
  --ink-soft: #6d6862;
  --ink-faint: #a39d95;
  --line: #e6e0d8;
  --line-strong: #d6cec3;
  --accent: #6f8f7d;          /* 低饱和雾绿 */
  --accent-soft: #eaf0ec;
  --danger: #b3705f;
  --danger-soft: #f6ebe8;
  /* 圆角与阴影 */
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-1: 0 1px 2px rgba(47, 44, 40, .05), 0 4px 14px rgba(47, 44, 40, .045);
  --shadow-2: 0 6px 14px rgba(47, 44, 40, .10), 0 18px 40px rgba(47, 44, 40, .12);
  --ring: 0 0 0 3px rgba(111, 143, 125, .28);
  --tap: 44px;                /* 触屏最小点击尺寸 */
}

/* ==========================================================================
   第 7 步：让“应用设置”里的选择一定生效
   --------------------------------------------------------------------------
   背景色/主题色/深浅模式由 js/appearance.js 写成 <html> 上的内联 CSS 变量。
   但内联样式的优先级和一个 :root 规则**打平**，而媒体查询里的规则出现在后面
   就会赢 —— 那样“强制浅色”在系统深色下会失效。
   这里用 html[data-mode]（属性选择器，特异性更高）把背景/强调色重新声明一遍，
   指向同一批变量，保证用户的选择永远压得住系统偏好。
   -------------------------------------------------------------------------- */
html[data-mode="light"], html[data-mode="dark"] {
  --bg: var(--skin-bg);
  --bg-soft: var(--skin-bg-soft);
  --surface: var(--skin-surface);
  --line: var(--skin-line);
  --line-strong: var(--skin-line-strong);
  --accent: var(--skin-accent);
  --accent-soft: var(--skin-accent-soft);
}
/* 深浅模式决定的两组“墨色/阴影”也显式声明，避免媒体查询打平后抢先 */
html[data-mode="light"] {
  --ink: #2f2c28;
  --ink-soft: #6d6862;
  --ink-faint: #a39d95;
  --danger: #b3705f;
  --danger-soft: #f6ebe8;
  --shadow-1: 0 1px 2px rgba(47, 44, 40, .05), 0 4px 14px rgba(47, 44, 40, .045);
  --shadow-2: 0 6px 14px rgba(47, 44, 40, .10), 0 18px 40px rgba(47, 44, 40, .12);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
/* 第 9 步：深色模式改成“接近纯黑 + 白字”（用户反馈原来的偏灰）。
   主背景由背景色预设给（#0d~#14），这里负责墨色与阴影。
   对比度都算过：主文字压在 --bg 上 ≥ 15:1，次要文字 ≥ 6:1。 */
html[data-mode="dark"] {
  --ink: #f5f5f5;          /* 主文字：接近纯白 */
  --ink-soft: #b3b3b3;     /* 次要文字：浅灰 */
  --ink-faint: #8a8a8a;    /* 辅助文字：再淡一档，但仍可读 */
  --danger: #e08a78;
  --danger-soft: #2a1c19;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .45), 0 4px 14px rgba(0, 0, 0, .38);
  --shadow-2: 0 8px 18px rgba(0, 0, 0, .55), 0 20px 44px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent);
}
/* 深色下少数几处写死的颜色（原来是给纯深色准备的）也跟着模式走 */
html[data-mode="light"] .data-value-warn { color: #9a7a2a; }
html[data-mode="dark"] .data-value-warn { color: #e0bd63; }
html[data-mode="light"] .data-warn { border-color: #e0d3a8; background: #fbf6e6; color: #7a6520; }
html[data-mode="dark"] .data-warn { border-color: #4a4028; background: #262014; color: #eddcab; }
html[data-mode="light"] .feedback-warn { border-color: #e0d3a8; background: #fbf6e6; color: #7a6520; }
html[data-mode="dark"] .feedback-warn { border-color: #4a4028; background: #262014; color: #eddcab; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --bg-soft: #181716;
    --surface: #1d1c1a;
    --surface-soft: #232220;
    --ink: #f5f5f5;
    --ink-soft: #b3b3b3;
    --ink-faint: #8a8a8a;
    --line: #2e2c29;
    --line-strong: #3d3a36;
    --accent: #8fbf95;
    --accent-soft: #1b241d;
    --danger: #e08a78;
    --danger-soft: #2a1c19;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow-2: 0 8px 18px rgba(0, 0, 0, .42), 0 20px 44px rgba(0, 0, 0, .45);
    --ring: 0 0 0 3px rgba(143, 174, 156, .3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC",
               "Noto Sans SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* 手机上给“贴边”留出安全距离 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* --------------------------------------------------------- 顶栏（吸顶） */
/* ==========================================================================
   第 9 步：平板 / 电脑适配
   --------------------------------------------------------------------------
   手机（<600px）   ：保持原样 —— 侧边栏是覆盖式的，点汉堡菜单滑出。
   平板竖屏（≥600px）：侧边栏默认展开，不再需要汉堡菜单。
   平板横屏 / 电脑（≥900px）：侧边栏常驻并**占位**（不遮盖内容），
                             主区域居中、限宽 720px。
   ========================================================================== */
.app-shell {
  /* 手机：单列；平板起变成「侧边栏 | 内容」，页脚横跨整行 */
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "main"
    "footer";
  align-content: start;
  /* 占满顶栏以下的全部高度 */
  flex: 1 1 auto;
  min-height: 0;
}
.app-main { grid-area: main; }
.app-footer { grid-area: footer; }
#sidebar { grid-area: sidebar; }
#block-template { grid-area: none; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .app-header { background: var(--bg); }
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 1.06rem;
  font-weight: 650;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.brand-mark {
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
}

/* --------------------------------------------------------- 按钮 */
.btn {
  font: inherit;
  font-size: .95rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 14px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
  user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: color-mix(in srgb, var(--accent) 80%, #000);
  box-shadow: var(--shadow-1);
}
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.05); }
}

/* --------------------------------------------------------- 主体 */
.app-main {
  /* 宽度由 Grid 决定；内容的可读宽度由下面的 .board 等限住 */
  min-width: 0;
  width: 100%;
  padding: 14px 12px 28px;
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: .88rem;
}

/* --------------------------------------------------------- 笔记块列表 */
.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  /* 第 11 步：视觉顺序是 [文字区][手柄][删除]。
     文字区贴左边缘（不加额外左内边距），右侧留 8px 给按钮。
     内部顺序由各元素的 order 决定（见 .handle / .block-delete）。 */
  padding: 8px 8px 8px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  transition: box-shadow .16s ease, border-color .16s ease, background-color .16s ease;
}
.block:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-1), var(--ring);
}

/* 拖拽手柄：手机上唯一的拖拽起点 */
.handle {
  position: relative;      /* 给扩大的触控热区（::before）当定位基准 */
  flex: 0 0 auto;
  order: 2;                /* 第 11 步：手柄在文字区**右边** */
  /* 第 8 步：整块长按取消后，手柄成了唯一的拖拽入口，所以做得更好按 ——
     宽度 34px → 48px，字形也放大一档 */
  width: 48px;
  min-height: var(--tap);
  margin-top: 1px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.28rem;
  line-height: 1;
  border-radius: var(--r-sm);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;      /* 关键：手机上按手柄拖动时不允许页面滚动 */
  user-select: none;
  -webkit-user-select: none;
}
/* 触控热区再往外扩一圈：手指不容易按偏（不改变视觉尺寸） */
.handle::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -6px;
  right: -6px;
  border-radius: inherit;
}
/* 手柄在被按住/拖动时给一点反馈，让用户知道“抓到了” */
.handle:active,
.block.is-dragging .handle {
  color: var(--accent);
  background: var(--accent-soft);
}
.handle:active { cursor: grabbing; }
.handle:focus-visible { outline: none; box-shadow: var(--ring); }

.block-body {
  flex: 1 1 auto;
  min-width: 0;
  order: 1;                     /* 文字区：最左，贴边缘 */
  padding: 4px 0 4px 0;
}

.block-text {
  min-height: 1.6em;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 1rem;
  color: var(--ink);
}
.block-text:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
}

.block-meta {
  height: 0;
  overflow: hidden;
  transition: height .15s ease;
}
.block:focus-within .block-meta { height: 1.25rem; }
.block-count {
  font-size: .74rem;
  color: var(--ink-faint);
  letter-spacing: .02em;
}

/* 删除：手机上没有 hover，所以一直可见，但保持低调 */
.block-delete {
  flex: 0 0 auto;
  order: 3;                /* 第 11 步：删除键在**最右** */
  width: 34px;
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: .92rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s ease, background-color .15s ease;
  touch-action: manipulation;
}
.block-delete:focus-visible { outline: none; box-shadow: var(--ring); }
/* “再点一次确认删除”的状态：把 ✕ 变成文字按钮，让用户看清自己在确认什么 */
.block-delete.is-armed {
  width: auto;
  padding: 0 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: .82rem;
  white-space: nowrap;
}
@media (hover: hover) {
  .block-delete { opacity: .45; }
  .block:hover .block-delete { opacity: 1; }
  .block-delete.is-armed { opacity: 1; }
  .block-delete:hover { color: var(--danger); background: var(--danger-soft); }
}

/* 拖动中的样子 */
.block.is-dragging {
  box-shadow: var(--shadow-2);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  opacity: .97;
  z-index: 40;
}
.block.is-ghost { opacity: .35; }              /* 内置拖拽：原位留下的占位影子 */
.board.is-sorting .block:not(.is-dragging) { transition: transform .12s ease; }

/* --------------------------------------------------------- 空状态 */
.empty {
  text-align: center;
  padding: 46px 18px 34px;
  color: var(--ink-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
}
.empty-mark { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.empty-title { margin: 0 0 6px; font-weight: 600; color: var(--ink); }
.empty-hint { margin: 0; font-size: .88rem; color: var(--ink-soft); }

.board-tail-hint {
  margin: 14px 2px 0;
  text-align: center;
  font-size: .8rem;
  color: var(--ink-faint);
}

/* --------------------------------------------------------- 底栏 */
.app-footer {
  /* 宽度交给 Grid；这里只管居中和留白 */
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 0 14px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
}
.footer-line { margin: 2px 0; font-size: .78rem; color: var(--ink-soft); }
.footer-dim { color: var(--ink-faint); }

/* 脚注里的文字链接：低干扰，但手指点得到 */
.footer-link {
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline-block;
  padding: 8px 6px;          /* 把点击区域撑到手指够得着 */
  min-height: 32px;
}
.footer-link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
@media (hover: hover) { .footer-link:hover { color: var(--accent); } }

.save-state { transition: color .2s ease; }
.save-state.is-saving { color: var(--ink-faint); }
.save-state.is-saved { color: var(--accent); }
.save-state.is-error { color: var(--danger); }

/* ==========================================================================
   顶栏图标按钮（设置齿轮）
   ========================================================================== */
.icon-btn {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease, transform .12s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: hover) {
  .icon-btn:hover { color: var(--accent); border-color: var(--line-strong); }
}

/* ==========================================================================
   设置覆盖层
   手机上全屏铺满；电脑上居中一块面板。打开时 <html> 带 .overlay-open 锁滚动。
   ========================================================================== */
.overlay-open, .overlay-open body { overflow: hidden; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.overlay[hidden] { display: none; }

.overlay-panel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;                 /* 关键：让内部滚动区能正确收缩 */
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.settings-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));   /* 底部留出关闭按钮的位置 */
}
.settings-scroll[hidden] { display: none; }

.settings-title {
  margin: 0 0 14px;
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: .02em;
}

.settings-foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: .78rem;
  color: var(--ink-faint);
}

/* 关闭按钮：手机固定在底部（大拇指好够），电脑上挪到面板右上角 */
.overlay-close {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 5;
  font: inherit;
  font-size: .95rem;
  min-height: var(--tap);
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background-color .15s ease;
}
.overlay-close:active { transform: translateX(-50%) scale(.97); }
.overlay-close:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: hover) {
  .overlay-close:hover { background: var(--surface-soft); }
}

/* 设置入口列表 */
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nav-list li[hidden] { display: none; }

.nav-item {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .15s ease, background-color .15s ease, transform .12s ease;
}
.nav-item:active { transform: scale(.99); }
.nav-item:focus-visible { outline: none; box-shadow: var(--shadow-1), var(--ring); }
@media (hover: hover) {
  .nav-item:hover { border-color: var(--line-strong); background: var(--surface-soft); }
}
.nav-icon { flex: 0 0 auto; font-size: 1.25rem; line-height: 1; width: 26px; text-align: center; }
.nav-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 1rem; font-weight: 600; }
.nav-sub { font-size: .82rem; color: var(--ink-soft); }
.nav-arrow { flex: 0 0 auto; color: var(--ink-faint); font-size: 1.3rem; line-height: 1; }

/* 子页头部：返回 + 标题 */
.sub-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.sub-head .settings-title { margin: 0; }
.back-btn {
  flex: 0 0 auto;
  font: inherit;
  font-size: .92rem;
  min-height: var(--tap);
  padding: 0 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.back-btn:active { transform: scale(.97); }
.back-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* 开关行 */
.switch-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  min-height: 64px;
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.switch-row:focus-visible { outline: none; box-shadow: var(--shadow-1), var(--ring); }
.switch-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.switch-label { font-size: 1rem; font-weight: 600; }
.switch-sub { font-size: .82rem; color: var(--ink-soft); line-height: 1.5; }
.switch-state { font-size: .78rem; color: var(--ink-faint); }

/* 开关本体 */
.switch {
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--line-strong);
  border: 1px solid var(--line-strong);
  position: relative;
  transition: background-color .18s ease, border-color .18s ease;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s ease;
}
.switch-row[aria-checked="true"] .switch {
  background: var(--accent);
  border-color: var(--accent);
}
.switch-row[aria-checked="true"] .switch-knob { transform: translateX(20px); }
.switch-row[aria-checked="true"] .switch-state { color: var(--accent); }

/* 占位页 */
.placeholder {
  padding: 30px 18px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
}
.placeholder-text { margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.placeholder-sub { margin: 0; font-size: .86rem; color: var(--ink-soft); }

/* ==========================================================================
   数据与隐私页（第 3 步）
   ========================================================================== */
.data-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 16px 14px;
  margin-bottom: 14px;
}
.data-heading {
  margin: 0 0 10px;
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--ink);
}
.data-lead {
  margin: 0 0 10px;
  font-size: .9rem;
  line-height: 1.65;
  color: var(--ink-soft);
}
.data-lead:last-child { margin-bottom: 0; }
.data-lead-dim { color: var(--ink-faint); }

/* 状态表：左边标签，右边值 */
.data-table {
  margin: 0 0 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: baseline;
  font-size: .9rem;
}
.data-table dt {
  color: var(--ink-faint);
  white-space: nowrap;
}
.data-table dd { margin: 0; min-width: 0; }
.data-value {
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.data-value-good { color: var(--accent); }
.data-value-warn { color: #9a7b28; }
.data-value-bad { color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .data-value-warn { color: #d9b356; }
}

.data-warn {
  margin: 0;
  padding: 11px 12px;
  border-radius: var(--r-md);
  border: 1px solid #e8d6ae;
  background: #fdf4e3;
  color: #7a5a17;
  font-size: .86rem;
  line-height: 1.6;
}
@media (prefers-color-scheme: dark) {
  .data-warn { border-color: #5c4f2f; background: #362f1f; color: #e8d49b; }
}

/* 备份/恢复按钮区 */
.data-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 8px;
}
.data-btn {
  justify-self: start;
  min-height: var(--tap);
  white-space: nowrap;
}
.data-btn-hint {
  font-size: .8rem;
  color: var(--ink-faint);
  line-height: 1.45;
}
.btn-ghost-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}
@media (hover: hover) {
  .btn-ghost-danger:hover { background: var(--danger-soft); }
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: color-mix(in srgb, var(--danger) 80%, #000);
}

/* 选完文件后的“合并 / 覆盖”选择 */
.import-ask {
  margin-top: 10px;
  padding: 13px 13px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: var(--r-md);
  background: var(--accent-soft);
}
.import-ask[hidden] { display: none; }
.import-ask-text { margin: 0 0 10px; font-size: .9rem; font-weight: 600; color: var(--ink); }
.import-ask-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.import-ask-hint { margin: 0; font-size: .8rem; line-height: 1.6; color: var(--ink-soft); }

/* 覆盖的二次确认 */
.confirm-box {
  margin-top: 10px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--r-md);
  background: var(--danger-soft);
}
.confirm-box[hidden] { display: none; }
.confirm-title { margin: 0 0 7px; font-weight: 650; color: var(--ink); }
.confirm-text { margin: 0 0 11px; font-size: .86rem; line-height: 1.6; color: var(--ink-soft); }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 操作结果反馈 */
.feedback {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: .86rem;
  line-height: 1.6;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.feedback[hidden] { display: none; }
.feedback-ok { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); color: var(--ink); }
.feedback-warn { border-color: #e8d6ae; background: #fdf4e3; color: #7a5a17; }
.feedback-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .feedback-warn { border-color: #5c4f2f; background: #362f1f; color: #e8d49b; }
}

/* 备份提醒：入口旁边的小圆点 */
.nav-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: middle;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.nav-dot[hidden] { display: none; }

/* ==========================================================================
   广告与支持页（第 4 步）
   这一页只有用户主动进来才看得到；主页面任何地方都不出现广告。
   ========================================================================== */

/* 透明进度：三个数字 */
.progress-figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.progress-figure {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  min-width: 0;
}
.progress-label {
  font-size: .76rem;
  color: var(--ink-faint);
  white-space: nowrap;
}
.progress-value {
  font-size: .98rem;
  font-weight: 650;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.progress-value-gap { color: var(--accent); }

/* 进度条 */
.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .35s ease;
}
.progress-note {
  margin: 9px 0 0;
  font-size: .8rem;
  color: var(--ink-faint);
  line-height: 1.6;
}
.progress-note:empty { display: none; }

/* 捐赠入口卡片 */
.donate-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 10px;
}
.donate-list[hidden] { display: none; }

.donate-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  transition: border-color .15s ease, background-color .15s ease, transform .12s ease;
  touch-action: manipulation;
}
.donate-card:active { transform: scale(.99); }
.donate-card:focus-visible { outline: none; box-shadow: var(--shadow-1), var(--ring); }
@media (hover: hover) {
  .donate-card:hover { border-color: var(--accent); background: var(--accent-soft); }
}
.donate-name { flex: 0 0 auto; font-weight: 650; }
.donate-note {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .82rem;
  color: var(--ink-soft);
}
.donate-arrow { flex: 0 0 auto; color: var(--ink-faint); font-size: 1rem; }

.donate-empty {
  margin: 0 0 10px;
  padding: 14px;
  text-align: center;
  font-size: .88rem;
  color: var(--ink-faint);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}
.donate-empty[hidden] { display: none; }

/* 赞助商位 */
.sponsor-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 10px;
}
.sponsor-list[hidden] { display: none; }
.sponsor-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}
.sponsor-name { font-weight: 650; }
.sponsor-note { flex: 1 1 auto; font-size: .82rem; color: var(--ink-soft); }
.sponsor-link {
  flex: 0 0 auto;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  font-size: .86rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sponsor-link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

.sponsor-empty {
  margin: 0 0 10px;
  padding: 14px;
  text-align: center;
  font-size: .88rem;
  color: var(--ink-faint);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}
.sponsor-empty[hidden] { display: none; }

/* 页脚那两句 */
.support-footer-line {
  margin: 22px 0 4px;
  text-align: center;
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
}
.support-footer-note {
  margin: 0 0 6px;
  text-align: center;
  font-size: .8rem;
  color: var(--ink-faint);
  line-height: 1.6;
}

/* 小屏：三个数字改成竖排更好读 */
@media (max-width: 460px) {
  .progress-figures { grid-template-columns: 1fr; gap: 7px; }
  .progress-figure { flex-direction: row; align-items: baseline; justify-content: space-between; }
}

/* 给读屏用、但视觉上隐藏（文件选择框） */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 小屏：按钮和说明改成上下排，省横向空间 */
@media (max-width: 520px) {
  .data-actions { grid-template-columns: 1fr; gap: 6px; }
  .data-btn { width: 100%; justify-content: center; }
  .data-btn-hint { margin-bottom: 8px; }
  .data-table { grid-template-columns: 1fr; gap: 2px; }
  .data-table dt { font-size: .78rem; margin-top: 6px; }
}

/* 警示样式的提示条（设置存不住时用） */
.notice-warn {
  border-color: #e8d6ae;
  background: #fdf4e3;
  color: #7a5a17;
}
@media (prefers-color-scheme: dark) {
  .notice-warn { border-color: #5c4f2f; background: #362f1f; color: #e8d49b; }
}

/* 电脑上：居中面板 + 圆角阴影，关闭按钮回到右上角 */
@media (min-width: 720px) {
  .overlay {
    background: rgba(28, 27, 25, .38);
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  @media (prefers-color-scheme: dark) {
    .overlay { background: rgba(0, 0, 0, .55); }
  }
  .overlay-panel {
    flex: 0 1 auto;
    max-height: 82vh;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    overflow: hidden;
  }
  .settings-scroll { padding: 22px 22px 26px; }
  .overlay-close {
    left: auto;
    right: 14px;
    bottom: auto;
    top: 14px;
    transform: none;
    padding: 0 14px;
    font-size: .88rem;
    border-radius: var(--r-md);
  }
  .overlay-close:active { transform: scale(.97); }
  .overlay-close-text { display: inline; }
  .sub-head .settings-title { padding-right: 90px; }   /* 给右上角关闭按钮让位 */
}

/* 手机上：关闭按钮只留图标会把文字一起显示更好点，这里保持“✕ 关闭” */
@media (max-width: 719px) {
  .settings-scroll { padding-top: 22px; }
}

/* --------------------------------------------------------- 小屏微调 */
@media (max-width: 420px) {
  .header-inner { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 1rem; }
  .btn { padding: 0 11px; font-size: .9rem; }
  .btn-label { display: none; }        /* 小屏只留“＋”，避免挤压齿轮按钮 */
  .app-main { padding: 10px 8px 24px; }
  .block { padding: 6px 6px 6px 2px; border-radius: var(--r-md); }
  /* 第 8 步：手柄在窄屏上也要保持好按（原来被压到 32px） */
  .handle { width: 48px; }
  .block-delete { width: 32px; }
}

/* 大屏：更宽松的留白 */
@media (min-width: 900px) {
  .app-main { padding-top: 22px; }
  .board { gap: 12px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ==========================================================================
   第 5 步：顶栏改造 + 侧边栏（窗口列表）+ 弹窗
   ========================================================================== */

/* ---------------------------------------------- 顶栏：汉堡 / 标题 / 新建 */
.window-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.window-title {
  max-width: 100%;
  min-height: var(--tap);
  padding: 0 10px;
  font: inherit;
  font-size: .98rem;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  touch-action: manipulation;
}
.window-title:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: hover) {
  .window-title:hover { background: var(--surface-soft); border-color: var(--line); }
}
.window-title-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 10px;
  font: inherit;
  font-size: .98rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
}
.window-title-input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }

/* ---------------------------------------------- 侧边栏 */
.sidebar-open, .sidebar-open body { overflow: hidden; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(28, 27, 25, .35);
  opacity: 0;
  transition: opacity .18s ease-out;
}
.sidebar-backdrop.is-open { opacity: 1; }
.sidebar-backdrop[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .sidebar-backdrop { background: rgba(0, 0, 0, .5); }
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 61;
  width: min(86vw, 330px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* 第 9 步：改成 transform 动画 —— 只走 GPU 合成，不触发重排/重绘，
     所以点汉堡菜单时不会卡（原来用 left/width 这类属性会强制布局）。 */
  transform: translate3d(-102%, 0, 0);
  transition: transform .18s ease-out;
  will-change: transform;
  /* 还没滑进来时不要挡住下面的内容 */
  visibility: hidden;
}
.sidebar.is-open {
  transform: translate3d(0, 0, 0);
  visibility: visible;
}
/* 宽屏常驻时不要动画、也不要位移 */
@media (min-width: 900px) {
  .sidebar { transform: none; visibility: visible; transition: none; }
}
.sidebar[hidden] { display: none; }

.sidebar-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: .03em;
}

.sidebar-actions { flex: 0 0 auto; padding: 10px 12px 6px; }
.sidebar-new {
  width: 100%;
  min-height: var(--tap);
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 80%, #000);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease;
}
.sidebar-new:active { transform: scale(.98); }
.sidebar-new:focus-visible { outline: none; box-shadow: var(--ring); }

/* 窗口列表 */
.window-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
  margin: 0;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.window-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  transition: background-color .15s ease, border-color .15s ease;
  /* 第 9 步：这里**故意不声明 touch-action** ——
     声明 pan-y 的话浏览器仍然认为自己负责竖向滚动，长按时会直接发
     pointercancel 把事件抢走，窗口就拖不动了。
     正确做法是等长按计时到了（确认用户是要拖），由 JS 临时声明 none。 */
}
.window-item.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.window-item.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.window-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-left: 10px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  color: #fff;
  background: var(--surface);
}
.window-check.is-on { background: var(--accent); border-color: var(--accent); }

.window-pin {
  flex: 0 0 auto;
  margin-left: 8px;
  font-size: .78rem;
  line-height: 1;
}

.window-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 56px;
  padding: 9px 6px;
  font: inherit;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  touch-action: manipulation;
}
.window-main:focus-visible { outline: none; box-shadow: var(--ring); }
.window-name {
  font-size: .94rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.window-meta { font-size: .74rem; color: var(--ink-faint); }

.window-more {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  margin-right: 4px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.1rem;
  line-height: 1;
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
}
.window-more:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: hover) {
  .window-more:hover { background: var(--surface-soft); color: var(--ink); }
}

/* 侧边栏底部 */
.sidebar-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.sidebar-empty {
  margin: 0 0 8px;
  text-align: center;
  font-size: .82rem;
  color: var(--ink-faint);
}
.sidebar-empty[hidden] { display: none; }

.sidebar-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sidebar-bulk[hidden] { display: none; }
.sidebar-bulk-count {
  flex: 1 1 auto;
  font-size: .82rem;
  color: var(--ink-soft);
}

.sidebar-settings {
  width: 100%;
  min-height: var(--tap);
  margin-top: 6px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}
.sidebar-settings:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: hover) {
  .sidebar-settings:hover { background: var(--surface-soft); border-color: var(--line-strong); }
}

/* ---------------------------------------------- 浮层菜单（三个点） */
.popover {
  position: fixed;
  z-index: 70;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.popover[hidden] { display: none; }
.popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 12px;
  font: inherit;
  font-size: .92rem;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
}
.popover-item:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: hover) {
  .popover-item:hover { background: var(--surface-soft); }
}
.popover-item-danger { color: var(--danger); }

/* ---------------------------------------------- 弹窗（重命名 / 删除确认） */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 27, 25, .45);
}
.modal[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .modal { background: rgba(0, 0, 0, .6); }
}
.modal-card {
  width: 100%;
  max-width: 340px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.modal-title { margin: 0 0 12px; font-size: 1rem; font-weight: 650; }
.modal-text { margin: 0 0 14px; font-size: .88rem; line-height: 1.6; color: var(--ink-soft); }
.modal-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  margin-bottom: 14px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
}
.modal-input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------------------------------------- 拖动中的视觉反馈 */
.block.is-dragging {
  transform: scale(1.02);
  box-shadow: 0 10px 26px rgba(47, 44, 40, .22), 0 2px 6px rgba(47, 44, 40, .12);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: var(--surface);
}
@media (prefers-color-scheme: dark) {
  .block.is-dragging {
    box-shadow: 0 12px 30px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .4);
  }
}

/* 小屏：顶栏只留图标，标题居中 */
@media (max-width: 520px) {
  .header-inner { gap: 6px; }
  .window-title { font-size: .92rem; padding: 0 4px; }
}

/* ==========================================================================
   第 6 步：侧边栏两层结构（文件夹 → 窗口）+ 跨窗口拖拽的落点反馈
   ========================================================================== */

.sidebar-actions { display: flex; flex-direction: column; gap: 7px; }
.sidebar-new-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
@media (hover: hover) {
  .sidebar-new-ghost:hover { background: var(--surface-soft); }
}

.folder-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.folder-block {
  border-radius: var(--r-md);
  border: 1px solid transparent;
}
.folder-block.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.folder-block.is-dragging-row { opacity: .5; }
/* 文件夹排序拖拽时的落点：在目标上方画一条线 */
.folder-block.is-drop-before {
  box-shadow: 0 -3px 0 0 var(--accent);
}

.folder-head {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  /* 同上：touch-action 由 JS 在长按确认后临时声明 */
}

.folder-name-btn {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 6px 4px 6px 8px;
  font: inherit;
  font-size: .86rem;
  font-weight: 650;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  touch-action: manipulation;
}
.folder-name-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.folder-caret { flex: 0 0 auto; color: var(--ink-faint); font-size: .72rem; width: 10px; }
.folder-pin { flex: 0 0 auto; font-size: .72rem; }
.folder-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-count {
  flex: 0 0 auto;
  font-size: .7rem;
  font-weight: 400;
  color: var(--ink-faint);
}

.folder-windows {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 2px solid var(--line);
  min-height: 12px;                 /* 空文件夹也要能接住拖拽 */
}
/* 跨文件夹拖窗口时的落点高亮：明显但不刺眼 */
.folder-windows.is-drop-target {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  outline: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  border-radius: var(--r-md);
}

.folder-block.is-drop-target {
  outline: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  background: var(--accent-soft);
}

.folder-empty {
  padding: 8px 10px;
  font-size: .78rem;
  color: var(--ink-faint);
}

/* 跨窗口拖块的落点：整行高亮 */
.window-item.is-block-drop-target {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.window-item.is-block-drop-target .window-name,
.window-item.is-block-drop-target .window-meta { color: #fff; }

/* 拖块时给整个页面一个提示态（指针样式 + 禁止选中） */
.block-dragging, .block-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

/* 拖拽提示条 */
.drop-hint {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: 88vw;
  padding: 10px 16px;
  font-size: .84rem;
  color: #fff;
  background: rgba(47, 44, 40, .92);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  pointer-events: none;
  text-align: center;
}
.drop-hint[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .drop-hint { background: rgba(236, 232, 227, .94); color: #1c1b19; }
}

/* 侧边栏底部的多选说明 */
.sidebar-bulk-text {
  margin: 0 0 8px;
  font-size: .74rem;
  line-height: 1.5;
  color: var(--ink-faint);
}
.sidebar-bulk-text:empty { display: none; }

/* ==========================================================================
   第 7 步：应用设置页 / 离线提示 / 关闭按钮
   ========================================================================== */

/* ------------------------- 设置页关闭按钮：用 danger 色，和普通按钮区分开 */
/* 说明：只改主关闭按钮；子页里的「返回」保持原样。 */
.overlay-close {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}
@media (hover: hover) {
  .overlay-close:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
  }
}
.overlay-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 40%, transparent);
}
.overlay-close:active { background: color-mix(in srgb, var(--danger) 82%, #000); color: #fff; }
/* 子页的返回按钮不受影响，明确写一遍保持原样 */
.back-btn { color: var(--ink-soft); background: transparent; border-color: var(--line); }

/* ---------------------------------------------------- 顶栏的离线小提示 */
.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 42vw;
  padding: 4px 9px;
  font-size: .7rem;
  line-height: 1.35;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.offline-badge[hidden] { display: none; }
@media (max-width: 420px) {
  .offline-badge { max-width: 34vw; font-size: .66rem; padding: 3px 7px; }
}

/* ------------------------------------------------------------ 应用设置页 */
.appear-section {
  margin: 0 0 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}
.appear-section:last-of-type { border-bottom: none; }
.appear-title {
  margin: 0 0 4px;
  font-size: .95rem;
  font-weight: 650;
  color: var(--ink);
}
.appear-hint {
  margin: 0 0 12px;
  font-size: .78rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.appear-note {
  margin: 10px 0 0;
  font-size: .74rem;
  color: var(--ink-faint);
}
.appear-foot {
  min-height: 1.4em;
  margin: 6px 0 0;
  font-size: .78rem;
  color: var(--ink-soft);
}
.appear-foot.is-ok { color: var(--accent); }
.appear-foot.is-warn { color: var(--danger); }

/* 图标选择 */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
}
.icon-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 6px;
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-choice:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-choice.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 32%, transparent);
}
.icon-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  font-size: 24px;
  line-height: 1;
  border-radius: 12px;
}
.icon-name { font-size: .7rem; color: var(--ink-soft); }

/* 主题色 / 背景色色块 */
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 7px 12px 7px 8px;
  font: inherit;
  font-size: .78rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
.swatch:focus-visible { outline: none; box-shadow: var(--ring); }
.swatch.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}
.swatch-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .12);
}
.swatch-row-wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.swatch-block {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border-radius: var(--r-md);
  padding: 9px 11px;
}
.swatch-chip {
  width: 100%;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
}
.swatch-name { font-size: .8rem; font-weight: 600; }
.swatch-hint { font-size: .68rem; color: var(--ink-faint); }

/* 深浅模式 */
.mode-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.mode-choice {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: var(--tap);
  padding: 9px 11px;
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  touch-action: manipulation;
}
.mode-choice:focus-visible { outline: none; box-shadow: var(--ring); }
.mode-choice.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 26%, transparent);
}
.mode-name { font-size: .82rem; font-weight: 600; color: var(--ink); }
.mode-hint { font-size: .68rem; color: var(--ink-faint); }

/* 装到桌面说明 */
.install-box {
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.install-box.is-installed { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.install-head { margin: 0 0 5px; font-size: .84rem; font-weight: 650; color: var(--ink); }
.install-text { margin: 0 0 8px; font-size: .78rem; line-height: 1.65; color: var(--ink-soft); }
.install-steps {
  margin: 0 0 10px;
  padding-left: 20px;
  font-size: .78rem;
  line-height: 1.75;
  color: var(--ink-soft);
}
.install-status { margin: 8px 0 0; font-size: .72rem; color: var(--ink-faint); }
.install-box .btn { margin-top: 4px; }

/* 拖块时左边缘的提示条：不抢焦点、不挡操作，纯视觉反馈 */
.edge-hint {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 95;
  padding: 10px 12px 10px 8px;
  font-size: .72rem;
  color: var(--ink-soft);
  background: linear-gradient(to right,
    color-mix(in srgb, var(--accent) 34%, transparent),
    color-mix(in srgb, var(--accent) 8%, transparent));
  border-radius: 0 999px 999px 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.edge-hint[hidden] { display: none; }
.edge-hint.is-armed {
  color: #fff;
  background: linear-gradient(to right,
    color-mix(in srgb, var(--accent) 88%, transparent),
    color-mix(in srgb, var(--accent) 26%, transparent));
}

/* 拖窗口时的插入线（第 7 步）：在目标窗口的上边或下边画一条强调色的线 */
.window-item.is-insert-before { box-shadow: 0 -3px 0 0 var(--accent); }
.window-item.is-insert-after { box-shadow: 0 3px 0 0 var(--accent); }
.window-item.is-insert-before,
.window-item.is-insert-after { border-color: var(--accent); }

/* 关闭按钮：整条规则显式使用 danger 变量（方便一眼确认，也让样式更集中） */
html .overlay-close {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}

/* ==========================================================================
   第 8 步：顶栏与弹窗
   ========================================================================== */

/* “新建窗口”的图标：用 CSS 画一扇窗户（横梁 + 竖梁），
   不用 emoji，这样能跟着主题色和深浅模式走。
   为什么不用“+”：会和新块按钮的“＋”混淆。 */
.icon-window {
  position: relative;
  display: block;
  width: 19px;
  height: 17px;
  border: 1.8px solid currentColor;
  border-radius: 3.5px;
}
/* 上面的横梁 */
.icon-window::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 3.6px;
  height: 1.8px;
  background: currentColor;
}
/* 中间的竖梁 */
.icon-window::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5.4px;
  bottom: 0;
  width: 1.8px;
  margin-left: -0.9px;
  background: currentColor;
}

/* 顶栏三个按钮变两个：给它们更多呼吸空间，别挤在一起 */
.header-actions { gap: 12px; }

/* 重命名/命名弹窗的副标题（只在“新建”时出现） */
.modal-sub {
  margin: -4px 0 12px;
  font-size: .78rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.modal-sub[hidden] { display: none; }

/* ==========================================================================
   第 8 步：字号 / 背景图 / 设置分组小标题
   ========================================================================== */

/* ---------------------------------------------------------------- 字号 */
/* 思路：不动字体族，也不动行距，只按档位微调各处文字尺寸。
   用 data-font 一档一条规则，不依赖 JS 计算，刷新也能立刻对上。 */
html[data-font="small"]  .block-text  { font-size: .95rem; }
html[data-font="normal"] .block-text  { font-size: 1rem; }
html[data-font="large"]  .block-text  { font-size: 1.1rem; }
html[data-font="xlarge"] .block-text  { font-size: 1.22rem; }

html[data-font="small"]  .window-name,
html[data-font="small"]  .folder-name  { font-size: .9rem; }
html[data-font="large"]  .window-name,
html[data-font="large"]  .folder-name  { font-size: 1rem; }
html[data-font="xlarge"] .window-name,
html[data-font="xlarge"] .folder-name  { font-size: 1.06rem; }

html[data-font="small"]  .window-title { font-size: 1rem; }
html[data-font="large"]  .window-title { font-size: 1.16rem; }
html[data-font="xlarge"] .window-title { font-size: 1.26rem; }

html[data-font="small"]  .nav-label,
html[data-font="small"]  .switch-label,
html[data-font="small"]  .appear-title,
html[data-font="small"]  .data-heading   { font-size: .9rem; }
html[data-font="large"]  .nav-label,
html[data-font="large"]  .switch-label,
html[data-font="large"]  .appear-title,
html[data-font="large"]  .data-heading   { font-size: 1.02rem; }
html[data-font="xlarge"] .nav-label,
html[data-font="xlarge"] .switch-label,
html[data-font="xlarge"] .appear-title,
html[data-font="xlarge"] .data-heading   { font-size: 1.08rem; }

html[data-font="large"]  .nav-sub,
html[data-font="large"]  .switch-sub,
html[data-font="large"]  .appear-hint,
html[data-font="large"]  .data-lead       { font-size: .84rem; }
html[data-font="xlarge"] .nav-sub,
html[data-font="xlarge"] .switch-sub,
html[data-font="xlarge"] .appear-hint,
html[data-font="xlarge"] .data-lead       { font-size: .9rem; }

/* 背景图开启时：把图铺在内容**下面**（::-before 在正常流之下、背景之上）。
   可调透明度；深色模式再叠一层暗色遮罩，保证文字对比度（第 13 条硬性约束）。

   实现说明：底色仍由 <html> 的背景负责，只把 <body> 变透明，
   再把「遮罩 + 图片」一次写在 body::before 的 background 简写里 ——
   这样只有一层，也就不会挡住内容。 */
html[data-bg-image="on"] body {
  background-color: transparent;
}
html[data-bg-image="on"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-image-opacity, .35);
}
/* 深色：图上面压一层暗色，避免亮图把浅色字“吃掉” */
html[data-bg-image="on"][data-mode="dark"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* 第 9 步：深色下背景图压得更狠（.5 → .72），否则亮图会把白字“吃掉” */
  background: rgba(8, 8, 8, .72);
}
/* 浅色：压一点点白，保证深色文字仍然清楚 */
html[data-bg-image="on"][data-mode="light"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, .16);
}
/* 主体内容要抬到背景图之上 */
html[data-bg-image="on"] .app-header,
html[data-bg-image="on"] .app-main,
html[data-bg-image="on"] .sidebar,
html[data-bg-image="on"] .overlay {
  position: relative;
  z-index: 1;
}
/* 开了背景图时，块和头部用半透明底，让图透出来但字仍然清楚 */
html[data-bg-image="on"] .block {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
html[data-bg-image="on"][data-mode="dark"] .block {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}
html[data-bg-image="on"][data-mode="dark"] .app-header {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}
html[data-bg-image="on"] .app-header {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(3px);
}

/* ------------------------------------------------------ 设置页分组小标题 */
.settings-group-title {
  margin: 22px 0 10px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.settings-group-title:first-of-type { margin-top: 6px; }

/* ------------------------------------------------------------ 背景图区块 */
.bgimage-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.bgimage-title {
  margin: 0 0 4px;
  font-size: .84rem;
  font-weight: 650;
  color: var(--ink);
}
.bgimage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
}
.bgimage-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.bgimage-preview[hidden] { display: none; }
.bgimage-thumb {
  flex: 0 0 auto;
  width: 108px;
  height: 68px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background-color: var(--bg-soft);
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-1);
}
.bgimage-thumb-icon { width: 68px; height: 68px; border-radius: 16px; }
.bgimage-meta {
  font-size: .74rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.bgimage-opacity { margin-top: 14px; }
.bgimage-opacity[hidden] { display: none; }
.bgimage-opacity-label {
  display: block;
  margin-bottom: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink);
}
.bgimage-range {
  width: 100%;
  min-height: var(--tap);
  accent-color: var(--accent);
}

/* 数据页：导出选项里的勾选框 */
.data-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 12px;
  min-height: var(--tap);
  font-size: .78rem;
  line-height: 1.6;
  color: var(--ink-soft);
  cursor: pointer;
}
.data-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

/* ==========================================================================
   第 9 步：批量栏（全选 / 反选 / 删除 / 取消）
   ========================================================================== */
.sidebar-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* 批量栏里的小按钮：仍然保持 44px 的最小可点高度 */
.btn-small {
  min-height: var(--tap);
  padding: 8px 12px;
  font-size: .78rem;
}
.sidebar-bulk-count {
  display: block;
  margin-bottom: 6px;
}


/* 平板竖屏（600-899px）：侧边栏默认可见，但仍然是覆盖层（点内容会收起来） */
@media (min-width: 600px) {
  /* 内容区不拉得太宽，居中显示（这就是“电脑上主区域 720px 居中”的落地方式） */
  .board, .app-main > .notice, .app-main > .empty, .app-main > .board-tail-hint {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
  .app-main { padding-left: 16px; padding-right: 16px; }
  .app-footer { padding-left: 16px; padding-right: 16px; }
  .header-inner { max-width: 900px; margin: 0 auto; }
  .block-text { font-size: 1rem; }
}

/* 平板竖屏起（≥600px）：侧边栏常驻并**占位**（不遮盖内容），
   这样平板和电脑上都不再需要点汉堡菜单。
   600-899 用 240px，900+ 用 280px，1280+ 用 300px。 */
@media (min-width: 600px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-areas:
      "sidebar main"
      "sidebar footer";
  }
  .sidebar {
    position: relative;
    top: auto; left: auto; bottom: auto;
    width: auto;
    height: auto;
    transform: none;
    visibility: visible;
    transition: none;
    box-shadow: none;
    border-right: 1px solid var(--line);
    z-index: 1;
    padding-top: 0;
  }
  /* 常驻时不需要遮罩 */
  .sidebar-backdrop { display: none !important; }
  /* 常驻模式下“关闭”和汉堡菜单都没意义，藏掉 */
  #sidebar-close { display: none; }
  #btn-menu { display: none; }
}

@media (min-width: 900px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .app-header .header-inner { max-width: 1060px; margin: 0 auto; }
  /* 滚动条位置也跟着调整（原来是整页滚） */
  .settings-scroll { padding-left: 8px; padding-right: 8px; }
}

/* 更宽的屏幕：给主区域一点左右留白，视觉上不贴边 */
@media (min-width: 1280px) {
  .app-shell { grid-template-columns: 300px minmax(0, 1fr); }
}

/* 鼠标设备才有 hover 效果；触屏不要依赖 hover（第 5 条） */
@media (hover: none) {
  .window-item:hover, .folder-block:hover { background: inherit; }
}
@media (hover: hover) {
  .window-item:hover { background: var(--surface-soft, #fbfaf8); }
  .folder-head:hover { background: var(--surface-soft, #fbfaf8); }
  /* 桌面端手柄的光标提示更明确 */
  .handle { cursor: grab; }
  .handle:active { cursor: grabbing; }
}

/* 第 9 步：侧边栏“外壳先出、内容随后”。
   列表为空时也保证有一段可见高度，这样点汉堡菜单的瞬间就能看到侧边栏在滑出，
   不会出现“等了半拍才看到东西”的观感。 */
.folder-list {
  min-height: 45vh;
}
.sidebar-actions { flex: 0 0 auto; }
@media (min-width: 900px) {
  .folder-list { min-height: 0; }   /* 宽屏常驻，不需要撑高 */
}
