:root {
  --bg: #eef1f5;
  --panel: rgba(255, 255, 255, 0.92);
  --line: #dfe3ea;
  --text: #1d2430;
  --muted: #6b7686;
  --accent: #1f6feb;
  --accent-soft: #e7f0ff;
  --warn: #c2410c;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(20, 30, 50, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hide { display: none !important; }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---------- 顶部 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: linear-gradient(#ffffff, rgba(255,255,255,0.86));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-name { font-size: 15px; font-weight: 700; white-space: nowrap; }
.brand-tag {
  font-size: 12px; color: var(--accent); background: var(--accent-soft);
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip {
  font-size: 12px; color: var(--muted); background: #f4f6f9;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.icon-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; font-size: 16px; cursor: pointer; color: var(--text);
}

/* ---------- 面板 ---------- */
.panel {
  position: fixed; top: 60px; z-index: 25; width: 232px;
  max-height: calc(100% - 130px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
body.panels-off .panel { transform: translateX(-110%); }
body.panels-off .panel-right { transform: translateX(110%); }
.panel { transition: transform .22s ease; }
.panel-left { left: 12px; }
.panel-right { right: 12px; width: 212px; }
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: #cfd5de; border-radius: 3px; }

.block { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }

.grid-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid-btns button {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 7px; padding: 6px 4px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: background .12s, border-color .12s;
}
.grid-btns button:hover { background: #f5f8fc; border-color: #c7d2e2; }
.grid-btns button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.layers { display: flex; flex-direction: column; gap: 2px; }
.layer {
  display: flex; align-items: center; gap: 8px; padding: 4px 4px;
  border-radius: 6px; cursor: pointer; user-select: none;
}
.layer:hover { background: #f4f7fb; }
.layer input { margin: 0; accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.layer .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.18); flex: none; }
.layer .nm { flex: 1; }
.layer .ct { font-size: 11px; color: var(--muted); }

.info { font-size: 12px; color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.info b { color: var(--text); font-weight: 600; text-align: right; }

.rooms { display: flex; flex-direction: column; gap: 2px; }
.room-group { font-size: 11px; color: var(--muted); margin: 6px 0 2px; font-weight: 700; }
.room-group:first-child { margin-top: 0; }
.room {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.room:hover { background: #f4f7fb; }
.room.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.room .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.room .ar { margin-left: auto; font-size: 11px; color: var(--muted); }

/* ---------- 工具条 ---------- */
.toolbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.tool-sep { width: 1px; height: 22px; background: var(--line); }
.seg { display: flex; background: #eef1f5; border-radius: 8px; padding: 2px; }
.seg button {
  border: 0; background: transparent; padding: 5px 14px; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: var(--muted); font-family: inherit;
  white-space: nowrap;
}
.seg button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tool-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.tool-btn:hover { background: #f5f8fc; }
.tool-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- 浮动面板 ---------- */
.float-box {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 19;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 12px; min-width: 300px;
  display: flex; flex-direction: column; gap: 8px; backdrop-filter: blur(8px);
}
.float-box .row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.float-box label { color: var(--muted); width: 34px; flex: none; }
.float-box select, .float-box input[type=range] { flex: 1; font-family: inherit; font-size: 13px; }
.float-box select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: #fff; }
.val { width: 62px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.measure-text { font-size: 13px; }
.measure-text b { color: var(--accent); font-size: 15px; }
.mini-btn { align-self: flex-end; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }

.hint {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%); z-index: 18;
  background: rgba(29, 36, 48, .78); color: #fff; font-size: 12px;
  padding: 5px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap;
  max-width: calc(100% - 24px); text-align: center;
}

.joy {
  position: fixed; left: 26px; bottom: 84px; width: 108px; height: 108px; z-index: 18;
  border-radius: 50%; background: rgba(255,255,255,.55); border: 1px solid var(--line);
  touch-action: none;
}
.joy i {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; background: rgba(31,111,235,.75);
}

.tip {
  position: fixed; z-index: 30; pointer-events: none; font-size: 12px;
  background: rgba(29, 36, 48, .86); color: #fff; padding: 3px 8px; border-radius: 6px;
  white-space: nowrap; transform: translate(12px, 12px);
}

.fatal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: #fff; padding: 24px; text-align: center; color: var(--warn); font-size: 14px; white-space: pre-wrap;
}

/* 面板展开时让开漫游提示与摇杆 */
body.panel-open .hint, body.panel-open .joy { display: none; }

/* ---------- 加载 ---------- */
.loading {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: opacity .35s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-box { width: 260px; text-align: center; }
.loading-title { font-size: 18px; font-weight: 700; }
.loading-sub { font-size: 12px; color: var(--accent); margin: 2px 0 16px; }
.bar { height: 4px; background: #d9dee6; border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.loading-text { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- 移动端 ---------- */
.only-mobile { display: none; }
@media (max-width: 860px) {
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .hide-sm { display: none; }
  .panel {
    top: 56px; max-height: calc(100% - 150px);
    transform: translateX(-110%); transition: transform .22s ease;
  }
  .panel-right { transform: translateX(110%); }
  .panel.open { transform: translateX(0); }
  .toolbar { bottom: 10px; padding: 5px 6px; gap: 6px; }
  .tool-btn { padding: 6px 9px; }
  .seg button { padding: 5px 10px; }
  .float-box { min-width: 0; width: calc(100% - 24px); bottom: 66px; }
  .hint { font-size: 11px; top: 56px; white-space: normal; border-radius: 12px; }
  .joy { bottom: 76px; }
}
