/* ==================================================================
   福音 Logo 设计器 —— UI 主题
   默认「白天」暖中性浅色；「夜晚」为深色。语义化变量，一键切换。
   ================================================================== */
:root,
:root[data-theme="light"] {
  --bg:        #f4f6f9;   /* 全局底：清透浅灰白 */
  --panel:     #ffffff;   /* 面板：纯净白 */
  --panel-2:   #f5f7fa;   /* 次级面板 / 输入底 */
  --stroke:    #e9edf2;   /* 分隔线：很淡 */
  --stroke-2:  #dbe1e9;
  --text:      #2b3542;   /* 主文字 */
  --text-dim:  #5f6b79;
  --text-mut:  #9aa4b1;
  --accent:    #2f8f66;   /* 主色：清新林绿 */
  --accent-2:  #277a57;
  --accent-soft: #e7f4ee;
  --danger:    #d0574b;
  --ok:        #2f9f63;
  --topbar-a:  #ffffff;   /* 顶栏渐变 */
  --topbar-b:  #fbfcfe;
  --stage-bg:  #eef1f5;   /* 画布外工作区：明亮 */
  --ruler-bg:  #f7f9fb;
  --ruler-tick:#dce1e8;
  --hover:     #eef2f7;
  --sel-bg:    #e7f4ee;
  --board-a:   #e9edf2;   /* 透明棋盘格深块 */
  --board-b:   #fbfcfe;   /* 透明棋盘格浅块 */
  --scroll:    #d3d9e1;
  --scroll-h:  #bcc4cf;
  --grid-line: rgba(30,42,56,.04);
  --overlay:   rgba(38,48,59,.28);
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 12px 40px rgba(45,58,74,.12);
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", sans-serif;
}

