/* 来霖智造园 · 园区三维运维
   与楼宇孪生共用一套布局：顶栏、左侧栏、右检查器贴边停靠，三维画面占中间区域。
   实色表面、1px 分隔线、3px 圆角，不用阴影和毛玻璃。 */

:root {
  --scene: #cdd9d9;          /* 与渲染器日间背景一致 */
  --surface: #f5f7f5;
  --surface-2: #e9eeea;
  --ink: #1e3430;
  --ink-2: #4f6259;
  --ink-3: #6b7b73;
  --rule: #d3dbd6;
  --accent: #2f5d4e;
  --accent-ink: #f3f7f2;
  --normal: #4f8a6c;
  --warning: #a88a2e;
  --alarm: #b0602c;
  --alarm-bg: #f6e8da;
  --offline: #97a29c;
  --side: 248px;
  --panel: 336px;
  --top: 48px;
  --radius: 3px;
  --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;
  color-scheme: light;
}
body.night {
  --scene: #3c5665;          /* 与渲染器夜间背景一致 */
  --surface: #1c3136;
  --surface-2: #243d40;
  --ink: #e1e8df;
  --ink-2: #b1c0b4;
  --ink-3: #8b9c92;
  --rule: #2f4a4b;
  --accent: #9cc4a6;
  --accent-ink: #11251f;
  --normal: #8fc3a0;
  --warning: #d6bb6a;
  --alarm: #e3a46f;
  --alarm-bg: #3e3528;
  --offline: #6f807a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  background: var(--scene); color: var(--ink);
  font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
b, strong { font-weight: 600; }
.num, b, code { font-variant-numeric: tabular-nums; }
code { font-family: var(--mono); font-size: 12px; }
svg { display: block; }
[hidden] { display: none !important; }
.mobile-only { display: none; }

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 20;
  display: flex; align-items: center; gap: 20px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.project { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; min-width: calc(var(--side) - 16px); }
.project strong { font-size: 15px; letter-spacing: .5px; }
.project span { font-size: 12px; color: var(--ink-3); }
.tabs { display: flex; height: 100%; }
.tabs button { position: relative; padding: 0 12px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.active { color: var(--ink); font-weight: 600; }
.tabs button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; background: var(--accent); }
.tabs button b { font-size: 12px; color: var(--alarm); margin-left: 2px; }
.readouts { display: flex; align-items: stretch; height: 100%; margin-left: auto; }
.readout {
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  border-left: 1px solid var(--rule); white-space: nowrap;
}
.readout:last-child { border-right: 1px solid var(--rule); }
button.readout:hover { background: var(--surface-2); }
.readout > span { font-size: 12px; color: var(--ink-3); }
.readout > b { font-size: 16px; font-weight: 500; }
.readout b small { font-size: 11px; color: var(--ink-3); font-weight: 400; margin-left: 3px; }
.readout.is-alarm > b { color: var(--alarm); font-weight: 600; }
.readout.source > b { font: 12px var(--mono); color: var(--ink-2); }
.readout.source.stale > span { color: var(--alarm); }
.tools { display: flex; gap: 6px; }
.tool {
  height: 28px; padding: 0 10px; font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
  white-space: nowrap;
}
.tool:hover { background: var(--surface-2); color: var(--ink); }
.tool.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ── Left sidebar ────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: var(--top); bottom: 0; width: var(--side); z-index: 15;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--rule);
  overflow-y: auto;
}
.side-group { padding: 12px 12px; border-bottom: 1px solid var(--rule); }
.side-group h2 { display: flex; align-items: baseline; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); margin: 0 4px 8px; }
.side-group h2 .link { margin-left: auto; }
.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.mode-switch button { height: 30px; font-size: 13px; color: var(--ink-2); }
.mode-switch button + button { border-left: 1px solid var(--rule); }
.mode-switch button:hover { background: var(--surface-2); }
.mode-switch button.active { background: var(--accent); color: var(--accent-ink); }

