:root {
  --bg: #0b0b0e;
  --glass: rgba(16, 16, 20, 0.66);
  --glass-line: rgba(255, 255, 255, 0.09);
  --text: #ece9e4;
  --muted: rgba(236, 233, 228, 0.56);
  --faint: rgba(236, 233, 228, 0.32);
  --accent: #ff5e2c;
  --accent-soft: rgba(255, 94, 44, 0.16);
  --paper: #f4f1ec;
  --ok: #3fd27f;
  --gap: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; transition: opacity 0.25s ease; }
body.switching #view { opacity: 0.35; }
body.placing #view { cursor: crosshair; }

.glass, .topbar, .spaces, .rail, .panel, .caption, .placebar, .badge, .toast {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  backdrop-filter: blur(18px) saturate(1.25);
}

/* ── 위: 장소·공간 ─────────────────────────────── */
.topbar {
  position: fixed; top: var(--gap); left: var(--gap); right: var(--gap); z-index: 5;
  height: 60px; padding: 0 12px 0 18px; border-radius: 18px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-width: 0; }
.brand img { height: 16px; width: auto; display: block; }
.brand span { font-size: 9.5px; letter-spacing: 0.22em; font-weight: 700; color: var(--muted); white-space: nowrap; }
.venues, .spaces { display: flex; gap: 4px; padding: 4px; border-radius: 13px; }
.venues { background: rgba(255, 255, 255, 0.05); }
.venue, .space {
  border: 0; background: transparent; border-radius: 9px; padding: 7px 14px;
  display: flex; align-items: baseline; gap: 7px; white-space: nowrap; color: var(--muted);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.venue b, .space b { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.venue small, .space small { font-size: 8.5px; letter-spacing: 0.14em; font-weight: 600; opacity: 0.7; }
.venue:hover, .space:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.venue[aria-pressed="true"] { background: var(--paper); color: #151517; }
.spaces { position: fixed; top: calc(var(--gap) + 70px); left: 50%; translate: -50% 0; z-index: 5; border-radius: 13px; }
.space { padding: 6px 13px; }
.space b { font-size: 13px; }
.space[aria-pressed="true"] { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 94, 44, 0.65); }

/* ── 왼쪽: 시점 ───────────────────────────────── */
.rail {
  position: fixed; left: var(--gap); top: 50%; translate: 0 -50%; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 18px;
}
.rail-label { writing-mode: vertical-rl; rotate: 180deg; font-size: 8.5px; letter-spacing: 0.24em; font-weight: 700; color: var(--faint); margin-bottom: 4px; }
.rail button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; color: var(--muted); transition: background-color 0.2s, color 0.2s, border-color 0.2s; }
.rail button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.rail button[aria-pressed="true"] { color: #fff; background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.16); }
#place-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.rail-sep { width: 22px; height: 1px; background: var(--glass-line); margin: 2px 0; }

/* ── 오른쪽: 조명 제어 ────────────────────────── */
.panel {
  position: fixed; right: var(--gap); top: calc(var(--gap) + 76px); z-index: 5;
  width: 336px; max-height: calc(100svh - 76px - var(--gap) * 2 - 8px);
  overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
  border-radius: 22px; padding: 20px 20px 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.kicker { margin: 0; font-size: 9.5px; letter-spacing: 0.22em; font-weight: 700; color: var(--muted); }
.panel h2 { margin: 6px 0 0; font-size: 21px; font-weight: 700; letter-spacing: -0.03em; }
.master { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.04); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.master .led { width: 7px; height: 7px; border-radius: 50%; background: #777; }
.master[aria-checked="true"] { border-color: rgba(63, 210, 127, 0.55); background: rgba(63, 210, 127, 0.12); }
.master[aria-checked="true"] .led { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.panel-toggle { display: none; }
.sect { border-top: 1px solid var(--glass-line); padding-top: 16px; margin-top: 16px; }
.sect-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.hint { font-size: 10.5px; color: var(--faint); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { border-radius: 13px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.03); padding: 13px 4px 11px; display: grid; justify-items: center; gap: 5px; color: var(--muted); transition: border-color 0.2s, background-color 0.2s, color 0.2s; }
.preset b { font-size: 12px; color: var(--text); letter-spacing: -0.01em; }
.preset small { font-size: 7.5px; letter-spacing: 0.1em; font-weight: 700; opacity: 0.7; text-align: center; }
.preset:hover { border-color: rgba(255, 255, 255, 0.22); }
.preset[aria-pressed="true"] { background: rgba(255, 94, 44, 0.14); border-color: rgba(255, 94, 44, 0.75); color: #ffb79c; }

/* 슬라이더 — 네이티브 range 를 그대로 쓰고 모양만 바꾼다 */
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.slider-head label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.slider-head output { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.slider-head output small { font-size: 11px; margin-left: 2px; color: var(--muted); font-weight: 600; }
input[type="range"] {
  --slider-track-size: 3px;
  --slider-thumb-size: 18px;
  --slider-track-color: rgba(255, 255, 255, 0.14);
  --slider-fill-color: #f4f1ec;
  --attr-min: 0; --attr-max: 100; --control-value: 50;
  --slider-progress: calc((var(--control-value) - var(--attr-min)) / (var(--attr-max) - var(--attr-min)) * 100%);
  appearance: none; -webkit-appearance: none; width: 100%; height: 30px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: var(--slider-track-size); border-radius: 999px;
  background: linear-gradient(to right, var(--slider-fill-color) var(--slider-progress), var(--slider-track-color) var(--slider-progress));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--slider-thumb-size); height: var(--slider-thumb-size);
  margin-top: calc((var(--slider-track-size) - var(--slider-thumb-size)) / 2);
  border-radius: 50%; border: 3px solid #f4f1ec; background: #141416; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track { height: var(--slider-track-size); border-radius: 999px; background: var(--slider-track-color); }
input[type="range"]::-moz-range-progress { height: var(--slider-track-size); border-radius: 999px; background: var(--slider-fill-color); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; border: 3px solid #f4f1ec; background: #141416; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
input.cct::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(to right, #ffa646, #ffd9a8 35%, #fff4e6 60%, #cfe0ff); }
input.cct::-moz-range-track { height: 4px; background: linear-gradient(to right, #ffa646, #ffd9a8 35%, #fff4e6 60%, #cfe0ff); }
input.cct::-moz-range-progress { background: transparent; }
.ticks { display: flex; justify-content: space-between; font-size: 8.5px; letter-spacing: 0.08em; color: var(--faint); font-weight: 600; }

/* 조도 */
.lux-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; }
.lux-head b { font-size: 18px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.lux-bar { position: relative; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); margin: 10px 0 8px; }
.lux-bar .range { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: rgba(63, 210, 127, 0.4); }
.lux-bar .mark { position: absolute; top: -5px; width: 3px; height: 16px; margin-left: -1.5px; border-radius: 2px; background: #fff; box-shadow: 0 0 8px rgba(255, 255, 255, 0.6); transition: left 0.25s ease; }
.lux-note { margin: 0; font-size: 11.5px; color: var(--muted); }
.lux[data-verdict="low"] .lux-head b { color: #ffb37f; }
.lux[data-verdict="high"] .lux-head b { color: #9cc4ff; }
.lux[data-verdict="ok"] .lux-head b { color: #8ff0b7; }
.lux-foot { margin: 6px 0 0; font-size: 10px; line-height: 1.5; color: var(--faint); }

/* 조명 구역 */
.zones summary { list-style: none; display: flex; align-items: center; gap: 8px; font-size: 10px; letter-spacing: 0.18em; font-weight: 700; color: var(--muted); cursor: pointer; }
.zones summary::-webkit-details-marker { display: none; }
.zones .dot, .badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); flex: none; }
.zones .chev { margin-left: auto; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: 45deg; transition: rotate 0.2s; }
.zones[open] .chev { rotate: -135deg; }
.zones ul { list-style: none; margin: 10px 0 0; padding: 0; }
.zone { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 2px; border: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); background: transparent; text-align: left; }
.zname { font-size: 12.5px; font-weight: 600; display: grid; }
.zname small { font-size: 8px; letter-spacing: 0.14em; color: var(--faint); font-weight: 700; margin-top: 2px; }
.zsw { width: 30px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; flex: none; transition: background-color 0.2s; }
.zsw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: translate 0.2s; }
.zone[aria-checked="true"] .zsw { background: var(--accent); }
.zone[aria-checked="true"] .zsw::after { translate: 12px 0; }

.panel-foot { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--glass-line); padding-top: 14px; margin-top: 14px; }
.save, .accent { border: 0; border-radius: 10px; padding: 9px 14px; font-size: 12.5px; font-weight: 700; background: var(--paper); color: #151517; }
.accent { background: var(--accent); color: #fff; }
.ghost { border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; background: transparent; color: var(--muted); }
.ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }

/* ── 아래: 공간 설명·배치·표식 ─────────────────── */
/* 아래 줄: 공간 설명 + 추천 제품 */
.dock { position: fixed; left: calc(var(--gap) + 84px); right: calc(var(--gap) * 2 + 336px); bottom: 18px; z-index: 4; display: flex; gap: 10px; align-items: stretch; }
.caption { flex: 0 1 340px; min-width: 0; display: flex; gap: 16px; align-items: center; padding: 14px 18px; border-radius: 16px; }
.recos { flex: 1 1 0; min-width: 0; border-radius: 16px; padding: 10px 6px 10px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--glass); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(18px) saturate(1.25); backdrop-filter: blur(18px) saturate(1.25); }
.recos-head { display: flex; justify-content: space-between; align-items: baseline; padding-right: 8px; }
.recos-head h2 { margin: 0; font-size: 11px; letter-spacing: 0.08em; font-weight: 700; color: var(--muted); }
.recos-head a, .recos-m .hint { font-size: 10.5px; color: #ffb79c; text-decoration: none; font-weight: 600; }
.recos-list { list-style: none; margin: 0; padding: 0 0 4px; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.recos-list li { flex: none; scroll-snap-align: start; display: grid; gap: 4px; align-content: start; }
.reco-extra { display: flex; gap: 10px; padding: 0 4px; white-space: nowrap; overflow: hidden; max-width: 248px; }
.reco-extra a { font-size: 10px; color: var(--muted); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.reco-extra a:hover { color: #ffb79c; }
.reco-extra .reco-video { color: #ffb79c; flex: none; }
.reco { display: flex; gap: 10px; align-items: center; width: 248px; padding: 7px 10px 7px 7px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.035); color: var(--text); text-decoration: none; transition: border-color 0.2s, background-color 0.2s; }
.reco:hover { border-color: rgba(255, 94, 44, 0.6); background: rgba(255, 94, 44, 0.08); }
.reco img { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; background: #fff; flex: none; }
.reco-text { display: grid; gap: 2px; min-width: 0; }
.reco-text small { font-size: 9.5px; color: var(--faint); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reco-text b { font-size: 12px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reco-meta { font-size: 10.5px; color: #ffb79c; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recos-m { display: none; }
.cap-no { font: italic 600 32px/1 Georgia, "Times New Roman", serif; color: var(--muted); padding-right: 16px; border-right: 1px solid var(--glass-line); }
.cap-meta { margin: 0; font-size: 9px; letter-spacing: 0.16em; font-weight: 700; color: var(--faint); text-transform: uppercase; }
.cap-title { margin: 5px 0 4px; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.35; }
.cap-view { margin: 0; font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; }
.placebar { position: fixed; left: 50%; bottom: 18px; translate: -50% 0; z-index: 6; border-radius: 16px; padding: 12px 14px; width: max-content; max-width: calc(100vw - 2 * var(--gap)); }
.placebar[hidden] { display: none; }
.placebar-hint { margin: 0 0 10px; font-size: 11.5px; color: var(--muted); }
.placebar-hint span { color: #ffb79c; font-weight: 700; margin-left: 4px; }
.placebar-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ptypes { display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: rgba(255, 255, 255, 0.05); }
.ptype { border: 0; background: transparent; border-radius: 8px; padding: 7px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ptype[aria-pressed="true"] { background: var(--paper); color: #151517; }
body.placing .dock { display: none; }
.badge { position: fixed; right: var(--gap); bottom: 18px; z-index: 4; margin: 0; display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; font-size: 9px; letter-spacing: 0.16em; font-weight: 700; color: var(--muted); }
.toast { position: fixed; left: 50%; top: calc(var(--gap) + 128px); translate: -50% -6px; z-index: 8; padding: 10px 16px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.25s, translate 0.25s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; translate: -50% 0; }

.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); transition: opacity 0.6s ease, visibility 0.6s; }
.loading p { margin: 0; font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
body.ready .loading { opacity: 0; visibility: hidden; }
.nowebgl { display: none; }
body.no-webgl .nowebgl { display: grid; position: fixed; inset: 0; z-index: 30; place-content: center; gap: 16px; padding: 24px; background: var(--bg); text-align: center; }
body.no-webgl .nowebgl img { max-width: min(860px, 100%); border-radius: 12px; }

/* 패널이 좁은 창(사이트 안 임베드)에서 겹치지 않게 */
@media (max-width: 1280px) {
  .brand span { display: none; }
}
@media (max-width: 1180px) {
  .caption { flex-basis: 270px; }
  .cap-title { font-size: 14px; }
  .cap-no { font-size: 26px; }
}
@media (max-width: 980px) {
  .brand span { display: none; }
  .venue small, .space small { display: none; }
  .caption { display: none; }
}

/* ── 휴대폰 ─────────────────────────────────── */
@media (max-width: 760px) {
  :root { --gap: 8px; }
  .topbar { height: auto; padding: 6px; grid-template-columns: 1fr; border-radius: 14px; }
  .brand { display: none; }
  .venues { overflow-x: auto; scrollbar-width: none; justify-self: stretch; }
  .venues::-webkit-scrollbar, .spaces::-webkit-scrollbar { display: none; }
  .venue { padding: 7px 11px; }
  .spaces { top: calc(var(--gap) + 58px); left: var(--gap); right: var(--gap); translate: none; overflow-x: auto; scrollbar-width: none; }
  .rail { top: calc(var(--gap) + 108px); translate: none; flex-direction: row; padding: 6px; border-radius: 14px; }
  .rail-label { display: none; }
  .rail-sep { width: 1px; height: 22px; }
  .rail button { width: 40px; height: 40px; }
  .panel { top: auto; bottom: var(--gap); left: var(--gap); right: var(--gap); width: auto; max-height: 62svh; padding: 14px 16px; border-radius: 18px; }
  .panel h2 { font-size: 17px; }
  .panel-body { display: none; }
  body.panel-open .panel-body { display: block; }
  .panel-toggle { display: block; width: 100%; margin-top: 12px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; background: rgba(255, 255, 255, 0.05); padding: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
  body.panel-open .panel-toggle { font-size: 0; }
  body.panel-open .panel-toggle::after { content: "조명 제어 접기"; font-size: 12.5px; }
  body.placing .panel { display: none; }
  .dock { display: none; }
  .recos-m { display: block; }
  .recos-m .recos-list { flex-direction: column; overflow: visible; }
  .recos-m .reco { width: 100%; }
  .placebar { bottom: var(--gap); width: calc(100vw - 2 * var(--gap)); }
  .toast { top: calc(var(--gap) + 160px); }
}

@media (prefers-reduced-motion: reduce) {
  #view, .toast, .loading, .zsw, .zsw::after, .lux-bar .mark { transition: none; }
}
