/* MIKAI ARCHITECT — warm, residential, Scandinavian */

:root {
  --ink: #2b2824;
  --ink-soft: #6a635a;
  --paper: #f7f1e8;
  --paper-2: #efe7db;
  --line: #ddd4c6;
  --accent: #c46a4a;
  --accent-ink: #fffaf5;
  --sage: #6d7f62;
  --shadow: 0 10px 30px rgba(60, 44, 28, 0.10);
  --radius: 14px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #d8cfc3;
}

#app {
  position: relative;
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
}

#stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: grab;
  touch-action: none;
}

#view.tool-draw { cursor: crosshair; }
#view.tool-shape { cursor: crosshair; }
#view.tool-plan { cursor: crosshair; }
#view.tool-wall,
#view.tool-curve,
#view.tool-line {
  cursor: url("cursor-pencil.svg") 2 22, url("cursor-pencil.svg") 2 22, crosshair;
}
#view.tool-circle,
#view.tool-offset { cursor: crosshair; }
#view.tool-orbit { cursor: grab; }
#view.tool-push { cursor: ns-resize; }
#view.tool-paint { cursor: cell; }
#view.tool-select { cursor: default; }
#view.tool-walk { cursor: default; }
#view.tool-library { cursor: copy; }
#view.orbiting { cursor: grabbing; }

