/* ============================================================
   PDF 编辑器 — 玻璃拟态主题（深色默认 / 浅色可选，data-theme 切换）
   ============================================================ */
:root,
[data-theme="dark"] {
  --bg: #0b0f17;
  --bg2: #111827;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-solid: #151c2b;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e7edf6;
  --muted: #8b96ab;
  --accent1: #6366f1;
  --accent2: #22d3ee;
  --grad: linear-gradient(135deg, #6366f1, #22d3ee);
  --danger: #f43f5e;
  --ok: #34d399;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;

  /* 面板/条栏背景（深色半透明玻璃） */
  --bar-bg: rgba(15, 20, 31, 0.82);
  --bar-bg-2: rgba(15, 20, 31, 0.72);
  --bar-bg-3: rgba(15, 20, 31, 0.66);
  --hover-bg: rgba(255, 255, 255, 0.09);
  --hover-bg-2: rgba(255, 255, 255, 0.12);
  --hover-bg-3: rgba(255, 255, 255, 0.1);
  --toast-bg: rgba(21, 28, 43, 0.92);
  --overlay: rgba(8, 11, 17, 0.7);
  --loader-bg: rgba(11, 15, 23, 0.72);
  --badge-bg: rgba(11, 15, 23, 0.75);
  --badge-bg-2: rgba(11, 15, 23, 0.8);
  --badge-fg: #ffffff;
  --swatch-border: rgba(255, 255, 255, 0.25);
  --range-track: rgba(255, 255, 255, 0.16);
  --kbd-bg: rgba(255, 255, 255, 0.09);
  --row-line: rgba(255, 255, 255, 0.05);
  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.25);
  --dash-border: rgba(255, 255, 255, 0.18);
  --glow-soft: rgba(34, 211, 238, 0.1);
  --glow-line: rgba(34, 211, 238, 0.65);
  --glow-fill: rgba(34, 211, 238, 0.12);
  --glow-fill-hover: rgba(34, 211, 238, 0.22);
  --ring: rgba(34, 211, 238, 0.18);
  --edit-line: rgba(34, 211, 238, 0.65);
  --blob-1: #4f46e5;
  --blob-2: #0891b2;
  --blob-3: #7c3aed;
  --blob-opacity: 0.35;
}

[data-theme="light"] {
  --bg: #f2f5fa;
  --bg2: #e8edf5;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #1c2536;
  --muted: #5b6b84;
  --grad: linear-gradient(135deg, #4f46e5, #0891b2);
  --danger: #e11d48;
  --ok: #059669;
  --shadow: 0 12px 32px rgba(30, 41, 59, 0.16);

  --bar-bg: rgba(255, 255, 255, 0.82);
  --bar-bg-2: rgba(255, 255, 255, 0.74);
  --bar-bg-3: rgba(255, 255, 255, 0.72);
  --hover-bg: rgba(15, 23, 42, 0.06);
  --hover-bg-2: rgba(15, 23, 42, 0.09);
  --hover-bg-3: rgba(15, 23, 42, 0.08);
  --toast-bg: rgba(255, 255, 255, 0.95);
  --overlay: rgba(30, 41, 59, 0.38);
  --loader-bg: rgba(242, 245, 250, 0.78);
  --badge-bg: rgba(255, 255, 255, 0.9);
  --badge-bg-2: rgba(255, 255, 255, 0.92);
  --badge-fg: #22303f;
  --swatch-border: rgba(15, 23, 42, 0.22);
  --range-track: rgba(15, 23, 42, 0.16);
  --kbd-bg: rgba(15, 23, 42, 0.06);
  --row-line: rgba(15, 23, 42, 0.06);
  --scroll-thumb: rgba(15, 23, 42, 0.2);
  --scroll-thumb-hover: rgba(15, 23, 42, 0.32);
  --dash-border: rgba(15, 23, 42, 0.22);
  --glow-soft: rgba(79, 70, 229, 0.08);
  --glow-line: rgba(79, 70, 229, 0.55);
  --glow-fill: rgba(79, 70, 229, 0.08);
  --glow-fill-hover: rgba(79, 70, 229, 0.15);
  --ring: rgba(79, 70, 229, 0.16);
  --edit-line: rgba(8, 145, 178, 0.6);
  --blob-1: #818cf8;
  --blob-2: #67e8f9;
  --blob-3: #a78bfa;
  --blob-opacity: 0.28;
}

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

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

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* 主题切换时的全局过渡（仅切换瞬间生效，避免初始加载闪烁） */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease,
    box-shadow 0.4s ease, background 0.4s ease !important;
}
/* 浏览器原生 View Transition（支持时呈现柔和交叉淡化） */
::view-transition-old(root) { animation: vtFade 0.4s ease; }
::view-transition-new(root) { animation: vtFade 0.4s ease; }
@keyframes vtFade { from { opacity: 0.15; } to { opacity: 1; } }

