/* =========================================================
   几何画板 · Paper & Ink theme  —  六哥制造
   纸面画布 + 浅色面板 + 唯一蓝色强调。
   语义：蓝=构造/选中  琥珀=测量/标注  绿=周长/角度  红=危险

   结构版式（顶栏 / 图标工具网格 / 可折叠分区 / 缩放控件）
   与 Paper & Ink 配色合并版；配套 index.html / app.js 使用。
   ========================================================= */

:root {
  --bg: #eef1f6;
  --bg-deep: #e6eaf1;
  --panel: #f7f9fc;
  --panel-2: #ffffff;
  --elev: #e9edf4;
  --line: #dde3ec;
  --line-2: #c9d2e0;
  --text: #1c2333;
  --text-2: #5c6678;
  --text-3: #8b95a8;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --blue-soft: #e8effd;
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --green: #15803d;
  --red: #dc2626;
  --radius: 8px;
  --mono: "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, ui-monospace, monospace;
  --sans: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  --shadow-2: 0 8px 24px rgba(29, 41, 66, 0.10);
  --shadow-3: 0 20px 60px rgba(29, 41, 66, 0.16);
}

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

[hidden] { display: none !important; }

html, body, #app {
  height: 100%; width: 100%; overflow: hidden;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 274px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
#sidebar::-webkit-scrollbar { width: 10px; }
#sidebar::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 5px;
  border: 2px solid transparent; background-clip: padding-box;
}
#sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  flex-shrink: 0; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
}
.brand-mark svg { display: block; }
.brand-text { flex: 1; min-width: 0; }
#logo { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: 0.3px; line-height: 1.15; white-space: nowrap; }
#maker { font-size: 10.5px; color: var(--text-3); margin-top: 2px; letter-spacing: 0.2px; white-space: nowrap; }

.icon-btn {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2);
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: grid; place-items: center; transition: all 0.14s; font-family: var(--sans);
  margin: 0;
}
.icon-btn:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }

.help-menu {
  position: absolute; top: calc(100% + 6px); right: 8px; z-index: 90; width: 172px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 5px;
  display: flex; flex-direction: column; gap: 2px;
  animation: menuIn 0.12s ease;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.help-menu button {
  width: 100%; margin: 0; text-align: left; padding: 8px 10px;
  border: 1px solid transparent; background: transparent; color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 12.5px; font-family: var(--sans);
}
.help-menu button:hover { background: var(--blue-soft); color: var(--blue-2); }

/* ---------- Collapsible sections ---------- */
.side-sec { padding-bottom: 6px; }
.side-sec + .side-sec { border-top: 1px solid var(--line); }
.side-sec.collapsible .section-header { cursor: pointer; user-select: none; }
.side-sec.collapsible .section-header::after {
  content: ""; flex: 0 0 auto;
  width: 7px; height: 7px; margin-left: 2px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.16s;
  background: none;
}
.side-sec.collapsible.collapsed .section-header::after {
  transform: rotate(-45deg) translate(-1px, -1px);
}
.side-sec .sec-body { overflow: hidden; }
.side-sec.collapsed .sec-body { display: none; }

/* ---------- Section headers ---------- */
.section-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  letter-spacing: 1.2px;
  padding: 13px 16px 6px;
}
.section-header::before { content: ""; width: 14px; height: 1px; background: var(--line-2); flex-shrink: 0; }
.section-header::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Tool grids ---------- */
.tools { padding: 2px 10px 4px; display: grid; gap: 5px; }
.tools.grid-3 { grid-template-columns: repeat(3, 1fr); }
.tools.grid-2 { grid-template-columns: 1fr 1fr; }