.assets { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 220px; padding-bottom: 0; }
.search, .filter-row select {
  width: 100%; height: 28px; padding: 0 8px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); outline: none;
}
.search:focus, .filter-row select:focus { border-color: var(--ink-3); }
.search::placeholder { color: var(--ink-3); }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.filter-row select { min-width: 0; }
.filters { display: flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin-top: 6px; }
.filters button { flex: 1; height: 26px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.filters button + button { border-left: 1px solid var(--rule); }
.filters button:hover { background: var(--surface-2); }
.filters button.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.filters button b { font-weight: 500; font-size: 11px; color: var(--ink-3); margin-left: 2px; }
.filters.compact button { height: 24px; font-size: 11px; padding: 0 8px; }

.asset-list { display: flex; flex-direction: column; overflow-y: auto; flex: 1 1 0; min-height: 120px; margin: 8px -12px 0; border-top: 1px solid var(--rule); scrollbar-width: thin; }
.asset-row {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) 8px; align-items: center; gap: 6px;
  padding: 6px 12px; text-align: left; border-bottom: 1px solid var(--rule);
}
.asset-row:hover { background: var(--surface-2); }
.asset-row code { font-weight: 600; font-size: 11px; color: var(--ink-2); }
.asset-row span { min-width: 0; }
.asset-row b { display: block; font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-row small { display: block; font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-row i { width: 8px; height: 8px; border-radius: 1px; }
.asset-row.selected { background: var(--accent); color: var(--accent-ink); }
.asset-row.selected code, .asset-row.selected small { color: var(--accent-ink); }
.asset-row.selected i { box-shadow: 0 0 0 1px var(--accent-ink); }
.asset-row.alarm:not(.selected) { background: var(--alarm-bg); }
.empty { padding: 16px 4px; font-size: 12px; color: var(--ink-3); }

.side-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; padding: 8px 10px; }
.check { display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 4px; font-size: 12px; white-space: nowrap; color: var(--ink-2); text-align: left; border-radius: var(--radius); }
.check:hover { background: var(--surface-2); }
.check i { width: 12px; height: 12px; border: 1px solid var(--ink-3); border-radius: 2px; flex: none; }
.check.active { color: var(--ink); }
.check.active i { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface); }
.legend { display: flex; gap: 12px; padding: 10px 16px 0; font-size: 12px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 1px; }
.keys { padding: 8px 16px 0; font-size: 11px; line-height: 1.7; color: var(--ink-3); }
.side-meta { padding: 8px 16px 14px; font-size: 11px; line-height: 1.7; color: var(--ink-3); }
.side-meta .link { margin-right: 12px; }
.link { font-size: 11px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--ink); }

.st-normal { background: var(--normal); }
.st-warning { background: var(--warning); }
.st-alarm { background: var(--alarm); }
.st-offline, .st-unknown { background: var(--offline); }

