#room-viewer {
  position: relative;
  --room-tool-size: 34px;
  --room-tool-gap: 4px;
  --room-controls-top: .36rem;
  --room-stage-footer: 32px;
  --room-control-height: 32px;
  --room-control-border: #d6dbe2;
  --room-control-surface: #fff;
  --room-control-active: #eef0f3;
  --room-control-ink: #263345;
}

#room-viewer .room-toolbar {
  position: absolute;
  z-index: 4;
  inset-block-start: var(--room-controls-top);
  inset-inline-start: 0;
  display: block;
  max-inline-size: calc(100% - var(--room-tool-size) - var(--room-tool-gap));
  padding: 0;
  border: 0;
  pointer-events: none;
  scroll-margin-top: 5.5rem;
}

#room-viewer .room-toolbar button { pointer-events: auto; }

#room-viewer .room-toolbar:target:not(:focus-visible) {
  outline: 0;
}

.room-coverage-options {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  column-gap: .3rem;
}

.room-coverage-options > button {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: .38rem;
  min-height: var(--room-tool-size);
  padding: 0 .38rem;
  border: 0;
  border-radius: .28rem;
  background: transparent;
  color: #596575;
  font: 600 .73rem/1.2 var(--body);
}

.room-coverage-options > button[aria-pressed="true"] {
  font-weight: 750;
}

.room-coverage-options > button[aria-pressed="true"] svg {
  color: var(--action);
}

.room-audio-options {
  grid-area: 1 / 2;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.room-audio-options button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .34rem;
  min-height: 28px;
  padding: .2rem .48rem;
  border: 1px solid var(--room-control-border);
  border-radius: .32rem;
  background: var(--room-control-surface);
  color: var(--room-control-ink);
  font: 650 .74rem/1.2 var(--display);
  white-space: nowrap;
}

.room-audio-options button::before {
  flex: 0 0 .58rem;
  width: .58rem;
  height: .58rem;
  border: 1px solid var(--audio-ink);
  border-radius: 50%;
  content: "";
}

.room-audio-options [data-room-audio-mode="audio"] {
  --audio-ink: #08766b;
  --audio-border: #8fc1ba;
  --audio-surface: #edf8f5;
}

.room-audio-options [data-room-audio-mode="audio"]::before { border-style: dashed; }

.room-audio-options [data-room-audio-mode="speaker"] {
  --audio-ink: #6841ae;
  --audio-border: #b6a2d9;
  --audio-surface: #f4effb;
}

.room-audio-options button:is(:hover, [aria-pressed="true"]) {
  border-color: var(--audio-border);
  background: var(--audio-surface);
  color: var(--audio-ink);
}

.room-tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .32rem;
  border: 0;
  border-radius: .32rem;
  background: transparent;
  color: var(--room-control-ink);
  font: 750 .78rem/1.2 var(--display);
}

.room-view-tools [data-room-step] {
  isolation: isolate;
}

.room-view-tools [data-room-step]::after {
  position: absolute;
  z-index: -1;
  inset: 50% auto auto 50%;
  width: var(--room-control-height);
  height: var(--room-control-height);
  border: 1px solid var(--room-control-border);
  border-radius: inherit;
  background: var(--room-control-fill, var(--room-control-surface));
  pointer-events: none;
  content: "";
  transform: translate(-50%, -50%);
  transition: background-color .16s ease;
}

#room-viewer [data-room-eye] svg {
  width: 20px;
  height: 20px;
}

#room-viewer [data-room-labels] svg {
  width: 17px;
  height: 17px;
}

#room-viewer :is([data-room-labels], [data-room-eye])[aria-pressed="false"]::before {
  position: absolute;
  z-index: 1;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  width: 21px;
  height: 1.5px;
  border-radius: 1px;
  background: #858e98;
  pointer-events: none;
  content: "";
  transform: translate(-50%, -50%) rotate(43deg);
}

#room-viewer [data-room-labels][aria-pressed="false"]::before { width: 17px; }

.room-coverage-options svg,
.room-tool svg {
  width: 14px;
  height: 14px;
  flex: none;
}

#room-viewer .room-stage {
  min-height: clamp(17.5rem, 27vw, 23rem);
  aspect-ratio: 1.62;
}

#room-viewer:not([data-room-ready]) :is(.room-coverage-options, .room-mount, #room-help, .room-drag-cue, .room-view-tools, .room-view-actions) {
  visibility: hidden;
}

