:root {
  --bg: #faf8f4;
  --ink: #2b2925;
  --muted: #7a746b;
  --line: #e4dfd5;
  --accent: #8c5f62;
  --gold: #e8b04b;
  --radius: 10px;
  --panel-w: 360px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #dfe6ea; color: var(--ink);
  font: 14px/1.45 Inter, system-ui, sans-serif; }
#cesium { position: fixed; inset: 0; }
.cesium-viewer-bottom { left: calc(var(--panel-w) + 16px) !important; }
button { font: inherit; cursor: pointer; }

/* Panel */
#panel { position: fixed; top: 12px; left: 12px; bottom: 12px; width: var(--panel-w); background: var(--bg);
  border-radius: 14px; box-shadow: 0 6px 30px rgba(0,0,0,.18); overflow-y: auto; padding: 18px 18px 14px;
  transition: transform .25s ease; z-index: 5; }
#panel header h1 { font: 600 30px/1.1 "Cormorant Garamond", serif; margin: 0; letter-spacing: .3px; }
.sub { margin: 4px 0 8px; color: var(--muted); }
.badge { display: inline-block; margin: 0; padding: 3px 9px; border-radius: 99px; background: #ece7dc; font-size: 12px; color: var(--muted); }
.badge.google { background: #e3efe6; color: #3d6b4a; }
section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.hint, .muted { color: var(--muted); font-size: 12px; }
footer { margin-top: 16px; font-size: 11px; color: var(--muted); }
#panel-toggle { display: none; }

/* Unit stack */
.stack { display: grid; grid-template-columns: 26px 1fr 1fr 8px 1fr 1fr 1fr; gap: 3px; font-size: 11px; }
.stack .lvl { color: var(--muted); display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; }
.stack .hdr { color: var(--muted); text-align: center; font-size: 10px; letter-spacing: .8px; text-transform: uppercase; padding-bottom: 2px; }
.stack .cell { border: 0; border-radius: 4px; padding: 6px 2px; min-height: 30px; color: #1f1d1a; background: var(--c);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  outline: 2px solid transparent; outline-offset: 1px; transition: outline-color .15s, transform .1s; }
.stack .cell small { opacity: .75; font-size: 10px; }
.stack .cell.dark { color: #fff; }
.stack .cell:hover { transform: translateY(-1px); }
.stack .cell.sel { outline-color: var(--gold); box-shadow: 0 0 0 4px rgba(232,176,75,.35); }
.stack .void { border: 1px dashed var(--line); border-radius: 4px; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 10px; text-align: center; }

.stack .cell.sold small { opacity: .9; font-weight: 600; letter-spacing: .5px; }
.legend { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.legend .key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .key.sold { background: #c0392b; }
.legend .key.sel { background: var(--gold); margin-left: 10px; }
.sold-tag[hidden] { display: none; }
.sold-tag { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 99px;
  background: #c0392b; color: #fff; font: 600 11px/1.4 Inter, sans-serif; letter-spacing: .6px; text-transform: uppercase; }

.disclaimer { font-size: 11px; line-height: 1.5; color: var(--muted); margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
details .disclaimer { border-top: 0; padding-top: 0; margin: 0 0 8px; }
.guide-card .disclaimer { margin: 0 0 14px; }

.agents-only { display: inline-block; margin: 0 0 8px; padding: 3px 9px; border-radius: 6px; background: #f39200;
  color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.disclaimer.operator + .disclaimer { border-top: 0; padding-top: 0; margin-top: 6px; }

/* Card */
.card-head { display: flex; gap: 10px; align-items: center; }
.swatch { width: 14px; height: 40px; border-radius: 4px; flex: none; }
.card-head h3 { margin: 0; font: 600 26px/1 "Cormorant Garamond", serif; }
.card-head p { margin: 2px 0 0; }
.facts { display: grid; grid-template-columns: 108px 1fr; gap: 4px 10px; margin: 12px 0 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.est { font-size: 12px; background: #fbf1dc; border-radius: 6px; padding: 6px 8px; margin: 0 0 8px; }
.plan-thumb { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.plan-thumb img { width: 100%; height: 220px; object-fit: contain; display: block; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions button, #viewbar button { flex: 1; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }

.walk-link { display: block; margin-top: 8px; padding: 9px 10px; border-radius: 8px; text-align: center; text-decoration: none;
  color: var(--ink); background: #f1ece2; border: 1px solid var(--line); font-weight: 500; }
.walk-link:hover { border-color: var(--ink); }

/* Toggles */
.toggle { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; }
#sun-controls { padding: 4px 0 0 24px; }
#sun-controls .row { display: flex; gap: 8px; align-items: center; }
#sun-controls input[type=range] { flex: 1; }
#sun-controls select { margin-top: 6px; width: 100%; padding: 5px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }

/* First-person bar */
#viewbar { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: rgba(250,248,244,.96);
  border-radius: 14px; box-shadow: 0 6px 30px rgba(0,0,0,.25); padding: 12px 14px; z-index: 6; min-width: 340px; max-width: calc(100vw - 32px); }
.v-top { display: flex; gap: 10px; align-items: center; }
.v-title { flex: 1; text-align: center; }
#viewbar strong { font: 600 24px/1 "Cormorant Garamond", serif; display: block; }
#viewbar #v-sub { color: var(--muted); font-size: 12px; }
#viewbar .mini { flex: 0 0 42px; height: 42px; }
#viewbar .mini:disabled { opacity: .35; cursor: default; }
#v-lens { flex: 0 0 auto !important; }
.v-controls { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.v-controls #v-left, .v-controls #v-right { flex: 0 0 42px; }
#v-heading { min-width: 44px; text-align: center; font-weight: 600; }
.v-block { margin: 8px 0 0; padding: 6px 9px; border-radius: 8px; background: #fbf1dc; font-size: 12px; text-align: center; }
.v-hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); text-align: center; }
body.fp #panel { transform: translateX(calc(-100% - 24px)); }
body.fp #cesium { cursor: grab; }

/* Tooltip */
#tooltip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 12px; z-index: 7; transform: translate(12px, -28px); white-space: nowrap; }

/* Lightbox */
#lightbox { position: fixed; inset: 0; background: rgba(20,18,16,.8); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 8px; }
#lb-close { position: absolute; top: 12px; right: 16px; font-size: 32px; color: #fff; background: none; border: 0; }

/* Calibration */
#calib { position: fixed; top: 12px; right: 12px; width: 240px; background: var(--bg); border-radius: 12px; padding: 12px; z-index: 8; box-shadow: 0 6px 30px rgba(0,0,0,.18); }
#calib label { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; font-size: 12px; }
#calib input { width: 90px; }
#calib textarea { width: 100%; font: 11px monospace; }

/* Chips, groups, notes */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-size: 12px; }
.chips button:hover { border-color: var(--ink); }
details.group { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
details.group summary { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details.group summary::after { content: "+"; font-size: 16px; line-height: 1; }
details.group[open] summary::after { content: "–"; }
details.group[open] summary { margin-bottom: 8px; }
.notes { padding-left: 18px; margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.notes li { margin-bottom: 4px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-size: 12px; }
button.mini { padding: 4px 0; width: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
#sun-controls .row { margin-bottom: 6px; }
#sun-date { flex: 1; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.sun-facts { grid-template-columns: 118px 1fr; margin: 6px 0; font-size: 13px; }
.fac-list { margin: 4px 0 6px; padding-left: 0; list-style: none; font-size: 12px; }
.fac-list li { display: flex; gap: 8px; align-items: center; padding: 2px 0; cursor: pointer; }
.fac-list li span { flex: none; width: 18px; height: 18px; border-radius: 50%; background: #2f6f73; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; }

.siteplan { margin-bottom: 8px; }
.siteplan select { width: 100%; margin-top: 4px; padding: 5px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font: inherit; }
.siteplan .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.siteplan input[type=range] { flex: 1; }

/* Compass */
#compass { position: fixed; top: 16px; right: 16px; width: 58px; height: 58px; z-index: 6; cursor: pointer; filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }
#compass circle { fill: rgba(250,248,244,.94); stroke: var(--line); }
#compass .n { fill: #b0473c; }
#compass .s { fill: #9a948a; }
#compass .lbl { font: 600 8px Inter, sans-serif; fill: var(--ink); text-anchor: middle; }
#compass .lbl.sm { font-size: 7px; fill: var(--muted); }

/* Pinned info popup */
#info { position: fixed; z-index: 7; background: var(--bg); color: var(--ink); border-radius: 10px; padding: 8px 12px; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,.2); transform: translate(-50%, calc(-100% - 14px)); max-width: 260px; pointer-events: none; }
#info strong { display: block; }
#info span { color: var(--muted); font-size: 12px; }

/* Guide */
#guide { position: fixed; inset: 0; z-index: 30; background: rgba(20,18,16,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
#guide[hidden] { display: none; }
.guide-card { background: var(--bg); border-radius: 16px; padding: 22px 24px; max-width: 440px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.guide-card h2 { font: 600 28px/1.1 "Cormorant Garamond", serif; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0 0 12px; }
.guide-card ol { padding-left: 20px; margin: 0 0 12px; }
.guide-card li { margin-bottom: 8px; }
.guide-card button { width: 100%; padding: 11px; border-radius: 10px; }

/* Phone: panel becomes a bottom sheet */
@media (max-width: 720px) {
  :root { --panel-w: 100vw; }
  .cesium-viewer-bottom { left: 8px !important; }
  /* The map fills only the space above the bottom sheet, so the building stays centred. */
  #cesium { bottom: calc(46vh - 14px); }
  body.sheet-collapsed #cesium, body.fp #cesium { bottom: 0; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 46vh; border-radius: 16px 16px 0 0; padding: 22px 16px 16px; }
  #panel.collapsed { transform: translateY(calc(100% - 64px)); }
  #panel-toggle { display: block; position: absolute; top: 0; left: 0; right: 0; height: 22px; border: 0; background: none; }
  #panel-toggle span { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto; }
  body.fp #panel { transform: translateY(110%); }
  #viewbar { bottom: 16px; min-width: 0; width: calc(100vw - 32px); }
  #calib { top: 8px; right: 8px; }
  #compass { top: 10px; right: 10px; width: 48px; height: 48px; }
  .v-controls { flex-wrap: wrap; }
}