/* icon-above tool button (drawing tools) */
.tool {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-2); padding: 7px 2px 6px; border-radius: var(--radius);
  cursor: pointer; font-size: 11px; text-align: center; font-family: var(--sans);
  transition: border-color 0.13s, background 0.13s, color 0.13s, box-shadow 0.13s;
  overflow: hidden; margin: 0; width: auto;
  white-space: nowrap;
}
.tool .t-ico { width: 20px; height: 20px; color: var(--text-2); transition: color 0.13s; flex-shrink: 0; }
.tool .t-ico svg { display: block; width: 100%; height: 100%; }
.tool:hover { background: var(--elev); color: var(--text); border-color: var(--line-2); }
.tool:hover .t-ico { color: var(--blue); }
.tool.active {
  background: var(--blue-soft); color: var(--blue-2);
  border-color: var(--blue); font-weight: 600;
}
.tool.active .t-ico { color: var(--blue); }

/* horizontal icon+text tool button (measure / construct / transform) */
.tools.grid-2 .tool {
  flex-direction: row; justify-content: flex-start; gap: 7px;
  padding: 6px 8px; font-size: 12px;
}
.tools.grid-2 .tool .t-ico { width: 16px; height: 16px; }
.tools.grid-2 .tool span.t-label { overflow: hidden; text-overflow: ellipsis; }

/* preset thumbnail button */
.tools.grid-preset { grid-template-columns: repeat(3, 1fr); }
.tools.grid-preset .tool { padding: 6px 2px 5px; }
.tools.grid-preset .tool .t-ico { width: 22px; height: 22px; }
.tools.grid-preset .tool .t-ico svg { stroke-width: 1.4; }

/* ---------- Colors ---------- */
.colors { padding: 4px 16px 2px; display: flex; flex-wrap: wrap; gap: 9px; }
.color {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line-2); transition: transform 0.12s, border-color 0.12s;
}
.color:hover { transform: scale(1.14); border-color: var(--text-2); }
.color.active { border-color: var(--text); }

/* ---------- Row / range / num ---------- */
.row { display: flex; align-items: center; padding: 5px 16px 8px; gap: 10px; }
.row input[type="range"] { flex: 1; accent-color: var(--blue); height: 4px; }
.num {
  width: 30px; text-align: center; color: var(--text);
  font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px;
}

/* ---------- Options ---------- */
.opts { padding: 2px 16px 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.opts label {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  color: var(--text-2); font-size: 12px; transition: color 0.12s;
  white-space: nowrap;
}
.opts label:hover { color: var(--text); }
.opts input[type="checkbox"] { accent-color: var(--blue); width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- Buttons ---------- */
button {
  font-family: var(--sans); background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-2); padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; font-size: 12.5px; transition: all 0.13s;
}
button:hover { background: var(--elev); border-color: var(--blue); color: var(--blue-2); }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--blue); border-color: var(--blue);
  color: #ffffff; font-weight: 600;
}
button.primary:hover { background: var(--blue-2); border-color: var(--blue-2); color: #ffffff; }
button.danger { color: var(--red); border-color: #f3c6c6; background: var(--panel-2); }
button.danger:hover { background: #fdf0f0; border-color: var(--red); color: #b91c1c; }
button.ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
button.ghost:hover { color: var(--text); border-color: var(--line-2); background: var(--elev); }

/* ---------- Inputs ---------- */
select, textarea, input[type="text"], input[type="password"] {
  font-family: var(--sans); background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 10px;
  font-size: 12.5px; width: 100%; transition: border-color 0.13s, box-shadow 0.13s;
}
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft);
}
textarea { resize: vertical; font-family: var(--sans); min-height: 60px; }

#sidebar select, #sidebar textarea { margin: 3px 12px; width: calc(100% - 24px); }
#sidebar > .side-sec button.primary,
#sidebar > .side-sec button.ghost { margin: 3px 12px; width: calc(100% - 24px); }

#aiInput { min-height: 64px; max-height: 120px; }

#footer {
  text-align: center; font-size: 10.5px; color: var(--text-3);
  padding: 12px 12px 14px; margin-top: auto; border-top: 1px solid var(--line); letter-spacing: 0.3px;
}