/* ── Viewport ────────────────────────────────────────── */
.viewport { position: fixed; top: var(--top); left: var(--side); right: var(--panel); bottom: 0; overflow: hidden; }
.scene-viewport { position: absolute; inset: 0; touch-action: none; }
.scene-viewport canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; outline-offset: -2px; }
.scene-viewport canvas:active { cursor: grabbing; }
.scene-markers, .building-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.view-title { position: absolute; left: 16px; top: 12px; font-size: 14px; font-weight: 600; color: var(--ink); pointer-events: none; }
.view-title small { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 10px; }
.view-bar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 6px; z-index: 6; }
.compass { display: flex; align-items: center; gap: 3px; height: 28px; padding: 0 8px 0 6px; font-size: 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.compass svg { width: 14px; height: 14px; fill: var(--ink-2); transform-origin: 50% 50%; }
#mobile-assets { display: none; }
.device-tool { display: none; }
.isolated .device-tool.available { display: block; }
.banner {
  position: absolute; left: 16px; right: 16px; top: 44px; z-index: 7;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 8px 12px; font-size: 12px; color: var(--ink);
  background: var(--alarm-bg); border: 1px solid var(--alarm); border-radius: var(--radius);
}

/* Device markers: code tag + leader + anchor point. */
.marker {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -100%); white-space: nowrap;
}
.marker .tag {
  display: flex; align-items: center; gap: 6px; padding: 1px 6px;
  font: 600 11px/18px var(--mono); letter-spacing: .3px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--ink-3); border-radius: 2px;
}
.marker .tag span { font: 400 12px/18px var(--font); letter-spacing: 0; }
.marker .stem { width: 1px; height: 14px; background: var(--ink-3); }
.marker .foot { width: 5px; height: 5px; background: var(--ink-2); border-radius: 50%; }
.marker:hover .tag { border-color: var(--ink); }
.marker.warning .tag { border-color: var(--warning); box-shadow: inset 3px 0 0 var(--warning); }
.marker.alarm .tag { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.marker.alarm .stem, .marker.alarm .foot { background: var(--alarm); }
.marker.offline .tag { color: var(--ink-3); border-style: dashed; }
.marker.selected .tag { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.marker.selected .stem, .marker.selected .foot { background: var(--accent); }
.marker.selected.alarm .tag { background: var(--alarm); border-color: var(--ink); color: #fff; }
.marker.selected { z-index: 2; }

.building-label {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  padding: 1px 6px; font-size: 12px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 2px;
}
.building-label b { font: 600 11px var(--mono); color: var(--ink); margin-right: 5px; }

.part-labels { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.part-label {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -100%); white-space: nowrap;
}
.part-label .tag { padding: 1px 6px; font-size: 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--ink-3); border-radius: 2px; }
.part-label .tag b { font: 600 11px var(--mono); margin-right: 6px; }
.part-label .stem { width: 1px; height: 22px; background: var(--ink-3); }

.loading {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  background: var(--scene); color: var(--ink-2); font-size: 14px; letter-spacing: 1px;
}
.graphics-error { position: absolute; left: 16px; right: 16px; top: 44px; z-index: 30; padding: 12px; font-size: 13px; line-height: 1.7; background: var(--alarm-bg); border: 1px solid var(--alarm); border-radius: var(--radius); }
.scene-viewport canvas { opacity: 0; transition: opacity .4s; }
.scene-ready .scene-viewport canvas { opacity: 1; }

/* ── Right inspector ─────────────────────────────────── */
.panel {
  position: fixed; right: 0; top: var(--top); bottom: 0; width: var(--panel); z-index: 15;
  background: var(--surface); border-left: 1px solid var(--rule);
  overflow-y: auto; padding: 16px 18px 20px; scrollbar-width: thin;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-head h2 { font-size: 17px; font-weight: 600; line-height: 1.35; }
.panel-head p { font: 12px var(--mono); color: var(--ink-3); margin-top: 2px; }
.back { font-size: 12px; color: var(--ink-2); padding: 2px 8px; border: 1px solid var(--rule); border-radius: var(--radius); white-space: nowrap; }
.back:hover { background: var(--surface-2); }
.status-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.status-line i { width: 8px; height: 8px; border-radius: 1px; }
.status-line .dim { color: var(--ink-3); font-size: 12px; margin-left: auto; }
.status-line.alarm #device-status { color: var(--alarm); font-weight: 600; }
.section { border-top: 1px solid var(--rule); margin-top: 16px; padding-top: 12px; }
.section h3 { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.section h3 small { font-size: 11px; font-weight: 400; }
.main-reading { display: flex; align-items: baseline; gap: 6px; }
.main-reading b { font-size: 34px; font-weight: 400; letter-spacing: -1px; line-height: 1.15; }
.main-reading small { font-size: 13px; color: var(--ink-3); }
.main-reading.alarm b { color: var(--alarm); }
.main-reading.warning b { color: var(--warning); }
.main-reading.offline b { color: var(--ink-3); }
.reading-track { position: relative; height: 4px; margin: 8px 0 6px; background: var(--surface-2); }
.reading-track > div { height: 100%; background: var(--normal); width: 0; transition: width .2s; }
.main-reading.alarm + .reading-track > div { background: var(--alarm); }
.main-reading.warning + .reading-track > div { background: var(--warning); }
.reading-track i { position: absolute; top: -3px; width: 1px; height: 10px; background: var(--ink-2); }
.caption { font-size: 12px; color: var(--ink-3); line-height: 1.6; margin-top: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 5px; font-size: 13px; margin: 8px 0 0; }
.kv dt { color: var(--ink-2); white-space: nowrap; }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
.kv.details dd { font-size: 12px; }
.kv.help { margin: 14px 0 18px; }
.kv.help dd { text-align: left; color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.kv.help dt { font-weight: 600; color: var(--ink); }
.trend-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.trend-bar .filters { margin-top: 0; }
.trend-bar .tool { height: 26px; }
.chart-wrap { position: relative; height: 96px; margin-top: 8px; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-message { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--ink-3); pointer-events: none; text-align: center; }
.chart-axis { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; }
.chart-grid { stroke: var(--rule); stroke-dasharray: 3 4; }
.chart-text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart-limit { stroke: var(--alarm); stroke-dasharray: 4 4; stroke-width: 1; }
.chart-limit-text { fill: var(--alarm); font-size: 11px; }
.chart-area { fill: var(--accent); opacity: .08; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent); }

.alarm-box { padding: 10px 12px; background: var(--alarm-bg); border-radius: var(--radius); }
.alarm-box + .alarm-box { margin-top: 6px; }
.alarm-box header { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--alarm); font-weight: 600; }
.alarm-box header span { font: 400 11px var(--mono); color: var(--ink-3); }
.alarm-box p { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.alarm-box .btn { margin-top: 8px; height: 28px; }
.alarm-box .acked { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.quiet-line { font-size: 13px; color: var(--ink-3); }

.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 32px;
  font-size: 13px; border-radius: var(--radius); border: 1px solid var(--rule); color: var(--ink);
  background: var(--surface);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn-col { display: grid; gap: 6px; margin-top: 8px; }
.demo-tools summary { font-size: 12px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.footnote { margin-top: 18px; font-size: 11px; color: var(--ink-3); }
.footnote code { font-size: 11px; }

/* ── Records (alarm / audit) ─────────────────────────── */
.data-section {
  position: fixed; top: var(--top); left: var(--side); right: 0; bottom: 0; z-index: 14;
  display: flex; flex-direction: column; padding: 16px 20px 16px;
  background: var(--surface); overflow: auto;
}
.data-mode .viewport, .data-mode .panel { display: none; }
.data-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.data-heading h1 { font-size: 17px; font-weight: 600; }
.data-heading p { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.table-filters { align-self: flex-start; margin: 12px 0 8px; }
.table-filters button { padding: 0 14px; }
.data-content { overflow: auto; }
.records-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.records-table th { position: sticky; top: 0; text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 7px 10px; background: var(--surface); border-bottom: 1px solid var(--ink-3); white-space: nowrap; }
.records-table td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; font-variant-numeric: tabular-nums; }
.records-table tr:hover td { background: var(--surface-2); }
.records-table td small { display: block; font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.records-table code { font-weight: 600; }
.sev { display: inline-block; min-width: 34px; padding: 0 5px; font-size: 12px; line-height: 20px; text-align: center; border-radius: 2px; }
.sev.alarm { background: var(--alarm); color: #fff; }
.sev.warning { border: 1px solid var(--warning); color: var(--warning); }
.table-ack { height: 26px; padding: 0 10px; font-size: 12px; border: 1px solid var(--rule); border-radius: var(--radius); }
.table-ack:hover { background: var(--surface-2); }
.empty-state { padding: 32px 4px; font-size: 13px; color: var(--ink-3); }
.empty-state strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

/* ── Overlays ────────────────────────────────────────── */
.toast-stack {
  position: fixed; left: calc(var(--side) + (100vw - var(--side) - var(--panel)) / 2); bottom: 60px; z-index: 80;
  transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none;
}
.toast { max-width: min(520px, 90vw); padding: 9px 14px; font-size: 13px; line-height: 1.5; background: var(--ink); color: var(--surface); border-radius: var(--radius); }
.toast.error { background: var(--alarm); color: #fff; }

dialog {
  width: min(440px, calc(100vw - 32px)); padding: 20px 22px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--ink-3); border-radius: var(--radius);
}
dialog::backdrop { background: rgba(20, 36, 32, .45); }
#help-dialog { width: min(560px, calc(100vw - 32px)); }
dialog h2 { font-size: 17px; font-weight: 600; margin-bottom: 8px; padding-right: 48px; }
dialog p { font-size: 13px; line-height: 1.7; color: var(--ink-2); }
dialog label { display: block; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
dialog input, dialog textarea {
  display: block; width: 100%; margin-top: 4px; padding: 6px 8px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); outline: none; resize: vertical;
}
dialog input:focus, dialog textarea:focus { border-color: var(--ink-3); }
dialog .btn.primary { margin-top: 16px; }
dialog .btn-row .btn.primary { margin-top: 0; }
dialog .btn-row { margin-top: 16px; }
.dialog-close { position: absolute; right: 14px; top: 16px; font-size: 12px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.form-error { color: var(--alarm) !important; font-size: 12px; min-height: 0; margin-top: 8px; }
.form-error:empty { display: none; }

/* Presentation: only the model. */
.photo-mode .topbar, .photo-mode .sidebar, .photo-mode .panel,
.photo-mode .view-title, .photo-mode .scene-markers, .photo-mode .building-labels, .photo-mode .part-labels { display: none !important; }
.photo-mode .viewport { inset: 0; }
.photo-mode .view-bar { opacity: .35; }
.photo-mode .view-bar:hover { opacity: 1; }
.photo-mode .toast-stack { left: 50%; }
.touring .scene-markers, .touring .building-labels { display: none; }
.isolated .building-labels, .isolated .scene-markers { display: none; }

/* ── Narrow desktop ──────────────────────────────────── */
@media (max-width: 1360px) {
  :root { --side: 224px; --panel: 312px; }
  .project span { display: none; }
  .project { min-width: 0; }
  .readout { padding: 0 10px; }
  .readout > span { font-size: 11px; }
  #export-model { display: none; }
}
@media (max-width: 1180px) {
  .readouts .readout:nth-child(3), .readout.source > span { display: none; }
  .tabs button { padding: 0 8px; }
}

/* ── Tablet / phone ──────────────────────────────────── */
@media (max-width: 900px) {
  :root { --top: 44px; --strip: 44px; --sheet: 40vh; }
  .mobile-only { display: inline-block; }
  .topbar { gap: 8px; padding: 0 10px; }
  .project strong { font-size: 14px; }
  .tabs button { padding: 0 6px; font-size: 12px; }
  .tabs button:last-child { display: none; }
  .readout { padding: 0 8px; gap: 4px; }
  .readout > span, .readouts .readout:nth-child(3), .readouts .readout:nth-child(4), .readout.source { display: none; }
  .readout > b { font-size: 14px; }
  .readouts .readout:first-child > b::before { content: "在线 "; font-size: 11px; color: var(--ink-3); font-weight: 400; }
  #open-alarms > b::before { content: "告警 "; font-size: 11px; color: var(--ink-3); font-weight: 400; }
  .tools .tool:not(#login-button) { display: none; }
  #login-button { display: none; }

  .sidebar {
    inset: var(--top) 0 auto 0; width: auto; height: var(--strip);
    flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid var(--rule); scrollbar-width: none;
  }
  .side-group { display: contents; }
  .side-group > h2, .keys, .legend, .side-meta { display: none; }
  .mode-switch { flex: none; margin-left: 10px; }
  .mode-switch button { padding: 0 12px; }
  .side-toggles { display: flex; flex-direction: row; flex: none; margin: 0 10px 0 8px; }
  .check { height: 30px; font-size: 12px; white-space: nowrap; }
  #high-quality, #tour-button, #layer-pipes { display: none; }
  .assets { display: none; }
  .assets-open .assets {
    position: fixed; top: calc(var(--top) + var(--strip)); left: 0; right: 0; bottom: var(--sheet); z-index: 25;
    display: flex; background: var(--surface); padding: 12px; border-bottom: 1px solid var(--rule);
  }
  .assets-open .assets > h2 { display: flex; }

  .viewport { top: calc(var(--top) + var(--strip)); left: 0; right: 0; bottom: var(--sheet); }
  .panel { top: auto; left: 0; width: auto; height: var(--sheet); border-left: 0; border-top: 1px solid var(--rule); padding: 12px 14px 16px; }
  .panel-hidden .panel { display: none; }
  .panel-hidden .viewport { bottom: 0; }
  #close-inspector { display: none; }
  .view-title { font-size: 13px; left: 10px; top: 8px; }
  .compass { display: none; }
  #mobile-assets { display: block; }
  .view-bar { bottom: 8px; }
  .data-section { left: 0; top: var(--top); padding: 12px; z-index: 22; }
  .records-table { min-width: 620px; }
  .toast-stack { left: 50%; bottom: calc(var(--sheet) + 50px); }
  .main-reading b { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
