/* Room demo component. Scoped under .rd; theme through the custom properties. */
.rd {
  --rd-primary: #713600;
  --rd-primary-ink: #ffffff;
  --rd-accent: #ffca99;
  --rd-ink: #2b1d12;
  --rd-muted: #6e5b4b;
  --rd-line: #e6d9c8;
  --rd-surface: #fffdf9;
  --rd-stage: #efe6da;
  --rd-radius: 18px;
  --rd-focus: 0 0 0 2px #fff, 0 0 0 4px var(--rd-primary);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  color: var(--rd-ink);
  scroll-margin-top: 12px;
}

.rd [hidden] { display: none !important; }

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

/* ---------- stage ---------- */
.rd-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: var(--rd-stage-max, none);
  min-height: 260px;
  border-radius: var(--rd-radius);
  background: var(--rd-stage);
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

.rd-plan, .rd-canvas { position: absolute; inset: 0; transition: opacity .5s ease; }
.rd-plan { display: grid; place-items: center; padding: 56px 4% 64px; }
.rd-plan svg { width: 100%; height: 100%; }
.rd-canvas { opacity: 0; touch-action: pan-y; }
.rd-canvas canvas { display: block; width: 100%; height: 100%; }
.rd-canvas[role="application"] { cursor: grab; }
.rd-canvas:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--rd-primary); border-radius: var(--rd-radius); }
.rd-dragging .rd-canvas { cursor: grabbing !important; }

.rd:not([data-mode="loading"]):not([data-mode="static"]) .rd-plan { opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility 0s .5s; }
.rd:not([data-mode="loading"]):not([data-mode="static"]) .rd-canvas { opacity: 1; }

/* ---------- overlay labels ---------- */
.rd-labels { position: absolute; inset: 0; pointer-events: none; }
.rd-dim, .rd-measure {
  position: absolute; left: 0; top: 0;
  font-size: 13px; line-height: 1; white-space: nowrap;
  padding: 5px 8px; border-radius: 999px;
}
.rd-dim { color: #5b4330; background: rgba(255, 253, 249, .88); box-shadow: 0 0 0 1px rgba(156, 123, 92, .25); }
.rd-measure { color: var(--rd-primary-ink); background: var(--rd-primary); font-weight: 700; box-shadow: 0 2px 8px rgba(60, 30, 0, .25); }

.rd-handle {
  position: absolute; left: 0; top: 0;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%;
  background: var(--rd-surface); color: var(--rd-primary);
  box-shadow: 0 0 0 2px var(--rd-primary), 0 4px 12px rgba(60, 30, 0, .22);
  cursor: grab; touch-action: none;
}
.rd-handle svg { width: 22px; height: 22px; }
.rd-handle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--rd-primary), 0 0 0 6px var(--rd-accent); }
.rd-handle.is-demo { background: var(--rd-accent); }
.rd-dragging .rd-handle { cursor: grabbing; }

.rd-top {
  position: absolute; left: 14px; right: 14px; top: 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  pointer-events: none;
}
.rd-caption {
  margin: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 9px 13px; border-radius: 12px;
  background: rgba(255, 253, 249, .92); box-shadow: 0 1px 2px rgba(60, 30, 0, .08);
}
.rd-caption-step { font-size: 12px; color: var(--rd-muted); }
.rd-caption-title { font-size: 16px; font-weight: 700; }
.rd-chip {
  margin-left: auto; padding: 7px 12px; border-radius: 999px;
  background: var(--rd-accent); color: var(--rd-primary); font-size: 14px; font-weight: 700;
}

