/* ============ 铺排大师 · 主题变量 ============ */
:root{
  --bg:#f4f6f9;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --surface-3:#eef2f7;
  --line:#e3e9f0;
  --line-strong:#cdd7e3;
  --text:#1f2b3d;
  --text-2:#5b6b7f;
  --text-3:#93a1b3;
  --primary:#2563eb;
  --primary-d:#1d4ed8;
  --primary-soft:#e8f0fe;
  --accent:#0e9384;
  --accent-soft:#e2f5f1;
  --warn:#d98324;
  --warn-soft:#fdf1e0;
  --danger:#d64545;
  --danger-soft:#fdeaea;
  --radius:8px;
  --radius-sm:6px;
  --shadow:0 1px 2px rgba(20,40,70,.05),0 4px 14px rgba(20,40,70,.05);
  --on-primary:#ffffff;
  --canvas-bg:#fbfcfe;
  --canvas-grid:#dbe3ec;
  --ruler-bg:#f8fafc;
  --ruler-line:#e3e9f0;
  --ruler-tick:#64748b;
  --ruler-minor:#9aa8b8;
  --ruler-text:#334155;
  --tile-num:rgba(31,43,61,.55);
  --guide:#e11d48;
  --guide-cap:#ffffff;
  --reopen-hover:#d7e5fd;
  --backdrop:rgba(20,30,45,.35);
  --lg-whole-bg:#cfe0fb;
  --lg-whole-line:#5b8def;
  --lg-cut-bg:#f6d9ad;
  --lg-cut-line:#d98324;
  --lg-obs-bg:#e2e6ec;
  --lg-obs-line:#8895a6;
  --font:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",Roboto,Helvetica,Arial,sans-serif;
}

/* 暗色主题：只覆盖颜色变量，布局与字号完全沿用浅色主题 */
[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0f172a;
  --surface:#1e293b;
  --surface-2:#172033;
  --surface-3:#334155;
  --line:#334155;
  --line-strong:#475569;
  --text:#e2e8f0;
  --text-2:#a8b7ca;
  --text-3:#7c8ca3;
  --primary:#60a5fa;
  --primary-d:#3b82f6;
  --primary-soft:#1e3a5f;
  --accent:#2dd4bf;
  --accent-soft:#134e4a;
  --warn:#fbbf24;
  --warn-soft:#4a3410;
  --danger:#f87171;
  --danger-soft:#4a1d1d;
  --shadow:0 1px 2px rgba(0,0,0,.25),0 4px 14px rgba(0,0,0,.28);
  --on-primary:#0b1220;
  --canvas-bg:#0b1220;
  --canvas-grid:#1e293b;
  --ruler-bg:#162033;
  --ruler-line:#334155;
  --ruler-tick:#94a3b8;
  --ruler-minor:#64748b;
  --ruler-text:#cbd5e1;
  --tile-num:rgba(226,232,240,.6);
  --guide:#fb7185;
  --guide-cap:#0f172a;
  --reopen-hover:#1e3a5f;
  --backdrop:rgba(0,0,0,.55);
  --lg-whole-bg:#1e3a5f;
  --lg-whole-line:#60a5fa;
  --lg-cut-bg:#5a3d1e;
  --lg-cut-line:#fbbf24;
  --lg-obs-bg:#334155;
  --lg-obs-line:#94a3b8;
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;font-family:var(--font);color:var(--text);background:var(--bg);
  font-size:13px;line-height:1.5;-webkit-font-smoothing:antialiased;
  display:flex;flex-direction:column;overflow:hidden;
}
button,input,select{font-family:inherit;font-size:inherit;color:inherit;}
button{cursor:pointer;}
h1,h2,h3,h4,p{margin:0;}
[hidden]{display:none !important;}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}