/* ---------- Main / topbar / canvas ---------- */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#topbar {
  position: relative;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand-mini { display: flex; align-items: center; gap: 8px; margin-right: 2px; }
.brand-mini .bm-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-mini .bm-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-mini #logo { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: 0.3px; white-space: nowrap; }
.brand-mini #maker { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-group + .tb-group { margin-left: 10px; }
.tb-spacer { flex: 1; }
.tb-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; flex-shrink: 0; }

.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--text-2); padding: 6px 9px; font-size: 12px; line-height: 1;
}
.tb-btn svg { width: 16px; height: 16px; display: block; flex-shrink: 0; }
.tb-btn:hover { background: var(--elev); border-color: var(--line-2); color: var(--text); }
.tb-btn:active { transform: translateY(1px); }
.tb-btn.icon-only { padding: 6px; }
.tb-btn.danger { color: var(--red); }
.tb-btn.danger:hover { background: #fdf0f0; border-color: #f3c6c6; color: #b91c1c; }

.zoom-group .tb-btn { padding: 5px 7px; }
.zoom-label {
  min-width: 52px; text-align: center;
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11.5px;
  color: var(--text-2); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 4px;
  cursor: pointer;
}
.zoom-label:hover { color: var(--blue-2); border-color: var(--line-2); }

/* ---------- Bottom dock ---------- */
#dock {
  display: flex; align-items: stretch; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.dock-group { display: flex; gap: 3px; }
.dock-group .tool { min-width: 54px; padding: 5px 4px 4px; gap: 3px; font-size: 10.5px; }
.dock-group .tool .t-ico { width: 20px; height: 20px; }
.dock-sep { width: 1px; background: var(--line-2); margin: 4px 3px; flex-shrink: 0; }
.dock-colors { padding: 0; gap: 6px; align-items: center; }
.dock-width { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.dock-width input[type="range"] { width: 90px; accent-color: var(--blue); }

.dock-pop { position: relative; display: flex; }
.dock-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text-2); padding: 6px 12px; font-size: 12.5px; margin: 0;
  white-space: nowrap;
}
.dock-btn::after {
  content: ""; width: 6px; height: 6px; flex-shrink: 0;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
}
.dock-btn:hover { background: var(--elev); border-color: var(--line-2); color: var(--text); }
.dock-btn.open { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-2); }
.dock-btn.open::after { transform: rotate(45deg) translateY(-2px); }
.dock-btn-ai { color: var(--blue-2); font-weight: 600; }

.dock-panel {
  position: absolute; bottom: calc(100% + 10px); left: 0; z-index: 90;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow-3); padding: 10px; min-width: 230px;
}
.dock-panel-wide { width: 300px; }
.dock-panel .tools { padding: 0; }
.dock-panel .opts { padding: 0; gap: 8px 12px; }
.panel-hint { font-size: 11px; color: var(--text-3); margin-bottom: 8px; }
.dock-panel select, .dock-panel textarea { margin: 0 0 6px; width: 100%; }
.dock-panel button.primary, .dock-panel button.ghost { margin: 0 0 6px; width: 100%; }
.dock-panel-ai { width: 280px; }
.dock-panel-ai #aiInput { min-height: 56px; max-height: 110px; }

/* ---------- AI assistant chat ---------- */
.chat-panel {
  position: fixed; right: 10px; bottom: 96px; z-index: 95;
  width: 350px; height: 470px; max-height: calc(100vh - 170px);
  display: flex; flex-direction: column; padding: 0;
}
.agent-head {
  padding: 10px 12px; font-size: 13px; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--line); background: var(--panel);
  border-radius: 12px 12px 0 0;
}
.agent-sub { font-size: 10.5px; font-weight: 400; color: var(--text-3); margin-left: 6px; }
.agent-log {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg);
}
.agent-log .msg {
  max-width: 88%; padding: 7px 10px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.agent-log .msg.user {
  align-self: flex-end; background: var(--blue); color: #fff;
  border-bottom-right-radius: 3px;
}
.agent-log .msg.ai {
  align-self: flex-start; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-bottom-left-radius: 3px;
}
.agent-log .msg.thinking { color: var(--text-3); }
.agent-log .msg.error {
  background: #fdecec; color: #b91c1c;
  border: 1px solid #f5b5b5; border-bottom-left-radius: 3px;
  font-weight: 600;
}
.agent-logbtn {
  float: right; margin-top: -2px;
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text-3); font-size: 10.5px; padding: 2px 8px; cursor: pointer;
}
.agent-logbtn:hover { color: var(--blue); border-color: var(--blue); }