/* ---------------- 背景装饰 ---------------- */
.bg-decor { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--blob-opacity); transition: background 0.4s ease, opacity 0.4s ease; }
.blob-1 { width: 520px; height: 520px; background: var(--blob-1); top: -160px; left: -120px; animation: drift 26s ease-in-out infinite alternate; }
.blob-2 { width: 420px; height: 420px; background: var(--blob-2); bottom: -140px; right: -100px; animation: drift 32s ease-in-out infinite alternate-reverse; }
.blob-3 { width: 300px; height: 300px; background: var(--blob-3); top: 45%; left: 55%; opacity: calc(var(--blob-opacity) * 0.65); animation: drift 38s ease-in-out infinite alternate; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, -50px) scale(1.18); }
}

/* ---------------- 载入遮罩 ---------------- */
.loader {
  position: fixed; inset: 0; z-index: 200;
  background: var(--loader-bg);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  animation: fadeIn 0.2s ease;
}
.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loaderText { color: var(--muted); font-size: 14px; letter-spacing: 1px; }

/* ---------------- 欢迎页 ---------------- */
.landing {
  position: relative; z-index: 1;
  height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.landing-inner {
  max-width: 760px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  text-align: center;
}
.logo-badge {
  width: 84px; height: 84px; border-radius: 24px;
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; box-shadow: var(--shadow);
  animation: floaty 4.5s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.landing-title { font-size: 52px; font-weight: 800; letter-spacing: 2px; }
.grad {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.landing-sub { color: var(--muted); font-size: 16px; }

.drop-zone {
  width: 100%; padding: 42px 24px;
  border: 2px dashed var(--dash-border);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  transition: border-color 0.3s ease, transform 0.3s ease, background 0.3s ease;
  animation: fadeUp 0.7s ease 0.15s both;
}
.drop-zone.dragover {
  border-color: var(--accent2);
  background: var(--glow-soft);
  transform: scale(1.015);
  box-shadow: 0 0 0 6px var(--ring);
}
.drop-icon { font-size: 46px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.drop-text { color: var(--muted); }
.drop-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.feature-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; animation: fadeUp 0.7s ease 0.3s both; }
.chip {
  padding: 7px 15px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: 13px; color: var(--text);
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.chip:hover { transform: translateY(-3px); border-color: var(--accent2); background: var(--glow-soft); }
.landing-foot {
  display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap;
  color: var(--muted); font-size: 13px; animation: fadeUp 0.7s ease 0.45s both;
}
.foot-link {
  color: var(--accent2); text-decoration: none; font-weight: 600;
  border-bottom: 1px dashed var(--accent2);
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: inline-flex; align-items: center; gap: 4px;
}
.foot-link:hover { opacity: 0.75; transform: translateY(-1px); }
.foot-link svg { width: 13px; height: 13px; fill: currentColor; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel); color: var(--text);
  padding: 8px 16px; border-radius: 10px;
  font-size: 14px;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); background: var(--hover-bg-3); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary {
  background: var(--grad); border: none; color: #fff; font-weight: 600;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(34, 211, 238, 0.4); }
.btn-ghost { background: transparent; }
.btn-big { padding: 12px 26px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; font-weight: 700; }

/* GitHub 仓库按钮 */
.btn-github {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; font-weight: 600;
}
.btn-github svg { width: 15px; height: 15px; fill: currentColor; transition: transform 0.3s ease; }
.btn-github:hover svg { transform: rotate(-8deg) scale(1.15); }

/* 主题切换按钮 */
.btn-theme { font-size: 15px; line-height: 1; }
.btn-theme.switching { animation: themeSpin 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes themeSpin {
  from { transform: rotate(0) scale(1); }
  50%  { transform: rotate(180deg) scale(0.55); }
  to   { transform: rotate(360deg) scale(1); }
}
/* 欢迎页右上角的主题按钮 */
.landing-theme-btn {
  position: absolute; top: 22px; right: 22px;
  width: 42px; height: 42px; font-size: 19px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  z-index: 5;
  animation: fadeUp 0.6s ease 0.2s both;
}

/* ---------------- 编辑器主界面 ---------------- */
.app {
  position: relative; z-index: 1;
  height: 100%;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 30%);
  animation: fadeIn 0.35s ease;
}

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: var(--bar-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-icon { font-size: 22px; animation: floaty 4s ease-in-out infinite; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.back-home {
  position: fixed;
  left: 30px;
  top: 25px;
  text-decoration: none;
  z-index: 10;
}
.dirty-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
  opacity: 0; transition: opacity 0.3s ease;
}
.dirty-dot.on { opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.topbar-center { flex: 1; min-width: 0; text-align: center; }
.file-name {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------------- 工具栏 ---------------- */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px;
  background: var(--bar-bg-2);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  z-index: 29;
}
.tool-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tool-sep { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; }
.tool-label { font-size: 12px; color: var(--muted); }
.tool-btn {
  width: 38px; height: 38px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.22s ease;
}
.tool-btn:hover { background: var(--hover-bg); transform: translateY(-1px); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; background: transparent; }
.tool-btn:disabled:hover { background: transparent; }
.tool-btn.active {
  background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}
.tool-toggle.active { background: rgba(244, 63, 94, 0.22); border-color: var(--danger); color: #ff9db0; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--swatch-border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.swatch:hover { transform: scale(1.18); }
.swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent2); transform: scale(1.12); }
.color-input {
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: transparent; padding: 0; cursor: pointer;
}

/* 颜色折叠按钮 + 下拉浮层 */
.color-wrap { position: relative; }
.color-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.color-toggle:hover { border-color: var(--accent2); transform: translateY(-1px); background: var(--hover-bg-3); }
.color-toggle:active { transform: translateY(0) scale(0.97); }
.color-preview {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--swatch-border);
  display: inline-block;
}
.color-caret { font-size: 10px; color: var(--muted); transition: transform 0.2s ease; }
.color-toggle.open .color-caret { transform: rotate(180deg); }
.color-menu {
  position: fixed; z-index: 120;
  display: grid;
  grid-template-columns: repeat(4, 30px);
  gap: 9px;
  padding: 13px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: popIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.color-menu .color-input { justify-self: center; }

/* 图形工具折叠按钮 + 下拉浮层 */
.shape-wrap { position: relative; }
.shape-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.shape-toggle:hover { border-color: var(--accent2); transform: translateY(-1px); background: var(--hover-bg-3); }
.shape-toggle:active { transform: translateY(0) scale(0.97); }
.shape-toggle.active {
  background: var(--grad); border-color: transparent;
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}
.shape-toggle.active .shape-preview svg { stroke: #fff; }
.shape-preview { display: flex; align-items: center; }
.shape-preview svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.shape-caret { font-size: 10px; color: var(--muted); transition: transform 0.2s ease; }
.shape-toggle.open .shape-caret { transform: rotate(180deg); }
.shape-menu {
  position: fixed; z-index: 120;
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 8px;
  padding: 13px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: popIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.shape-opt {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent; color: var(--text);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.shape-opt svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.shape-opt:hover { transform: scale(1.1); border-color: var(--accent2); background: var(--glow-soft); }
.shape-opt.active { border-color: var(--accent2); background: var(--glow-fill); box-shadow: 0 0 0 3px var(--ring); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 110px; height: 5px; border-radius: 4px;
  background: var(--range-track); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent2); cursor: pointer;
  box-shadow: 0 0 8px var(--glow-line);
}

/* ---------------- 选中对象属性面板 ---------------- */
.obj-panel {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  flex-shrink: 0;
}
.obj-panel-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  padding-right: 6px; border-right: 1px solid var(--border);
}
.obj-select {
  background: var(--panel-solid); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 8px; font-size: 13px; outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.obj-select:hover { border-color: var(--accent2); }
.obj-select option { background: var(--panel-solid); color: var(--text); }
.obj-delete:hover { background: rgba(244, 63, 94, 0.25); color: #ff9db0; }

/* ---------------- 主体布局 ---------------- */
.main { flex: 1; display: flex; min-height: 0; }

.viewport-wrap {
  flex: 1; position: relative; min-width: 0;
  background:
    radial-gradient(circle at 30% 20%, var(--glow-soft), transparent 45%),
    radial-gradient(circle at 75% 80%, var(--glow-soft), transparent 45%);
}
.empty-hint {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--muted);
}
.empty-hint-icon { font-size: 64px; opacity: 0.5; animation: floaty 3.6s ease-in-out infinite; }

.page-scroll {
  position: absolute; inset: 0;
  overflow: auto; padding: 26px;
  display: flex; justify-content: center;
}
.page-view {
  position: relative;
  box-shadow: var(--shadow);
  border-radius: 4px;
  background: #fff;
  align-self: flex-start;
}
.page-view.page-in-anim { animation: pageIn 0.4s ease; }

/* 选中对象的悬浮删除按钮：右上角红色圆形，带垃圾桶图标 */
.sel-delete {
  position: absolute;
  z-index: 5;
  width: 30px; height: 30px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(220, 38, 38, .35);
  background: #fff;
  color: #dc2626;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(220, 38, 38, .25), 0 1px 4px rgba(0,0,0,.2);
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.sel-delete svg { width: 16px; height: 16px; fill: currentColor; }
.sel-delete:hover { background: #dc2626; color: #fff; border-color: #dc2626; transform: scale(1.12); }
.sel-delete:active { transform: scale(.95); }
.sel-delete.hidden { display: none; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* 层级与事件：
   1) pdfCanvas      — PDF 渲染层，只显示，鼠标事件穿透（pointer-events:none）
   2) textLayer      — 改字模式命中检测用，事件穿透（由 fabric 事件 + JS 命中）
   3) fabric wrapper — 标注层（fabric 5 自动包裹 #fabCanvas），接收鼠标事件
   4) editLayer      — 改字输入框层，穿透，但输入框本身接收事件 */
#pdfCanvas { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; border: 0; padding: 0; }
#textLayer { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }
.page-view .canvas-container { position: relative; z-index: 3; }
#fabCanvas { position: absolute; left: 0; top: 0; border: 0; padding: 0; }
.edit-layer { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; }
.edit-layer .edit-input { pointer-events: auto; }

/* pdf.js 文本层（透明，仅用于命中检测与编辑定位） */
.textLayer {
  position: absolute; inset: 0; overflow: hidden;
  line-height: 1; text-size-adjust: none;
  opacity: 1;
}
.textLayer span, .textLayer br {
  position: absolute; white-space: pre;
  color: transparent;
  transform-origin: 0% 0%;
  cursor: text;
}
.textLayer span.editing-src { outline: 1px dashed var(--glow-line); background: var(--glow-fill); cursor: pointer; }
.textLayer span.editing-src:hover { background: var(--glow-fill-hover); }

.edit-layer .edit-input {
  position: absolute;
  border: 1.5px solid var(--edit-line);
  background: #fff; color: #111;
  padding: 0 3px; outline: none;
  border-radius: 3px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.35);
  font-family: var(--font);
  min-width: 30px;
  animation: popIn 0.18s ease;
}
.edit-layer .edit-del-btn {
  position: absolute;
  pointer-events: auto;
  width: 20px; height: 20px;
  padding: 0;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.18);
  background: #fff;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  opacity: .85;
}
.edit-layer .edit-del-btn:hover { background: #fee; color: #c00; border-color: #f3b4b4; opacity: 1; }
@keyframes popIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------- 缩略图侧栏 ---------------- */
.thumb-panel {
  width: 210px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bar-bg-3);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
}
.thumb-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 8px;
  font-size: 13px; font-weight: 600;
}
.thumb-list {
  flex: 1; overflow-y: auto;
  padding: 4px 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.thumb {
  position: relative;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--panel);
  padding: 8px;
  cursor: grab;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
  animation: fadeUp 0.4s ease both;
}
.thumb:hover { border-color: var(--dash-border); transform: translateY(-2px); }
.thumb.active { border-color: var(--accent2); box-shadow: 0 0 0 3px var(--ring); }
.thumb.dragging { opacity: 0.4; transform: scale(0.96); }
.thumb.drop-before { box-shadow: 0 -3px 0 0 var(--accent2); }
.thumb.drop-after { box-shadow: 0 3px 0 0 var(--accent2); }
.thumb canvas { display: block; width: 100%; height: auto; border-radius: 4px; background: #fff; }
.thumb-num {
  position: absolute; left: 8px; top: 8px;
  font-size: 11px; font-weight: 700;
  background: var(--badge-bg); color: var(--badge-fg);
  padding: 2px 7px; border-radius: 999px;
  pointer-events: none;
}
.thumb-ops {
  position: absolute; right: 8px; top: 8px;
  display: none; gap: 4px;
}
.thumb:hover .thumb-ops { display: flex; animation: fadeIn 0.2s ease; }
.thumb-op {
  width: 24px; height: 24px; border-radius: 7px;
  border: none; font-size: 12px;
  background: var(--badge-bg-2); color: var(--badge-fg);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
.thumb-op:hover { transform: scale(1.12); }
.thumb-op.rot { background: rgba(37, 99, 235, 0.85); }
.thumb-op.del { background: rgba(244, 63, 94, 0.85); }
.thumb-op:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------- 状态栏 ---------------- */
.statusbar {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 18px;
  background: var(--bar-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
  z-index: 30;
}
.statusbar .spacer { flex: 1; }
.mini-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text);
  font-size: 13px;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
}
.mini-btn:hover { background: var(--hover-bg-2); transform: translateY(-1px); }
.mini-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.sep { opacity: 0.4; }

/* ---------------- Toast ---------------- */
.toasts {
  position: fixed; top: 18px; right: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 240px; max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateX(40px); opacity: 0; } }
.toast-icon { font-size: 17px; }
.toast.ok .toast-icon { color: var(--ok); }
.toast.err .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--accent2); }

/* ---------------- 帮助弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 150;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.25s ease;
}
.modal-card {
  width: min(460px, 92vw);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: popIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  width: 30px; height: 30px; border-radius: 9px;
  border: none; background: var(--kbd-bg); color: var(--text);
  font-size: 13px;
  transition: background 0.2s ease;
}
.modal-close:hover { background: rgba(244,63,94,0.3); }
.modal-body { padding: 18px 20px; max-height: 60vh; overflow-y: auto; }
.keys { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.keys td { padding: 7px 4px; border-bottom: 1px solid var(--row-line); }
.keys td:first-child { color: var(--muted); }
kbd {
  background: var(--kbd-bg);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 6px; padding: 2px 7px;
  font-family: var(--mono); font-size: 12px;
}
.note { margin-top: 14px; font-size: 12.5px; line-height: 1.6; }

/* ---------------- 通用动画 ---------------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp 0.6s ease both; }
.pop-in { animation: popIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* 响应式 */
@media (max-width: 900px) {
  .thumb-panel { width: 130px; }
  .landing-title { font-size: 38px; }
  .toolbar { flex-wrap: wrap; }
}
