/* css/app.css —— 绘图画板样式（移动优先 + 桌面增强） */
:root {
  --bg: #0f1319;
  --panel: #171c24;
  --panel-2: #1e242e;
  --line: #2a323d;
  --line-2: #38424f;
  --text: #e8eef6;
  --dim: #93a1b3;
  --accent: #4da3ff;
  --accent-2: #2f7fe0;
  --danger: #ff6b6b;
  --ok: #45c07a;
  --radius: 12px;
  --tb-h: 62px;
  --top-h: 52px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
body { overflow: hidden; }
.hidden { display: none !important; }
.ic { width: 24px; height: 24px; display: block; fill: none; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------------- 登录 ---------------- */
.screen-auth {
  align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 20% 0%, #1b2430 0%, #0e1218 60%);
  padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab));
  overflow: auto;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px 20px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.brand { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, #4da3ff, #a878ff); }
.brand-sub { color: var(--dim); font-size: 12.5px; margin: 6px 0 16px; }
.seg { display: flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-item {
  flex: 1; border: 0; background: transparent; color: var(--dim); font: inherit; font-size: 14px;
  padding: 9px 0; border-radius: 8px; cursor: pointer;
}
.seg-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.field { display: block; margin: 14px 0 0; }
.field > span { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #10151c; color: var(--text); font: inherit; font-size: 16px; /* 16px 防 iOS 自动放大 */
}
.field input:focus { outline: none; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--dim); font-size: 13px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.auth-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 14px; padding: 10px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(255, 107, 107, .5); }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 8px; }
.auth-alt { display: flex; flex-direction: column; align-items: center; margin-top: 10px; }
.auth-users { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.auth-user-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-radius: 8px; }
.auth-user-row:active { background: var(--panel-2); }
.auth-user-row .nm { flex: 1; }
.auth-foot { color: var(--dim); font-size: 11.5px; margin-top: 14px; text-align: center; line-height: 1.6; }

/* ---------------- 画布界面 ---------------- */
.screen-app { background: var(--bg); }
.topbar {
  height: calc(var(--top-h) + var(--sat)); padding: var(--sat) 8px 0; flex: none;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .top-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 10px; border: 0; background: transparent;
  color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { background: var(--panel-2); }
.doc-title {
  flex: 1; min-width: 0; background: transparent; border: 1px solid transparent; color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; padding: 8px 6px; border-radius: 8px;
}
.doc-title:focus { outline: none; border-color: var(--line-2); background: #10151c; }
/* 顶栏"当前工具"标识 */
.tool-now {
  display: flex; align-items: center; gap: 4px; flex: none;
  padding: 5px 9px; border-radius: 999px; font-size: 12px; color: var(--accent);
  background: rgba(77, 163, 255, .12); border: 1px solid rgba(77, 163, 255, .35);
}
.tool-now .ic { width: 16px; height: 16px; }
.tool-now[data-tool="eraser"] { color: #ffb4b4; background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .35); }
.tool-now[data-tool="select"] { color: var(--dim); background: var(--panel-2); border-color: var(--line-2); }

/* 右上角图层按钮 + 图层面板 */
.layer-btn {
  display: flex; align-items: center; gap: 4px; flex: none; max-width: 130px;
  padding: 6px 10px; border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
}
.layer-btn .ic { width: 16px; height: 16px; flex: none; }
.layer-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(77, 163, 255, .14); }
.layer-pop {
  position: fixed; z-index: 40; top: calc(var(--top-h) + var(--sat) + 6px); right: 10px;
  width: min(340px, 92vw); max-height: min(66vh, 460px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  transform: translateY(-8px) scale(.98); opacity: 0; pointer-events: none;
  transition: transform .16s ease-out, opacity .16s ease-out;
}
.layer-pop[data-open="true"] { transform: none; opacity: 1; pointer-events: auto; }
.lp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.lp-head b { color: var(--dim); font-weight: 500; margin-left: 4px; }
.lp-head-actions { display: flex; align-items: center; gap: 4px; }
.lp-mini, .lp-close {
  width: 28px; height: 28px; border: 0; border-radius: 8px; background: var(--panel-2); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer; font: inherit; font-size: 16px;
}
.lp-mini .ic { width: 16px; height: 16px; }
.lp-close { background: transparent; color: var(--dim); }
.lp-list { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.lp-row {
  display: flex; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); cursor: pointer;
}
.lp-row.active { border-color: var(--accent); background: rgba(77, 163, 255, .12); }
.lp-thumb {
  position: relative; width: 66px; height: 44px; flex: none; border-radius: 7px; overflow: hidden;
  border: 1px solid var(--line-2); background: #fff; display: flex; align-items: center; justify-content: center;
}
.lp-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lp-thumb i { font-style: normal; font-size: 11px; color: #9aa1ab; }
.lp-hidden {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 13, 18, .62); color: #fff; font-size: 10.5px; font-style: normal;
}
.lp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.lp-name { display: flex; align-items: center; gap: 4px; }
.lp-name > span { flex: 1; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-name > b { font-size: 11px; color: var(--dim); font-weight: 500; }
.lp-ico {
  width: 26px; height: 26px; flex: none; border: 0; border-radius: 7px; background: transparent;
  color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.lp-ico .ic { width: 16px; height: 16px; }
.lp-ico.off { color: #6b7280; }
.lp-ico.on { color: #ffd166; }
.lp-op { display: flex; align-items: center; gap: 6px; }
.lp-op input[type="range"] { flex: 1; height: 18px; accent-color: var(--accent); }
.lp-op-val { font-size: 11px; color: var(--dim); min-width: 34px; text-align: right; }
.lp-tip { margin: 0; padding: 6px 10px 9px; font-size: 11px; color: var(--dim); line-height: 1.5; border-top: 1px solid var(--line); }
@media (max-width: 430px) {
  .tool-now span { display: none; }        /* 小屏只留图标，别把标题挤没 */
  .tool-now { padding: 5px 7px; }
  .layer-btn span { display: none; }
  .layer-btn { padding: 6px 8px; }
}
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #0b0e13; }
.stage .layer { position: absolute; inset: 0; display: block; }
.layer-bg { z-index: 1; }
.layer-scene { z-index: 2; }
.layer-ui { z-index: 3; }

.zoom-chip {
  position: absolute; right: 10px; bottom: 10px; z-index: 5;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: rgba(23, 28, 36, .92); border: 1px solid var(--line); border-radius: 12px;
}
.zoom-chip .mini {
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--text);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.zoom-chip .mini .ic { width: 20px; height: 20px; }
.zoom-chip .mini:active { background: var(--panel-2); }
#zoomText { min-width: 46px; text-align: center; font-size: 12px; color: var(--dim); }
.hint-chip {
  position: absolute; left: 50%; transform: translateX(-50%); top: 10px; z-index: 5;
  background: rgba(23, 28, 36, .92); border: 1px solid var(--line); color: var(--dim);
  font-size: 12px; padding: 6px 12px; border-radius: 999px; opacity: 0; transition: opacity .2s;
  pointer-events: none; max-width: 80%; text-align: center;
}
.hint-chip.show { opacity: 1; }

/* ---------------- 常驻工具条（快捷工具可横向滚动 / 拖拽） ---------------- */
.toolbar {
  flex: none; height: calc(var(--tb-h) + var(--sab)); padding-bottom: var(--sab);
  display: flex; align-items: center; gap: 2px; padding-left: 4px; padding-right: 6px;
  background: var(--panel); border-top: 1px solid var(--line);
}
/* 可滚动的快捷工具区 */
.tb-strip {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab; touch-action: pan-x;
  /* 左右两端做渐隐，暗示还能往两边拖 */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}
.tb-strip::-webkit-scrollbar { display: none; }
.tb-strip.dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.tb-strip.no-mask { -webkit-mask-image: none; mask-image: none; }
.tb-strip .tool { flex: 0 0 auto; min-width: 56px; padding: 0 6px; }
/* 左右滚动按钮：只在内容真的溢出了才出现 */
.tb-nav {
  display: none; flex: none; width: 26px; height: 46px; border: 0; border-radius: 9px;
  background: var(--panel-2); color: var(--text); align-items: center; justify-content: center; cursor: pointer;
}
.tb-nav .ic { width: 20px; height: 20px; }
.tb-nav:active { background: #232b36; }
.tb-nav[disabled] { opacity: .3; }
.toolbar[data-scroll="true"] .tb-nav { display: flex; }
.tb-fixed { display: flex; align-items: center; gap: 2px; flex: none; }
.tool {
  flex: 1 1 0; min-width: 58px; height: 50px; border: 0; border-radius: 12px; background: transparent;
  color: var(--dim); font: inherit; font-size: 11.5px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; cursor: pointer;
}
.tool .ic { width: 22px; height: 22px; }
.tool:active { background: var(--panel-2); }
.tool.active { color: var(--accent); background: rgba(77, 163, 255, .14); font-weight: 600; }
.tool[disabled] { opacity: .35; }
.tool-more.active { color: var(--accent); background: rgba(77, 163, 255, .14); }
.tb-sep { width: 1px; height: 30px; background: var(--line); flex: none; margin: 0 2px; }
/* 快捷工具容器必须是 flex：否则里面的按钮会竖着堆起来把工具条撑高 */
#quickTools { display: flex; align-items: center; gap: 4px; flex: none; }

/* ---------------- 可展开面板 ---------------- */
.sheet {
  position: fixed; left: 0; right: 0; z-index: 30;
  /* 贴着工具条上方展开：这样"更多"打开时，外面的拖拽/铅笔/橡皮仍然可点 */
  bottom: calc(var(--tb-h) + var(--sab));
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  transform: translateY(calc(100% + var(--tb-h) + var(--sab)));
  transition: transform .24s cubic-bezier(.4, 0, .2, 1);
  max-height: min(70vh, 560px); display: flex; flex-direction: column;
  overflow: hidden;                 /* 内容不能溢出圆角 */
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .45);
}
.sheet[data-open="true"] { transform: translateY(0); }
.sheet-grip { padding: 8px 0 4px; display: flex; justify-content: center; cursor: pointer; touch-action: none; }
.sheet-grip span { width: 44px; height: 4px; border-radius: 2px; background: var(--line-2); }
.seg-sheet { margin: 0 12px 8px; }
.sheet-body { overflow: auto; padding: 4px 12px 22px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.sheet-body::-webkit-scrollbar { width: 8px; }
.sheet-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.sheet-body::-webkit-scrollbar-track { background: transparent; }
.sheet-scrim {
  /* 只盖住画布区域：底下的快捷工具条要留着能点（面板展开时也能直接换笔） */
  position: fixed; left: 0; right: 0; top: 0; bottom: calc(var(--tb-h) + var(--sab));
  z-index: 25; background: rgba(0, 0, 0, .45); opacity: 0;
  pointer-events: none; transition: opacity .24s;
}
.sheet-scrim.show { opacity: 1; pointer-events: auto; }

.grid-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gt {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; color: var(--text);
  padding: 10px 4px; font: inherit; font-size: 11.5px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; cursor: pointer;
}
.gt .ic { width: 22px; height: 22px; }
.gt.active { border-color: var(--accent); color: var(--accent); background: rgba(77, 163, 255, .12); }
.sec-title { font-size: 12px; color: var(--dim); margin: 14px 0 8px; letter-spacing: .3px; }

/* ---------------- 调色盘（参考画世界 Pro 的颜色面板） ---------------- */
.pick-head { display: flex; gap: 10px; align-items: stretch; }
.pick-now {
  width: 74px; flex: none; border-radius: 12px; border: 1px solid var(--line-2);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; min-height: 62px;
}
.pick-now i { font-style: normal; font-size: 10.5px; letter-spacing: .2px; }
.pick-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.pick-row { display: flex; align-items: center; gap: 6px; }
.pick-row > span { font-size: 12px; color: var(--dim); width: 30px; flex: none; }
.hex-input {
  flex: 1; min-width: 0; background: #10151c; border: 1px solid var(--line-2); color: var(--text);
  border-radius: 8px; padding: 8px 9px; font: inherit; font-size: 13px; letter-spacing: .4px;
  text-transform: lowercase;
}
.hex-input:focus { outline: none; border-color: var(--accent); }
.hsv { display: flex; gap: 10px; }
.sv-box {
  position: relative; flex: 1; height: 96px; border-radius: 10px; border: 1px solid var(--line-2);
  touch-action: none; cursor: crosshair; overflow: hidden;
  background:
    linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
    linear-gradient(to right, #fff, var(--hue, #f00));
}
.hue-bar {
  position: relative; width: 24px; height: 96px; border-radius: 10px; border: 1px solid var(--line-2);
  touch-action: none; cursor: pointer;
  background: linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.sv-knob, .hue-knob {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none;
}
.hue-knob { left: 50%; }
.pal-head { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pal-head::-webkit-scrollbar { display: none; }
.pal-tab {
  flex: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--dim);
  font: inherit; font-size: 12px; padding: 6px 12px; border-radius: 999px; cursor: pointer; margin: 0;
}
.pal-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(77, 163, 255, .12); }
.colors { display: grid; gap: 8px; }
.swatch.sm { width: 30px; height: 30px; }

/* ---------------- 工具页的"当前工具设置" ---------------- */
.opt-label { font-size: 12px; color: var(--dim); width: 44px; flex: none; }
.opt-row { align-items: center; margin-bottom: 6px; }
.opt-tip { color: var(--dim); font-size: 12px; line-height: 1.6; margin: 4px 0 0; }

/* ---------------- 图层 ---------------- */
.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer;
}
.layer-row.active { border-color: var(--accent); background: rgba(77, 163, 255, .12); }
.layer-row .layer-name {
  flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layer-row .layer-count { font-size: 11px; color: var(--dim); flex: none; }
.layer-ico {
  width: 30px; height: 30px; flex: none; border: 0; background: transparent; color: var(--text);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.layer-ico .ic { width: 18px; height: 18px; }
.layer-ico:active { background: var(--panel); }
.layer-ico.off { color: #6b7280; }
.layer-ico.on { color: #ffd166; }
.chip-btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, .4); }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .12);
}
.swatch.active { border-color: var(--accent); transform: scale(1.06); }
.swatch.pick { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.swatch.pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.chip-btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit;
  font-size: 12.5px; padding: 9px 12px; border-radius: 10px; cursor: pointer;
}
.chip-btn.active { border-color: var(--accent); color: var(--accent); }
.chip-btn.danger { color: var(--danger); }
.slider-row { display: flex; align-items: center; gap: 10px; }
input[type="range"] { flex: 1; accent-color: var(--accent); height: 28px; }
.slider-val { min-width: 42px; text-align: right; color: var(--dim); font-size: 12.5px; }
.w-preview { height: 34px; display: flex; align-items: center; }
.w-preview i { display: block; background: currentColor; border-radius: 999px; }
.act-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; color: var(--text);
  font: inherit; font-size: 12.5px; padding: 12px 6px; cursor: pointer;
}
.act:active { background: #232b36; }
.act.wide { grid-column: span 3; }
.act.danger { color: var(--danger); }
.bg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; color: var(--dim);
}
.bg-item.active { border-color: var(--accent); color: var(--accent); }
.bg-thumb { width: 100%; height: 34px; border-radius: 6px; border: 1px solid var(--line-2); }

/* ---------------- 历史画布 ---------------- */
.screen-gallery { background: var(--bg); }
.gal-title { font-size: 16px; font-weight: 700; }
.gal-search { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex: none; }
.gal-search input {
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #10151c; color: var(--text); font: inherit; font-size: 16px;
}
.gal-search input:focus { outline: none; border-color: var(--accent); }
.gal-stat { color: var(--dim); font-size: 11.5px; white-space: nowrap; }
.gal-list {
  flex: 1; overflow: auto; padding: 0 12px calc(20px + var(--sab));
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
  align-content: start;      /* 卡片按内容高度排列，不被拉伸到整屏 */
  -webkit-overflow-scrolling: touch;
}
.gal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer; position: relative; align-self: start;
}
.gal-card:active { border-color: var(--accent); }
.gal-thumb { width: 100%; aspect-ratio: 4 / 3; background: #0e1218; object-fit: contain; display: block; }
.gal-thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 12px; }
.gal-body { padding: 8px 10px 10px; }
.gal-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-meta { font-size: 11px; color: var(--dim); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.gal-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.gal-fav {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(14, 18, 24, .72);
  color: #ffd166; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.gal-fav .ic { width: 18px; height: 18px; }
.gal-fav[data-fav="false"] { color: rgba(255, 255, 255, .6); }
.gal-more {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(14, 18, 24, .72);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px; line-height: 1;
}
.gal-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--dim); }
.empty-art { font-size: 42px; }

/* ---------------- 浮层：菜单 / 对话框 / 提示 ---------------- */
.popmenu {
  position: fixed; z-index: 60; min-width: 172px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); display: none;
}
.popmenu.show { display: block; }
.pm-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 11px 10px; border-radius: 8px; cursor: pointer; text-align: left;
}
.pm-item:active { background: var(--panel-2); }
.pm-item .ic { width: 18px; height: 18px; color: var(--dim); }
.pm-item.danger { color: var(--danger); }
.pm-sep { height: 1px; background: var(--line); margin: 4px 2px; }

.dialog-wrap {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px;
}
.dialog h3 { margin: 0 0 10px; font-size: 16px; }
.dialog p { color: var(--dim); font-size: 13px; margin: 0 0 12px; line-height: 1.6; }
.dialog input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #10151c; color: var(--text); font: inherit; font-size: 16px; margin-bottom: 4px;
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tb-h) + var(--sab) + 16px);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: rgba(28, 34, 43, .96); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  max-width: 84vw; text-align: center; animation: toast-in .18s ease-out;
}
.toast.ok { border-color: rgba(69, 192, 122, .6); }
.toast.err { border-color: rgba(255, 107, 107, .6); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.text-editor { position: fixed; z-index: 65; background: rgba(16, 21, 28, .97); border: 1px solid var(--accent); border-radius: 10px; padding: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5); }
.text-editor textarea {
  background: transparent; color: var(--text); border: 0; outline: none;
  padding: 6px 8px; font: inherit; font-size: 16px; min-width: 180px; min-height: 46px;
  resize: none; display: block; width: 100%;
}
.te-bar { display: flex; gap: 6px; justify-content: flex-end; padding: 4px 2px 0; }
.te-btn {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
.te-ok { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------- 桌面增强 ---------------- */
@media (min-width: 821px) {
  .sheet {
    left: 50%; right: auto; width: min(680px, 92vw); border-radius: 18px;
    bottom: calc(var(--tb-h) + 18px); max-height: min(76vh, 640px);
    transform: translate(-50%, calc(100% + var(--tb-h) + 30px));
  }
  .sheet[data-open="true"] { transform: translate(-50%, 0); }
  .sheet-scrim.show { background: rgba(0, 0, 0, .28); }
  .toolbar { gap: 4px; }
  .tb-strip .tool { min-width: 68px; }
  .tb-nav { width: 30px; height: 50px; }
  .grid-tools { grid-template-columns: repeat(6, 1fr); }
  .gal-list { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .toolbar, .topbar { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 400px) {
  .tool { min-width: 50px; font-size: 10.5px; }
  .tool .ic { width: 20px; height: 20px; }
  .grid-tools { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .sheet { max-height: 82vh; }
  .toolbar { height: calc(54px + var(--sab)); }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-scrim, .toast { transition: none; animation: none; }
}