/* ---- AI 动画播放条 ---- */
#animBar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 6px;
  padding: 6px 10px; z-index: 60;
  background: rgba(255,255,255,0.97); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(29,41,66,0.14);
}
#animBar .ab-title { font-size: 12.5px; font-weight: 600; color: var(--text); margin-right: 2px; }
#animBar button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 10px; font-size: 12px; color: var(--text); cursor: pointer;
}
#animBar button:hover { border-color: var(--blue); color: var(--blue); }
#animBar button.ab-primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
#animBar button:disabled { opacity: 0.6; cursor: default; }
.agent-log .tool-log {
  align-self: flex-start; max-width: 96%;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; white-space: pre-wrap;
}
.agent-input-row {
  display: flex; gap: 6px; padding: 8px;
  border-top: 1px solid var(--line); background: var(--panel);
  border-radius: 0 0 12px 12px;
}
.agent-input-row input { flex: 1; margin: 0; width: auto; }
.agent-input-row button { margin: 0; width: auto; white-space: nowrap; }

#canvasWrap {
  flex: 1; overflow: auto; background: var(--bg-deep);
  display: flex; padding: 26px;
}
#canvas {
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(29, 41, 66, 0.10), 0 12px 40px rgba(29, 41, 66, 0.10);
  cursor: crosshair;
  margin: auto;               /* safe centering that still allows scroll when larger */
  display: block;
}
#canvas.tool-select { cursor: default; }
#canvas.tool-freehand { cursor: crosshair; }
#canvas.tool-text { cursor: text; }
#canvas.panning { cursor: grabbing !important; }

#statusbar {
  background: var(--panel-2);
  border-top: 1px solid var(--line); padding: 6px 12px;
  display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--text-2);
}
#statusbar .spacer { flex: 1; }
#toolHint { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%; }
#posInfo { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); }
#makerTag { color: var(--text-3); font-size: 10.5px; letter-spacing: 0.3px; }

/* ---------- Selection floating toolbar ---------- */
#selToolbar { font-family: var(--sans) !important; }
#selToolbar button { margin: 0; padding: 4px 9px; font-size: 12px; }

/* ---------- Dialogs ---------- */
.dlg {
  background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 14px; padding: 24px;
  color: var(--text); width: 440px; max-width: 90vw; box-shadow: var(--shadow-3);
}
.dlg::backdrop { background: rgba(29, 41, 66, 0.35); }
.dlg h2 { font-size: 18px; color: var(--text); }
.dlg h3 { font-size: 15px; color: var(--text); margin-bottom: 8px; font-weight: 600; }
.dlg .hint { color: var(--text-2); font-size: 11.5px; margin-bottom: 14px; line-height: 1.55; }
.dlg label { display: block; font-size: 11.5px; color: var(--text-2); margin: 10px 0 4px; }
.dlg input { margin-bottom: 4px; }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.dlg-actions .spacer { flex: 1; }
.dlg-actions button { width: auto; margin: 0; padding: 8px 16px; }