/* ============ 顶栏 ============ */
.topbar{
  height:58px;flex:0 0 58px;background:var(--surface);border-bottom:1px solid var(--line);
  display:flex;align-items:center;gap:20px;padding:0 18px;z-index:20;
}
.brand{display:flex;align-items:center;gap:10px;flex:0 0 250px;width:250px;}
.brand-mark{
  width:34px;height:34px;border-radius:9px;background:var(--primary);color:var(--on-primary);
  display:flex;align-items:center;justify-content:center;flex:0 0 auto;
}
.brand-text{display:flex;flex-direction:column;line-height:1.2;}
.brand-text h1{font-size:15px;font-weight:650;letter-spacing:.3px;line-height:1.2;}
.brand-text small{font-size:11px;color:var(--text-3);margin-top:2px;}

.mode-switch{
  display:flex;background:var(--surface-3);border-radius:9px;padding:3px;gap:2px;
}
.mode-btn{
  border:0;background:transparent;color:var(--text-2);padding:7px 14px;border-radius:7px;
  display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:500;transition:.15s;
}
.mode-btn:hover{color:var(--text);}
.mode-btn.is-active{background:var(--surface);color:var(--primary);box-shadow:0 1px 3px rgba(20,40,70,.12);}

.top-actions{margin-left:auto;display:flex;align-items:center;gap:10px;}
.save-indicator{font-size:11.5px;color:var(--accent);display:flex;align-items:center;gap:5px;}
.save-indicator::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent);}

.btn{
  border:1px solid var(--line-strong);background:var(--surface);border-radius:var(--radius-sm);
  padding:8px 13px;display:inline-flex;align-items:center;gap:6px;font-weight:500;font-size:12.5px;
  transition:.15s;white-space:nowrap;
}
.btn:hover{border-color:var(--primary);color:var(--primary);}
.btn-ghost{border-color:transparent;color:var(--text-2);}
.btn-ghost:hover{background:var(--surface-3);color:var(--text);}
.btn-primary{background:var(--primary);border-color:var(--primary);color:var(--on-primary);box-shadow:0 1px 3px rgba(37,99,235,.3);}
.btn-primary:hover{background:var(--primary-d);border-color:var(--primary-d);color:var(--on-primary);}
.btn-soft{background:var(--surface-2);border-color:var(--line-strong);color:var(--text-2);}
.btn-soft:hover{background:var(--primary-soft);border-color:var(--primary);color:var(--primary);}
.caret{margin-left:2px;opacity:.8;}

.export-wrap{position:relative;}
.export-menu{
  position:absolute;right:0;top:44px;width:236px;background:var(--surface);border:1px solid var(--line);
  border-radius:10px;box-shadow:0 10px 30px rgba(20,40,70,.16);padding:6px;z-index:40;
}
.export-menu button{
  width:100%;border:0;background:transparent;text-align:left;display:flex;gap:10px;align-items:center;
  padding:9px 10px;border-radius:7px;
}
.export-menu button:hover{background:var(--primary-soft);}
.export-menu .em-ico{
  width:28px;height:28px;flex:0 0 auto;border-radius:6px;background:var(--surface-3);
  display:flex;align-items:center;justify-content:center;color:var(--primary);font-size:15px;
}
.export-menu b{display:block;font-weight:600;font-size:12.5px;}
.export-menu small{display:block;color:var(--text-3);font-size:11px;margin-top:1px;}

/* ============ 工作区三栏 ============ */
.workspace{flex:1;display:flex;min-height:0;}
.panel{
  background:var(--surface);display:flex;flex-direction:column;min-height:0;position:relative;
  flex:0 0 288px;width:288px;z-index:10;transition:flex-basis .2s,width .2s;
}
.panel-left{border-right:1px solid var(--line);}
.panel-right{border-left:1px solid var(--line);flex-basis:300px;width:300px;}
.panel.is-collapsed{flex-basis:0;width:0;overflow:hidden;}
.panel-head{
  height:46px;flex:0 0 46px;display:flex;align-items:center;justify-content:space-between;
  padding:0 14px;border-bottom:1px solid var(--line);
}
.panel-head h2{font-size:13px;font-weight:600;letter-spacing:.3px;}
.icon-btn{
  border:0;background:transparent;color:var(--text-3);border-radius:6px;width:28px;height:28px;
  display:inline-flex;align-items:center;justify-content:center;font-size:17px;transition:.15s;
}
.icon-btn:hover{background:var(--surface-3);color:var(--text);}
/* 原生滚动条完全隐藏且不占宽度；用浮在面板右侧的细条指示滚动位置 */
.panel-scroll{flex:1;overflow-y:auto;padding:4px 0 24px;scrollbar-width:none;}
.panel-scroll::-webkit-scrollbar{width:0;height:0;display:none;}
.float-scroll{
  position:absolute;right:2px;top:0;width:4px;border-radius:3px;
  background:var(--line-strong);opacity:0;pointer-events:none;z-index:15;
  transition:opacity .15s;
}
.panel:hover .float-scroll.is-active{opacity:.95;}

