:root{
  --g-blue:#1a73e8; --g-blue-dark:#1557b0; --g-blue-bg:#e8f0fe;
  --g-red:#d93025; --g-red-bg:#fce8e6;
  --g-green:#188038; --g-yellow:#f9ab00;
  --surface:#ffffff; --bg:#f6f8fc; --border:#e3e6ea;
  --text:#202124; --text-2:#5f6368; --text-3:#80868b;
  --radius:14px; --radius-sm:10px;
  --shadow-1: 0 1px 2px 0 rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 2px 6px 2px rgba(60,64,67,.15), 0 1px 2px 0 rgba(60,64,67,.30);
}
*{box-sizing:border-box; margin:0; padding:0;}
html,body{height:100%; overflow:hidden;}
body{
  font-family:'Google Sans','Roboto','Noto Sans SC',-apple-system,BlinkMacSystemFont,sans-serif;
  background:var(--bg); color:var(--text); font-size:14px;
  display:flex; flex-direction:column; height:100vh;
}
/* ---------- HEADER ---------- */
header{
  height:60px; flex:0 0 auto; background:var(--surface); border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; padding:0 20px; z-index:50;
  transition: all .2s;
}
.brand{display:flex; align-items:center; gap:12px; min-width:0;}
.brand .logo{width:34px; height:34px; border-radius:9px; background:conic-gradient(from 220deg,#1a73e8,#34a853 40%,#fbbc04 70%,#1a73e8); display:flex; align-items:center; justify-content:center; box-shadow:var(--shadow-1); flex:0 0 auto;}
.brand .logo svg{width:18px; height:18px;}
.brand h1{font-size:17px; font-weight:500; letter-spacing:.1px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.brand .sub{font-size:11px; color:var(--text-3); font-weight:400; margin-top:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.header-actions{display:flex; align-items:center; gap:4px; flex:0 0 auto;}
.btn{
  display:inline-flex; align-items:center; gap:6px; border:none; background:transparent; cursor:pointer;
  font-family:inherit; font-size:13.5px; font-weight:500; color:var(--text-2); border-radius:20px;
  padding:9px 16px; transition:background .15s, color .15s; white-space:nowrap;
}
.btn:hover{background:#f1f3f4; color:var(--text);}
.btn svg{width:17px; height:17px; flex:0 0 auto;}
.btn-primary{background:var(--g-blue); color:#fff; box-shadow:var(--shadow-1); padding:9px 18px;}
.btn-primary:hover{background:var(--g-blue-dark); color:#fff;}
.divider-v{width:1px; height:24px; background:var(--border); margin:0 6px;}

/* ---------- BODY LAYOUT ---------- */
.body{flex:1; display:flex; min-height:0; position:relative;}
.sidebar{
  width:326px; flex:0 0 auto; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:14px;
  background:var(--bg); transition:transform .2s ease, margin-left .2s ease, width .2s ease;
}
.sidebar::-webkit-scrollbar{width:8px;}
.sidebar::-webkit-scrollbar-thumb{background:#dadce0; border-radius:8px;}

.card{background:var(--surface); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow-1);}
.card h2, .card-head{font-size:14px; font-weight:500; margin-bottom:14px; display:flex; align-items:center; justify-content:space-between; color:var(--text);}
.card h2 .title-left, .card-head .title-left{display:flex; align-items:center; gap:8px;}
.card h2 .dot{width:6px;height:6px;border-radius:50%;background:var(--g-blue);}

/* 折叠控制按钮通用样式 */
.panel-toggle-btn{
  border:none; background:transparent; cursor:pointer; color:var(--text-3); border-radius:50%;
  width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center;
  transition:background .15s, color .15s;
}
.panel-toggle-btn:hover{background:#f1f3f4; color:var(--text);}
.panel-toggle-btn svg{width:16px; height:16px;}

/* 折叠恢复按钮样式 */
.restore-btn{
  position: absolute; z-index: 30; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); box-shadow: var(--shadow-2); border-radius: 20px;
  padding: 6px 14px; font-size: 12px; font-weight: 500; font-family: inherit;
  cursor: pointer; display: none; align-items: center; gap: 6px; transition: all .15s;
}
.restore-btn:hover{ background: var(--g-blue-bg); color: var(--g-blue); border-color: var(--g-blue); }
.restore-btn svg{ width: 14px; height: 14px; }

#btnRestoreSidebar { top: 16px; left: 16px; }
#btnRestoreTop { top: 16px; left: 50%; transform: translateX(-50%); }
#btnRestoreBottom { bottom: 16px; left: 50%; transform: translateX(-50%); }

/* 折叠控制类 */
body.sidebar-collapsed .sidebar { display: none !important; }
body.top-collapsed .toolbar-row { display: none !important; }
body.bottom-collapsed .bottom-row { display: none !important; }

body.sidebar-collapsed #btnRestoreSidebar { display: flex; }
body.top-collapsed #btnRestoreTop { display: flex; }
body.bottom-collapsed #btnRestoreBottom { display: flex; }

/* 一键沉浸模式（隐藏四周所有面板） */
body.hide-all-panels .sidebar,
body.hide-all-panels .toolbar-row,
body.hide-all-panels .bottom-row,
body.hide-all-panels .restore-btn { display: none !important; }
body.hide-all-panels .main { padding: 12px !important; }

/* 伪全屏备用模式 */
.viewport.pseudo-fullscreen {
  position: fixed !important; inset: 0 !important; z-index: 9999 !important;
  border-radius: 0 !important; width: 100vw !important; height: 100vh !important;
}

.field{margin-bottom:18px;}
.field:last-child{margin-bottom:0;}
.field-label{display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; font-size:13px; color:var(--text-2); font-weight:500; flex-wrap:wrap; gap:4px;}
.field-label .val-box{
  border:1px solid var(--border); border-radius:8px; padding:3px 10px; font-size:12.5px; color:var(--text); background:#fafbfc; min-width:52px; text-align:center; font-variant-numeric:tabular-nums; flex-shrink:0;
}
.range-wrap{display:flex; align-items:center; gap:10px;}
.range-wrap .lo,.range-wrap .hi{font-size:11px; color:var(--text-3); width:26px; flex:0 0 auto;}
.range-wrap .hi{text-align:right;}
input[type=range]{
  -webkit-appearance:none; appearance:none; flex:1; height:4px; border-radius:4px; outline:none;
  background:linear-gradient(to right, var(--g-blue) 0%, var(--g-blue) var(--pct,50%), #dde1e6 var(--pct,50%), #dde1e6 100%);
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; width:16px; height:16px; border-radius:50%; background:var(--g-blue);
  border:3px solid #fff; box-shadow:0 1px 4px rgba(0,0,0,.35); cursor:pointer; margin-top:0;
}
input[type=range]::-moz-range-thumb{width:16px; height:16px; border-radius:50%; background:var(--g-blue); border:3px solid #fff; box-shadow:0 1px 4px rgba(0,0,0,.35); cursor:pointer;}
input[type=range]:disabled{opacity:.4; cursor:not-allowed;}
.field.disabled{opacity:.42; pointer-events:none;}

.seg{display:flex; gap:8px;}
.seg button{
  flex:1; border:1.5px solid var(--border); background:var(--surface); border-radius:10px; padding:10px 8px;
  font-family:inherit; font-size:13px; font-weight:500; color:var(--text-2); cursor:pointer; display:flex; flex-direction:column;
  align-items:center; gap:6px; transition:all .15s; min-width:0;
}
.seg button svg{width:18px;height:18px;}
.seg button.active{border-color:var(--g-blue); background:var(--g-blue-bg); color:var(--g-blue);}
.seg button:hover:not(.active){background:#f6f8fc; border-color:#c9cdd3;}

.sub-head{display:flex; align-items:center; gap:6px; font-size:12.5px; font-weight:500; color:var(--text-3); text-transform:uppercase; letter-spacing:.4px; margin:4px 0 12px; padding-top:6px; border-top:1px dashed var(--border);}
.sub-head:first-of-type{border-top:none; padding-top:0; margin-top:0;}
.info-i{width:14px;height:14px; border-radius:50%; border:1.3px solid var(--text-3); color:var(--text-3); font-size:9.5px; display:inline-flex; align-items:center; justify-content:center; font-style:normal; cursor:default;}

.spec-grid{display:grid; grid-template-columns:1fr auto; row-gap:9px; font-size:13px;}
.spec-grid .k{color:var(--text-2);}
.spec-grid .v{color:var(--text); font-weight:500; text-align:right;}
.spec-block{background:#f8f9fb; border-radius:10px; padding:12px 14px; margin-top:8px;}
.spec-block .title{font-size:12px; font-weight:500; color:var(--g-blue); margin-bottom:8px;}

/* 已添加物体列表 */
.placed-list{
  margin-top:10px; 
  display:flex; 
  flex-direction:column; 
  gap:6px;
  max-height: 88px;
  overflow-y: auto;
  padding-right: 4px;
}
.placed-list::-webkit-scrollbar{width:5px;}
.placed-list::-webkit-scrollbar-thumb{background:#dadce0; border-radius:4px;}

.placed-empty{font-size:12px; color:var(--text-3); text-align:center; padding:10px 0;}
.placed-item{
  display:flex; align-items:center; gap:8px; padding:6px 9px; border-radius:9px; background:#f8f9fb;
  font-size:12.5px; cursor:pointer; border:1.5px solid transparent; flex: 0 0 auto;
}
.placed-item:hover{background:#f1f3f4;}
.placed-item.selected{border-color:var(--g-blue); background:var(--g-blue-bg);}
.placed-item .ic{width:22px;height:22px; border-radius:6px; background:#e1e5ea; display:flex; align-items:center; justify-content:center; flex:0 0 auto;}
.placed-item .ic svg{width:13px;height:13px;}
.placed-item .nm{flex:1; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.placed-item .rm{width:20px;height:20px; border-radius:50%; border:none; background:transparent; color:var(--text-3); cursor:pointer; display:flex; align-items:center; justify-content:center; flex:0 0 auto;}
.placed-item .rm:hover{background:var(--g-red-bg); color:var(--g-red);}

/* ---------- MAIN AREA ---------- */
.main{flex:1; display:flex; flex-direction:column; min-width:0; padding:16px 16px 16px 0; gap:12px; position:relative;}
.toolbar-row{display:flex; gap:12px; flex:0 0 auto;}
.toolbar-row .card{flex:1; padding:14px 16px; min-width:0;}

/* 图标网格流式适应，防止窄屏变形 */
.icon-row{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap:8px;
}
.icon-btn{
  border:1.5px solid var(--border); background:var(--surface); border-radius:10px; padding:8px 4px;
  display:flex; flex-direction:column; align-items:center; gap:5px; cursor:pointer; font-family:inherit;
  font-size:11.5px; color:var(--text-2); transition:all .15s; min-width:0;
}
.icon-btn svg{width:19px;height:19px;}
.icon-btn:hover{background:#f6f8fc; border-color:#c9cdd3; color:var(--text);}
.icon-btn.active{background:var(--g-blue-bg); border-color:var(--g-blue); color:var(--g-blue);}

.viewport{
  flex:1; position:relative; border-radius:var(--radius); overflow:hidden;
  background:linear-gradient(180deg,#eef2f8,#e4e9f1); box-shadow:var(--shadow-1);
  min-height:260px;
}
.viewport canvas{display:block; width:100%; height:100%; touch-action:none;}

.float{position:absolute; z-index:10;}
.mode-toggle{top:16px; right:16px; display:flex; background:var(--surface); border-radius:10px; padding:3px; box-shadow:var(--shadow-2); gap:2px;}
.mode-toggle button{border:none; background:transparent; padding:7px 16px; border-radius:8px; font-family:inherit; font-size:13px; font-weight:500; color:var(--text-2); cursor:pointer;}
.mode-toggle button.active{background:var(--g-blue); color:#fff;}

.compass{top:70px; right:22px; width:54px; height:54px; background:var(--surface); border-radius:50%; box-shadow:var(--shadow-2); display:flex; align-items:center; justify-content:center; pointer-events:none;}
.compass svg{width:100%; height:100%; transition:transform .1s linear;}

.grid-scale-badge{
  bottom:16px; left:16px; background:rgba(255,255,255,0.92); color:var(--text);
  font-size:12px; font-weight:500; padding:6px 14px; border-radius:20px;
  box-shadow:var(--shadow-2); border:1px solid var(--border); pointer-events:none;
}

.drag-hint{
  top:16px; left:50%; transform:translateX(-50%); background:rgba(32,33,36,.82); color:#fff; font-size:12px;
  padding:7px 14px; border-radius:20px; pointer-events:none; opacity:0; transition:opacity .25s; white-space:nowrap;
}
.drag-hint.show{opacity:1;}

.mode-label{background:rgba(26,115,232,.92); color:#fff; font-size:12px; font-weight:500; padding:5px 12px; border-radius:16px; pointer-events:none; transform:translate(-50%,-50%); white-space:nowrap;}
.dist-label{background:rgba(26,115,232,.9); color:#fff; font-size:11.5px; font-weight:600; padding:2px 8px; border-radius:10px; pointer-events:none; transform:translate(-50%,-50%); white-space:nowrap;}
.dist-label.blocked{background:rgba(217,48,37,.9);}

.right-toolbar{top:132px; right:22px; display:flex; flex-direction:column; gap:8px; background:var(--surface); border-radius:12px; padding:6px; box-shadow:var(--shadow-2);}
.right-toolbar button{
  width:42px; height:42px; border:none; background:transparent; border-radius:9px; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px; color:var(--text-2);
}
.right-toolbar button svg{width:17px;height:17px;}
.right-toolbar button span{font-size:8.5px;}
.right-toolbar button:hover{background:#f1f3f4;}
.right-toolbar button.active{background:var(--g-blue-bg); color:var(--g-blue);}
.right-toolbar .sep{height:1px; background:var(--border); margin:2px 4px;}

/* ---------- BOTTOM BAR ---------- */
.bottom-row{display:flex; gap:12px; flex:0 0 auto;}
.bottom-row .card{flex:1; padding:14px 18px; min-width:0;}
.bottom-row h3{font-size:12px; font-weight:500; color:var(--text-3); text-transform:uppercase; letter-spacing:.4px; margin-bottom:10px;}
.legend-row{display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-2); margin-bottom:8px;}
.legend-row:last-child{margin-bottom:0;}
.legend-dot{width:11px; height:11px; border-radius:50%; flex:0 0 auto;}
.pos-grid{display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px;}
.pos-grid div{font-size:13px;}
.pos-grid .lbl{color:var(--text-3); font-size:11px; margin-bottom:2px;}
.pos-grid .num{font-weight:500; font-variant-numeric:tabular-nums;}
.cov-row{display:flex; justify-content:space-between; align-items:baseline; margin-bottom:8px;}
.cov-row:last-child{margin-bottom:0;}
.cov-row .lbl{font-size:13px; color:var(--text-2);}
.cov-row .num{font-size:16px; font-weight:700; font-variant-numeric:tabular-nums;}
.cov-row .num.blue{color:var(--g-blue);}
.cov-row .num.red{color:var(--g-red);}

/* snackbar */
#snackbar{position:fixed; left:50%; bottom:26px; transform:translateX(-50%) translateY(20px); background:#323639; color:#fff;
  padding:11px 20px; border-radius:8px; font-size:13.5px; box-shadow:var(--shadow-2); z-index:999; opacity:0; pointer-events:none; transition:all .25s;}
#snackbar.show{opacity:1; transform:translateX(-50%) translateY(0);}

/* help modal */
.modal-bg{position:fixed; inset:0; background:rgba(32,33,36,.45); z-index:900; display:none; align-items:center; justify-content:center;}
.modal-bg.show{display:flex;}
.modal{background:#fff; border-radius:16px; padding:26px 28px; max-width:420px; box-shadow:var(--shadow-2); margin: 16px;}
.modal h3{font-size:17px; margin-bottom:14px; display:flex; align-items:center; gap:8px;}
.modal ul{padding-left:18px; display:flex; flex-direction:column; gap:8px; font-size:13.5px; color:var(--text-2); line-height:1.5;}
.modal .close{margin-top:20px; text-align:right;}
.modal .close button{background:var(--g-blue); color:#fff; border:none; padding:9px 20px; border-radius:20px; font-family:inherit; font-size:13.5px; font-weight:500; cursor:pointer;}

/* ============================================================
   RESPONSIVE MEDIA QUERIES (自适应媒体查询)
============================================================ */

/* 1. 中等屏幕与笔记本 (900px ~ 1100px) */
@media (max-width: 1024px) {
  .sidebar { width: 280px; }
}

/* 2. 平板与小屏幕 (768px ~ 900px) */
@media (max-width: 900px) {
  .sidebar { width: 260px; padding: 12px; gap: 10px; }
  .main { padding: 12px 12px 12px 0; gap: 10px; }
  .toolbar-row { flex-direction: column; gap: 10px; }
  .bottom-row { flex-wrap: wrap; gap: 10px; }
  .bottom-row .card { flex: 1 1 200px; }
}

/* 3. 移动端/手机屏幕 (< 768px)：自动切换为上下流式布局 */
@media (max-width: 768px) {
  html, body { overflow-y: auto; height: auto; min-height: 100vh; }
  
  header { height: auto; min-height: 52px; padding: 10px 12px; }
  .brand .sub { display: none; } /* 移动端收起副标题 */
  .brand h1 { font-size: 15px; }
  .btn { padding: 6px 12px; font-size: 12px; }
  .btn svg { width: 15px; height: 15px; }
  
  .body { flex-direction: column; overflow: visible; height: auto; }
  
  /* 3D 视图保持在手机屏幕最上方黄金区域 */
  .main { order: 1; padding: 12px; flex: none; width: 100%; gap: 12px; }
  .viewport { height: 48vh; min-height: 300px; max-height: 480px; }
  
  /* 控制面板平滑流动排列在画布下方 */
  .sidebar { order: 2; width: 100%; flex: none; overflow: visible; padding: 0 12px 12px 12px; gap: 12px; }
  .toolbar-row { flex-direction: column; gap: 12px; }
  .bottom-row { flex-direction: column; gap: 12px; }
  .bottom-row .card { width: 100%; }
}

/* 4. 超小手机屏幕 (< 480px) 微调 */
@media (max-width: 480px) {
  header { padding: 8px 10px; }
  .brand .logo { width: 28px; height: 28px; }
  .brand h1 { font-size: 14px; }
  .header-actions .divider-v { display: none; }
  .btn { padding: 5px 8px; font-size: 11.5px; }
  
  .mode-toggle { top: 10px; right: 10px; }
  .mode-toggle button { padding: 5px 10px; font-size: 11.5px; }
  
  .right-toolbar { top: 52px; right: 10px; padding: 4px; gap: 4px; }
  .right-toolbar button { width: 34px; height: 34px; }
  .right-toolbar button span { display: none; } /* 手机端只显示右侧工具栏图标 */
  
  .compass { top: 10px; left: 10px; width: 42px; height: 42px; }
  .grid-scale-badge { bottom: 10px; left: 10px; font-size: 10.5px; padding: 4px 10px; }
}
/* 安装高度要求表格样式 */
.req-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text);
  text-align: center;
}
.req-table th, .req-table td {
  border: 1px solid var(--border);
  padding: 10px 8px;
  line-height: 1.4;
}
.req-table th {
  background: #f1f3f4;
  font-weight: 500;
  color: var(--text);
}
.req-table td {
  background: #fff;
}