:root {
  --bg: #17181c;
  --panel: #23252b;
  --panel2: #2d3037;
  --text: #eceae6;
  --muted: #9a9ca3;
  --accent: #4f8cff;
  --accent-text: #fff;
  --danger: #ff6b5e;
  --line: #3a3d45;
  --plan-floor: #f3efe7;
  --plan-wall: #2b2b2b;
  --plan-text: #333;
  --plan-muted: #666;
  --plan-window: #2a6df4;
  --plan-door: #c2410c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; }
[hidden] { display: none !important; }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-height: 44px; cursor: pointer;
}
button:active { filter: brightness(1.2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.big { font-size: 1.15rem; padding: 16px 28px; width: 100%; max-width: 360px; }
button.icon { background: none; border: none; font-size: 1.6rem; min-width: 44px; padding: 4px 8px; }
button.link { background: none; border: none; color: var(--accent); text-decoration: underline; }
button.danger { color: var(--danger); }
button.chip { min-height: 36px; padding: 6px 12px; border-radius: 18px; background: rgba(35,37,43,.85); }
button:disabled { opacity: .45; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.bar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar h1 { margin: 0; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar h1:first-child { flex: 1; padding-left: 4px; }
.scroll { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
main.scroll { padding: 16px; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0 8px; text-align: center; }
.section { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 24px 0 8px; }

.rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.rooms li { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; }
.rooms .thumb { aspect-ratio: 4/3; background: var(--plan-floor); display: flex; align-items: center; justify-content: center; padding: 8px; }
.rooms .thumb svg { width: 100%; height: 100%; }
.rooms .meta { padding: 8px 10px; }
.rooms .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; padding: 8px 12px; background: var(--panel); }
.tabs button { flex: 1; min-height: 36px; padding: 6px; border-radius: 10px; background: none; border-color: transparent; color: var(--muted); }
.tabs button.on { background: var(--panel2); color: var(--text); border-color: var(--line); }
.tab-body { flex: 1; position: relative; min-height: 0; }
.viewer { position: absolute; inset: 0; touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.float-row { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; }
.plan { background: var(--plan-floor); min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 12px; }
.plan svg { width: 100%; height: auto; max-height: calc(100vh - 220px); }
#info { padding: 16px; }
#info table { width: 100%; border-collapse: collapse; }
#info td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
#info td:last-child { text-align: right; color: var(--muted); }
#info h3 { margin: 20px 0 6px; font-size: 1rem; }
#info .op { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
#info .op button { min-height: 32px; padding: 4px 10px; }
.actions { display: flex; gap: 8px; padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--line); }
.actions button { flex: 1; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.card { background: var(--panel); padding: 20px; border-radius: 16px; min-width: 260px; text-align: center; }
progress { width: 100%; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; width: min(420px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin: 0 0 12px; font-size: 1.15rem; }
dialog form > button { display: block; width: 100%; margin: 6px 0; text-align: left; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
dialog .row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
dialog select, dialog input:not([type=checkbox]), dialog textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; width: 100%; }
dialog .row select { width: auto; margin-left: auto; }
dialog input[type=checkbox] { width: 22px; height: 22px; }
hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #000d; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; max-width: calc(100vw - 32px); }

/* ---- AR overlay ---- */
#ar-overlay { position: fixed; inset: 0; z-index: 100; color: #fff; pointer-events: none; font-size: 15px; }
#ar-overlay .ar-panel, #ar-overlay button { pointer-events: auto; }
.ar-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: linear-gradient(#000a, #0000); }
#ar-step { flex: 1; font-weight: 600; }
#ar-snaps { background: #0008; padding: 4px 10px; border-radius: 12px; }
#ar-hint { position: absolute; top: calc(58px + env(safe-area-inset-top)); left: 12px; right: 12px; background: #000a; padding: 10px 12px; border-radius: 12px; text-align: center; }
#ar-cross { position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; }
#ar-cross::before, #ar-cross::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 2px #000; }
#ar-cross::before { left: 17px; top: 0; width: 2px; height: 36px; }
#ar-cross::after { top: 17px; left: 0; height: 2px; width: 36px; }
#ar-cross.flash { animation: flash .35s; }
@keyframes flash { from { transform: scale(1.8); opacity: .3; } to { transform: scale(1); opacity: 1; } }
#ar-readout { position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%); background: #000b; padding: 4px 12px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.ar-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(#0000, #000a); }
.ar-bottom button { background: #000a; border-color: #fff4; color: #fff; }
.ar-bottom button.primary { background: var(--accent); border-color: var(--accent); min-width: 160px; }
.seg { display: flex; border: 1px solid #fff4; border-radius: 12px; overflow: hidden; pointer-events: auto; }
.seg button { border: none; border-radius: 0; background: #000a; }
.seg button.on { background: #fff; color: #000; }
#ar-map { position: absolute; right: 12px; top: calc(140px + env(safe-area-inset-top)); width: 120px; height: 120px; border-radius: 12px; }