#room-viewer[data-room-ready] .room-viewer-fallback {
  display: none;
}

.room-viewer-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .45rem;
  padding: clamp(.5rem, 2vw, 1rem);
}

.room-viewer-fallback img {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  object-fit: contain;
}

.room-viewer-fallback p {
  margin: 0;
  color: var(--muted);
}

.room-viewer-fallback nav {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .9rem;
}

.room-viewer-fallback a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--action-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .17em;
}

.room-mount {
  position: absolute;
  inset: 0 calc(var(--room-tool-size) + var(--room-tool-gap)) var(--room-stage-footer) 0;
}

.room-device-markers {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: clip;
  pointer-events: none;
}

.room-device-leader {
  position: absolute;
  height: 1px;
  background: rgb(79 115 162 / 38%);
  pointer-events: none;
  transform-origin: left center;
}

.room-device-marker {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font: 600 .625rem/1 var(--body);
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
  touch-action: manipulation;
  transform: translate(-50%, -50%);
}

.room-device-marker::before {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: inherit;
  background: rgb(26 56 94 / 84%);
  box-shadow: 0 1px 3px rgb(22 46 79 / 15%);
  content: "";
  transform: translate(-50%, -50%);
}

.room-device-marker:is([aria-expanded="true"], [aria-pressed="true"], :focus-visible) {
  z-index: 2;
}

.room-device-marker:is([aria-expanded="true"], [aria-pressed="true"])::before {
  background: rgb(26 56 94 / 95%);
  border-color: rgb(255 255 255 / 50%);
}

.room-device-marker:focus-visible,
.room-device-detail-close:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.room-device-detail {
  position: absolute;
  z-index: 4;
  inset-block-start: 47%;
  inset-inline-end: calc(var(--room-tool-size) + var(--room-tool-gap) + .4rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: .3rem;
  width: min(13.5rem, 42%);
  max-height: calc(53% - var(--room-stage-footer));
  padding: .56rem .64rem;
  border: 1px solid #c9d6e7;
  border-radius: .56rem;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 5px 16px rgb(27 55 95 / 13%);
  color: var(--room-control-ink);
}

.room-device-detail-close {
  position: absolute;
  inset-block-start: .16rem;
  inset-inline-end: .16rem;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: .28rem;
  background: transparent;
  color: #4a607d;
  font: 700 1rem/1 var(--body);
}

.room-device-detail-close svg {
  width: 14px;
  height: 14px;
}

.room-device-detail [data-room-device-title] {
  margin: 0;
  padding-inline-end: 1.15rem;
  color: #172f51;
  font: 800 .83rem/1.26 var(--display);
}

.room-device-detail [data-room-device-description] {
  margin: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  color: #415671;
  font: 550 .75rem/1.39 var(--body);
}

.room-device-markers[hidden],
.room-device-marker[hidden],
.room-device-leader[hidden],
.room-device-detail[hidden] {
  display: none;
}

.room-view-tools {
  position: absolute;
  z-index: 3;
  inset-block-start: var(--room-controls-top);
  inset-inline-end: 0;
  display: grid;
  gap: var(--room-tool-gap);
}

.room-view-tools .room-tool {
  width: var(--room-tool-size);
  height: var(--room-tool-size);
  padding: 0;
}

.room-view-tools .room-tool svg {
  width: 15px;
  height: 15px;
}

.room-tool:disabled,
.room-tool[aria-disabled="true"] {
  opacity: .46;
  cursor: default;
}

.room-view-actions {
  position: absolute;
  z-index: 3;
  inset-inline: 0;
  inset-block-end: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.room-camera-key {
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .12rem .62rem;
  margin-inline: .25rem auto;
  color: var(--room-control-ink);
  font: 400 .72rem/1.2 var(--body);
}

.room-camera-key[hidden] {
  display: none;
}

.room-camera-key span {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  white-space: nowrap;
}

.room-camera-key span::before {
  content: "";
  width: .72rem;
  border-block-start: 2px solid #6945bc;
}

.room-camera-key span + span::before {
  border-block-start: 2px dotted #1a8056;
}

#room-viewer .viewer-reset {
  position: static;
  width: 32px;
  height: 32px;
  padding: 8px;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  color: var(--room-control-ink);
  pointer-events: auto;
}

.room-explore-more {
  display: inline-flex;
  flex-shrink: 0;
  min-height: 32px;
  align-items: center;
  padding: .16rem .15rem .16rem .48rem;
  color: var(--action-dark);
  font: 750 .77rem/1.2 var(--display);
  text-decoration: underline;
  text-underline-offset: .21em;
  pointer-events: auto;
}

.room-drag-cue {
  position: absolute;
  z-index: 4;
  inset-block-start: calc((100% - var(--room-stage-footer)) / 2);
  inset-inline-start: calc((100% - var(--room-tool-size) - var(--room-tool-gap)) / 2);
  display: flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  padding: .4rem .8rem;
  border: 1px solid #d6dbe2;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(26 33 42 / 12%);
  color: var(--room-control-ink);
  font: 750 .78rem/1.2 var(--display);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.room-drag-cue[hidden] {
  display: none;
}

.room-drag-cue svg {
  width: 46px;
  height: 22px;
  overflow: visible;
}

.room-drag-mouse {
  animation: room-drag-suggestion 2.25s ease-in-out 2 both;
}

@keyframes room-drag-suggestion {
  0%, 62%, 100% { transform: translateX(0); }
  18% { transform: translateX(-6px); }
  42% { transform: translateX(6px); }
}

.room-preview-summary {
  padding-block: .65rem .3rem;
  border-block-start: 1px solid var(--line);
}

.room-preview-summary dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .38rem .78rem;
  margin: 0;
}

.room-preview-summary dt {
  color: var(--muted);
  font: 650 .72rem/1.35 var(--body);
}

.room-preview-summary dd {
  margin: .14rem 0 0;
  color: var(--ink);
  font: 700 .82rem/1.4 var(--display);
  overflow-wrap: anywhere;
}

@media (hover: hover) {
  .room-coverage-options > button:hover {
    color: var(--ink);
  }
  .room-view-tools [data-room-step]:not(:disabled):not([aria-disabled="true"]):hover {
    --room-control-fill: var(--room-control-active);
  }
  #room-viewer :is([data-room-labels], [data-room-eye]):hover {
    color: var(--ink);
  }
  #room-viewer .viewer-reset:hover {
    background: var(--room-control-active);
  }
  .room-explore-more:hover {
    color: var(--action);
  }
  .room-device-marker:hover::before {
    background: rgb(26 56 94 / 93%);
  }
  .room-device-detail-close:hover {
    background: #edf3fa;
  }
}