#siteStart {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 40, 36, 0.28);
  pointer-events: auto;
}
#siteStart[hidden] { display: none !important; }
.site-start-card {
  width: min(420px, 92vw);
  padding: 22px 22px 18px;
  border-radius: 16px;
  background: #f7f1e8;
  box-shadow: 0 16px 40px rgba(40, 30, 20, 0.22);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.site-start-card h2 { margin: 0 0 4px; font-size: 20px; }
.site-start-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; padding: 14px 14px;
  border: 1px solid #ddd4c6; border-radius: 12px; background: #fffaf5;
  cursor: pointer; font: inherit; color: inherit;
}
.site-start-btn:hover { border-color: #2b2824; }
.site-start-btn strong { font-size: 15px; }
.site-start-btn span { font-size: 12px; color: #6a635a; }

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand img { display: block; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand-text span {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(72vw, 920px);
}

.place-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  background: rgba(247, 241, 232, 0.96);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.place-bar > span {
  font-weight: 650;
  letter-spacing: 0.01em;
}
.place-bar input {
  width: 200px;
  max-width: 42vw;
  border: 1px solid #c8c0b4;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
}
.place-bar input:focus {
  outline: none;
  border-color: #d2b8a4;
}
.place-bar .pill {
  box-shadow: none;
  padding: 6px 12px;
}

.site-dem-card {
  background: var(--paper-2);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
}
.site-dem-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}
.site-dem-card p {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.site-dem-card .site-dem-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.site-dem-card .site-dem-pin {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #c8c0b4;
  background: #fff;
  font: 13px/1.3 sans-serif;
}

@media (max-width: 900px) {
  .top-actions {
    max-width: calc(100vw - 32px);
  }
  .place-bar {
    flex-wrap: wrap;
    border-radius: 16px;
  }
  .place-bar input {
    width: 200px;
  }
}

.pill {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(247, 241, 232, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.pill:hover:not(:disabled) { background: #fffaf3; }
.pill.active { background: #fff; border-color: #e4d5c4; box-shadow: inset 0 0 0 1px #f3e6d6; }
.pill:disabled { opacity: 0.45; cursor: default; }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.toggle input { accent-color: var(--accent); }

.rail {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  max-height: calc(100% - 140px);
  overflow-y: auto;
}

.tool {
  appearance: none;
  width: 132px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  border-radius: 14px;
  padding: 8px 10px 7px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  text-align: left;
}

.tool svg {
  width: 22px;
  height: 22px;
}

.tool:hover:not(:disabled) { background: rgba(255, 250, 243, 0.9); }
.tool.active {
  background: #fff;
  border-color: #e4d5c4;
  box-shadow: inset 0 0 0 1px #f3e6d6;
}
.tool.walk.active {
  background: #f8ece4;
  border-color: #e8c4b4;
}
#toolWalk.walk-on,
body.walking #toolWalk.walk-on {
  background: #f8ece4;
  border-color: #e8c4b4;
  box-shadow: inset 0 0 0 1px #f3e6d6;
}
.tool.soon {
  opacity: 0.42;
  cursor: default;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  padding-top: 12px;
}

.palette {
  position: absolute;
  left: 172px;
  top: 50%;
  transform: translateY(-18%);
  z-index: 5;
  width: 248px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 14px;
  background: rgba(247, 241, 232, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.palette p {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.tex-scale {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
}
.tex-scale label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-soft);
}
.tex-scale input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.sculpt-scale {
  position: absolute;
  left: 172px;
  top: 50%;
  transform: translateY(-18%);
  z-index: 5;
  width: 196px;
  padding: 12px 14px 10px;
  background: rgba(247, 241, 232, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sculpt-scale[hidden] { display: none !important; }
.sculpt-scale label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink);
}
.sculpt-scale input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.sculpt-scale p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.swatch {
  appearance: none;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(60, 44, 28, 0.12);
}

.swatch.active { border-color: var(--ink); }
.swatch.tex {
  background-size: cover;
  background-position: center;
}
.swatch span {
  display: none;
}

.plan-bar {
  position: absolute;
  left: 172px;
  bottom: 64px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(247, 241, 232, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  max-width: min(880px, calc(100% - 200px));
}
.plan-bar[hidden] { display: none; }
.plan-bar .pill {
  padding: 6px 12px;
  font-size: 12px;
  box-shadow: none;
}
.plan-bar .pill.active {
  background: #fff;
  border-color: #e4d5c4;
  box-shadow: inset 0 0 0 1px #f3e6d6;
}
.plan-bar .plan-note {
  font-size: 11px;
  color: var(--ink-soft);
  padding: 0 6px;
}
.plan-opacity {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 0 4px;
}
.plan-opacity input[type="range"] {
  width: 72px;
  accent-color: var(--accent);
}
.plan-size {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 0 4px;
}
.plan-size input[type="number"] {
  width: 58px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}


.shape-bar {
  position: absolute;
  left: 172px;
  bottom: 118px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(247, 241, 232, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  max-width: min(720px, calc(100% - 200px));
}
.shape-bar[hidden] { display: none; }
.shape-bar .shape-kind {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
  padding: 0 8px 0 4px;
}
.shape-bar .plan-size input[type="number"] {
  width: 58px;
}


.hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 9px 16px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--ink-soft);
  pointer-events: none;
  white-space: nowrap;
}

.coach {
  position: absolute;
  left: 50%;
  bottom: 68px;
  transform: translateX(-50%);
  z-index: 6;
  padding: 12px 18px;
  background: #2b2824;
  color: #f7f1e8;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.coach::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  background: #2b2824;
  transform: translateX(-50%) rotate(45deg);
}

.dim-readout {
  position: absolute;
  z-index: 6;
  transform: translate(-50%, -140%);
  padding: 6px 10px;
  background: rgba(43, 40, 36, 0.9);
  color: #fffaf3;
  border-radius: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  letter-spacing: 0.02em;
}

.toast {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  padding: 10px 16px;
  background: rgba(43, 40, 36, 0.9);
  color: #fffaf3;
  border-radius: 999px;
  font-size: 13px;
  pointer-events: none;
}

.walk-hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 250, 243, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(43, 40, 36, 0.25);
}

.walk-help {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 16px;
  background: rgba(43, 40, 36, 0.72);
  color: #f7f1e8;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

body.walking .topbar,
body.walking .rail,
body.walking .library,
body.walking .plan-bar,
body.walking .shape-bar,
body.walking .palette,
body.walking .cam-panel,
body.walking .architect,
body.walking .hint {
  pointer-events: auto;
  z-index: 8;
}

body.walking .walk-hud {
  pointer-events: none;
}

.walk-leave {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
}

body.walking .walk-leave { pointer-events: auto; }

.walk-stick {
  display: none;
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(43, 40, 36, 0.28);
  border: 1.5px solid rgba(255, 250, 243, 0.38);
  box-shadow: 0 8px 22px rgba(43, 40, 36, 0.18);
  z-index: 6;
}
.walk-stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 250, 243, 0.9);
  box-shadow: 0 2px 8px rgba(43, 40, 36, 0.28);
}
body.walking .walk-stick:not([hidden]) {
  display: block;
}
@media (pointer: coarse) {
  body.walking .walk-stick:not([hidden]) {
    display: block;
  }
}
body.view-only .walk-stick {
  pointer-events: auto;
}
body.walking #view {
  touch-action: none;
}

#zoomPad {
  display: none;
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(22px, calc(18px + env(safe-area-inset-bottom)));
  z-index: 6;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#zoomPad:not([hidden]) {
  display: flex;
}
@media (hover: none) and (pointer: coarse) {
  #zoomPad[hidden],
  #zoomPad {
    display: flex;
  }
}
body.walking #zoomPad,
body.walking #zoomPad:not([hidden]),
body.walking #zoomPad[hidden] {
  display: none !important;
}
body.view-only #zoomPad:not([hidden]),
body.view-only #zoomPad {
  pointer-events: auto;
}
#zoomPad button {
  appearance: none;
  -webkit-appearance: none;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 250, 243, 0.38);
  background: rgba(43, 40, 36, 0.72);
  color: #fffaf5;
  font: 600 26px/1 var(--font);
  box-shadow: 0 8px 22px rgba(43, 40, 36, 0.18);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  backdrop-filter: blur(10px);
}
#zoomPad button:active {
  background: rgba(43, 40, 36, 0.88);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.architect {
  flex: 0 0 320px;
  width: 320px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(247, 241, 232, 0.96);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(60, 44, 28, 0.06);
  z-index: 8;
}

