:root {
  --bg: #1b1d21;
  --panel: rgba(28, 30, 35, 0.92);
  --panel-solid: #22252b;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8e6e1;
  --muted: #9a9890;
  --accent: #e0b25a;
  --accent-ink: #1b1d21;
  --danger: #e0715a;
  --ok: #7cc49a;
  --field: rgba(255, 255, 255, 0.06);
  --radius: 7px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 13px/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

button { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 5px 9px; cursor: pointer; white-space: nowrap; }
button:hover { background: rgba(255, 255, 255, 0.12); }
button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger:hover { background: var(--danger); color: var(--accent-ink); }
button:disabled { opacity: 0.4; cursor: default; }
button.icon { padding: 2px 8px; font-size: 16px; line-height: 1; }
input { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 5px 7px; min-width: 0; width: 100%; }
input:focus { outline: 1px solid var(--accent); }
code { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
[hidden] { display: none !important; }

/* sidebar ------------------------------------------------------------- */
#sidebar { position: fixed; top: 10px; left: 10px; bottom: 10px; width: 300px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); z-index: 5; }
#sidebar.collapsed { display: none; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 9px 10px 8px 12px; border-bottom: 1px solid var(--line); }
.side-head .brand { font-weight: 700; letter-spacing: 0.02em; }
.side-head #room-status { flex: 1; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-body { overflow-y: auto; padding: 4px 10px 12px; flex: 1; }
details { border-bottom: 1px solid var(--line); padding: 6px 0 8px; }
details:last-child { border-bottom: 0; }
summary { cursor: pointer; font-weight: 600; padding: 3px 0 6px; user-select: none; }
.floating { position: fixed; top: 10px; left: 10px; z-index: 5; background: var(--panel); }

.row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.row .grow { flex: 1; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.grid3 label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
.grid3 .span2 { grid-column: span 2; align-self: end; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.list li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius); cursor: pointer; }
.list li:hover { background: var(--field); }
.list li.sel { background: rgba(224, 178, 90, 0.18); }
.list .thumb { width: 38px; height: 38px; border-radius: 5px; background: var(--field); flex: none; object-fit: cover;
  display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 12px; }
.list .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list .meta .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta .dims { font-size: 11.5px; color: var(--muted); }
.list .badge { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.list.compact li { padding: 3px 6px; }
.list.compact .x { margin-left: auto; padding: 0 6px; font-size: 12px; }

.chips { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chips li button { padding: 2px 8px; font-size: 12px; }

/* toolbar + selection bar --------------------------------------------- */
#toolbar { position: fixed; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 5; padding: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.seg button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

#selbar { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center;
  padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; z-index: 5; max-width: calc(100vw - 340px); }
#sel-name { font-weight: 600; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* overlays ------------------------------------------------------------ */
.tag { position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: none; z-index: 3;
  background: rgba(20, 21, 24, 0.86); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.tag .dims { color: var(--muted); margin-left: 6px; }
.tag.measure { transform: translate(-50%, -50%); border-color: var(--accent); color: var(--accent); font-weight: 600; }
#mode-hint { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 6px 12px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-weight: 600; }
#help { padding: 8px 12px 10px; border-top: 1px solid var(--line); line-height: 1.5; }
#help b { color: var(--text); font-weight: 600; }
#toasts { position: fixed; right: 10px; top: 60px; display: flex; flex-direction: column; gap: 6px; z-index: 8; width: 340px; }
.toast { background: var(--panel-solid); border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 6px;
  padding: 7px 10px; cursor: pointer; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); word-break: break-word; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
#drop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(15, 16, 18, 0.7);
  border: 3px dashed var(--accent); font-size: 18px; pointer-events: none; }
