/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
}

html, body {
  width: 100%; height: 100%;
  min-height: 100dvh; /* 动态视口：iOS 旋转/地址栏收起时高度跟随可视区域，避免顶栏被挤出 */
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  touch-action: none;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

/* ===== 顶部操作栏 ===== */
.topbar {
  height: 50px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar::-webkit-scrollbar { display: none; }
.top-spacer { flex: 1; min-width: 6px; }

.op-btn {
  width: 38px; height: 38px;
  border: none; background: transparent;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
  flex-shrink: 0;
}
.op-btn svg { width: 21px; height: 21px; }
.op-btn:active { background: #f1f3f6; }
.op-btn:disabled { opacity: .3; }
.op-btn.danger { color: #ef4444; }
.op-btn.on { background: #e8effe; color: var(--accent); }
.op-btn.text-btn.on { color: var(--accent); border-color: var(--accent); background: rgba(37,99,235,.08); }
.op-btn.primary {
  width: auto; padding: 0 14px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 600; border-radius: 10px;
}
.op-btn.primary:active { background: #1d4ed8; }
/* 隐藏按钮：默认黑字，处于"已隐藏"状态时文字变蓝 */
.op-btn.text-btn {
  width: auto; padding: 0 10px;
  font-size: 13px; font-weight: 500; letter-spacing: .5px;
  color: #111827;
  border: 1px solid var(--border);
}
.op-btn.text-btn.hide-on { color: var(--accent); border-color: var(--accent); background: rgba(37, 99, 235, .08); }

.zoom-label {
  min-width: 48px; text-align: center;
  font-size: 13px; color: var(--muted);
  flex-shrink: 0;
}

/* ===== 画布 ===== */
.canvas-wrap {
  flex: 1; position: relative;
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
}
#canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; background: #e6e7ec;
  touch-action: none;
}

.hint {
  position: absolute; left: 50%; bottom: 12px;
  transform: translateX(-50%);
  background: rgba(31,41,55,.8); color: #fff;
  font-size: 12px; padding: 6px 12px; border-radius: 14px;
  white-space: nowrap; pointer-events: none;
  transition: opacity .4s; z-index: 5;
}
.hint.fade { opacity: 0; }

/* ===== 底部工具条（横滑） ===== */
.toolbar {
  height: 74px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: row;
  align-items: center; gap: 2px;
  padding: 6px 4px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }

.tool {
  min-width: 50px;
  border: none; background: transparent;
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 6px 4px;
  cursor: pointer; color: var(--text);
  flex-shrink: 0;
}
.tool svg { width: 24px; height: 24px; }
.tool span { font-size: 11px; color: var(--muted); }
.tool.active { background: #e8effe; color: var(--accent); }
.tool.active span { color: var(--accent); }

/* 填充按钮（放在工具条里，可横滑） */
.fill-tool {
  min-width: 50px;
  border: none; background: transparent;
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 6px 4px;
  cursor: pointer; color: var(--text);
  flex-shrink: 0;
}
.fill-tool svg { width: 24px; height: 24px; }
.fill-tool span { font-size: 11px; color: var(--muted); }
.fill-tool.active { background: #e8effe; color: var(--accent); }
.fill-tool.active span { color: var(--accent); }

/* 功能辅助按钮（置顶/置底/合并/全屏，放工具条里可横滑，不参与工具切换） */
.tool-aux {
  min-width: 50px;
  border: none; background: transparent;
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 6px 4px;
  cursor: pointer; color: var(--text);
  flex-shrink: 0;
}
.tool-aux svg { width: 24px; height: 24px; }
.tool-aux span { font-size: 11px; color: var(--muted); }
.tool-aux:active { background: #eef1f6; }
.tool-aux.active { background: #e8effe; }
.tool-aux.active span { color: var(--accent); }
.tool-aux.active svg { color: var(--accent); }
/* 攒组中：按钮亮起来，提示正在往里加图元 */
.tool-aux.collecting { background: #fff4e5; }
.tool-aux.collecting span { color: #c26a05; font-weight: 700; }
.tool-aux.collecting svg { color: #c26a05; }

/* ===== 属性条：颜色按钮 + 粗细 ===== */
.propbar {
  /* 52px 内容 + 18px 底部留白（避开 App 水印/安全区）；border-box 下总高要一起加 */
  height: calc(70px + env(safe-area-inset-bottom));
  border-bottom: 18px solid var(--panel);
  scrollbar-width: none;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 10px;
  flex-shrink: 0;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.color-btn {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px 0 6px;
  border: 1px solid var(--border); background: #fff;
  border-radius: 9px; cursor: pointer;
  flex-shrink: 0;
}
.color-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border);
  background: #1f2937; flex-shrink: 0;
}
.color-label { font-size: 13px; color: var(--muted); }
.style-btn {
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border); background: #fff;
  border-radius: 9px; cursor: pointer; color: var(--text);
  flex-shrink: 0;
}
.style-btn svg { width: 20px; height: 20px; }
.style-btn:active { background: #f1f3f6; }
.style-btn.on { background: #e8effe; color: var(--accent); border-color: #bcd3fb; }
.style-btn.on .style-label { color: var(--accent); }
.style-label { font-size: 13px; color: var(--muted); }

/* ===== 文字样式弹窗：字体 + 艺术效果 ===== */
.style-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.style-panel {
  width: min(92vw, 360px);
  background: #fff; border-radius: 16px;
  padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
  max-height: 88vh; overflow-y: auto;
}
.ts-section { margin-bottom: 16px; }
.ts-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.ts-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ts-item {
  min-width: 64px; padding: 8px 12px;
  border: 1px solid var(--border); background: #fff;
  border-radius: 9px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.ts-item.active { background: #e8effe; color: var(--accent); border-color: #bcd3fb; }
.ts-item[data-font="songti"] { font-family: "Noto Serif SC", "Songti SC", "SimSun", serif; }
.ts-item[data-font="kaiti"] { font-family: "Kaiti SC", "KaiTi", "STKaiti", serif; }
.ts-item[data-font="xingshu"] { font-family: "Zhi Mang Xing", cursive; }
.ts-item[data-font="maobi"] { font-family: "Ma Shan Zheng", cursive; }
.ts-item[data-font="shouxie"] { font-family: "Long Cang", cursive; }
.ts-item[data-font="kuaile"] { font-family: "ZCOOL KuaiLe", cursive; }
.ts-item[data-font="xiaowei"] { font-family: "ZCOOL XiaoWei", cursive; }
.ts-sub {
  font-size: 12px; color: var(--muted);
  margin: 10px 0 -2px; opacity: .8;
}
.ts-status {
  font-size: 13px; color: var(--accent);
  background: #e8effe; border-radius: 8px;
  padding: 8px 10px; margin-bottom: 10px;
  line-height: 1.4;
}
.ts-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ===== 笔型弹窗 ===== */
.brush-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.brush-panel {
  width: min(92vw, 340px);
  background: #fff; border-radius: 16px;
  padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.brush-list { display: flex; flex-direction: column; gap: 8px; }
.brush-item {
  display: grid; grid-template-columns: 62px 1fr; grid-template-rows: auto auto;
  align-items: center; column-gap: 10px;
  padding: 10px 12px; text-align: left;
  border: 1px solid var(--border); background: #fff;
  border-radius: 11px; cursor: pointer; color: var(--text);
}
.brush-item:active { background: #f7f8fa; }
.brush-item.active { border-color: var(--accent); background: #eff4ff; }
.brush-item .bi-preview { grid-row: 1 / span 2; }
.brush-item .bi-preview svg { width: 60px; height: 24px; }
.brush-item .bi-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.brush-item.active .bi-name { color: var(--accent); }
.brush-item .bi-desc { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

/* ===== 调色板弹窗 ===== */
.color-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.color-panel {
  width: min(92vw, 360px);
  background: #fff; border-radius: 16px;
  padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
  max-height: 88vh; overflow-y: auto;
}
.cm-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cm-title { font-size: 16px; font-weight: 600; color: var(--text); }
.cm-close {
  width: 30px; height: 30px; border: none; background: #f1f3f6;
  border-radius: 8px; cursor: pointer; color: var(--text); font-size: 15px;
}
.cm-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.cm-tabs button {
  flex: 1; padding: 8px;
  border: 1px solid var(--border); background: #fff;
  border-radius: 9px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.cm-tabs button.active { background: #e8effe; color: var(--accent); border-color: #bcd3fb; }
.cm-pane canvas { width: 100%; border-radius: 8px; display: block; }
#svCanvas { height: 180px; }
.hue-bar { height: 18px; margin-top: 8px; }
#specCanvas { height: 40px; }
.cm-slider { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.cm-slider .sl { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.cm-slider .sl span { width: 18px; text-align: center; font-weight: 600; }
.cm-slider input[type="range"] { flex: 1; accent-color: var(--accent); }
.cm-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.cm-preview { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); flex-shrink: 0; }
.cm-hex { font-size: 14px; font-family: monospace; color: var(--text); }

.widths { display: flex; align-items: center; gap: 6px; }
.width {
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border); background: #fff;
  border-radius: 9px; font-size: 13px; color: var(--muted);
  cursor: pointer;
}
.width.active { background: #e8effe; color: var(--accent); border-color: #bcd3fb; }

/* 弧线顶点手柄 */
.arc-ctrl {
  fill: #fff; stroke: var(--accent); stroke-width: 2.5;
  cursor: pointer;
}
.arc-point {
  fill: #fff; stroke: #94a3b8; stroke-width: 2;
  cursor: pointer;
}
.arc-point.key-anchor {
  fill: #dbeafe; stroke: var(--accent); stroke-width: 2;
}

/* ===== 选中框与手柄 ===== */
.sel-box {
  fill: none; stroke: var(--accent);
  stroke-width: 1; stroke-dasharray: 4 3;
}
.handle {
  fill: #fff; stroke: var(--accent); stroke-width: 1.8;
  cursor: pointer;
}
.rotate-line { stroke: var(--accent); stroke-width: 1.5; }
.rotate-handle {
  fill: #fff; stroke: var(--accent); stroke-width: 2;
  cursor: pointer;
}

/* 框选矩形 + 对齐参考线 */
.selbox-rect {
  fill: rgba(37,99,235,.12); stroke: var(--accent);
  stroke-width: 1.4; stroke-dasharray: 5 4;
  pointer-events: none;
}
.snap-line { stroke: #f43f5e; stroke-width: 1.2; pointer-events: none; }
.snap-hit { stroke: #2563eb; stroke-width: 2.5; fill: rgba(37, 99, 235, 0.25); pointer-events: none; }
/* 接近提示：附近有端点，再靠一点就会被吸上 */
.snap-near { stroke: #f87171; stroke-width: 3; fill: rgba(248, 113, 113, 0.18); stroke-dasharray: 4 3; pointer-events: none; }

/* 文字编辑浮层 */
.text-editor {
  position: absolute;
  border: 1px dashed var(--accent);
  background: rgba(255,255,255,.97);
  outline: none; padding: 4px 6px;
  min-width: 80px; z-index: 20;
  border-radius: 6px;
}
#drawLayer text { user-select: none; }

/* ===== 全屏查看：隐藏所有工具栏 ===== */
.fs-restore {
  position: absolute; right: 16px; bottom: 16px;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(31,41,55,.85); color: #fff;
  border: none; display: none;
  align-items: center; justify-content: center;
  z-index: 30; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.fs-restore svg { width: 22px; height: 22px; }
.fs-restore:active { background: rgba(31,41,55,.95); }

body.fullscreen .topbar,
body.fullscreen .toolbar,
body.fullscreen .propbar { display: none; }
body.fullscreen .fs-restore { display: flex; }
body.fullscreen .canvas-wrap { flex: 1; }

/* ===== 折线末端续接锚点 ===== */
.poly-anchor-circle {
  fill: var(--accent); stroke: #fff; stroke-width: 2.5;
  opacity: .95; cursor: pointer;
}
.poly-anchor-plus {
  fill: #fff; font-size: 20px; font-weight: 600;
  pointer-events: none;
}

/* 点刷：颗粒大小 / 密度 */
.spray-opts { display: none; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.spray-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.spray-row:last-child { margin-bottom: 0; }
.spray-label { font-size: 13px; color: #6b7280; width: 32px; flex: none; }
.spray-seg { display: flex; gap: 6px; flex: 1; }
.spray-seg button {
  flex: 1; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; color: #374151; font-size: 13px; font-family: inherit; cursor: pointer;
}
.spray-seg button.active { background: #e8effe; border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* 抠图操作条 */
.lasso-bar {
  display: none; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 8px; background: #fff; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.lasso-bar.show { display: flex; }
.lasso-bar button {
  height: 34px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 13px; cursor: pointer;
}
.lasso-bar button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.lasso-bar button { font-size: 12px; white-space: nowrap; }

/* 绘制时的手指放大预览圈 */
.loupe-wrap {
  position: fixed; left: 0; top: 0;
  width: 132px; height: 132px;
  border-radius: 50%; overflow: hidden;
  display: none; pointer-events: none; z-index: 45;
  background: #fff;
  border: 2px solid rgba(37, 99, 235, .55);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .28);
}
.loupe-wrap.show { display: block; }
#loupe { width: 100%; height: 100%; display: block; }
.loupe-cross { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.loupe-cross::before {
  content: ''; position: absolute; left: 0; top: 8px; width: 18px; height: 2px;
  background: rgba(37, 99, 235, .65);
}
.loupe-cross::after {
  content: ''; position: absolute; top: 0; left: 8px; width: 2px; height: 18px;
  background: rgba(37, 99, 235, .65);
}

/* ===== 动画模式面板 ===== */
/* 输入框 / 文本框仍然允许正常的文字选择与光标操作 */
input, textarea, [contenteditable] {
  -webkit-user-select: text; user-select: text;
  -webkit-touch-callout: default;
}

.anim-panel, .anim-panel * {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.dock, .dock *, .topbar, .topbar *, .op-bar, .op-bar *, .panel, .panel * {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.anim-panel {
  position: relative;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 8px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
body.anim-mode .anim-panel { display: flex; }
body.anim-mode .toolbar, body.anim-mode .propbar, body.anim-mode .lasso-bar { display: none; }
/* 动画模式用面板里自己的参数条，底部那排常驻数值条先收起来，避免两处重复 */
body.anim-mode .num-bar { display: none; }
body.anim-playing .topbar, body.anim-playing .toolbar, body.anim-playing .propbar,
body.anim-playing .anim-panel, body.anim-playing .hint,
body.anim-playing .fs-restore, body.anim-playing .style-modal,
body.anim-playing .brush-modal { display: none !important; }

.anim-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.anim-chips::-webkit-scrollbar { display: none; }
.anim-chip {
  flex: 0 0 auto; height: 28px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.14); font-size: 12px; font-weight: 700;
  color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,0.28); opacity: 1;
}
/* 攒组/形态层多选：被选中的名字按钮加一圈白环 */
.anim-chip.sel { box-shadow: 0 0 0 3px #fff, 0 0 0 6px #c26a05; }
.anim-chip.on { box-shadow: 0 2px 7px rgba(0,0,0,0.28); outline: 2px solid #fff; outline-offset: -2px; }
/* 运动=蓝、形态=橙、色彩=绿，一眼看出当前在哪层 */
#animLayerM { background: #e8f1ff; color: #1b6bf0; border-color: #cfe0ff; }
#animLayerS { background: #fff1e4; color: #e07a1f; border-color: #ffdfc7; }
#animLayerC { background: #e9f7ee; color: #1f9d55; border-color: #cfe9d8; }
#animLayerM.on { background: #1b6bf0; color: #fff; }
#animLayerS.on { background: #e07a1f; color: #fff; }
#animLayerC.on { background: #1f9d55; color: #fff; }
.anim-elem { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.anim-elem-name { font-size: 13px; font-weight: 600; color: var(--text); max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anim-elem-in {
  flex: 1; min-width: 0; height: 30px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; padding: 0 8px;
}
.anim-elem-all { flex: 0 0 auto; height: 30px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-size: 12px; padding: 0 10px; color: var(--muted); }
.anim-switch { color: #1d4ed8; border-color: #bfd3ff; background: #eef4ff; font-weight: 600; }
.anim-autokey { color: var(--muted); }
.anim-autokey.on { color: #1d4ed8; border-color: #bfd3ff; background: #eef4ff; font-weight: 600; }
.ap-btn { height: 30px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); background: #fff; font-size: 12px; color: #1d4ed8; }
.anim-head { display: flex; align-items: center; gap: 6px; }
.anim-btn {
  height: 30px; min-width: 38px; padding: 0 9px;
  border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text);
  font-size: 13px; font-weight: 500; flex-shrink: 0;
}
.anim-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.anim-scenes { min-width: 0;
  display: flex; gap: 6px; overflow-x: auto; flex: 1;
  scrollbar-width: none; padding: 2px 0;
}
.anim-scenes::-webkit-scrollbar { display: none; }
.scene-chip {
  height: 28px; padding: 0 9px; border-radius: 14px;
  border: 1px solid var(--border); background: #fff;
  color: var(--text); font-size: 13px; white-space: nowrap; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.scene-chip .sc-n { font-style: normal; font-size: 11px; opacity: 0.85; }
.scene-chip.on .sc-n { opacity: 0.95; }
.scene-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.anim-track {
  display: flex; align-items: flex-start;
  /* 时间轴最多长到屏幕中间偏上，超过就在框内上下滑动查看 */
  max-height: 26vh;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.anim-labels { width: 40px; flex: none; }
.anim-label {
  height: 26px; line-height: 26px; margin: 1px 0; font-size: 11px; text-align: center;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 8px;
}
.anim-label.on { color: #fff; background: var(--accent); }
.anim-slots { position: relative; flex: 1; padding: 0 10px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.anim-rows { position: relative; }
.anim-row { position: relative; height: 26px; margin: 1px 0; border-radius: 8px; background: #eff1f4; }
.anim-row.on { background: #e3edff; }
/* 时间刻度：一眼看出关键帧在第几秒 */
.anim-ruler { position: relative; height: 15px; margin-bottom: 1px; }
.anim-tick { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid rgba(15,23,42,.18); }
.anim-tick.minor { border-left-color: rgba(15,23,42,.08); }
.anim-tick em {
  position: absolute; top: -1px; left: 1px; font-style: normal; font-size: 9px;
  line-height: 14px; color: #8a94a6; white-space: nowrap; transform: translateX(-50%);
  left: 0;
}
.anim-tick.major em { color: #4b5563; font-weight: 600; }
/* 帧点：15px 圆点 + 38px 宽的透明热区，手指很容易点到 */
.anim-mark-hit {
  position: absolute; top: 50%; width: 38px; margin-left: -19px; height: 26px; margin-top: -13px;
  background: transparent; z-index: 2; touch-action: none;
}
.anim-mark {
  position: absolute; left: 50%; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px;
  background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 2px #fff;
}
.anim-mark-hit.on .anim-mark { background: #e6007a; }
.anim-cursor {
  position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px;
  background: #e6007a; pointer-events: none; z-index: 4;
}
.anim-empty { min-height: 40px; line-height: 1.55; padding: 8px 10px; box-sizing: border-box; font-size: 12px; color: var(--muted); text-align: center; white-space: normal; word-break: break-word; }
.anim-foot {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
}
.anim-foot::-webkit-scrollbar { display: none; }
/* 走帧单独一行、比底栏按钮更宽，精细对时间时好按 */
.anim-seek { display: grid; grid-template-columns: 1fr auto auto auto 1fr; gap: 6px; }
.anim-step-btn { min-width: 0; padding: 0 8px; font-size: 12px; font-weight: 600; height: 34px; }
.anim-step-btn.on { background: #eef4ff; border-color: #2563eb; color: #2563eb; }
.anim-seek-btn { min-width: 0; height: 34px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.anim-key-btn { min-width: 52px; font-weight: 600; }
.anim-layer-btn { min-width: 48px; padding: 0 8px; }
/* 当前层的参数条：按层切换显示对应的一组 */
.anim-params { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.anim-params::-webkit-scrollbar { display: none; }
.anim-params .ap-group { display: none; align-items: center; gap: 6px; }
.anim-params[data-layer="M"] .ap-group[data-layer="M"],
.anim-params[data-layer="S"] .ap-group[data-layer="S"],
.anim-params[data-layer="C"] .ap-group[data-layer="C"] { display: flex; }
.ap-lb { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ap-in {
  height: 34px; width: 74px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13px; text-align: center; padding: 0 6px;
}
.ap-in.sm { width: 58px; }
.ap-color { width: 40px; height: 34px; padding: 2px; border-radius: 10px; border: 1px solid var(--border); background: #fff; }
.anim-dur-input {
  height: 34px; width: 60px; flex-shrink: 0;
  border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text);
  font-size: 13px; text-align: center; padding: 0 4px;
}
.anim-label { flex: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }

/* 动画模式下顶栏「动画」按钮高亮，随时能看清自己在什么状态 */
body.anim-mode #btnAnim { color: #fff; background: var(--accent); border-color: var(--accent); border-radius: 10px; }

/* 有图元被锁定时，顶栏锁按钮高亮 */
#btnLock.on { color: #fff; background: var(--accent); border-radius: 10px; }

/* ===== 图元参数窗口（精确绘图 / 精确操作） ===== */
.num-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: #f6f7f9;
  border-top: 1px solid #e9ecf1;
  font-size: 12px;
  color: #5b6472;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.num-bar.show { display: flex; }
.num-cell { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.num-cell > b { font-weight: 500; color: #8a93a3; }
.num-cell input {
  width: 54px;
  padding: 3px 2px;
  border: 1px solid #d6dae1;
  border-radius: 6px;
  background: #fff;
  color: #1f2430;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.num-cell input:focus { outline: none; border-color: #2563eb; }
.num-cell.ro > b { color: #b3bac6; }
.num-live { color: #2563eb; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
body.anim-playing .num-bar { display: none !important; }

/* ===== 导出面板 / 预览层 ===== */
.export-sheet { position: fixed; inset: 0; display: none; z-index: 120; background: rgba(16,20,28,.38); }
.export-sheet.show { display: flex; align-items: flex-end; }
.export-panel {
  width: 100%; background: #fff; border-radius: 16px 16px 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 28px rgba(16,20,28,.16);
}
.export-title { font-size: 13px; color: #8a93a3; margin-bottom: 10px; }
.export-rows { display: flex; flex-direction: column; gap: 8px; }
.export-rows button {
  padding: 13px 12px; border: 1px solid #e9ecf1; border-radius: 11px;
  background: #f8f9fb; font-size: 14px; color: #1f2430; text-align: left;
}
.export-rows button:active { background: #eef2f8; }
.export-cancel {
  margin-top: 10px; width: 100%; padding: 12px; border: none; border-radius: 11px;
  background: #f2f4f7; color: #5b6472; font-size: 14px;
}
.export-view {
  position: fixed; inset: 0; display: none; z-index: 130; background: #0f1218;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
}
.export-view.show { display: flex; }
.export-tip { color: #9aa4b2; font-size: 13px; text-align: center; }
.export-view img {
  max-width: 100%; max-height: 64vh; object-fit: contain;
  background: #fff; border-radius: 8px; box-shadow: 0 6px 26px rgba(0,0,0,.4);
}
.export-view img.plain { background: none; box-shadow: none; }
/* GIF 预览用棋盘格垫底：透明区一眼可见 */
.export-view img.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d8dde5 25%, transparent 25%),
    linear-gradient(-45deg, #d8dde5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8dde5 75%),
    linear-gradient(-45deg, transparent 75%, #d8dde5 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.export-actions { display: flex; gap: 12px; }
.export-btn {
  display: inline-block; padding: 10px 20px; border-radius: 10px; border: none;
  font-size: 14px; text-decoration: none; color: #1f2430; background: #fff;
}
.export-btn.primary { background: #2563eb; color: #fff; }

/* ===== 阵列面板的间距行 ===== */
.arr-gap { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; color: #5b6472; }
.arr-gap b { font-weight: 500; color: #8a93a3; flex: 0 0 auto; }
.arr-gap input {
  flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid #d6dae1; border-radius: 9px;
  font-size: 14px; text-align: center; color: #1f2430; background: #fff;
}
.arr-toggle {
  padding: 9px 12px; border-radius: 9px; border: 1px solid #d6dae1; background: #fff;
  font-size: 13px; color: #5b6472; flex: 0 0 auto;
}
.arr-toggle.on { background: #e8f0ff; border-color: #2563eb; color: #2563eb; }

/* ===== 悬浮球 ===== */
.orb-layer { position: absolute; inset: 0; pointer-events: none; z-index: 62; }
.orb {
  position: absolute; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-size: 13px; letter-spacing: .5px;
  pointer-events: auto; user-select: none; -webkit-user-select: none;
  box-shadow: 0 4px 14px rgba(16, 20, 28, .26);
  border: 1.5px solid rgba(255, 255, 255, .55);
  font-weight: 500;
  touch-action: none;
}
.orb.press { transform: scale(.92); }
/* 当前正在使用的功能：球上的文字变黄，和工具栏按钮的高亮联动 */
.orb.active { color: #ffd84a; text-shadow: 0 0 6px rgba(255,216,74,.55); }
body.anim-mode .orb-layer,
body.anim-playing .orb-layer { display: none; }
.orb-cmds { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; }
.orb-cmds::-webkit-scrollbar { display: none; }
.orb-chip {
  flex: 0 0 auto; padding: 7px 11px; border-radius: 8px; border: 1px solid #e2e6ee;
  background: #f7f8fa; font-size: 12px; color: #5b6472;
}
.orb-chip.on { background: #2563eb; border-color: #2563eb; color: #fff; }
.orb-line { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; color: #8a93a3; }
.orb-line b { font-weight: 500; flex: 0 0 auto; }
.orb-line input[type="range"] { flex: 1; min-width: 0; accent-color: #2563eb; }
.orb-colors { display: flex; gap: 8px; overflow-x: auto; }
.orb-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; flex: 0 0 auto; }
.orb-dot.on { border-color: #1f2430; }

.snap-line.center { stroke-width: 1.6; opacity: 1; }
.snap-line { opacity: .8; }
.snap-line.guide { stroke: #2563eb; stroke-width: 1.4; opacity: .85; stroke-dasharray: 8 5; }

.export-note {
  margin: 8px 4px 2px;
  font-size: 12px;
  line-height: 1.6;
  color: #6b7280;
  text-align: left;
}

/* ===== GIF 导出：范围框控制条 ===== */
.gif-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
  box-shadow: 0 -6px 20px rgba(16,20,28,.14);
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px 8px 10px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.gif-bar.show { display: flex; }
.gif-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gif-label { font-size: 12px; color: #6b7280; }
.gif-num {
  width: 64px; height: 32px;
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 13px; text-align: center; color: #111827; background: #fff;
}
.gif-ratio, .gif-go, .gif-cancel {
  height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 9px;
  background: #fff; font-size: 12px; color: #374151; white-space: nowrap;
}
.gif-ratio.on { background: #eff4ff; border-color: #2563eb; color: #2563eb; }
  .gif-all { margin-left: auto; }
  .gif-all.on { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.gif-go { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 600; }
.gif-go.alt { background: #111827; border-color: #111827; }
.gif-cancel { color: #6b7280; }


/* 插入图片来源选择：相册 / 剪贴板 */
.src-sheet {
  display: none; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  padding: 8px; background: #fff; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.src-sheet.show { display: flex; }
.src-sheet button {
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.src-sheet button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
/* 复制参数面板 */
.copy-rows { padding: 4px 0 10px; }
.copy-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.copy-row label { font-size: 13px; color: #40485a; white-space: nowrap; }
.copy-row input {
  flex: 1; min-width: 0; padding: 9px 10px; font-size: 15px; color: #1f2430;
  border: 1px solid #d8dce4; border-radius: 9px; background: #fff;
}
.copy-tip { font-size: 12px; color: #8a90a0; white-space: nowrap; }


/* 框心的移动手柄：小图元也能一指点中拖动 */
.move-handle { fill: rgba(37, 99, 235, .12); stroke: var(--accent); stroke-width: 1.6; }
/* 旋转中心（轴心）手柄：虚线小圆，拖过之后变成实线亮色，一眼看出"没在正中间" */
.pivot-hit { fill: rgba(255,255,255,.001); pointer-events: auto; cursor: pointer; }
.pivot-handle {
  fill: rgba(255, 255, 255, .55);
  stroke: rgba(120, 80, 220, .85);
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
}
.pivot-handle.on {
  stroke: #7c4dff;
  stroke-width: 2;
  stroke-dasharray: none;
  fill: rgba(124, 77, 255, .16);
}
.pivot-dot { fill: rgba(120, 80, 220, .9); pointer-events: none; }
.pivot-dot.on { fill: #7c4dff; }


/* 拼图参数 */
.mosaic-opts { padding: 2px 0 4px; }
.mosaic-opt-title { font-size: 13px; color: #8a93a3; margin: 10px 0 8px; }
.mosaic-opt-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.mosaic-opt-row button {
  min-width: 62px; height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid #e9ecf1; background: #f8f9fb; font-size: 13px; color: #1f2430;
}
.mosaic-opt-row button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }


/* A4 分页导出的翻页条 */
.export-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 4px 0 2px; }
.export-pager span { font-size: 13px; color: #9aa1ae; }
.export-page-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid #333a45;
  background: #1c2027; color: #fff; font-size: 16px; line-height: 1;
}
.export-page-btn:active { background: #262c36; }


/* ===== 顶栏两排：上排固定，下排横滑 ===== */
.topbar {
  height: auto;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: visible;
}
.toprow {
  display: flex;
  align-items: center;
  gap: 0;
  height: 48px;
  padding: 0 6px;
  flex-shrink: 0;
}
.toprow-fixed {
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.toprow-fixed::-webkit-scrollbar { display: none; }
.toprow-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.toprow-scroll::-webkit-scrollbar { display: none; }
/* 两排按钮统一尺寸：宽高一致，高度给足好按 */
.toprow .op-btn,
.toprow .tool,
.toprow .tool-aux,
.toprow .fill-tool {
  width: 36px;
  height: 40px;
  min-width: 0;
  padding: 0;
  gap: 0;
  flex-direction: row;
  border-radius: 9px;
  flex-shrink: 0;
}
.toprow .op-btn.text-btn { width: 36px; font-size: 12px; }
.toprow .tool span,
.toprow .tool-aux span,
.toprow .fill-tool span { display: none; }
.toprow .tool svg,
.toprow .tool-aux svg,
.toprow .fill-tool svg,
.toprow .op-btn svg { width: 22px; height: 22px; }
.toprow-fixed .op-btn,
.toprow-fixed .tool,
.toprow-fixed .tool-aux,
.toprow-fixed .fill-tool { height: 34px; }

/* 一键循环：按固定节奏铺帧（摆脚/眨眼/伸缩） */
.ap-cycle { color: #7c3aed; border-color: #ddd6fe; background: #faf5ff; }
.cycle-panel {
  display: none;
  position: absolute;
  left: 6px; right: 6px;
  bottom: calc(100% + 6px);
  z-index: 9;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.14);
  padding: 8px 10px;
  flex-direction: column;
  gap: 6px;
}
.cycle-panel.on { display: flex; }
.cp-line { display: flex; align-items: center; gap: 6px; }
.cp-lb { font-size: 12px; color: #6b7280; flex: 0 0 auto; }
.cp-opt { height: 28px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: #fff; font-size: 12px; color: #374151; }
.cp-opt.on { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.cp-go { flex: 1; height: 30px; border-radius: 9px; border: 0; background: #7c3aed; color: #fff; font-size: 13px; }
.cp-x { height: 30px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: #6b7280; font-size: 13px; }

/* 「全部」是个开关：只有它开着才显示所有图元轨道 */
.anim-elem-all.on { background: #2563eb; border-color: #2563eb; color: #fff; }
.cp-mini { height: 28px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); background: #f8fafc; color: #6b7280; font-size: 12px; }
.cp-target { font-size: 12px; color: #7c3aed; background: #faf5ff; border-radius: 8px; padding: 4px 8px; }

.proj-name-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px 6px; }
.proj-name-row label { font-size: 13px; color: #6b7280; flex-shrink: 0; }
.proj-name-row input { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; font-size: 14px; }

/* 初始化：动画清零的危重操作，单独给个红字提示 */
.anim-init { color: #b91c1c; border-color: #fecaca; background: #fff5f5; }

/* 锁定按钮上的"这次会作用到几块"角标 */
#btnLock { position: relative; }
#btnLock::after {
  content: attr(data-count);
  position: absolute; top: -2px; right: -2px;
  min-width: 14px; height: 14px; line-height: 14px;
  padding: 0 3px; border-radius: 8px;
  background: #e11d48; color: #fff;
  font-size: 10px; font-weight: 600; text-align: center;
  pointer-events: none;
}
#btnLock:not([data-count=""])::after { display: block; }
#btnLock[data-count=""]::after { display: none; }

/* 「锁其他」生效时的明显状态：蓝底白字，一眼看出它在起作用 */
#btnLockOthers.on { background: var(--accent); border-radius: 10px; }
#btnLockOthers.on svg, #btnLockOthers.on span { color: #fff; }
/* 「全解锁」按钮：红色描边，专门用来一键清空锁定 */
#btnUnlockAll svg, #btnUnlockAll span { color: #e11d48; }


/* 光标所在时间（精确到 0.1s）：占掉原来「10帧」那个位置 */
.anim-time {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; min-width: 62px; padding: 0 8px; border-radius: 10px;
  border: 1px solid #d9e2f5; background: #f4f7ff; color: #1d4ed8;
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 悬浮方向盘 */
.dpad {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* 固定在整块屏幕上（不是只压在画布区域），才能拖到面板那边去，少挡画面 */
  position: fixed; right: 16px; bottom: 96px;
  width: 132px; height: 132px;
  display: grid;
  grid-template-columns: 44px 44px 44px;
  grid-template-rows: 44px 44px 44px;
  grid-template-areas: ". up ." "left hub right" ". down .";
  gap: 0;
  border-radius: 50%;
  background: rgba(24, 28, 38, 0.78);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  touch-action: none;
  z-index: 30;
}
.dpad[hidden] { display: none; }
.dpad-k {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  width: 44px; height: 44px; border: none; background: transparent;
  color: rgba(255, 255, 255, 0.92); font-size: 18px; line-height: 1;
  border-radius: 12px; touch-action: none;
}
.dpad-k:active { background: rgba(255, 255, 255, 0.18); color: #fff; }
.dpad-k[data-dpad="up"] { grid-area: up; }
.dpad-k[data-dpad="down"] { grid-area: down; }
.dpad-k[data-dpad="left"] { grid-area: left; }
.dpad-k[data-dpad="right"] { grid-area: right; }
.dpad-hub {
  grid-area: hub; width: 34px; height: 34px; margin: 5px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.16);
}


/* 图元名称栏里的子图元：比组小一号、带一点缩进感，一眼能看出它属于上面那个组 */
.anim-chip.child {
  font-size: 11px;
  padding: 0 9px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55);
  opacity: .92;
}

/* 醒目按钮：导入(蓝) / 新建(绿) / 动画(橙)，实底白字，和普通白底黑字按钮拉开对比 */
.op-btn.tone-blue { background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 600; }
.op-btn.tone-blue:active { background: #1d4ed8; }
.op-btn.tone-green { background: #16a34a; color: #fff; border-color: #16a34a; font-weight: 600; }
.op-btn.tone-green:active { background: #15803d; }
.tool-aux.tone-amber { background: #ea580c; border-color: #ea580c; border-radius: 10px; }
.tool-aux.tone-amber svg { color: #fff; }
.tool-aux.tone-amber span { color: #fff; font-weight: 600; }
.tool-aux.tone-amber:active { background: #c2410c; }

/* 新建前的确认弹窗 */
.wb-ask-mask {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(17,24,39,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.wb-ask-box {
  width: 100%; max-width: 340px;
  background: #fff; border-radius: 14px; padding: 18px 18px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
}
.wb-ask-title { font-size: 16px; font-weight: 700; color: #111827; margin-bottom: 8px; }
.wb-ask-desc { font-size: 13px; line-height: 1.6; color: #4b5563; margin-bottom: 14px; }
.wb-ask-row { display: flex; gap: 10px; }
.wb-ask-btn {
  flex: 1; height: 42px; border-radius: 10px; border: 1px solid var(--border, #d1d5db);
  background: #fff; font-size: 14px; font-weight: 600; color: #111827;
}
.wb-ask-btn.yes { background: #16a34a; border-color: #16a34a; color: #fff; }
.wb-ask-btn.no { background: #fff; color: #b91c1c; border-color: #fca5a5; }

/* ===== 矮屏 / 横屏自适应：底部条压缩，给画布留出地方 ===== */
.anim-panel { max-height: 66vh; overflow-y: auto; }

@media (max-height: 620px) {
  .topbar { height: 42px; }
  .op-btn { width: 32px; height: 32px; }
  .op-btn svg { width: 18px; height: 18px; }

  .toolbar { height: 56px; padding: 4px; gap: 2px; }
  .tool, .tool-aux, .fill-tool { min-width: 42px; padding: 4px 3px; gap: 2px; }
  .tool svg, .tool-aux svg, .fill-tool svg { width: 20px; height: 20px; }
  .tool span, .tool-aux span, .fill-tool span { font-size: 10px; }

  .propbar { height: 50px; border-bottom-width: 10px; }
  .color-btn, .style-btn { height: 28px; }
  .color-btn { padding: 0 8px 0 5px; }
  .color-swatch { width: 20px; height: 20px; }

  /* 动画面板：整体压一档，时间轴在框内上下滚，不再把画布挤没 */
  .anim-panel { max-height: 70vh; gap: 3px; padding: 4px 10px 6px; }
  .anim-seek-btn, .anim-step-btn, .anim-btn { height: 28px; }
  .anim-chip { height: 26px; }
  .anim-elem-in, .anim-elem-all, .ap-btn, .scene-chip { height: 26px; }
  .ap-in, .ap-color, .anim-dur-input { height: 28px; }
  .anim-track { max-height: 16vh; }
  .anim-row, .anim-label { height: 22px; line-height: 22px; }
}

@media (max-height: 500px) {
  .anim-panel { max-height: 80vh; gap: 2px; padding: 3px 10px 5px; }
  .anim-track { max-height: 10vh; }
  /* 很矮的屏：图元胶囊条收起来，当前图元名字在下面那行已经有了 */
  .anim-chips { display: none; }
  .anim-seek-btn, .anim-step-btn, .anim-btn { height: 26px; }
  .anim-elem-in, .anim-elem-all, .ap-btn, .scene-chip { height: 24px; }
  .ap-in, .ap-color, .anim-dur-input { height: 26px; }
}

/* 横屏：动画面板收成右侧竖向侧栏，画布占左侧剩余宽度 */
@media (orientation: landscape) {
  body.anim-mode .anim-panel {
    position: fixed; top: 46px; right: 0; bottom: 0;
    width: min(48vw, 420px); min-width: 300px; max-height: none;
    border-top: none; border-left: 1px solid var(--border);
    gap: 3px; padding: 6px 8px 10px;
    overflow-y: auto;
    box-shadow: -4px 0 16px rgba(16,20,28,.10);
  }
  body.anim-mode .canvas-wrap { margin-right: min(48vw, 420px); }
  .anim-seek, .anim-elem, .anim-head, .anim-foot, .anim-foot2 { flex-wrap: wrap; }
  .anim-seek-btn, .anim-step-btn, .anim-btn { height: 28px; }
  .anim-chip { height: 26px; }
  .anim-elem-in, .anim-elem-all, .ap-btn, .scene-chip { height: 26px; }
  .ap-in, .ap-color, .anim-dur-input { height: 28px; }
  .anim-track { max-height: 160px; }
  .anim-row, .anim-label { height: 22px; line-height: 22px; }
}
