/* Layout: full-bleed 3D scene; title top-left, room schedule top-right, view dock along the bottom. */
:root {
  --ground: #e9eee9;
  --panel: rgba(247, 249, 246, 0.88);
  --panel-solid: #f7f9f6;
  --ink: #17262a;
  --muted: #5a6a68;
  --line: rgba(23, 38, 42, 0.13);
  --accent: #1d6a61;
  --accent-ink: #ffffff;
  --hover: rgba(29, 106, 97, 0.09);
  --zone-service: #dbe8df;
  --zone-wet: #e6ebed;
  --zone-living: #ffffff;
  --zone-outdoor: #e9e2d4;
  --swatch-edge: rgba(23, 38, 42, 0.55);
  --shadow: 0 10px 30px rgba(18, 36, 40, 0.14), 0 1px 2px rgba(18, 36, 40, 0.08);

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --top: calc(env(safe-area-inset-top, 0px) + 16px);
  --bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0e1517;
    --panel: rgba(16, 25, 28, 0.86);
    --panel-solid: #111b1e;
    --ink: #e5eeec;
    --muted: #9cb0ad;
    --line: rgba(229, 238, 236, 0.13);
    --accent: #63b8ab;
    --accent-ink: #08201c;
    --hover: rgba(99, 184, 171, 0.14);
    --zone-service: #2d4637;
    --zone-wet: #34424a;
    --zone-living: #d9dfdd;
    --zone-outdoor: #5a5243;
    --swatch-edge: rgba(229, 238, 236, 0.5);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0e1517;
  --panel: rgba(16, 25, 28, 0.86);
  --panel-solid: #111b1e;
  --ink: #e5eeec;
  --muted: #9cb0ad;
  --line: rgba(229, 238, 236, 0.13);
  --accent: #63b8ab;
  --accent-ink: #08201c;
  --hover: rgba(99, 184, 171, 0.14);
  --zone-service: #2d4637;
  --zone-wet: #34424a;
  --zone-living: #d9dfdd;
  --zone-outdoor: #5a5243;
  --swatch-edge: rgba(229, 238, 236, 0.5);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.45 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-font-smoothing: antialiased;
}

.scene { position: fixed; inset: 0; }
.scene canvas { display: block; touch-action: none; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }

/* ---------- panels ---------- */

.brand, .schedule, .bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

.brand {
  position: fixed;
  top: var(--top);
  left: var(--gutter-l);
  max-width: min(360px, calc(100vw - 180px));
  padding: 14px 18px 13px;
  display: grid;
  gap: 4px;
}
.eyebrow {
  margin: 0;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.back {
  justify-self: start;
  margin-bottom: 4px;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--hover);
  color: var(--accent);
  font: 600 12px/1.2 var(--font-body);
  text-decoration: none;
}
.back:hover { background: var(--accent); color: var(--accent-ink); }
.brand h1 {
  margin: 0;
  font: 700 26px/1.05 var(--font-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.meta {
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font: 400 12px/1.3 var(--font-mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- room schedule ---------- */

.schedule {
  position: fixed;
  top: var(--top);
  right: var(--gutter-r);
  width: 300px;
  max-height: calc(100% - var(--top) - 170px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.schedule summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  font: 600 13px/1.2 var(--font-body);
}
.schedule summary::-webkit-details-marker { display: none; }
.schedule summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s;
}
.schedule[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.schedule .count {
  margin-left: auto;
  font: 400 11px/1 var(--font-mono);
  color: var(--muted);
}
.schedule[open] summary { border-bottom: 1px solid var(--line); }

.rooms {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
}
.rooms button {
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  grid-template-areas: "sw name area" "sw dim area";
  column-gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.rooms button:hover { background: var(--hover); }
.rooms button[aria-pressed="true"] { background: var(--hover); box-shadow: inset 0 0 0 1px var(--accent); }
.swatch {
  grid-area: sw;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--swatch-edge);
}
.swatch[data-zone="service"] { background: var(--zone-service); }
.swatch[data-zone="wet"] { background: var(--zone-wet); }
.swatch[data-zone="living"] { background: var(--zone-living); }
.swatch[data-zone="outdoor"] { background: var(--zone-outdoor); }
.rname { grid-area: name; font-weight: 500; }
.rdim { grid-area: dim; font: 400 11px/1.3 var(--font-mono); color: var(--muted); }
.rarea {
  grid-area: area;
  font: 500 17px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.rarea small { font: 400 11px var(--font-mono); color: var(--muted); }

.note {
  margin: 0;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- bottom dock ---------- */

.dock {
  position: fixed;
  left: var(--gutter-l);
  right: var(--gutter-r);
  bottom: var(--bottom);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.dock > * { pointer-events: auto; max-width: 100%; }

.hint {
  margin: 0;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--panel);
  color: var(--muted);
  font: 400 11.5px/1.3 var(--font-mono);
  pointer-events: none;
}

.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}
.bar::-webkit-scrollbar { display: none; }

.views { display: flex; gap: 2px; }

.views button, .seg button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: 500 13px/1 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}
.views button:hover, .seg button:hover { background: var(--hover); }
.views button[aria-pressed="true"], .seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.dir {
  font: 500 10px/1 var(--font-mono);
  opacity: 0.6;
}

.compass {
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.compass svg { width: 30px; height: 30px; overflow: visible; }
.compass .n { fill: var(--accent); }
.compass .s { fill: var(--muted); opacity: 0.45; }
.compass text { font: 600 6px var(--font-mono); fill: var(--ink); }

.settings { gap: 4px; }
.seg { display: flex; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1.5px var(--panel-solid); }
.dot.teal { background: #1d6a61; }
.dot.terracotta { background: #c5573c; }

.toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 10px;
  font: 500 13px/1 var(--font-body);
  cursor: pointer;
  white-space: nowrap;
}
.toggle:hover { background: var(--hover); }
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: 26px;
  height: 15px;
  border-radius: 99px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--panel-solid);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(11px); }

button:focus-visible, .toggle input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 3D room labels ---------- */

.room-label {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  transition: transform 0.2s;
}
.room-label b {
  font: 600 10.5px/1.2 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.room-label span { font: 400 10.5px/1.2 var(--font-mono); color: var(--muted); }
.room-label.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.noscript {
  position: fixed;
  inset: 40% 16px auto;
  text-align: center;
}

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  .brand { padding: 10px 13px; max-width: calc(100vw - 150px - var(--gutter-l) - var(--gutter-r)); }
  .brand h1 { font-size: 19px; }
  .meta span:last-child { display: none; }
  .schedule { width: auto; max-width: calc(100vw - var(--gutter-l) - var(--gutter-r)); }
  .schedule[open] {
    left: var(--gutter-l);
    z-index: 2;
    max-height: calc(100% - var(--top) - 150px);
  }
  .schedule .count { display: none; }
  .hint { display: none; }
  .dock { align-items: stretch; }
  .views button, .seg button { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