.rd-card {
  position: absolute; left: 14px; bottom: 70px;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100% - 28px);
  padding: 10px 12px; border-radius: 14px;
  background: var(--rd-surface); box-shadow: 0 6px 22px rgba(60, 30, 0, .16);
  pointer-events: none;
}
.rd-card-thumb { width: 56px; height: 40px; display: grid; place-items: center; border-radius: 9px; background: #f3ebdf; }
.rd-card-thumb svg { width: 44px; }
.rd-card-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rd-card-text strong { font-size: 15px; }
.rd-card-text small { font-size: 13px; color: var(--rd-muted); }
.rd-card-text em { font-style: normal; font-size: 11px; color: var(--rd-muted); }
.rd-card-add {
  margin-left: 4px; padding: 8px 12px; border-radius: 10px; white-space: nowrap;
  font-size: 14px; font-weight: 700; color: var(--rd-primary-ink); background: var(--rd-primary);
  transition: background-color .2s ease, transform .2s ease;
}
.rd-card-add.is-pressed { background: #4f2600; transform: scale(.96); }

.rd-status {
  position: absolute; left: 14px; right: 14px; bottom: 14px; margin: 0;
  font-size: 14px; color: var(--rd-muted); text-align: center;
}
.rd-status:empty { display: none; }
.rd[data-mode="static"] .rd-status { text-align: left; padding: 8px 12px; border-radius: 12px; background: rgba(255, 253, 249, .92); color: var(--rd-ink); }

/* ---------- playback ---------- */
.rd-playbar {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.rd-playbar button {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; min-width: 40px; padding: 0 13px;
  border: 0; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 700;
  color: var(--rd-primary); background: rgba(255, 253, 249, .94);
  box-shadow: 0 1px 3px rgba(60, 30, 0, .14);
  cursor: pointer;
}
.rd-playbar .rd-replay { padding: 0; justify-content: center; }
.rd-playbar svg { width: 18px; height: 18px; flex: none; }
.rd-playbar button:hover { background: #fff; }
.rd-progress {
  flex: 1; height: 4px; border-radius: 4px; overflow: hidden;
  background: rgba(113, 54, 0, .14);
}
.rd-progress span { display: block; height: 100%; background: var(--rd-primary); transform-origin: left; transform: scaleX(0); }

/* ---------- controls ---------- */
.rd-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 12px 18px;
}
.rd-group-view { justify-self: end; }
.rd-group { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rd-group legend, .rd-legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--rd-muted); }
.rd-group legend { float: left; width: 100%; }
.rd-group legend + * { clear: both; }

.rd-seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: #f1e8dc; }
.rd-opt { position: relative; display: flex; cursor: pointer; }
.rd-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.rd-seg .rd-opt > span {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  min-height: 40px; min-width: 44px; padding: 4px 12px;
  border-radius: 10px; font-size: 15px; font-weight: 700; line-height: 1.15;
  color: var(--rd-muted);
  transition: background-color .15s ease, color .15s ease;
}
.rd-seg-wide { display: grid; grid-template-columns: 1fr 1fr; }
.rd-seg-wide .rd-opt > span { flex: 1; align-items: flex-start; }
.rd-seg .rd-opt small { font-size: 12px; font-weight: 400; color: inherit; opacity: .85; }
.rd-seg .rd-opt input:checked + span { background: var(--rd-surface); color: var(--rd-primary); box-shadow: 0 1px 3px rgba(60, 30, 0, .14); }
.rd-seg .rd-opt:hover input:not(:checked) + span { color: var(--rd-ink); }
.rd-opt input:focus-visible + span { box-shadow: var(--rd-focus); }

.rd-swatches { display: flex; gap: 6px; padding: 4px 0; }
.rd-swatch > span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.rd-swatch i { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.rd-swatch input:checked + span { box-shadow: 0 0 0 2px var(--rd-primary); }
.rd-swatch input:focus-visible + span { box-shadow: 0 0 0 2px var(--rd-primary), 0 0 0 5px var(--rd-accent); }

.rd-walk {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--rd-primary); background: var(--rd-surface); color: var(--rd-primary);
  font: inherit; font-size: 15px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.rd-walk svg { width: 20px; height: 20px; flex: none; }
.rd-walk[aria-pressed="true"] { background: var(--rd-primary); color: var(--rd-primary-ink); }
.rd-walk:disabled { opacity: .45; cursor: not-allowed; }
.rd-walk:hover:not(:disabled) { background: #fbf1e6; }
.rd-walk[aria-pressed="true"]:hover { background: #5c2c00; }

.rd button:focus-visible { outline: none; box-shadow: var(--rd-focus); }

.rd-hint { margin: 0; min-height: 1.4em; font-size: 15px; color: var(--rd-ink); }
.rd-note { margin: -6px 0 0; font-size: 13px; color: var(--rd-muted); }

/* ---------- narrow ---------- */
@media (max-width: 720px) {
  .rd-stage { aspect-ratio: 1 / 1; min-height: 0; border-radius: 16px; }
  .rd-controls { grid-template-columns: auto 1fr; }
  .rd-group-sofa, .rd-group-color { grid-column: 1 / -1; }
  .rd-group-view { justify-self: stretch; }
  .rd-group-layout { order: 1; }
  .rd-group-view { order: 2; }
  .rd-group-sofa { order: 3; }
  .rd-group-color { order: 4; }
  .rd-walk { width: 100%; }
  .rd-playbar .rd-play span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rd-playbar .rd-play { padding: 0; justify-content: center; }
  .rd-card { bottom: 64px; left: 10px; gap: 10px; }
  .rd-card-thumb { display: none; }
  .rd-caption-title { font-size: 15px; }
  .rd-dim, .rd-measure { font-size: 12px; }
}


@media (prefers-reduced-motion: reduce) {
  .rd-plan, .rd-canvas, .rd-seg .rd-opt > span, .rd-card-add { transition: none; }
}