/* intro dialog content */
.intro-dlg { width: 640px; margin: auto; }
.dlg { margin: auto; }
.intro-scroll { max-height: 56vh; overflow-y: auto; padding-right: 8px; line-height: 1.65; }
.intro-scroll:focus, .intro-scroll:focus-visible { outline: none; }
.intro-scroll h3 { color: var(--blue-2); margin-top: 16px; font-size: 13.5px; }
.intro-scroll h3:first-child { margin-top: 4px; }
.intro-scroll p, .intro-scroll ul, .intro-scroll ol { color: var(--text-2); }
.intro-scroll ul, .intro-scroll ol { padding-left: 20px; margin: 4px 0; }
.intro-scroll b { color: var(--text); }
.intro-end { color: var(--text-3); margin-top: 14px; }
.intro-check {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 12px; font-weight: normal; margin: 0;
}

/* ---------- AI loading ---------- */
.ai-loading #btnAi { opacity: 0.7; pointer-events: none; }
.ai-loading #btnAi::after { content: " …"; }

/* ---------- Keycap ---------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--blue-2);
  background: #eef2f9;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px;
  line-height: 1; box-shadow: 0 1px 0 rgba(29, 41, 66, 0.08); margin: 0 1px;
  vertical-align: middle;
}

/* =========================================================
   Guided Tour
   ========================================================= */
#tour { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }

.tour-panel {
  position: fixed; background: rgba(244, 246, 250, 0.78);
  pointer-events: auto;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.tour-ring {
  position: fixed; pointer-events: none; border-radius: 6px;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.tour-ring .bracket {
  position: absolute; width: 14px; height: 14px;
  border: 2px solid var(--blue);
}
.tour-ring .bracket.tl { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-top-left-radius: 5px; }
.tour-ring .bracket.tr { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-top-right-radius: 5px; }
.tour-ring .bracket.bl { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-bottom-left-radius: 5px; }
.tour-ring .bracket.br { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-bottom-right-radius: 5px; }
.tour-ring .pulse {
  position: absolute; inset: -2px; border-radius: 7px;
  border: 1px solid rgba(37, 99, 235, 0.5); animation: tourPulse 1.8s ease-in-out infinite;
}
@keyframes tourPulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.03); }
}

.tour-tip {
  position: fixed; width: 300px; max-width: calc(100vw - 24px);
  pointer-events: auto; z-index: 10000;
  background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-3);
  padding: 16px 16px 14px; opacity: 0; transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}