/* ============ 参数分区 ============ */
.sec{padding:0;}
.sec-title{
  display:flex;align-items:center;gap:8px;font-size:12.5px;font-weight:600;color:var(--text);
  cursor:pointer;user-select:none;height:37px;padding:0 14px;
  background:var(--surface-2);border-bottom:1px solid var(--line);
}
.sec-title:hover{background:var(--surface-3);}
.sec-title small{margin-left:auto;font-weight:400;color:var(--text-3);font-size:10.5px;}
/* 折叠图标：与顶部面板折叠按钮同款 28×28，靠右并与标题垂直居中 */
.sec-caret{margin-left:auto;width:28px;height:28px;flex:0 0 auto;transition:transform .18s;}
.sec-title small+.sec-caret{margin-left:6px;}
.sec.is-collapsed .sec-caret{transform:rotate(-90deg);}
/* 板块内容上下及元素之间统一 12px；用 flex 间距避免隐藏元素 / :last-child 造成间距不一致 */
.sec-body{padding:12px 14px;display:flex;flex-direction:column;gap:12px;}
.sec-num{
  width:19px;height:19px;flex:0 0 auto;border-radius:5px;background:var(--primary-soft);color:var(--primary);
  font-size:11px;font-weight:600;display:inline-flex;align-items:center;justify-content:center;
}
.field{display:flex;flex-direction:column;gap:5px;min-width:0;}
.field>span{font-size:11.5px;color:var(--text-2);font-weight:500;}
.field-row{display:flex;gap:10px;}
/* 两列行内所有控件等宽（含形状后的旋转按钮），与 33px 输入框高度统一 */
.field-row.two>*{flex:0 0 calc((100% - 10px)/2);width:calc((100% - 10px)/2);min-width:0;}
.room-rot-btn{align-self:flex-end;height:33px;padding:0 6px;justify-content:center;font-size:11.5px;}
input[type=number],input[type=text],select{
  width:100%;height:33px;border:1px solid var(--line-strong);border-radius:var(--radius-sm);
  padding:0 9px;background:var(--surface);outline:none;transition:.15s;color:var(--text);
}
input[type=number]:focus,input[type=text]:focus,select:focus{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-soft);}
select{appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%235b6b7f' stroke-width='2'><path d='M2 4l4 4 4-4'/></svg>");background-repeat:no-repeat;background-position:right 9px center;padding-right:26px;}
.input-unit{position:relative;}
.input-unit input{padding-right:34px;}
.input-unit .unit{position:absolute;right:9px;top:50%;transform:translateY(-50%);font-size:10.5px;color:var(--text-3);pointer-events:none;}
.sub-block{background:var(--surface-2);border:1px solid var(--line);border-radius:var(--radius);padding:10px;display:flex;flex-direction:column;gap:10px;}
/* 字段标题文字与勾选框同一行：标题靠左，勾选框靠右，字号统一为 11.5px */
.label-line{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:18px;}
.field-label{font-size:11.5px;color:var(--text-2);font-weight:500;cursor:pointer;}
.inline-check,.inline-checks{
  display:flex;align-items:center;flex:0 0 auto;
  font-size:11px;font-weight:500;color:var(--text-2);white-space:nowrap;cursor:pointer;
}
.inline-check{gap:6px;}
.inline-checks{gap:8px;}
.inline-check input{width:14px;height:14px;margin:0;accent-color:var(--primary);flex:0 0 auto;}
/* 正方形材料旋转无意义：整行置灰且不可勾选 */
.inline-check.is-disabled{opacity:.45;cursor:not-allowed;}
.inline-check.is-disabled input{cursor:not-allowed;}
.hint{font-size:10.5px;color:var(--text-3);line-height:1.6;}
.hint-center{text-align:center;}
/* 统一清除板块直接子元素与行内字段的自身外边距，间距全部由上面的 flex gap 控制 */
.sec-body>*,.sec-body>.field-row>.field,.sub-block>.field,.sub-block>.field-row>.field{margin:0;}
/* 障碍物列表 */
.item-list{display:flex;flex-direction:column;gap:8px;}
/* 无构造物时不占位，避免 flex gap 叠加导致按钮距标题栏变成 24px */
.item-list:empty{display:none;}
.item-card{border:1px solid var(--line);border-radius:var(--radius);padding:9px 10px;background:var(--surface-2);position:relative;transition:border-color .15s,box-shadow .15s;}
/* 画布中选中构造物时，左侧对应卡片同步高亮 */
.item-card.is-selected{border:1px dashed var(--primary);box-shadow:0 0 0 2px rgba(37,99,235,.14);background:var(--primary-soft);}
/* 名称框与旋转按钮各占一半，宽度与下方 X/Y 输入框完全一致；删除按钮浮在右上角 */
.item-card-head{display:grid;grid-template-columns:1fr 1fr;align-items:center;gap:6px;margin-bottom:8px;}
.item-card-head input[type=text]{height:27px;font-weight:500;background:var(--surface);width:100%;min-width:0;}
.item-card-head .rot-btn{height:27px;width:100%;min-width:0;padding:0 6px;display:inline-flex;align-items:center;justify-content:center;gap:4px;font-size:10.5px;}
/* 删除按钮放到卡片右上角外侧的小徽标，完全不占用名称行 / 旋转按钮内部空间 */
.item-card-head .del{position:absolute;top:-8px;right:-8px;border:1px solid var(--line);background:var(--surface);color:var(--text-3);width:16px;height:16px;border-radius:50%;font-size:12px;line-height:1;padding:0;display:flex;align-items:center;justify-content:center;z-index:2;}
.item-card-head .del:hover{background:var(--danger-soft);border-color:var(--danger);color:var(--danger);}
.item-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px;}
.item-grid label{display:flex;flex-direction:column;gap:3px;position:relative;}
.item-grid label span{font-size:10px;color:var(--text-3);}
.item-grid input{height:29px;padding-right:24px;font-size:12px;}
.item-grid label .unit{position:absolute;right:7px;bottom:8px;font-size:9.5px;color:var(--text-3);pointer-events:none;}
.rot-btn{border:1px solid var(--line-strong);background:var(--surface);border-radius:6px;padding:4px 8px;font-size:10.5px;color:var(--text-2);white-space:nowrap;transition:.15s;}
.rot-btn:hover{border-color:var(--primary);color:var(--primary);background:var(--primary-soft);}
/* 两个构造物操作按钮与输入框同宽（半宽）、同高（33px） */
.obstacle-actions{display:flex;gap:10px;}
.obstacle-actions .btn{flex:0 0 calc((100% - 10px)/2);width:calc((100% - 10px)/2);min-width:0;height:33px;padding:0 6px;justify-content:center;font-size:11.5px;}
.common-wrap{position:relative;flex:0 0 calc((100% - 10px)/2);width:calc((100% - 10px)/2);min-width:0;display:flex;}
.common-wrap .btn{flex:1;width:100%;min-width:0;height:33px;padding:0 6px;justify-content:center;font-size:11.5px;}
/* 常用构造物悬浮窗：fixed 定位浮于按钮右侧，避免被左栏滚动区裁剪 */
.fixture-pop{
  position:fixed;z-index:60;
  width:224px;max-height:320px;overflow-y:auto;background:var(--surface);
  border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 30px rgba(20,40,70,.18);padding:6px;
}
.fixture-pop::-webkit-scrollbar{width:6px;}
.fixture-pop::-webkit-scrollbar-thumb{background:var(--line-strong);border-radius:3px;}
.fixture-pop .fp-title{padding:5px 8px 7px;font-size:10.5px;color:var(--text-3);border-bottom:1px solid var(--line);margin-bottom:4px;}
.fixture-pop .fp-item{
  display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;
  border:0;background:transparent;text-align:left;padding:7px 8px;border-radius:6px;font-size:11.5px;color:var(--text);
}
.fixture-pop .fp-item:hover{background:var(--primary-soft);color:var(--primary);}
.fixture-pop .fp-item small{color:var(--text-3);font-size:10px;white-space:nowrap;}
.fixture-pop .fp-item:hover small{color:var(--primary);}

