body.page-room {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
}

.page-room .topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  pointer-events: none;
}

.page-room .topbar .brand,
.page-room .topbar .account {
  pointer-events: auto;
  text-shadow: 0 1px 6px rgb(0 0 0 / 0.35);
}

body.is-editing .topbar .account {
  display: none;
}

@media (max-width: 600px) {
  .page-room .topbar .account {
    display: none;
  }
}

.room-stage {
  position: fixed;
  inset: 0;
}

.engine-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.room-ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.room-nameplate {
  position: absolute;
  left: 50%;
  top: max(0.9rem, env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  background: rgb(43 29 46 / 0.72);
  backdrop-filter: blur(6px);
  text-align: center;
}

.room-nameplate-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: normal;
  line-height: 1.3;
}

.chip-icon {
  margin-right: 0.4rem;
}

.engine-canvas:focus-visible {
  outline: 3px solid var(--glow);
  outline-offset: -3px;
}

.room-nameplate-sub {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: #a39a92;
  vertical-align: 0.05em;
}

.status-dot.is-online {
  background: #5fb26a;
}

.room-actions {
  position: absolute;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 0.5rem;
}

.chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 999px;
  background: rgb(43 29 46 / 0.78);
  backdrop-filter: blur(6px);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
}

.chip:hover,
.chip:focus-visible {
  background: rgb(74 47 69 / 0.9);
}

.room-hint {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  margin: 0;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgb(43 29 46 / 0.6);
  color: var(--ink-soft);
  font-size: 0.85rem;
  transition: opacity 0.6s ease;
}

.room-hint.is-hidden {
  opacity: 0;
}

.room-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.room-loading {
  flex-direction: column;
  gap: 1.2rem;
  background: var(--night);
  color: var(--ink-soft);
  transition: opacity 0.5s ease, visibility 0.5s;
}