.architect[hidden] { display: none; }

.architect-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.architect-title {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.architect-title strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.architect-title span {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 3px;
}

.architect-hide {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffaf3;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.architect-hide:hover { background: #fff; color: var(--ink); }

.architect-msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.msg p { margin: 0; }

.msg-who {
  display: block;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage);
  margin-bottom: 4px;
}

.msg-architect {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #eadfd2;
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 6px;
}

.architect-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 14px 10px;
}

.architect-prompts[hidden] { display: none; }

.architect-prompts button {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.architect-prompts button:hover { background: #fff; }

.architect-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(247, 241, 232, 0.9);
}

.architect-compose textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 12px;
  outline: none;
}

.architect-compose textarea:focus {
  border-color: #d2b8a4;
  box-shadow: 0 0 0 3px rgba(196, 106, 74, 0.12);
}

.architect-send {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.architect-send:hover { filter: brightness(1.05); }

.architect-show {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(247, 241, 232, 0.94);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 12px 8px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.architect-show[hidden] { display: none; }
.architect-show:hover { background: #fffaf3; }

#app.chat-collapsed .architect { display: none; }

@media (max-width: 900px) {
  .rail {
    left: 50%;
    top: auto;
    bottom: 16px;
    transform: translateX(-50%);
    flex-direction: row;
    max-height: none;
    max-width: calc(100% - 24px);
    overflow: auto;
    border-radius: 18px;
  }
  .tool { width: 92px; align-items: center; text-align: center; font-size: 11px; }
  .palette { left: 50%; top: auto; bottom: 118px; transform: translateX(-50%); }
  .hint { bottom: 118px; }
  .brand-text span { display: none; }
  #app { flex-direction: column; }
  .architect {
    flex: 0 0 38%;
    width: 100%;
    height: 38%;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .architect-show {
    right: 12px;
    top: auto;
    bottom: 16px;
    transform: none;
    writing-mode: horizontal-tb;
    padding: 8px 14px;
    border-radius: 999px;
  }
}

.storey-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow-x: auto;
  flex-wrap: nowrap;
  max-width: min(52vw, 420px);
}
.storey-tabs button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.storey-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #e4d5c4;
}

.library {
  position: absolute;
  left: 172px;
  top: 50%;
  transform: translateY(-42%);
  z-index: 6;
  width: 280px;
  max-height: min(72vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: rgba(247, 241, 232, 0.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.library[hidden] { display: none; }
.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.library-head strong { font-size: 14px; }
.library-close {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffaf3;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.library-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.library-tabs button {
  appearance: none;
  border: 1px solid transparent;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.library-tabs button.active {
  background: #fff;
  border-color: #e4d5c4;
}
.library-search {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 7px 9px;
  border-radius: 10px;
  margin-bottom: 8px;
  outline: none;
}
.library-search:focus { border-color: #d2b8a4; }
.library-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.library-item {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.library-item:hover { background: #fffaf3; }
.library-item.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(196,106,74,0.25); }
.library-item strong { display: block; font-size: 13px; }
.library-item span {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.library-empty {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 8px;
}

.mass-drop {
  border: 1px dashed #d2c4b0;
  background: #fffaf3;
  border-radius: 14px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
}
.mass-drop:hover, .mass-drop.over { border-color: var(--accent); background: #fff; }
.mass-drop strong { display: block; font-size: 13px; }
.mass-drop span { display: block; margin-top: 4px; font-size: 11px; color: var(--ink-soft); }
.mass-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 8px 0;
}
.mass-thumbs img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.mass-status { font-size: 12px; color: var(--ink-soft); margin: 6px 0 0; }

@media (max-width: 900px) {
  .library {
    left: 50%;
    top: auto;
    bottom: 118px;
    transform: translateX(-50%);
    width: min(320px, calc(100% - 24px));
  }
  .storey-tabs { display: none; }
}

.pill.danger {
  color: #8a3a2a;
  border-color: #e2c4b8;
}
.pill.danger:hover { background: #f6e4dc; }

.swatch-cats { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 2px 8px; }
.swatch-cat {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 3px 9px; font: 11px/1.2 var(--font); color: var(--ink-soft); cursor: pointer;
}
.swatch-cat.active { background: #fff; color: var(--ink); border-color: var(--accent); }
.swatch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.swatch-chip {
  position: relative; height: 72px; border: 1px solid var(--line); border-radius: 10px;
  background-size: cover; background-position: center; cursor: pointer; overflow: hidden;
}
.swatch-chip span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
  background: linear-gradient(transparent, rgba(30,24,18,0.72));
  color: #fff; font: 10px/1.2 var(--font); text-align: left;
}
.swatch-chip.active { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.swatch-grid.scenarios { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch-chip.scenario { height: 92px; }
.swatch-chip.scenario span { font-size: 11px; font-weight: 650; padding: 6px 7px; }
.swatch-credit { font: 11px/1.4 var(--font); color: var(--ink-soft); padding: 8px 2px 0; }

.library-list.dense { gap: 4px; }
.library-item.furn { padding: 6px 9px; }
.library-item.furn strong { font-size: 12px; }

.ground-paint {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.ground-paint p {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

body.view-only #rail,
body.view-only #library,
body.view-only #palette,
body.view-only #planBar,
body.view-only #shapeBar,
body.view-only #architect,
body.view-only #btnChatShow,
body.view-only #storeyTabs,
body.view-only #hint,
body.view-only #coach,
body.view-only #siteStart {
  display: none !important;
}
body.view-only .top-actions > *:not(#btnCameras) {
  display: none !important;
}
body.view-only .cam-edit {
  display: none !important;
}

body.view-only #btnLeaveWalk {
  display: none !important;
}

body.view-only #btnLook {
  display: block;
}

body.view-only.walking #btnLook {
  pointer-events: auto;
}

body.view-only .topbar {
  justify-content: flex-start;
}


.viewer-bar {
  display: none;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
body.view-only #viewerBar {
  display: flex;
}
body.view-only #viewerBar .pill.active {
  background: #2b2824;
  color: #f7f1e8;
}


.cam-panel {
  position: absolute;
  left: 172px;
  top: 88px;
  z-index: 6;
  width: 268px;
  max-height: min(72vh, 640px);
  overflow-y: auto;
  padding: 14px;
  background: rgba(247, 241, 232, 0.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.cam-panel[hidden] { display: none; }
.cam-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cam-head strong { font-size: 14px; }
.cam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.cam-actions .pill {
  padding: 6px 11px;
  font-size: 12px;
  box-shadow: none;
}
.cam-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  max-height: 160px;
  overflow: auto;
}
.cam-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 4px 6px 4px 4px;
}
.cam-row.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(196,106,74,0.22);
}
.cam-row button.cam-name {
  appearance: none;
  flex: 1 1 auto;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.cam-row button.cam-name:hover { background: #fffaf3; }
.cam-row button.cam-del {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}
.cam-row button.cam-del:hover { background: #f6e4dc; color: #8a3a2a; }
.cam-empty {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 4px 2px 2px;
}
.cam-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.cam-slider {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-soft);
}
.cam-slider span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.cam-slider i { font-style: normal; color: var(--ink); font-variant-numeric: tabular-nums; }
.cam-slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.cam-styles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.cam-styles button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.cam-styles button.active {
  background: #fff;
  border-color: var(--accent);
}
.cam-prompt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.cam-prompt span {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted, #6b6660);
}
.cam-prompt textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 9px;
  border-radius: 8px;
}
.cam-prompt textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.cam-render {
  display: flex;
  gap: 6px;
}
.cam-render .pill { padding: 7px 12px; font-size: 12px; box-shadow: none; }
.pill.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: #b85a3c;
}
.pill.accent:hover:not(:disabled) { background: #b85a3c; }
.pill.accent:disabled { opacity: 0.5; }

.render-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 40, 36, 0.42);
  padding: 24px;
}
.render-modal[hidden] { display: none; }
.render-card {
  width: min(920px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.render-stage {
  position: relative;
  background: #2b2824;
  min-height: 180px;
}
.render-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
}
.render-status {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  background: rgba(43, 40, 36, 0.78);
  color: #fffaf5;
  border-radius: 999px;
  font-size: 13px;
}
.render-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
}

@media (max-width: 900px) {
  .cam-panel {
    left: 50%;
    top: auto;
    bottom: 118px;
    transform: translateX(-50%);
    width: min(300px, calc(100% - 24px));
  }
}

/* Meet overlay — camera + people on the MIKAI space */
#meetHud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}
#meetHud .meet-top,
#meetHud .meet-self,
#meetHud .meet-people {
  pointer-events: auto;
}
.meet-top {
  position: absolute;
  top: 58px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.meet-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 13px;
}
.meet-chip.talk {
  color: var(--sage);
  border-color: rgba(109, 127, 98, 0.4);
}
.meet-chip code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.meet-ghost {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0 4px;
  font-size: 12px;
}
.meet-self {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 196px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
#selfVideo {
  width: 100%;
  height: 118px;
  object-fit: cover;
  border-radius: 10px;
  background: #1c1a17;
  transform: scaleX(-1);
}
#meetName {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  background: #fffaf4;
  color: var(--ink);
}
.meet-toggles {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.meet-toggles .pill { flex: 1; }
.meet-toggles .pill.on { background: #d8ecdf; }
.meet-toggles .pill.off { background: #f0d8d2; }
.meet-people {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 240px;
}
.meet-people .row {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(247, 241, 232, 0.92);
  border: 1px solid var(--line);
  font-size: 13px;
}
.meet-people .near { border-color: rgba(109, 127, 98, 0.45); }

body.meeting #rail,
body.meeting #library,
body.meeting #palette,
body.meeting #planBar,
body.meeting #shapeBar,
body.meeting #architect,
body.meeting #btnChatShow,
body.meeting #storeyTabs,
body.meeting #hint,
body.meeting #coach,
body.meeting #siteStart {
  display: none !important;
}
body.meeting .top-actions > *:not(#btnCameras):not(#btnMeet):not(#btnLeaveMeet) {
  display: none !important;
}
body.meeting #btnLeaveWalk { display: none !important; }
body.meeting #viewerBar { display: flex; }
body.meeting #btnMeet { background: #2b2824; color: #f7f1e8; }

body.meeting #btnLeaveMeet { display: inline-flex !important; background: #8a3a2a; color: #fff7f0; }

.meet-talk {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(280px, calc(100% - 24px));
  justify-content: center;
  text-align: center;
  font-size: 12px;
  padding: 5px 12px;
}
.meet-dock {
  position: absolute;
  left: 50%;
  bottom: max(12px, calc(8px + env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(247, 241, 232, 0.94);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  z-index: 31;
}
.meet-dock-btn {
  min-width: 52px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #efe6d8;
  color: var(--ink);
  font: 600 14px/1 system-ui, sans-serif;
  cursor: pointer;
}
.meet-dock-btn.on { background: #d8ecdf; }
.meet-dock-btn.off { background: #f0d8d2; }
.meet-dock-btn.leave { background: #8a3a2a; color: #fff7f0; }
.meet-dock-code {
  display: none;
  font: 11px ui-monospace, Menlo, monospace;
  opacity: 0.7;
  padding: 0 6px;
}
#meetHud .meet-self { pointer-events: auto; }

@media (max-width: 820px), (pointer: coarse) {
  body.meeting #topbar,
  body.meeting #viewerBar,
  body.meeting #btnMeet,
  body.meeting #btnLeaveMeet,
  body.meeting #btnCameras,
  body.meeting #lookHint,
  body.meeting #hint {
    display: none !important;
  }
  body.meeting #stage,
  body.meeting #view {
    top: 0 !important;
    height: 100% !important;
  }
  .meet-self,
  .meet-people,
  .meet-dock-code,
  .meet-dock-btn.extra,
  .meet-talk:not(.talk) {
    display: none !important;
  }
  .meet-talk.talk {
    top: max(8px, env(safe-area-inset-top));
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(247, 241, 232, 0.82);
  }
  .meet-dock {
    width: auto;
    max-width: calc(100% - 24px);
    gap: 10px;
    padding: 6px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .meet-dock-btn {
    min-width: 72px;
    min-height: 46px;
    padding: 0 16px;
    font-size: 16px;
  }
}

@media (min-width: 821px) and (pointer: fine) {
  .meet-dock-code { display: inline; }
  .meet-self { bottom: 76px; }
}

.photo-drop-stage {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 48px));
  padding: 16px 18px;
  border: 2px dashed #c9b79a;
  border-radius: 16px;
  background: rgba(255,250,243,0.94);
  text-align: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(40,30,16,0.12);
  pointer-events: auto;
}
.photo-drop-stage strong { display: block; font-size: 16px; letter-spacing: 0.01em; }
.photo-drop-stage span { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-soft); }
.photo-drop-stage:hover, .photo-drop-stage.over {
  border-color: var(--accent);
  background: #fff;
}
.photo-tab-drop { min-height: 140px; padding: 28px 16px; }
.brand-text span { letter-spacing: 0.08em; }

.photo-overlay {
  position: absolute;
  z-index: 9;
  left: 16px;
  bottom: 16px;
  width: min(320px, 42vw);
  margin: 0;
  background: rgba(255,250,243,0.95);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(40,30,16,0.18);
  pointer-events: none;
}
.photo-overlay img { display: block; width: 100%; height: auto; }
.photo-overlay figcaption { padding: 6px 10px 8px; font-size: 11px; color: var(--ink-soft); }