/* ============ 画布 ============ */
.canvas-area{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--bg);}
.canvas-toolbar{
  height:46px;flex:0 0 46px;background:var(--surface);border-bottom:1px solid var(--line);
  display:flex;align-items:center;gap:10px;padding:0 10px;
}
.tool-group{display:flex;align-items:center;gap:4px;}
.tool-group+.tool-group{border-left:1px solid var(--line);padding-left:10px;}
.zoom-label{width:auto;padding:0 9px;font-size:11.5px;font-weight:500;white-space:nowrap;}
.toggle{display:flex;align-items:center;gap:5px;font-size:11.5px;color:var(--text-2);cursor:pointer;margin-right:6px;white-space:nowrap;}
.toggle input{width:14px;height:14px;accent-color:var(--primary);}
.legend-toolbar{display:flex;align-items:center;gap:5px;font-size:10.5px;color:var(--text-2);white-space:nowrap;}
.legend-toolbar .lg{width:11px;height:11px;}
.legend-toolbar .lg:not(:first-child){margin-left:5px;}
.tool-hint{margin-left:auto;display:flex;align-items:center;gap:8px;font-size:11px;color:var(--text-3);min-width:0;}

.canvas-viewport{
  flex:1;min-height:0;position:relative;overflow:hidden;
  background-color:var(--canvas-bg);
  background-image:radial-gradient(var(--canvas-grid) .8px,transparent .8px);
  background-size:18px 18px;
  display:flex;align-items:center;justify-content:center;
}
#planSvg{width:100%;height:100%;display:block;touch-action:none;cursor:grab;}
.canvas-viewport.is-panning #planSvg{cursor:grabbing;}
.canvas-viewport.is-panning #planSvg .draggable,.canvas-viewport.is-panning #planSvg .tile{cursor:grabbing;}
.canvas-empty{position:absolute;color:var(--text-3);font-size:13px;}
.panel-reopen{
  display:inline-flex;align-items:center;gap:3px;height:28px;padding:0 8px;flex:0 0 auto;
  background:var(--primary-soft);border:1px solid transparent;border-radius:6px;
  color:var(--primary);font-size:11.5px;font-weight:600;transition:.15s;white-space:nowrap;
}
.panel-reopen:hover{background:var(--reopen-hover);border-color:var(--primary);}
.panel-reopen svg{flex:0 0 auto;}
.canvas-status{
  height:34px;flex:0 0 34px;background:var(--surface);border-top:1px solid var(--line);
  display:flex;align-items:center;gap:12px;padding:0 12px;font-size:11px;color:var(--text-2);
}
#statusInfo{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.status-right{color:var(--text-3);white-space:nowrap;}