.room-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Arriving from the hallway: the warm light behind the door, fading into the room. */
.room-loading.is-arrival {
  background: radial-gradient(circle at 50% 55%, #fff4dc 0%, #ffd9a0 45%, #2b1d2e 100%);
  color: #5a3a40;
  transition: opacity 0.9s ease, visibility 0.9s;
}

.room-loading.is-arrival .loading-door {
  display: none;
}

.loading-door {
  width: 56px;
  height: 88px;
  border-radius: 28px 28px 4px 4px;
  background: linear-gradient(160deg, var(--door) 0%, var(--door-dark) 100%);
  box-shadow: 0 10px 22px -6px var(--glow);
  animation: door-breathe 1.6s ease-in-out infinite;
}

@keyframes door-breathe {
  50% {
    box-shadow: 0 10px 30px -2px var(--glow);
  }
}

.room-panel-wrap {
  padding: 1.5rem;
  background: rgb(29 19 32 / 0.92);
}

.room-panel {
  max-width: 28rem;
  padding: 1.75rem;
  border-radius: var(--radius);
  background: var(--night);
  border: 1px solid rgb(255 255 255 / 0.08);
}

.room-panel h1 {
  font-size: 1.6rem;
  margin-top: 0;
}

.room-panel p,
.room-panel li {
  color: var(--ink-soft);
  line-height: 1.55;
}

.room-panel .button {
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.room-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgb(43 29 46 / 0.88);
  color: var(--ink);
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
}

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

.room-dialog {
  position: relative;
  max-width: min(92vw, 34rem);
  max-height: 88dvh;
  padding: 1.5rem;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: var(--radius);
  background: var(--night);
  color: var(--ink);
  overflow: auto;
}

.room-dialog::backdrop {
  background: rgb(20 12 22 / 0.65);
  backdrop-filter: blur(3px);
}

.room-dialog-close-form {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  margin: 0;
}

.room-dialog-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.room-dialog-close:hover,
.room-dialog-close:focus-visible {
  background: rgb(255 255 255 / 0.08);
  color: var(--ink);
}

.photo-dialog {
  padding-top: 3rem;
  text-align: center;
}

.photo-image {
  display: block;
  max-width: 100%;
  max-height: 68dvh;
  margin: 0 auto;
  border: 10px solid var(--woodFrame, #7d5236);
  border-radius: 4px;
  background: #fff;
}

.photo-caption {
  margin: 1rem 0 0;
  color: var(--ink-soft);
}

.photo-error {
  color: var(--ink-soft);
}

.chip-accent {
  background: var(--accent);
}

.things-list {
  display: grid;
  gap: 0.4rem;
  max-height: 55dvh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.things-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.05);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.things-item:hover,
.things-item:focus-visible {
  background: rgb(255 255 255 / 0.12);
}

.things-verb {
  font-size: 0.85rem;
  white-space: nowrap;
}

.chip[hidden] {
  display: none;
}

.info-dialog {
  width: min(92vw, 30rem);
}

.panel-kicker {
  margin: 0 2.5rem 0.2rem 0;
  color: var(--glow);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-title {
  margin: 0 2.5rem 1rem 0;
  font-size: 1.45rem;
}

.panel-body > * + * {
  margin-top: 0.9rem;
}

.panel-text {
  margin: 0;
  line-height: 1.55;
}

.panel-subhead {
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.muted {
  color: var(--ink-soft);
}

.panel-status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.panel-visits {
  margin: 0.75rem 0 0;
  color: var(--glow);
  font-size: 0.88rem;
}

.profile-city {
  margin: 0.6rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.panel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.panel-chips li {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.09);
  font-size: 0.88rem;
}

.panel-list {
  margin: 0;
  padding-left: 1.3rem;
  line-height: 1.7;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.profile-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  background: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
}

.profile-handle {
  margin: 0 0 0.15rem;
  font-weight: 700;
}

.collection-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.collection-item {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.tv-screen,
.tv-embed {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 1rem;
  border: 8px solid #2a2629;
  border-radius: 10px;
  background: linear-gradient(120deg, #3e4a6b, #cf7651, #e2b04a, #3e4a6b);
  background-size: 300% 300%;
  animation: tv-glow 8s ease-in-out infinite;
}

.tv-embed {
  padding: 0;
}

.song-embed {
  display: block;
  width: 100%;
  height: 152px;
  border: 0;
  border-radius: 12px;
  background: #1d1320;
}

.song-embed.is-tall {
  height: 352px;
}

.song-soundcloud {
  height: 166px;
}

.song-soundcloud.is-tall {
  height: 380px;
}

.song-youtube {
  height: auto;
  aspect-ratio: 16 / 9;
}

.tv-screen-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

.tv-screen-title {
  font-size: 1.3rem;
  font-weight: 800;
}

@keyframes tv-glow {
  50% {
    background-position: 100% 50%;
  }
}

.music-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.music-disc {
  flex: none;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0 18%, #221c1f 19% 100%);
  box-shadow: inset 0 0 0 6px #2f282b, inset 0 0 0 12px #221c1f, inset 0 0 0 13px #3a3236;
}

.music-disc.is-spinning {
  animation: spin 2.4s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.music-title {
  margin: 0;
  font-weight: 700;
}

.secret-note {
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: #3b2a22;
  font-style: italic;
}

.note-list,
.gift-list {
  display: grid;
  gap: 0.6rem;
  max-height: 40dvh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.note {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #fbf0c9;
  color: #3b2a22;
}

.note:nth-child(3n + 2) {
  background: #f6d9d3;
}

.note:nth-child(3n) {
  background: #e3ead6;
}

.note-message {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.note-author {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: #7d5236;
}

.panel-form {
  display: grid;
  gap: 0.5rem;
}

.panel-form input,
.panel-form select,
.panel-form textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.06);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.panel-form .button,
.info-dialog .button {
  justify-self: start;
  margin-top: 0;
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.gift-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gift-button {
  min-height: 44px;
  padding: 0 0.9rem;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.gift-button:hover,
.gift-button:focus-visible {
  background: rgb(255 255 255 / 0.14);
}

.panel-status-message {
  margin: 0;
  color: var(--glow);
}

.panel-footnote {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
  .tv-screen,
  .music-disc.is-spinning {
    animation: none;
  }
}
@media (max-width: 600px) {
  /* Icon-only chips on phones; the label stays available to screen readers. */
  .chip-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .chip-icon {
    margin-right: 0;
    font-size: 1.1rem;
  }

  .room-hint {
    left: 50%;
    right: auto;
    bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 3.5rem);
    transform: translateX(-50%);
    white-space: nowrap;
  }

  .room-nameplate {
    top: calc(max(0.9rem, env(safe-area-inset-top)) + 2.6rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-door {
    animation: none;
  }
}

/* ---- Room editor ---- */

.chip-danger {
  background: #8f3a2e;
}

.chip:disabled,
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

body.is-editing .room-actions,
body.is-editing .room-hint,
body.is-editing .room-tooltip {
  display: none;
}

body.is-editing .room-stage {
  right: var(--editor-width);
}

:root {
  --editor-width: 22rem;
}

.editor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  width: var(--editor-width);
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  background: var(--night);
  border-left: 1px solid rgb(255 255 255 / 0.08);
  box-shadow: -10px 0 30px rgb(0 0 0 / 0.25);
}

.editor[hidden] {
  display: none;
}

.editor-head {
  padding-top: 0.25rem;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.15rem;
}

.editor-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 10px var(--glow);
}

.editor-help {
  margin: 0.35rem 0 0.75rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.editor-help kbd {
  padding: 0 0.3rem;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 4px;
  font: inherit;
  font-size: 0.78rem;
}

.editor-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
}

.editor-tabs [role='tab'] {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.editor-tabs [role='tab'][aria-selected='true'] {
  background: var(--accent);
  color: var(--ink);
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  margin: 0.75rem -0.25rem 0;
  padding: 0 0.25rem;
  overflow-y: auto;
}

.editor-group + .editor-group {
  margin-top: 1rem;
}

.editor-group-title {
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.editor-item,
.editor-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.25rem;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.editor-item:hover,
.editor-item:focus-visible,
.editor-swatch:hover,
.editor-swatch:focus-visible {
  background: rgb(255 255 255 / 0.12);
}

.editor-item[aria-pressed='true'],
.editor-swatch[aria-pressed='true'] {
  border-color: var(--glow);
  box-shadow: inset 0 0 0 1px var(--glow);
}

.editor-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.editor-item-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.08);
  font-size: 1.3rem;
  font-weight: 700;
}

.editor-item-name {
  text-align: center;
  line-height: 1.2;
}

.editor-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.editor-swatch-chip {
  width: 100%;
  height: 2.2rem;
  border-radius: 6px;
}

.editor-find {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 0.6rem;
  background: var(--night);
}

.editor-search {
  width: 100%;
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
  color: var(--ink);
  font: inherit;
}

.editor-search::placeholder {
  color: var(--ink-soft);
}

.editor-filters {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.editor-filter {
  flex: none;
  min-height: 34px;
  padding: 0 0.75rem;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.editor-filter[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent);
}

.editor-group[hidden],
.editor-item[hidden] {
  display: none;
}

.editor-empty {
  margin: 0.5rem 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.editor-item-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.editor-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr));
  gap: 0.45rem;
}

.editor-color {
  aspect-ratio: 1;
  min-width: 2.25rem;
  border: 2px solid rgb(255 255 255 / 0.18);
  border-radius: 50%;
  cursor: pointer;
}

.editor-color[aria-pressed='true'] {
  border-color: var(--glow);
  box-shadow: 0 0 0 2px var(--night), 0 0 0 4px var(--glow);
}

.editor-sizes {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
}

.editor-size {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.editor-size[aria-pressed='true'] {
  background: var(--accent);
  font-weight: 600;
}

[data-editor-item][aria-busy='true'] .editor-color,
[data-editor-item][aria-busy='true'] .editor-size {
  cursor: progress;
}

.editor-group > [role='group'] + [role='group'] {
  margin-top: 0.6rem;
}

.editor-light-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.editor-toggle {
  min-width: 4rem;
  min-height: 40px;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.editor-toggle[aria-checked='true'] {
  border-color: var(--glow);
  background: rgb(255 207 122 / 0.18);
}

.editor-range {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.editor-range input {
  width: 100%;
  accent-color: var(--glow);
}

.editor-effects .editor-size {
  font-size: 0.85rem;
}

.editor-text {
  display: flex;
  gap: 0.4rem;
}

.editor-text .chip {
  pointer-events: auto;
}

.editor-photo-current {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.editor-photo-current li {
  position: relative;
}

.editor-photo-current img,
.editor-photo-missing {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 6px;
  background: rgb(255 255 255 / 0.08);
  object-fit: cover;
}

.editor-photo-remove {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.editor-photo-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.6rem, 1fr));
  gap: 0.4rem;
}

.editor-photo {
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 2px solid rgb(255 255 255 / 0.14);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.06);
  cursor: pointer;
}

.editor-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.editor-photo[aria-pressed='true'] {
  border-color: var(--glow);
}

.editor-upload {
  position: relative;
  margin-top: 0.6rem;
  pointer-events: auto;
  cursor: pointer;
}

.editor-upload:focus-within {
  outline: 3px solid var(--glow);
  outline-offset: 2px;
}

.editor-migrate {
  margin: 0.6rem 0 0 0.4rem;
  pointer-events: auto;
}

.editor-note {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  border: 6px solid #fbf8f2;
  border-bottom-width: 18px;
  border-radius: 3px;
  object-fit: cover;
}

.editor-selection {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgb(255 255 255 / 0.06);
}

.editor-selection[hidden] {
  display: none;
}

.editor-selection-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.editor-selection-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-weight: 700;
}

/* Phone-only controls (see the max-width: 700px block). */
.editor-touch,
.editor-handle {
  display: none;
}

.editor-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.editor-selection-actions .chip {
  pointer-events: auto;
}

.editor-status {
  min-height: 1.3em;
  margin: 0.6rem 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.editor-status.is-warning {
  color: #f0a08f;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-foot .button {
  margin: 0;
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.editor-link {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

@media (max-width: 700px) {
  /*
   * Phones: the editor is a bottom sheet. It "peeks" (just its tabs) so the room
   * gets most of the screen, and opens to show the lists. Save and Cancel move to a
   * slim bar at the top; the selected thing gets a floating toolbar above the sheet.
   * --editor-height is the sheet's measured height (set by EditorPanel).
   */
  body.is-editing .room-stage {
    right: 0;
    bottom: var(--editor-height, 8rem);
  }

  body.is-editing .topbar {
    display: none;
  }

  /* Out of sight, but still the page's heading for screen readers. */
  body.is-editing .room-nameplate {
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
  }

  .editor {
    top: auto;
    left: 0;
    width: auto;
    max-height: 62dvh;
    padding: 0 0.75rem max(0.6rem, env(safe-area-inset-bottom));
    border-left: 0;
    border-top: 1px solid rgb(255 255 255 / 0.08);
    border-radius: 16px 16px 0 0;
  }

  /* The catalogue is long, so Add opens fully; Item and Look fit their content. */
  .editor[data-sheet='open']:has(#editor-tab-add[aria-selected='true']) {
    height: 62dvh;
  }

  .editor-handle {
    position: relative;
    display: block;
    flex: none;
    height: 26px;
    margin: 0 -0.75rem;
    border: 0;
    background: none;
    cursor: grab;
    touch-action: none;
  }

  .editor-handle::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: rgb(255 255 255 / 0.3);
  }

  .editor-head {
    display: none;
  }

  .editor[data-sheet='peek'] .editor-scroll {
    display: none;
  }

  .editor-scroll {
    margin-top: 0.5rem;
  }

  .editor-status {
    min-height: 1.3em;
    margin: 0.45rem 0 0;
    overflow: hidden;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .editor-foot {
    position: fixed;
    inset: 0 0 auto;
    z-index: 26;
    padding: max(0.6rem, env(safe-area-inset-top)) 0.75rem 1.2rem;
    background: linear-gradient(rgb(28 19 30 / 0.85) 55%, rgb(28 19 30 / 0));
  }

  .editor-foot .editor-link {
    margin-left: 0.25rem;
  }

  .editor-foot [data-editor-command='save'] {
    order: 1;
    margin-left: auto;
  }

  .editor-selection {
    position: fixed;
    right: 0.5rem;
    bottom: calc(var(--editor-height, 8rem) + 0.5rem);
    left: 0.5rem;
    z-index: 26;
    margin: 0;
    padding: 0.5rem;
    border: 1px solid rgb(255 255 255 / 0.1);
    border-radius: 14px;
    background: rgb(43 29 46 / 0.94);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  }

  .editor-selection-head {
    margin-bottom: 0.4rem;
  }

  .editor-selection-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .editor-touch:not([hidden]) {
    display: inline-flex;
  }

  .editor[data-pending='true'] [data-editor-command='deselect'] {
    display: none;
  }

  .editor-selection-actions {
    flex-wrap: nowrap;
    gap: 0.25rem;
  }

  .editor-selection .chip {
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding: 0 0.7rem;
  }

  .editor-selection-actions .chip:not(.chip-danger) {
    padding: 0;
  }

  .editor-nudge {
    gap: 0.25rem;
    margin-inline: auto;
  }

  .editor-items {
    grid-template-columns: repeat(4, 1fr);
  }

  .editor-item img,
  .editor-item-icon {
    width: 44px;
    height: 44px;
  }
}