:root[data-theme="dark"] {
  --bg:        #10141a;
  --panel:     #171c23;
  --panel-2:   #1e242d;
  --stroke:    #262d38;
  --stroke-2:  #333c48;
  --text:      #e6ebf2;
  --text-dim:  #9aa5b3;
  --text-mut:  #6b7683;
  --accent:    #4a9d76;
  --accent-2:  #3f8a67;
  --accent-soft: #1c2c25;
  --danger:    #e0554c;
  --ok:        #3fbf7a;
  --topbar-a:  #1a2029;
  --topbar-b:  #12161c;
  --stage-bg:  #0b0e12;
  --ruler-bg:  #12161c;
  --ruler-tick:#2a323d;
  --hover:     #232b35;
  --sel-bg:    #1b2c24;
  /* 透明棋盘格始终保持浅中性色，确保深色/黑色图案在暗色界面下也能被衬托出来 */
  --board-a:   #b9bfc8;
  --board-b:   #d8dce2;
  --scroll:    #2b333f;
  --scroll-h:  #3a4552;
  --grid-line: rgba(255,255,255,.05);
  --overlay:   rgba(4,6,9,.62);
  --shadow:    0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }   /* 确保 hidden 属性始终生效，优先级高于 .modal 等 display 规则 */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  transition: background .3s, color .3s;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-h); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 顶部工具栏 ============ */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: linear-gradient(180deg, var(--topbar-a), var(--topbar-b));
  border-bottom: 1px solid var(--stroke);
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 260px; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 6px;
  background: conic-gradient(from 210deg, #f0b429, #f7d774, #f0b429, #caa32a);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.brand-name { font-weight: 700; letter-spacing: 2px; font-size: 14px; }
.brand-sub { color: var(--text-mut); font-size: 12px; letter-spacing: 1px; }

.tool-cluster { display: flex; align-items: center; gap: 6px; }
.tool-cluster.right { margin-left: auto; }
.divider { width: 1px; height: 22px; background: var(--stroke-2); margin: 0 6px; }

.tbtn {
  height: 32px; padding: 0 14px;
  background: var(--panel-2);
  border: 1px solid var(--stroke-2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.tbtn:hover { background: var(--hover); color: var(--text); border-color: var(--stroke-2); }
.tbtn:active { transform: translateY(1px); }
.tbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tbtn.primary:hover { background: var(--accent-2); }
.tbtn.ghost { background: transparent; }
.zoom-label { min-width: 46px; text-align: center; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); cursor: pointer; padding: 0 4px; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 10px; background: var(--stroke-2); position: relative; cursor: pointer; transition: .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 16px; background: #fff; }
.switch.block { display: flex; margin: 10px 0; }

/* ============ 拟物日夜切换开关 ============ */
.theme-toggle {
  border: none; background: none; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center;
}
.tt-track {
  position: relative; display: block;
  width: 62px; height: 28px; border-radius: 999px;
  background: linear-gradient(180deg, #8ec5ea, #cfe6f6);   /* 白天：晴空 */
  box-shadow: inset 0 2px 5px rgba(0,0,0,.18), inset 0 -1px 0 rgba(255,255,255,.5),
              0 1px 2px rgba(0,0,0,.12);
  transition: background .4s;
  overflow: hidden;
}
.tt-sun, .tt-moon {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; transition: opacity .35s, transform .35s;
}
.tt-sun {
  left: 7px; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #fff2b0, #ffd23e 60%, #f4a71d);
  box-shadow: 0 0 6px rgba(255,196,60,.9);
  opacity: 1;
}
.tt-moon {
  right: 7px; border-radius: 50%;
  background: radial-gradient(circle at 62% 40%, #f4f7ff, #cdd6e6 70%, #aab6cc);
  box-shadow: inset -4px -1px 0 -1px rgba(120,132,158,.7);
  opacity: 0; transform: translateY(-50%) scale(.6);
}
.tt-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #f2f4f7 70%, #dfe3ea);
  box-shadow: 0 2px 4px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.9);
  transition: transform .4s cubic-bezier(.32,1.4,.5,1), background .4s;
}
.theme-toggle[aria-checked="true"] .tt-track {
  background: linear-gradient(180deg, #23304a, #131a2b);   /* 夜晚：星空 */
  box-shadow: inset 0 2px 6px rgba(0,0,0,.55), inset 0 -1px 0 rgba(255,255,255,.06),
              0 1px 2px rgba(0,0,0,.3);
}
.theme-toggle[aria-checked="true"] .tt-thumb {
  transform: translateX(34px);
  background: radial-gradient(circle at 35% 30%, #e8edf7, #c3ccdd 70%, #9aa6bd);
}
.theme-toggle[aria-checked="true"] .tt-sun { opacity: 0; transform: translateY(-50%) scale(.6); }
.theme-toggle[aria-checked="true"] .tt-moon { opacity: 1; transform: translateY(-50%) scale(1); }

/* ============ 工作区布局 ============ */
.workspace { display: flex; height: calc(100vh - 52px); }
.panel {
  background: var(--panel);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.panel.left  { width: 248px; border-right: 1px solid var(--stroke); }
.panel.right { width: 280px; border-left: 1px solid var(--stroke); }
.panel-section { padding: 18px 18px 20px; border-bottom: 1px solid var(--stroke); }
.panel-section.grow { flex: 1; overflow-y: auto; }
.section-title { font-size: 11px; letter-spacing: 1.5px; color: var(--text-mut); text-transform: uppercase; margin-bottom: 12px; }

/* 右侧页签 */
.tabbar { display: flex; height: 42px; border-bottom: 1px solid var(--stroke); flex: 0 0 auto; }
.tab { flex: 1; border: none; background: transparent; color: var(--text-mut); font-size: 13px; cursor: pointer; position: relative; transition: .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tab:hover { color: var(--text-dim); }
.tab.on { color: var(--text); font-weight: 600; }
.tab.on::after { content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--stroke-2); font-size: 11px; color: var(--text-mut); display: inline-flex; align-items: center; justify-content: center; }
.tab.on .tab-count { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tab-body { display: flex; flex-direction: column; overflow-y: auto; flex: 1; }

/* 左侧素材库：子页签（内置图形 / 我的素材 / 快速模板） */
.lib-section { display: flex; flex-direction: column; flex: 1; overflow: hidden; padding-top: 0; }
.sub-tabbar { height: 40px; margin: 0 -18px 14px; padding: 0 6px; }
.sub-tabbar .tab { font-size: 12px; }
.lib-body { flex: 1; overflow-y: auto; min-height: 0; }

/* 添加元素 */
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-item {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 8px;
  background: var(--panel-2);
  border: 1px solid var(--stroke-2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer; transition: .15s;
}
.add-item:hover { background: var(--hover); color: var(--text); border-color: var(--accent); }
.ai-icon { width: 22px; height: 22px; opacity: .85; }
.ai-icon[data-glyph] { background: currentColor; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-size: contain; mask-size: contain; }
.ai-icon[data-glyph="text"]  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 5h14v3h-2V7h-4v10h2v2H9v-2h2V7H7v1H5z' fill='%23fff'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 5h14v3h-2V7h-4v10h2v2H9v-2h2V7H7v1H5z' fill='%23fff'/%3E%3C/svg%3E"); }
.ai-icon[data-glyph="image"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 4h18v16H3zM7 9a2 2 0 100-4 2 2 0 000 4zm-2 8l5-5 3 3 4-4 4 4v2H5z' fill='%23fff'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 4h18v16H3zM7 9a2 2 0 100-4 2 2 0 000 4zm-2 8l5-5 3 3 4-4 4 4v2H5z' fill='%23fff'/%3E%3C/svg%3E"); }
.ai-icon[data-glyph="line"]  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17L17 3l4 4L7 21z' fill='%23fff'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17L17 3l4 4L7 21z' fill='%23fff'/%3E%3C/svg%3E"); }
.ai-icon[data-glyph="rect"]  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v14H4z' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v14H4z' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E"); }

/* 素材库 */
.asset-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 40px; }
.asset-empty { grid-column: 1/-1; color: var(--text-mut); font-size: 12px; text-align: center; padding: 14px 6px; border: 1px dashed var(--stroke-2); border-radius: var(--radius-sm); }
.asset-thumb { aspect-ratio: 1; background: var(--panel-2) center/contain no-repeat; border: 1px solid var(--stroke-2); border-radius: var(--radius-sm); cursor: grab; transition: .15s; }
.asset-thumb:hover { border-color: var(--accent); }

/* 内置图形 */
.builtin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.builtin-item { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 6px; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: var(--radius-sm); cursor: pointer; transition: .15s; }
.builtin-item:hover { border-color: var(--accent); background: var(--hover); }
.builtin-item svg { width: 100%; height: 100%; color: var(--text); }

/* 模板卡片 */
.template-grid { display: grid; gap: 8px; }
.template-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 10px 12px; text-align: left; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: var(--radius-sm); cursor: pointer; transition: .15s; position: relative; }
.template-card:hover { border-color: var(--accent); background: var(--hover); }
.tpl-tag { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.tpl-name { font-size: 13px; font-weight: 600; color: var(--text); }
.tpl-desc { font-size: 11px; color: var(--text-mut); line-height: 1.4; }

.preset-btn { width: 100%; height: 36px; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; transition: .15s; }
.preset-btn:hover { border-color: var(--accent); background: var(--hover); }
.hint { color: var(--text-mut); font-size: 11px; line-height: 1.5; margin-top: 8px; }

/* ============ 舞台 / 画布 ============ */
.stage {
  flex: 1; position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: 22px 1fr;
  background: var(--stage-bg);
  overflow: hidden;
}
.ruler { background: var(--ruler-bg); color: var(--text-mut); overflow: hidden; position: relative; z-index: 5; }
.ruler-x { grid-column: 2; grid-row: 1; }
.ruler-y { grid-column: 1; grid-row: 2; }
.ruler-corner { grid-column: 1; grid-row: 1; background: var(--ruler-bg); border-right: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke); }
.ruler-x { border-bottom: 1px solid var(--stroke); }
.ruler-y { border-right: 1px solid var(--stroke); }

.canvas-scroll {
  grid-column: 2; grid-row: 2;
  overflow: auto; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.canvas-wrap { position: relative; box-shadow: var(--shadow); border-radius: 4px; }
.canvas-wrap canvas { position: absolute; top: 0; left: 0; display: block; }
#board {
  /* 透明棋盘格背景 */
  background-image:
    linear-gradient(45deg, var(--board-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--board-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--board-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--board-a) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-color: var(--board-b);
}
#overlay { pointer-events: none; z-index: 3; }

.statusbar {
  position: absolute; left: 22px; right: 0; bottom: 0; height: 26px;
  display: flex; align-items: center; gap: 20px; padding: 0 14px;
  background: var(--ruler-bg); border-top: 1px solid var(--stroke);
  color: var(--text-mut); font-size: 12px; font-variant-numeric: tabular-nums;
  z-index: 6;
}

/* ============ 属性面板 ============ */
.field-row { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.field-row label { color: var(--text-mut); font-size: 12px; white-space: nowrap; }

/* 位置 / 尺寸：2×2 网格，标签浮于输入框内 */
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.pg-field { position: relative; }
.pg-field .pg-tag {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-mut); pointer-events: none;
}
.pg-field input { padding-left: 30px; text-align: right; padding-right: 9px; }

/* 通用控件行：滑块占满 + 数字框 + 单位 + 小按钮 */
.ctrl-row { display: flex; align-items: center; gap: 8px; }
.ctrl-row input[type=range] { flex: 1 1 auto; min-width: 0; }
.ctrl-num { flex: 0 0 56px; width: 56px; text-align: center; padding: 0 4px; }
.ctrl-row .unit { font-size: 12px; color: var(--text-mut); margin-left: -4px; }
.mini.icon-btn { flex: 0 0 30px; width: 30px; height: 30px; padding: 0; font-size: 14px; }
.field-col { margin-bottom: 9px; }
.field-col label { display: block; color: var(--text-mut); font-size: 12px; margin-bottom: 5px; }
input[type=number], input[type=text], select, textarea {
  width: 100%; min-width: 0; height: 30px;
  background: var(--panel-2); border: 1px solid var(--stroke-2);
  border-radius: 6px; padding: 0 8px; color: var(--text);
  transition: .15s;
}
textarea { height: auto; padding: 7px 8px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=color] { width: 34px; height: 30px; padding: 2px; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: 6px; cursor: pointer; flex: 0 0 auto; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--stroke-2); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; }

.seg { display: flex; border: 1px solid var(--stroke-2); border-radius: 6px; overflow: hidden; }
.seg.full { width: 100%; }
.seg button { flex: 1; height: 30px; background: var(--panel-2); border: none; border-right: 1px solid var(--stroke-2); color: var(--text-dim); cursor: pointer; transition: .12s; white-space: nowrap; padding: 0 6px; }
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--hover); color: var(--text); }
.seg button.on { background: var(--accent); color: #fff; }

.btn-row { display: flex; gap: 6px; margin-top: 8px; }
.mini { flex: 1; height: 28px; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: 6px; color: var(--text-dim); cursor: pointer; transition: .12s; font-size: 12px; }
.mini:hover { background: var(--hover); color: var(--text); }
.mini.danger:hover { background: var(--accent-soft); color: var(--danger); border-color: var(--danger); }

/* 对齐 / 分布 / 变换 工具条 */
.align-bar { display: flex; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: 7px; padding: 3px; }
.align-bar button { flex: 1; height: 28px; min-width: 0; border: none; background: transparent; color: var(--text-dim); font-size: 15px; line-height: 1; border-radius: 5px; cursor: pointer; transition: .12s; display: flex; align-items: center; justify-content: center; }
.align-bar button .ic { display: block; width: 18px; height: 18px; }
.align-bar button:hover { background: var(--hover); color: var(--accent); }
.align-bar button.on { background: var(--accent); color: #fff; }
.align-bar .ab-sep { width: 1px; align-self: stretch; margin: 3px 2px; background: var(--stroke-2); flex: 0 0 auto; }

/* 颜色选择宿主（Pickr 挂载点，降级为原生色块） */
.color-host { display: inline-flex; align-items: center; }
.pcr-button, .color-swatch { width: 30px; height: 26px; border-radius: 6px; border: 1px solid var(--stroke-2); cursor: pointer; }

/* 图层列表 */
.layer-head { display: flex; align-items: center; justify-content: space-between; }
.layer-tools { display: inline-flex; gap: 6px; }
.chip { height: 22px; padding: 0 9px; font-size: 11px; letter-spacing: 0; text-transform: none; background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: 5px; color: var(--text-dim); cursor: pointer; transition: .12s; }
.chip:hover { background: var(--hover); color: var(--text); border-color: var(--accent); }
.layer-hint { margin: -4px 0 10px; }
.layer-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.layer-item { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; background: var(--panel-2); border: 1px solid transparent; border-radius: 6px; cursor: pointer; transition: .12s; }
.layer-item.group-child { margin-left: 14px; }
.layer-item.is-group { background: var(--accent-soft); }
.layer-item:hover { border-color: var(--stroke-2); }
.layer-item.sel { border-color: var(--accent); background: var(--sel-bg); }
.layer-item .lt-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-dim); }
.layer-item.sel .lt-name { color: var(--text); }
.layer-item .lt-vis { width: 18px; height: 18px; opacity: .6; cursor: pointer; }
.layer-item .lt-lock { width: 16px; opacity: .55; cursor: pointer; font-size: 12px; }
.layer-item.locked { opacity: .72; }
.layer-item.locked .lt-name { font-style: italic; }
.layer-item .lt-tag { font-size: 10px; color: var(--text-mut); border: 1px solid var(--stroke-2); border-radius: 4px; padding: 1px 5px; }

/* ============ 导出弹窗 ============ */
.modal { position: fixed; inset: 0; background: var(--overlay, rgba(20,28,38,.5)); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(3px); }
.modal-card { width: 460px; max-width: 92vw; background: var(--panel); border: 1px solid var(--stroke-2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { padding: 16px 20px; font-weight: 600; border-bottom: 1px solid var(--stroke); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--stroke); }
.ex-preview { margin-top: 14px; min-height: 120px; border: 1px solid var(--stroke-2); border-radius: 8px; display: flex; align-items: center; justify-content: center; background-image: linear-gradient(45deg,var(--board-a) 25%,transparent 25%),linear-gradient(-45deg,var(--board-a) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,var(--board-a) 75%),linear-gradient(-45deg,transparent 75%,var(--board-a) 75%); background-size: 16px 16px; background-position: 0 0,0 8px,8px -8px,-8px 0; background-color: var(--board-b); padding: 12px; }
.ex-preview img { max-width: 100%; max-height: 240px; }
.modal-card.wide { width: 640px; }

/* ============ 项目名 / 保存状态 ============ */
.proj-name { margin-left: 16px; height: 28px; width: 150px; padding: 0 10px; background: var(--panel-2); border: 1px solid transparent; border-radius: 6px; color: var(--text); font-size: 13px; transition: .15s; }
.proj-name:hover { border-color: var(--stroke-2); }
.proj-name:focus { border-color: var(--accent); background: var(--panel); outline: none; }
.save-state { margin-left: 10px; font-size: 11px; color: var(--text-mut); white-space: nowrap; }

/* 最近项目 */
.start-actions { margin-bottom: 14px; }
.start-new { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px; background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 10px; color: var(--accent); font-size: 14px; cursor: pointer; transition: .15s; }
.start-new:hover { background: var(--accent); color: #fff; }
.start-new .sn-plus { font-size: 20px; line-height: 1; }
.recent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-height: 52vh; overflow: auto; }
.recent-card { border: 1px solid var(--stroke-2); border-radius: 10px; overflow: hidden; cursor: pointer; transition: .15s; background: var(--panel-2); position: relative; }
.recent-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.rc-thumb { height: 92px; background: var(--board-b) center/contain no-repeat; }
.rc-meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.rc-name { font-size: 13px; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rc-time { font-size: 11px; color: var(--text-mut); }
.rc-del { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; opacity: 0; transition: .15s; }
.recent-card:hover .rc-del { opacity: 1; }
.rc-del:hover { background: #d94b4b; }

/* ============ 画布右键菜单 ============ */
.ctx-menu { position: fixed; z-index: 200; min-width: 176px; padding: 6px; background: var(--panel); border: 1px solid var(--stroke-2); border-radius: 10px; box-shadow: var(--shadow); animation: ctxin .1s ease; }
@keyframes ctxin { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.ctx-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 8px 12px; border: none; background: transparent; color: var(--text); font-size: 13px; text-align: left; border-radius: 6px; cursor: pointer; }
.ctx-item:hover { background: var(--accent-soft); color: var(--accent); }
.ctx-item.danger:hover { background: rgba(220,70,70,.14); color: #d94b4b; }
.ctx-item[disabled] { opacity: .38; pointer-events: none; }
.ctx-key { font-size: 11px; color: var(--text-mut); letter-spacing: .3px; }
.ctx-item:hover .ctx-key { color: inherit; opacity: .8; }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--stroke); }

/* ============ 图层扁平图标 / 就地重命名 ============ */
.layer-item .lt-vis, .layer-item .lt-lock { display: inline-flex; align-items: center; justify-content: center; }
.layer-item .ic { display: block; }
.inline-edit { flex: 1; height: 24px; padding: 0 6px; border: 1px solid var(--accent); border-radius: 5px; background: var(--panel); color: var(--text); font-size: 13px; outline: none; }

/* ============ 内置图形分类 ============ */
.builtin-box { display: flex; flex-direction: column; gap: 4px; }
.shape-cat { font-size: 11px; color: var(--text-mut); margin: 8px 0 2px; letter-spacing: .5px; }
.shape-cat:first-child { margin-top: 0; }

/* ============ 圆角控制 ============ */
.corner-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.corner-head label { flex: 0 0 auto; }
.corner-head .seg { flex: 0 0 auto; }
.corner-head .seg button { height: 26px; padding: 0 10px; }
.corner-head .chip { margin-left: auto; }
#cornerUniform { align-items: center; gap: 8px; }
#cornerUniform input[type=range] { flex: 1; }
.corner-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 6px 8px; align-items: center; }
.corner-grid label { color: var(--text-mut); font-size: 12px; }
.corner-grid input { width: 100%; }

/* ============ Toast 非阻塞提示 ============ */
#toastHost { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 400; pointer-events: none; }
.toast { min-width: 160px; max-width: 80vw; padding: 10px 16px; border-radius: 8px; background: var(--panel); color: var(--text); border: 1px solid var(--stroke-2); box-shadow: var(--shadow); font-size: 13px; text-align: center; opacity: 0; transform: translateY(8px); transition: .22s; }
.toast.show { opacity: 1; transform: none; }
.toast-error { border-color: #d94b4b; color: #d94b4b; }
.toast-success { border-color: var(--accent); color: var(--accent); }

/* ============ H5 响应式（底部导航 + 底部抽屉） ============ */
.canvas-wrap { touch-action: none; }   /* 触屏由脚本接管拖拽/平移，禁止浏览器手势干扰 */
.m-dock, .m-backdrop { display: none; }

@media (max-width: 900px) {
  /* --- 顶栏精简：只保留核心操作，缩放/网格/最近改到画布手势或底栏 --- */
  .topbar { height: 48px; padding: 0 10px; gap: 6px; }
  .brand-sub, .proj-name, .save-state { display: none; }
  .brand { min-width: auto; gap: 7px; }
  .brand-name { font-size: 13px; letter-spacing: 1px; }
  .tool-cluster .switch,
  .zoom-label,
  .tbtn[data-act="zoom-in"], .tbtn[data-act="zoom-out"], .tbtn[data-act="zoom-fit"],
  .tbtn[data-act="recent"], .tbtn[data-act="clear"],
  .tool-cluster .divider { display: none; }
  .tbtn { height: 30px; padding: 0 11px; }

  /* --- 工作区：画布铺满，让位给底栏；面板脱离流式布局 --- */
  .workspace { display: block; height: calc(100vh - 48px); position: relative; }
  .stage { position: absolute; inset: 0 0 56px 0; height: auto; }

  /* --- 侧栏 → 底部抽屉 --- */
  .panel.left, .panel.right {
    position: fixed; left: 0; right: 0; bottom: 56px;
    width: auto; height: 60vh; max-height: 60vh;
    display: flex; flex-direction: column; overflow-y: auto;
    border: none; border-top: 1px solid var(--stroke);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -14px 44px rgba(0, 0, 0, .2);
    transform: translateY(calc(100% + 56px));
    transition: transform .28s cubic-bezier(.32, .72, .3, 1);
    z-index: 45; padding-top: 6px;
    -webkit-overflow-scrolling: touch;
  }
  /* 抽屉顶部抓手 */
  .panel.left::before, .panel.right::before {
    content: ""; flex: 0 0 auto; align-self: center;
    width: 40px; height: 4px; margin: 4px 0 8px;
    border-radius: 2px; background: var(--stroke-2);
  }
  body.sheet-left  .panel.left  { transform: none; }
  body.sheet-right .panel.right { transform: none; }

  .panel-section { min-width: 0; border-right: none; }

  /* --- 背景遮罩 --- */
  .m-backdrop {
    position: fixed; inset: 0 0 56px 0; background: var(--overlay);
    z-index: 44; opacity: 0; pointer-events: none; transition: opacity .28s;
  }
  body.sheet-left .m-backdrop, body.sheet-right .m-backdrop {
    display: block; opacity: 1; pointer-events: auto;
  }

  /* --- 底部导航栏 --- */
  .m-dock {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 56px;
    background: var(--panel); border-top: 1px solid var(--stroke);
    z-index: 46; padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .m-dock-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; border: none; background: none; cursor: pointer;
    color: var(--text-mut); font-size: 11px; transition: color .15s;
  }
  .m-dock-btn svg { width: 22px; height: 22px; fill: currentColor; }
  .m-dock-btn.on { color: var(--accent); }

  /* --- 其它移动端微调 --- */
  .recent-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-card.wide { width: 94vw; }
  .align-bar button, .seg button { height: 34px; }   /* 放大触屏命中区 */
  .layer-item { height: 42px; }
}
@media (hover: none) and (pointer: coarse) {
  .rc-del { opacity: 1; }               /* 触屏没有 hover，删除键常显 */
}