/* ============ 右侧方案与统计 ============ */
.scheme-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:12px 14px 0;}
.scheme-card{
  border:1.5px solid var(--line);border-radius:9px;background:var(--surface);padding:8px 8px 9px;
  display:flex;flex-direction:column;align-items:center;gap:5px;transition:.15s;position:relative;overflow:hidden;
}
.scheme-card:hover{border-color:var(--line-strong);background:var(--surface-2);}
.scheme-card.is-active{border-color:var(--primary);background:var(--primary-soft);box-shadow:0 0 0 2px rgba(37,99,235,.08);}
.scheme-card svg{width:100%;height:44px;}
.scheme-card .sc-name{font-size:11.5px;font-weight:600;}
.scheme-card .sc-sub{font-size:9.5px;color:var(--text-3);}
.scheme-card.is-active .sc-sub{color:var(--primary);}
.sc-check{position:absolute;top:5px;right:5px;width:15px;height:15px;border-radius:50%;background:var(--primary);color:var(--on-primary);display:none;align-items:center;justify-content:center;font-size:10px;}
.scheme-card.is-active .sc-check{display:flex;}

.stats-block{padding:12px 14px;margin-top:0;}
/* 统计区间距统一 12px：相邻两个统计块不再叠加上下内边距 */
.stats-block+.stats-block{padding-top:0;}
.stats-title{font-size:12px;font-weight:600;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;}
.stats-title span{font-size:10.5px;font-weight:400;color:var(--primary);}
.metric-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;}
.metric{background:var(--surface-2);border-radius:var(--radius);padding:9px 10px;display:flex;flex-direction:column;gap:3px;}
.metric span{font-size:10.5px;color:var(--text-2);}
.metric b{font-size:16px;font-weight:650;color:var(--text);letter-spacing:.2px;}
.metric:nth-child(5) b{color:var(--accent);}
.metric:nth-child(6) b{color:var(--primary);}