.tour-tip.show { opacity: 1; transform: none; }
.tour-tip .step-no {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; color: var(--blue-2);
  letter-spacing: 1px; margin-bottom: 8px;
}
.tour-tip h4 { font-size: 15px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.tour-tip p { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.tour-tip .prog { display: flex; gap: 4px; margin: 14px 0 12px; }
.tour-tip .prog i { width: 14px; height: 3px; border-radius: 2px; background: var(--line); transition: background 0.2s; }
.tour-tip .prog i.on { background: var(--blue); }
.tour-tip .prog i.done { background: var(--blue); opacity: 0.5; }
.tour-tip .acts { display: flex; align-items: center; gap: 8px; }
.tour-tip .acts .spacer { flex: 1; }
.tour-tip .acts button { margin: 0; width: auto; padding: 7px 14px; font-size: 12px; }
.tour-tip .skip { background: transparent; border-color: transparent; color: var(--text-3); }
.tour-tip .skip:hover { color: var(--text-2); background: var(--elev); border-color: var(--line); }

.tour-tip .arrow {
  position: absolute; width: 12px; height: 12px;
  background: var(--panel-2); border: 1px solid var(--line-2); transform: rotate(45deg);
}
.tour-tip.side-right .arrow { left: -7px; border-top: 0; border-right: 0; }
.tour-tip.side-left .arrow { right: -7px; border-bottom: 0; border-left: 0; }
.tour-tip.side-bottom .arrow { top: -7px; border-left: 0; border-top: 0; }
.tour-tip.side-top .arrow { bottom: -7px; border-right: 0; border-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  .tour-panel, .tour-ring, .tour-tip { transition: none; }
  .tour-ring .pulse { animation: none; }
}

/* 选项面板：构造线型下拉框（占满整行，两列布局的最后一块） */
.opts .opts-select { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.opts select {
  flex: 1; min-height: 32px; padding: 3px 8px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2);
  font-size: 13px;
}

/* 开屏加载幕布：HTML 一解析就显示，app.js 初始化完成后淡出移除 */
#bootVeil {
  position: fixed; inset: 0; z-index: 9999; background: var(--panel-2, #fff);
  display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center;
  transition: opacity .35s ease;
}
#bootVeil.hide { opacity: 0; pointer-events: none; }
#bootVeil .bv-title { font-size: 34px; font-weight: 700; color: #1c2333; letter-spacing: 2px; }
#bootVeil .bv-hint { font-size: 14px; color: #8b95a8; }
#bootVeil .bv-bar { width: 220px; height: 8px; border-radius: 4px; background: #dde3ec; overflow: hidden; }
#bootVeil .bv-bar span {
  display: block; width: 70px; height: 100%; border-radius: 4px; background: #2563eb;
  animation: bvslide 1.1s ease-in-out infinite;
}
@keyframes bvslide {
  from { transform: translateX(-80px); }
  to { transform: translateX(230px); }
}

/* ===== 大字号 + 触控板优化 + 工具条隐藏（覆盖层，务必保持在文件末尾） ===== */

/* 触控板：防止双指滑动触发浏览器前进/后退的回弹与页面越界滚动 */
html, body { overscroll-behavior: none; }
#canvasWrap { overscroll-behavior: contain; }

/* ---- 字体整体加大一档 ---- */
body { font-size: 15px; }
.tb-btn { font-size: 14px !important; gap: 5px; }
.brand-mini #logo { font-size: 16px; }
.brand-mini #maker { font-size: 11.5px; }
#statusbar { font-size: 13.5px; }
#statusbar #toolHint, #statusbar #posInfo { font-size: 13.5px; }
#makerTag { font-size: 12px; }

/* dock 工具条 */
.dock-btn { font-size: 14.5px !important; }
#dock .tool { font-size: 12.5px !important; min-width: 62px; padding: 7px 5px 6px; }
#dock .tool .t-ico svg { width: 21px; height: 21px; }
.dock-panel { font-size: 14px; }
.dock-panel button, .dock-panel select, .dock-panel textarea, .dock-panel input[type="text"],
.dock-panel input[type="number"] { font-size: 14px; }
.panel-hint { font-size: 12.5px; }

/* AI 聊天 */
.agent-head { font-size: 14.5px; }
.agent-sub { font-size: 12px; }
.agent-log .msg { font-size: 14px; line-height: 1.6; }
.agent-log .tool-log { font-size: 11.5px; }
.agent-input-row input { font-size: 14px; }
#agentSend { font-size: 14px; }
#animBar .ab-title { font-size: 13.5px; }
#animBar button { font-size: 13px; }

/* 颜色/线宽/缩放标签 */
.zoom-label { font-size: 13px !important; }
#selToolbar button { font-size: 13px; }

/* 对话框 */
.dlg h3 { font-size: 16.5px; }
.dlg .hint { font-size: 12.5px; }
.dlg label { font-size: 12.5px; }

/* ---- 底部工具条隐藏 ---- */
#dock { transition: margin-bottom 0.18s ease; }
body.dock-hidden #dock {
  position: absolute; left: -9999px; top: -9999px;
  visibility: hidden;
}
#btnToggleDock.on { color: var(--blue); border-color: var(--blue); }

/* ---- 学校触控屏幕 ---- */
#canvas { touch-action: none; -webkit-tap-highlight-color: transparent; }
#dock, #topbar, #statusbar { user-select: none; -webkit-user-select: none; }
#dock .tool, .tb-btn, .dock-btn { touch-action: manipulation; }
/* 手指触控目标加大到 ~44px */
#dock .tool { min-height: 48px; min-width: 66px; padding: 8px 5px 7px; }
.dock-btn { min-height: 44px; }
.tb-btn { min-height: 40px; }
.dock-panel button { min-height: 40px; }
#animBar button { min-height: 38px; }