@media (max-width: 540px), (pointer: coarse) {
  #room-viewer {
    --room-tool-size: 44px;
    --room-tool-gap: 4px;
    --room-stage-footer: 44px;
  }
  .room-coverage-options > button,
  .room-audio-options button,
  #room-viewer .viewer-reset,
  .room-explore-more {
    min-height: 44px;
  }
  #room-viewer .viewer-reset {
    flex-shrink: 0;
    width: 44px;
    padding: 14px;
  }
  .room-device-marker {
    width: 30px;
    height: 30px;
  }
  .room-device-detail-close {
    width: 30px;
    height: 30px;
  }
  .room-device-detail [data-room-device-title] {
    padding-inline-end: 1.4rem;
  }
}

@media (max-width: 540px) {
  .room-control-label {
    -webkit-text-stroke: 2px #fff;
    paint-order: stroke fill;
  }
  .room-coverage-options svg { filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); }
  .room-audio-options button {
    padding-inline: .33rem;
  }
  .room-view-tools { gap: 2px; }
  #room-viewer .room-stage {
    min-height: 14.8rem;
    aspect-ratio: 1.38;
  }
  .room-device-detail {
    inset-block-start: 44%;
    width: min(11.25rem, 60%);
    max-height: calc(56% - var(--room-stage-footer));
  }
  .room-preview-summary dl {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr);
    column-gap: .3rem;
  }
  .room-preview-summary dd {
    font-size: .78rem;
  }
  .room-preview-summary dd[data-brief-features] {
    min-height: 2.8em;
  }
}

@media (max-width: 430px) {
  .room-audio-options button {
    font-size: .68rem;
    white-space: normal;
  }
}

@media (max-width: 380px) {
  .room-audio-options button { max-inline-size: 4.875rem; }
  .room-audio-options button::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .room-drag-mouse {
    animation: none;
  }
  .room-view-tools [data-room-step]::after {
    transition: none;
  }
}
