/* floorplan：顶栏 + 左栏图块库 + 中间平面图 + 右栏统计 / 属性。配色沿用 webcab 业主页的绿。 */
:root {
  --ink: #26332e;
  --dim: #75817b;
  --line: #e4e8e4;
  --accent: #2f8a6c;
  --accent-soft: #e8f3ed;
  --paper: #f3f4f1;
  --panel: #ffffff;
  --canvas: #fbfaf7;
  --danger: #c4553a;
  --warn: #ab6b31;
  --warn-soft: #fff4e8;
  --top-h: 52px;
  --side-w: 268px;
  --right-w: 300px;
  --strip-w: 34px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  font: 13px/1.45 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #8ac5ac; outline-offset: 2px; }
svg { flex: none; }
button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- 顶栏 */
#top {
  flex: none; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: visible; scrollbar-width: none;
  position: relative; z-index: 20;
}
#top::-webkit-scrollbar { display: none; }
body.top-hidden #top { display: none; }
.logo { display: flex; flex: none; align-items: center; gap: 6px; }
.logo img { display: block; }
.proj { display: flex; align-items: baseline; gap: 10px; min-width: 0; max-width: 22em; flex: 0 1 auto; }
#projName { width: 14em; field-sizing: content; min-width: 6em; max-width: 100%; border: 1px solid transparent; border-radius: 7px; padding: 5px 7px; font-weight: 500; font-size: 13px; background: transparent; }
@supports (field-sizing: content) { #projName { width: auto; } }
#projName:hover { border-color: var(--line); }
#projName:focus { border-color: #b3cabe; background: #fff; outline: none; }
.seg { display: flex; flex: none; padding: 3px; gap: 2px; background: var(--paper); border-radius: 10px; }
.seg button {
  display: flex; align-items: center; gap: 5px; border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.seg button:not(:disabled):hover { background: #e7ebe7; }
.seg button.on { background: #fff; color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.grow { flex: 1; }
button.plain { border: 0; background: transparent; padding: 6px 9px; border-radius: 8px; white-space: nowrap; }
button.plain:hover { background: var(--paper); }
button.icon { padding: 6px; display: grid; place-items: center; }
#showTop {
  display: none; position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 30; width: 44px; height: 20px;
  border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; background: var(--panel); place-items: center; padding: 0;
}
body.top-hidden #showTop { display: grid; }

#top > .menu-btn { flex: none; }
.top-sep { flex: none; width: 1px; height: 20px; background: var(--line); }
.history { display: flex; flex: none; gap: 1px; }
.history svg { stroke-width: 2; }
.file-menu .menu-btn { display: flex; align-items: center; gap: 3px; border-color: transparent; background: transparent; padding-inline: 9px 6px; }
.file-menu .menu-btn:hover, .file-menu.open .menu-btn { background: var(--paper); }
.caret { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.menu { position: relative; flex: none; }
.menu-btn { border: 1px solid var(--line); background: #fff; padding: 6px 11px; border-radius: 9px; white-space: nowrap; }
.menu-btn:hover { border-color: #b3cabe; }
.menu .pop {
  display: none; position: fixed; min-width: 190px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 10px 30px rgba(30, 40, 35, .14); z-index: 50;
}
.menu.open .pop { display: block; }
.pop label { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.pop label:hover, .pop button:hover { background: var(--paper); }
.pop input { accent-color: var(--accent); margin: 0; }
.pop button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; white-space: nowrap; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ---------------------------------------------------------------- 三栏 */
#main { flex: 1; min-height: 0; display: flex; position: relative; }
.side { flex: none; width: var(--side-w); background: var(--panel); display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 10; overflow: hidden; transition: width .22s ease, box-shadow .22s ease; }
/* 展开收起动画：里面的东西宽度不变（收的时候是被裁掉，不挤着重排），右栏贴右边；内容淡出、窄条淡入 */
#left > .side-head, #left > .side-body, #toolbox { width: var(--side-w); flex-shrink: 0; }
#right > .side-head, #right > .side-body { width: var(--right-w); align-self: flex-end; }
#left > .side-body, #right > .side-body { flex: 1 1 auto; }
.side-head, .side-body { transition: opacity .18s ease, visibility 0s; }
body.preload .side, body.preload .side * { transition: none !important; } /* 刚打开页面时收起不播动画 */
#left { border-right: 1px solid var(--line); }
#right { width: var(--right-w); border-left: 1px solid var(--line); }
.side-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--line); min-height: 46px; }
.side-head b { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.side-strip { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; height: 100%; border: 0; background: transparent; padding: 12px 0; color: var(--dim); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
#left.collapsed, #right.collapsed { width: var(--strip-w); }
.side.collapsed .side-head, .side.collapsed .side-body { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .18s ease, visibility 0s .18s; }
.side.collapsed .side-strip { opacity: 1; pointer-events: auto; transition-delay: .08s; }
.side.collapsed .side-strip:hover { background: var(--paper); color: var(--ink); }
/* 自动收起：两边窄条占位，展开的栏浮在画布上（画布不跟着缩） */
body.auto-hide #main { padding: 0 var(--strip-w); }
body.auto-hide .side { position: absolute; top: 0; bottom: 0; }
body.auto-hide #left { left: 0; }
body.auto-hide #right { right: 0; }
body.auto-hide .side:not(.collapsed) { box-shadow: 0 0 28px rgba(0, 0, 0, .16); z-index: 20; }
/* 钉住：回到普通的一栏，占位置、画布让开 */
body.auto-hide .side.pinned { position: relative; box-shadow: none; z-index: 10; }
body.auto-hide.pin-left #main { padding-left: 0; }
body.auto-hide.pin-right #main { padding-right: 0; }
.side-btns { display: flex; align-items: center; gap: 2px; }
.side-pin { display: none; color: var(--dim); }
body.auto-hide .side-pin { display: grid; }
.side-pin.on { color: var(--accent); }
.side-pin.on svg { fill: currentColor; fill-opacity: .3; }
.side-strip span { writing-mode: vertical-rl; letter-spacing: 2px; font-size: 12px; }
.search { width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.later-note { color: var(--dim); background: var(--paper); border-radius: 10px; padding: 12px 13px; margin: 12px 0; font-size: 12px; }

/* ---------------------------------------------------------------- 画布 */
#stage { flex: 1; min-width: 0; position: relative; overflow: hidden; background: var(--canvas); touch-action: none; }
#plan { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
#stage[data-tool="select"] #plan { cursor: default; }
#stage[data-tool="wall"] #plan, #stage[data-tool="div"] #plan, #stage[data-tool="measure"] #plan { cursor: crosshair; }
#stage[data-tool="demolish"] #plan { cursor: pointer; }
#stage.panning #plan { cursor: grabbing; }
#stage.can-drag #plan { cursor: move; }
#stage.on-node #plan { cursor: grab; }
#stage.on-label #plan { cursor: text; }
#toolOpts {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px rgba(30, 40, 35, .1); white-space: nowrap; z-index: 5; max-width: calc(100% - 24px); overflow-x: auto;
}
#toolOpts[hidden] { display: none; }
#toolOpts:not([hidden]) ~ #hint { top: 58px; }
#toolOpts:has(.ot) ~ #hint { top: 78px; }
#toolOpts button.ot { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; width: 54px; padding: 3px 1px; border-color: transparent; background: transparent; color: var(--dim); font-size: 11px; line-height: 1.15; white-space: normal; text-align: center; }
#toolOpts button.ot:hover { background: var(--paper); }
#toolOpts button.ot.on { border-color: transparent; }
#toolOpts .ot svg { flex: none; width: 22px; height: 22px; stroke-width: 1.4; color: var(--ink); }
#toolOpts .ot.on svg, #toolOpts .ot:hover svg { color: var(--accent); }
#toolOpts .ot-sep { align-self: stretch; width: 1px; margin: 2px; background: var(--line); }
#toolOpts .lab { color: var(--dim); }
#toolOpts button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 9px; }
#toolOpts button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
#toolOpts input[type="number"] { width: 64px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; }
#toolOpts label { display: flex; align-items: center; gap: 5px; }
#toolOpts input[type="checkbox"] { accent-color: var(--accent); }
#hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: max-content; max-width: min(640px, calc(100% - 32px)); text-align: center;
  color: var(--dim); font-size: 12px; background: rgba(251, 250, 247, .92); padding: 4px 10px; border-radius: 8px; pointer-events: none;
  opacity: 0; transition: opacity .4s;
}
#hint.show { opacity: 1; }
#lenEdit {
  position: absolute; z-index: 6; width: 86px; padding: 4px 6px; text-align: center; font-weight: 600; border: 2px solid var(--accent); border-radius: 8px; background: #fff;
  transform: translate(-50%, -50%);
}
.scalebar { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--dim); pointer-events: none; }
.scalebar .bar { height: 7px; border: 1.5px solid #6c655d; border-top: 0; width: 100px; }
.zoom {
  position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 2px; padding: 3px; background: #fff;
  border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 2px 10px rgba(30, 40, 35, .08);
}
.zoom button { border: 0; background: transparent; min-width: 30px; height: 30px; border-radius: 8px; padding: 0 6px; display: grid; place-items: center; font-size: 12px; }
.zoom button:hover { background: var(--paper); }
.view-toggles { display: flex; align-items: center; gap: 2px; padding-right: 4px; margin-right: 2px; border-right: 1px solid var(--line); }
.view-toggles button { color: var(--dim); opacity: .55; }
.view-toggles button.on { color: var(--accent); background: var(--accent-soft); opacity: 1; }
/* 图标的文字悬停才出来，不等浏览器自带提示那一秒；靠右对齐，最右边的也不会出屏 */
[data-tip] { position: relative; }
@media (hover: hover) {
  [data-tip]:hover::after { content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 8px); padding: 4px 8px; border-radius: 6px; background: #2f2b27; color: #fff; font-size: 12px; font-weight: 400; line-height: 1.3; white-space: nowrap; pointer-events: none; z-index: 8; }
}
.zoom button.on { color: var(--accent); font-weight: 600; }
.zoom #zoomIn, .zoom #zoomOut { font-size: 17px; }
#zoomPct { min-width: 44px; text-align: center; font-size: 12px; color: var(--dim); }
#topEnd { position: sticky; right: 0; flex: none; display: flex; align-items: center; gap: 4px; background: var(--panel); padding-left: 8px; } /* 顶栏放不下时，账号入口也要一直看得见 */
#freeBadge { flex: none; padding: 0 6px; color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
@media (max-width: 1023px) { #freeBadge { display: none; } } /* 放不下就不放，不挤按钮 */
@media (min-width: 1400px) { #freeBadge { position: absolute; left: 50%; transform: translateX(-50%); } } /* 够宽时放在正中间 */
@media (min-width: 761px) and (max-width: 1000px) { /* 平板竖屏：顶栏放不下，让出位置给常用按钮 */
  #projName { width: 110px; }
}
#authBtn { flex: none; }
#authBtn[hidden], #userMenu[hidden] { display: none; }
#userMenu .menu-btn span { display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
#userMenu .user-account { margin: 2px 8px 6px; color: var(--dim); font-size: 12px; word-break: break-all; }
#userMenu .pop a { display: block; padding: 6px 8px; color: inherit; text-decoration: none; border-radius: 6px; }
#userMenu .pop a:hover { background: var(--paper); }
#authDialog, #recDialog { border: 0; border-radius: 12px; padding: 0; width: min(380px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(0, 0, 0, .22); color: var(--ink); }
#recDialog { width: min(440px, calc(100vw - 32px)); }
#authDialog::backdrop, #recDialog::backdrop { background: rgba(30, 36, 33, .35); }
.rec-box a { color: var(--accent); }
.rec-box h3 { margin: 0; font-size: 15px; font-weight: 650; }
.rec-drop { display: grid; justify-items: center; gap: 4px; width: 100%; min-height: 150px; padding: 16px; align-content: center; border: 1.5px dashed #b3cabe; border-radius: 10px; background: var(--canvas); color: var(--dim); font-size: 12px; }
.rec-drop:hover, .rec-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.rec-drop b { color: var(--ink); font-size: 13px; font-weight: 600; }
.rec-drop svg { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rec-drop img { max-width: 100%; max-height: 190px; border-radius: 4px; }
.rec-run { display: flex; gap: 12px; align-items: center; }
.rec-run img { flex: none; width: 76px; height: 76px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; }
.rec-run > div { flex: 1; min-width: 0; display: grid; gap: 6px; }
.rec-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.rec-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 1s linear; }
.auth-actions button.quiet { border-color: transparent; background: none; color: var(--dim); padding-inline: 6px; }
.auth-actions button:disabled { opacity: .45; }
#recBtn { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
#recBtn:not(.ready) { background: var(--accent-soft); border-color: #c5e0d2; color: #1f6b52; font-weight: 600; }
#recBtn:not(.ready):hover { border-color: var(--accent); }
#recBtn .rec-ai { flex: none; width: 15px; height: 15px; fill: currentColor; }
#recBtn .rec-short { display: none; }
.rec-quota { font-size: 12px; color: var(--dim); }
.rec-quota.none { color: var(--warn); }
#recBtn.ready { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rec-spin { flex: none; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rec-spin .9s linear infinite; }
@keyframes rec-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rec-spin { animation-duration: 3s; } }
/* 新手引导 */
#welcome { border: 0; border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .22); color: var(--ink); }
#welcome::backdrop { background: rgba(30, 40, 35, .35); }
#welcome h3 { margin: 0; font-size: 17px; font-weight: 650; }
.welcome-opts { display: grid; gap: 8px; }
.welcome-opts button { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 14px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.welcome-opts button:hover, .welcome-opts button:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.welcome-opts svg { flex: none; width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.welcome-opts span { display: grid; gap: 2px; }
.welcome-opts b { font-size: 14px; font-weight: 600; }
.welcome-opts small { color: var(--dim); font-size: 12px; }
.welcome-local { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 12px; line-height: 1.5; }
#tour { position: fixed; inset: 0; z-index: 60; }
.tour-ring { position: fixed; border-radius: 10px; box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(30, 40, 35, .45); transition: all .25s ease; pointer-events: none; }
.tour-tip { position: fixed; display: grid; gap: 8px; width: min(300px, calc(100vw - 24px)); padding: 14px 16px; border-radius: 12px; background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, .22); color: var(--ink); font-size: 13px; }
.tour-tip b { font-size: 14px; font-weight: 650; }
.tour-tip p { margin: 0; color: var(--dim); line-height: 1.55; }
.tour-n { color: var(--accent); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .tour-ring { transition: none; } }
#dropHint { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(47, 138, 108, .1); pointer-events: none; }
#dropHint[hidden] { display: none; }
#dropHint::before { content: ""; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 14px; }
#dropHint > div { display: grid; justify-items: center; gap: 6px; padding: 22px 28px; border-radius: 12px; background: var(--paper); box-shadow: 0 12px 40px rgba(0, 0, 0, .18); color: var(--dim); font-size: 12px; text-align: center; }
#dropHint b { color: var(--ink); font-size: 15px; font-weight: 650; }
#dropHint svg { width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.auth-box { display: grid; gap: 12px; padding: 18px; font-size: 13px; }
.auth-tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--line); }
.auth-tabs button { border: 0; background: none; padding: 4px 2px 8px; font-size: 15px; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.auth-note { margin: 0; color: var(--dim); font-size: 12px; }
.auth-field { display: grid; gap: 4px; flex: 1; min-width: 0; }
.auth-field span { color: var(--dim); font-size: 12px; }
.auth-field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; width: 100%; box-sizing: border-box; }
.auth-field input:focus { outline: 0; border-color: var(--accent); }
.auth-code { display: flex; gap: 8px; align-items: flex-end; }
.auth-code button { flex: none; min-width: 92px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.auth-code button:disabled { color: var(--dim); }
.auth-terms { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--dim); }
.auth-terms a { color: var(--accent); }
.auth-error { margin: 0; color: var(--warn); font-size: 12px; }
.auth-error[hidden] { display: none; }
.auth-actions { display: flex; gap: 8px; align-items: center; }
.auth-actions .grow { flex: 1; }
.auth-actions button { padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.auth-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.auth-actions button.auth-link { border: 0; background: none; padding: 7px 0; color: var(--dim); font-size: 12px; }
#recBanner { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: min(680px, calc(100% - 24px)); max-height: 42%; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 18px rgba(0, 0, 0, .12); padding: 10px 12px; font-size: 13px; z-index: 7; }
#recBanner[hidden] { display: none; }
.rec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.rec-sum { margin: 5px 0 0; color: var(--dim); font-size: 12px; }
.rec-head .grow { flex: 1; }
.rec-head label { display: flex; align-items: center; gap: 4px; color: var(--dim); font-size: 12px; }
.rec-head input[type=range] { width: 70px; }
.rec-head button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 10px; font-size: 13px; }
.rec-head button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rec-usage { margin: 6px 0 0; color: var(--dim); font-size: 11px; }
.rec-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; font-size: 12px; }
.rec-list li { display: flex; gap: 6px; align-items: baseline; }
.rec-list li.info { color: var(--dim); }
.rec-list i { flex: none; width: 16px; height: 16px; border-radius: 50%; background: #d9542b; color: #fff; font-style: normal; font-size: 10px; font-weight: 600; display: inline-grid; place-items: center; }
#toast {
  position: absolute; left: 50%; top: 64px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: #2b3531; color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 8; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.warn { background: var(--warn); }

/* ---------------------------------------------------------------- 右栏 */
.card { margin-bottom: 16px; }
.card h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--dim); letter-spacing: .5px; }
.big { display: flex; align-items: baseline; gap: 6px; padding: 12px 14px; background: var(--accent-soft); border-radius: 12px; }
.big b { font-size: 26px; font-weight: 650; color: var(--accent); letter-spacing: -.5px; }
.big small { color: var(--dim); margin-left: auto; font-size: 11px; }
table.rooms { width: 100%; border-collapse: collapse; }
table.rooms td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.floor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.floor-grid button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px; font-size: 11px; line-height: 1.25; color: var(--dim); display: flex; flex-direction: column; gap: 3px; align-items: stretch; text-align: center; }
.floor-grid button:hover { border-color: #b3cabe; }
.floor-grid button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--ink); font-weight: 600; }
.floor-grid svg { width: 100%; height: auto; aspect-ratio: 1; display: block; stroke: none; border-radius: 5px; }
table.est input.price { width: 58px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 5px; background: #fff; text-align: right; font: inherit; font-variant-numeric: tabular-nums; }
table.est tr.total td { font-weight: 650; border-bottom: 0; }
table.rooms tr.row { cursor: pointer; }
table.rooms tr.row:hover td { background: var(--paper); }
table.rooms td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.rooms tr.sub td { color: var(--dim); font-size: 12px; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 7px; border: 1px solid rgba(0, 0, 0, .1); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--paper); border-radius: 10px; padding: 9px 11px; }
.stat span { display: block; color: var(--dim); font-size: 11px; }
.stat b { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat b small { font-size: 11px; font-weight: 400; color: var(--dim); margin-left: 2px; }
.stat.danger b { color: var(--danger); }
.problems { margin: 0; padding: 0; list-style: none; }
.problems li { padding: 7px 10px; margin-bottom: 5px; background: var(--warn-soft); color: var(--warn); border-radius: 8px; font-size: 12px; cursor: pointer; }
.ok-note { color: var(--accent); font-size: 12px; }

.ptitle { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ptitle .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--paper); flex: none; }
.ptitle .ico.wall-b { background: #2a2622; }
.ptitle .ico.wall-n { background: #8f8a83; }
.ptitle .ico.room { background: var(--accent-soft); color: var(--accent); }
.ptitle .ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.ptitle .ico.furn { background: #fff; border: 1px solid var(--line); }
.ptitle .ico.furn svg { width: 32px; height: 30px; }
.ptitle .tt { flex: 1; min-width: 0; }
.ptitle .tt b { display: block; font-size: 15px; }
.ptitle .tt small { color: var(--dim); }
.ptitle .back { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 9px; color: var(--dim); font-size: 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: 11px; color: var(--dim); }
.field input, .field select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field .unit { position: relative; }
.field .unit input { padding-right: 34px; }
.field .unit em { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--dim); font-size: 11px; pointer-events: none; }
.field .ro { padding: 7px 9px; background: var(--paper); border-radius: 8px; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 5px; margin-top: 2px; }
.chips button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 0; font-size: 12px; }
.chips button small { margin-left: 3px; font-size: 10px; color: var(--warn); }
.chips button:disabled { opacity: .45; }
.chips button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.toggle { display: flex; flex-direction: row !important; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.actions { display: flex; flex-direction: column; gap: 7px; margin-top: 18px; }
.actions button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px; }
.actions button:hover { border-color: #b3cabe; }
.actions button.danger { color: var(--danger); border-color: #efd2c9; }
.actions button.danger:hover { background: #fdf3f0; }
.actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.actions button.primary:hover { filter: brightness(1.06); }
.card .actions { margin-top: 8px; }
.scheme { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 9px; padding: 3px 4px 3px 10px; background: #fff; }
.scheme span { flex: 1; font-size: 12px; color: var(--dim); }
.scheme b { font-size: 13px; min-width: 44px; text-align: center; }
.actions .scheme button { padding: 2px 10px; font-size: 16px; line-height: 1.2; }
.pnote { color: var(--dim); font-size: 12px; margin-top: 14px; }

/* ---------------------------------------------------------------- 左栏顶部的工具：展开时是图标加文字，收起时只留一列图标，手机收起时浮在画布上 */
#toolbox { padding: 8px 10px; border-bottom: 1px solid var(--line); position: relative; z-index: 2; background: var(--panel); }
.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
#toolbox button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 6px 2px 5px; border: 0; border-radius: 8px; background: transparent; font-size: 12px; line-height: 1.2; white-space: nowrap; }
#toolbox button:hover { background: var(--paper); }
#toolbox button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#toolbox button[data-tool="demolish"].on { color: var(--danger); background: var(--warn-soft); }
#toolbox svg { flex: none; }
.side.collapsed #toolbox { width: 100%; padding: 4px 2px; border-bottom: 0; background: transparent; }
.side.collapsed .tool-grid { grid-template-columns: 1fr; gap: 2px; }
.side.collapsed #toolbox button { padding: 5px 0; }
.side.collapsed #toolbox button span { display: none; }
#left.collapsed .side-strip { padding-top: 232px; }

/* ---------------------------------------------------------------- 触屏：没有右键和 Esc，给个结束按钮；平板上窄条和按钮加大，手指好点 */
#touchDone { display: none; }
@media (hover: none) {
  #touchDone:not([hidden]) { display: block; position: absolute; right: 12px; bottom: 62px; z-index: 6; min-height: 44px; padding: 0 20px; border: 0; border-radius: 22px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; box-shadow: 0 2px 10px rgba(0, 0, 0, .2); }
}
@media (pointer: coarse) and (min-width: 761px) {
  :root { --strip-w: 44px; }
  .side.collapsed #toolbox { max-height: 100%; overflow: hidden auto; touch-action: pan-y; }
  .side.collapsed #toolbox button { padding: 9px 0; }
  #left.collapsed .side-strip { padding-top: 348px; }
  #toolbox button { min-height: 44px; }
  .menu-btn, .seg button, .zoom button { min-height: 38px; }
  .zoom button { min-width: 36px; }
  .pop button, .pop label { min-height: 40px; }
}

/* ---------------------------------------------------------------- 手机：左右栏默认收起，展开时盖在画布上 */
@media (max-width: 760px) {
  :root { --top-h: 48px; --side-w: min(86vw, 300px); --right-w: min(86vw, 320px); --strip-w: 0px; }
  #top { gap: 7px; padding: 0 8px; }
  .seg button span { display: none; }
  .seg button { padding: 6px 8px; }
  #projName { width: 7em; }
  .logo .logo-word, .proj, .top-sep { display: none; } /* 手机放不下：只留图标和常用按钮 */
  #top { gap: 4px; }
  .file-menu .menu-btn { padding-inline: 7px; }
  .file-menu .caret { display: none; }
  #recBtn .rec-long { display: none; }
  #recBtn .rec-short { display: inline; }
  .side { position: absolute; top: 0; bottom: 0; box-shadow: 0 0 30px rgba(0, 0, 0, .18); }
  #left { left: 0; }
  #right { right: 0; }
  #left.collapsed, #right.collapsed { width: 0; border: 0; box-shadow: none; overflow: hidden; }
  .side.collapsed .side-strip { display: none; }
  .side.collapsed #toolbox { position: fixed; left: 10px; bottom: calc(58px + env(safe-area-inset-bottom)); width: auto; display: flex; flex-direction: column-reverse; gap: 3px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); z-index: 5; }
  .side.collapsed .tool-grid { display: flex; gap: 2px; }
  .side.collapsed #toolbox button { padding: 6px 8px; }
  #stage .mobile-tabs { display: flex; }
  #toolOpts { top: 52px; }
  .view-toggles { position: fixed; right: 12px; bottom: calc(60px + env(safe-area-inset-bottom)); flex-direction: column; margin: 0; padding: 3px; background: #fff; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 2px 10px rgba(30, 40, 35, .08); }
  #touchDone:not([hidden]) { right: 62px; bottom: calc(110px + env(safe-area-inset-bottom)); }
  #toolOpts:has(.ot) { flex-wrap: wrap; justify-content: center; width: calc(100% - 24px); white-space: normal; }
  #toolOpts .ot-sep { display: none; }
  #hint { display: none; }
}
.mobile-tabs { display: none; position: absolute; top: 10px; left: 10px; right: 10px; justify-content: space-between; pointer-events: none; z-index: 4; }
.mobile-tabs button { pointer-events: auto; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 11px; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }

/* ---------------------------------------------------------------- 图块库 */
#lib { margin-top: 10px; }
.lib-group { margin: 12px 0 4px; font-size: 12px; font-weight: 600; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.lib-group em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 0 5px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.lib-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 5px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: grab; touch-action: none; user-select: none; }
.lib-item:hover { border-color: var(--accent); }
.lib-item.on { border-color: var(--accent); background: var(--accent-soft); }
.lib-item svg { width: 60px; height: 44px; }
.lib-item b { font-size: 11px; font-weight: 500; line-height: 1.2; text-align: center; }
.lib-item small { font-size: 10px; color: var(--dim); }
.lib-empty { color: var(--dim); font-size: 12px; padding: 12px 2px; }
#stage.placing { cursor: copy; }
.rec-alt { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--dim); cursor: pointer; }
.rec-alt:hover { border-color: var(--accent); }
.rec-alt input { margin: 2px 0 0; accent-color: var(--accent); }
.rec-alt b { display: block; color: var(--ink); font-size: 13px; font-weight: 600; }