.table-wrap{border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;max-height:190px;overflow-y:auto;}
.detail-table{width:100%;border-collapse:collapse;font-size:11px;}
.detail-table th{background:var(--surface-3);color:var(--text-2);font-weight:600;text-align:center;padding:7px 6px;position:sticky;top:0;}
.detail-table td{padding:6px 4px;border-top:1px solid var(--line);text-align:center;}
.detail-table td:nth-child(3),.detail-table td:nth-child(4){font-variant-numeric:tabular-nums;}
.detail-table .tag{font-size:9.5px;padding:1px 5px;border-radius:4px;background:var(--primary-soft);color:var(--primary);}
.detail-table .tag.cut{background:var(--warn-soft);color:var(--warn);}
.detail-table .hole-tag{display:block;font-size:9px;color:var(--text-3);margin-top:1px;white-space:nowrap;}

.lg{width:12px;height:12px;border-radius:2px;display:inline-block;flex:0 0 auto;}
.lg-whole{background:var(--lg-whole-bg);border:1px solid var(--lg-whole-line);}
.lg-cut{background:var(--lg-cut-bg);border:1px solid var(--lg-cut-line);}
.lg-obs{background:var(--lg-obs-bg);border:1px solid var(--lg-obs-line);}

/* ============ 提示 / 弹窗 ============ */
.toast{
  position:fixed;bottom:26px;left:50%;transform:translateX(-50%);background:var(--text);color:#fff;
  padding:10px 18px;border-radius:8px;font-size:12.5px;z-index:100;box-shadow:0 8px 24px rgba(0,0,0,.2);
}
.modal-backdrop{position:fixed;inset:0;background:var(--backdrop);display:flex;align-items:center;justify-content:center;z-index:90;}
.modal-card{width:min(460px,92vw);background:var(--surface);border-radius:14px;box-shadow:0 20px 60px rgba(0,0,0,.25);overflow:hidden;}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line);}
.modal-head h3{font-size:15px;}
.modal-body{padding:16px 22px 22px;color:var(--text-2);font-size:12.5px;}
.modal-body ol{padding-left:18px;line-height:1.9;margin:0;}
.modal-body h4{margin:16px 0 6px;font-size:12.5px;color:var(--text);}
.modal-body p{margin:0 0 6px;line-height:1.7;}
.modal-body ul{padding-left:18px;line-height:1.75;margin:0;}
.modal-body ul li{margin-bottom:3px;}
.modal-body .note{margin-top:14px;padding:10px 12px;background:var(--accent-soft);color:var(--accent);border-radius:8px;font-size:11.5px;}

