:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #15191e;
  --muted: #69727d;
  --line: #e2e5e9;
  --accent: #1f7a6d;
  --accent-text: #ffffff;
  --accent-soft: #e3f2ef;
  --danger: #c2402c;
  --ok: #2e9d57;
  --warn: #c48a12;
  --viewer-bg: #12161b;
  --plan-bg: #fbfaf7;
  --plan-floor: #f3ead9;
  --plan-grid: #e4d8c3;
  --plan-wall: #2b2f36;
  --plan-dim: #5b6370;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --card: #171d24;
    --text: #e7ebef;
    --muted: #8d98a5;
    --line: #26303a;
    --accent: #3fb8a3;
    --accent-text: #06201b;
    --accent-soft: #15302b;
    --danger: #ef6b55;
    --viewer-bg: #0b0e12;
    --plan-bg: #12161b;
    --plan-floor: #1f2a2b;
    --plan-grid: #2a3838;
    --plan-wall: #e7ebef;
    --plan-dim: #9aa4ae;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --card: #171d24; --text: #e7ebef; --muted: #8d98a5; --line: #26303a;
  --accent: #3fb8a3; --accent-text: #06201b; --accent-soft: #15302b; --danger: #ef6b55; --viewer-bg: #0b0e12;
  --plan-bg: #12161b; --plan-floor: #1f2a2b; --plan-grid: #2a3838; --plan-wall: #e7ebef; --plan-dim: #9aa4ae;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 960px; margin: 0 auto; padding: 0 16px 24px; display: grid; gap: 14px; }

.topbar { max-width: 960px; margin: 0 auto; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 28px; color: var(--accent); line-height: 1; }
h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
h1 .cn { font-weight: 500; color: var(--muted); margin-left: 4px; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }
h2 { font-size: 16px; margin: 0 0 8px; }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.online .dot { background: var(--ok); }
.status.offline .dot { background: var(--danger); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { margin: 4px 0 12px; color: var(--muted); font-size: 13.5px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 12px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 8px 4px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }
.model-field { margin-bottom: 10px; }
select, input[type="password"], input[type="text"] {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
.model-field select { width: 100%; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.wide { width: 100%; margin-top: 10px; }
.file-name { margin: 8px 0 0; font-size: 13px; overflow-wrap: anywhere; }

.cam-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; margin-bottom: 10px; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-badge { position: absolute; top: 8px; left: 8px; background: rgba(194,64,44,.9); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.share { font-size: 13px; overflow-wrap: anywhere; }
.share a { color: var(--accent); }

.progress { margin-top: 12px; padding: 10px; border-radius: 10px; background: var(--accent-soft); }
.progress-text { font-size: 13.5px; margin-bottom: 6px; }
.bar { height: 6px; background: rgba(127,127,127,.2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.thumbs { display: flex; gap: 4px; overflow-x: auto; margin-top: 8px; }
.thumbs img { height: 44px; border-radius: 4px; flex: none; }

.viewer-card { padding: 0; overflow: hidden; }
.viewer { position: relative; height: min(62vh, 560px); background: var(--viewer-bg); touch-action: none; }
.viewer canvas { width: 100% !important; height: 100% !important; display: block; }
.viewer-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #9aa4ae; font-size: 14px; pointer-events: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px 0; }
.toolbar input[type="range"] { width: 110px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
#resultInfo { padding: 6px 14px 12px; margin: 0; }

.watch { border-color: var(--accent); background: var(--accent-soft); display: flex; gap: 8px; flex-wrap: wrap; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; border-top: 1px solid var(--line); padding-top: 6px; }
.history li:first-child { border-top: 0; padding-top: 0; }
.foot { text-align: center; padding: 8px 16px 24px; }

.rtabs { margin: 10px 14px 0; }
.rtab { border: 0; background: transparent; color: var(--muted); padding: 8px 4px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.rtab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.plan { height: min(62vh, 560px); margin: 10px 14px 0; border-radius: 10px; overflow: hidden; background: var(--plan-bg); border: 1px solid var(--line); }
.plan svg { width: 100%; height: 100%; display: block; }
.plan-empty { height: 100%; display: grid; place-content: center; color: var(--muted); padding: 16px; text-align: center; }
.viewer-card .viewer { margin-top: 10px; }
.measure { padding: 10px 14px 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.tile { background: var(--bg); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.warnings { margin: 6px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.measure .muted.small { margin: 8px 0 0; }