/* SVG 交互元素 */
.tile{cursor:pointer;transition:opacity .1s;}
.tile:hover{opacity:.8;}
.ruler-tick{stroke:var(--ruler-tick);stroke-width:1;}
.ruler-minor{stroke:var(--ruler-minor);stroke-width:.8;}
.ruler-text{fill:var(--ruler-text);font-size:10px;font-weight:600;}
.dim-line{stroke:var(--primary);stroke-width:1.2;}
.dim-text{fill:var(--primary);font-size:11px;font-weight:600;}
.tile-num{fill:var(--tile-num);font-size:9px;pointer-events:none;}
.guide-line{stroke:var(--guide);stroke-width:1.6;stroke-dasharray:6 3;pointer-events:none;}
.guide-mark{fill:var(--guide);font-size:10px;font-weight:700;pointer-events:none;}
.guide-cap{fill:var(--guide-cap);stroke:var(--guide);stroke-width:2;pointer-events:none;}
/* 标尺两端的起始顺序切换按钮：平时只有字符，悬停时才显示底框 */
.ruler-flip rect{fill:transparent;stroke:none;transition:.15s;}
.ruler-flip text{fill:var(--ruler-tick);transition:.15s;}
.ruler-flip[data-flipped="1"] text{fill:var(--primary);}
.ruler-flip:hover rect{fill:var(--surface);stroke:var(--line-strong);stroke-width:.8;}
.ruler-flip:hover text{fill:var(--primary);font-weight:700;}

@media(max-width:1100px){
  .panel{flex-basis:250px;width:250px;}
  .panel-right{flex-basis:260px;width:260px;}
  .brand{flex-basis:212px;width:212px;}
  .brand-text small{display:none;}
  .mode-btn{padding:7px 10px;}
  /* 窄栏只压缩间距，字号仍与字段标签统一 */
  .label-line{gap:6px;}
  .inline-check{gap:4px;}
  .inline-checks{gap:4px;}
  .inline-check input{width:13px;height:13px;}
}

/* 平板：顶栏换行，两侧面板改为抽屉，画布优先 */
@media(max-width:768px){
  .topbar{
    height:auto;flex:0 0 auto;min-height:58px;flex-wrap:wrap;
    gap:8px 12px;padding:8px 12px;
  }
  .brand{flex:1 1 180px;width:auto;flex-basis:auto;}
  .mode-switch{order:3;flex:1 1 100%;justify-content:center;}
  .mode-btn{flex:1 1 0;justify-content:center;}
  .save-indicator{display:none;}
  .workspace{position:relative;}
  .panel{
    position:absolute;top:0;bottom:0;z-index:35;
    width:min(86vw,320px);flex-basis:auto;
    box-shadow:0 8px 30px rgba(20,40,70,.18);
    transform:translateX(-101%);
  }
  .panel-left{left:0;}
  .panel-right{right:0;transform:translateX(101%);}
  .panel:not(.is-collapsed){transform:translateX(0);}
  /* 收起时宽度归零，避免被 transform 移到视口外的抽屉撑大文档滚动宽度 */
  .panel.is-collapsed{width:0;overflow:hidden;border:0;}
  .panel-head{height:42px;flex:0 0 42px;}
  .canvas-toolbar{
    height:auto;flex:0 0 auto;min-height:46px;flex-wrap:wrap;
    gap:6px;padding:6px 8px;
  }
  .tool-group{flex-wrap:wrap;}
  .tool-group+.tool-group{border-left:0;padding-left:0;}
  .legend-toolbar{display:none;}
  .tool-hint{margin-left:auto;}
  .canvas-status{padding:0 8px;}
  .fixture-pop{width:min(224px,calc(100vw - 16px));}
  .modal-card{width:calc(100vw - 24px);max-height:calc(100vh - 40px);overflow-y:auto;}
}

/* 手机：进一步压缩顶栏与状态栏，保证 375px 可操作 */
@media(max-width:480px){
  .topbar{padding:6px 8px;gap:6px 8px;}
  .brand{flex:1 1 auto;}
  .brand-mark{width:28px;height:28px;}
  .brand-text h1{font-size:14px;}
  .mode-btn{padding:6px 8px;font-size:11.5px;}
  .btn{padding:7px 9px;font-size:11.5px;}
  .top-actions{gap:4px;}
  .canvas-toolbar{padding:5px 6px;}
  .toggle{font-size:10.5px;margin-right:4px;}
  .canvas-status{font-size:10px;}
  .status-right{display:none;}
  .panel{width:min(92vw,320px);}
}
