/* Focused call surface; the room retains its existing media lifecycle. */
#roomDock[hidden], .room-call-pane[hidden], .room-call-pane [hidden], .room-resume-card[hidden], .room-focus-dialog:not([open]) { display: none !important; }
.room-peer-media { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

#roomDock {
  position: sticky; top: 0; z-index: 350;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; box-sizing: border-box;
  padding: max(6px, env(safe-area-inset-top)) 12px 6px;
  background: #101813; color: #edf8f1; border-bottom: 1px solid #354b3d;
  box-shadow: 0 3px 12px #0005;
}
body.has-room-call header.site { top: var(--room-dock-h); }
body.has-room-call #view-studio #edPanel.ps-full {
  top: calc(var(--ps-vvtop, 0px) + var(--room-dock-h));
  height: calc(var(--ps-vvh, 100dvh) - var(--room-dock-h)); bottom: auto;
}
body.has-room-call #detailOverlay.open { top: var(--room-dock-h); }
body.has-room-call #detailOverlay .watch-player::before { content: "Independent playback"; display: block; font-size: .85rem; color: #d1e8e2; }
#roomDock .room-return { flex: 0 1 24rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#roomDock .room-status { margin-inline: 4px 12px; font-size: .79rem; color: #a8dbba; white-space: nowrap; }
#roomDock .room-leave { color: #ffd3dc; background: #3b1722; border-color: #753346; }

.room-button, .room-icon-button, .room-control, .room-call-pane :is(input, select) {
  box-sizing: border-box; min-height: 44px;
  font: inherit; color: #edf7f0; background: #19231d;
  border: 1px solid #35463b; border-radius: 10px; padding: 9px 13px;
}
.room-button, .room-icon-button, .room-control { cursor: pointer; touch-action: manipulation; font-weight: 650; line-height: 1.2; }
.room-button:disabled, .room-icon-button:disabled, .room-control:disabled { opacity: .42; cursor: not-allowed; }
.room-button[aria-pressed="true"] { color: #bcf8d0; border-color: #6ca883; background: #1c3a29; }
.room-button:focus-visible, .room-call-pane :focus-visible, .room-focus-dialog :focus-visible {
  outline: 2px solid #adffcb; outline-offset: 3px;
}

.room-call-pane, #communityHub section.room-call-pane {
  --call-bg: #0d110e; --call-tile: #191e1a; --call-edge: #2d3a31;
  display: flex; flex-direction: column; gap: 14px;
  position: relative; min-width: 0; min-height: 360px; box-sizing: border-box;
  margin: 0 0 10px; padding: 18px; overflow: hidden;
  color: #eef8f1; background: var(--call-bg); border: 1px solid var(--call-edge); border-radius: 18px;
  font-family: inherit; color-scheme: dark;
}
.room-call-pane :is(h3, h4, p, figure) { margin: 0; }
.room-call-top {
  order: 0; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 48px;
}
.room-call-heading { display: grid; flex: 1; gap: 4px; min-width: 0; }
.room-community-name { color: #8da997; font-size: .7rem; line-height: 1.25; letter-spacing: .015em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.room-call-pane .room-call-heading h3 { color: #f2faf5; font-family: inherit; font-size: 1.03rem; font-weight: 700; line-height: 1.25; letter-spacing: -.015em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.room-top-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 7px; }
.room-icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border-color: transparent; background: #171e19; border-radius: 12px; }
.room-call-top > .room-icon-button { flex: 0 0 44px; }
.room-icon-button svg { width: 20px; height: 20px; display: block; }
.room-icon-button[aria-pressed="true"] { color: #15271c; background: #d2f5df; }
.room-notice { order: 1; flex: 0 0 auto; padding: 10px 12px; border: 1px solid #3d5847; border-radius: 10px; color: #d6ebdd; background: #17241c; font-size: .8rem; line-height: 1.5; overflow-wrap: anywhere; }
.room-notice:empty { display: none; }

.room-lobby { order: 2; flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 22px 12px 12px; text-align: center; }
.room-lobby-icon { display: grid; place-items: center; width: 76px; height: 76px; background: #173323; color: #a2f5bd; border: 1px solid #305d40; border-radius: 24px; }
.room-lobby svg { width: 32px; height: 32px; }
.room-lobby h4 { color: #eefaef; font-size: 1.35rem; line-height: 1.25; letter-spacing: -.02em; }
.room-lobby p { max-width: 38ch; color: #a5b8ac; font-size: .88rem; line-height: 1.6; }
.room-join-actions { order: 3; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 0 18px; }
.room-join-actions button { min-height: 48px; padding: 12px 20px; }
.room-join-actions .room-join-primary { background: #9bedb6; border-color: #9bedb6; color: #0b2414; font-weight: 750; }
.room-join-actions .room-join-listen { background: transparent; color: #c7e2d1; border-color: #415a49; }
.room-join-hint { order: 4; align-self: center; max-width: 42ch; color: #8fa99a; font-size: .77rem; line-height: 1.5; text-align: center; }

.room-stage { order: 2; display: flex; flex: 1 1 auto; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 8px 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #38513f transparent; }
.room-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: center; gap: 12px; width: 100%; min-width: 0; margin: auto; }
.room-tiles[data-count="1"] { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
.room-tiles:is([data-count="2"], [data-count="3"], [data-count="4"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.room-tiles > :is(.room-peer, .room-self) {
  position: relative; isolation: isolate; display: grid; place-items: center;
  width: 100%; min-width: 0; min-height: 0; aspect-ratio: 16 / 10;
  margin: 0; overflow: hidden; border: 1px solid #303d33; border-radius: 16px; background: var(--call-tile, #191e1a);
}
.room-avatar {
  position: relative; z-index: 0; display: grid; place-items: center; flex: none;
  width: clamp(64px, 9vw, 112px); aspect-ratio: 1; overflow: hidden;
  border-radius: 50%; border: 1px solid #41604b; background: #253b2c; color: #cdf6da;
  font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 700; line-height: 1;
}
.room-avatar img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
img.room-avatar { display: block; height: auto; object-fit: cover; }
.room-avatar > :is(img, span) { border-radius: inherit; }
.room-avatar > span { display: grid; place-items: center; width: 100%; height: 100%; }
.room-tiles video.room-camera { position: absolute; z-index: 1; inset: 0; display: block; width: 100%; height: 100%; max-height: none; object-fit: cover; background: #101612; border: 0; border-radius: inherit; }
.room-tiles video.room-camera.is-mirrored { transform: scaleX(-1); }
.room-tiles .is-sharing video.room-camera { object-fit: contain; background: #050805; }
.room-person-label {
  position: absolute; z-index: 2; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; max-width: calc(100% - 24px);
  box-sizing: border-box; padding: 6px 10px; min-height: 32px; color: #f6fff9;
  background: #07100bd9; border: 1px solid #d6f5df13; border-radius: 9px;
  font-size: .8rem; line-height: 1.2; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.room-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-mic-state { display: inline-flex; align-items: center; flex: 0 0 auto; color: #c5e4cf; }
.room-mic-state, .room-mic-state svg { width: 15px; height: 15px; }
.room-mic-state.is-off, .room-mic-state.is-muted { color: #ffc3ce; }
.room-call-meta { order: 3; flex: 0 0 auto; color: #9fbaaa; font-size: .79rem; line-height: 1.5; text-align: center; overflow-wrap: anywhere; }
.room-call-meta:empty { display: none; }
.room-empty { order: 3; color: #9cb4a5; font-size: .83rem; line-height: 1.5; text-align: center; padding: 4px 0; }
.room-invite { order: 3; align-self: center; display: inline-flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; min-height: 44px; color: #c7f1d6; }
.room-invite svg { width: 18px; height: 18px; flex: none; }

.room-toolbar {
  order: 5; flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center; justify-items: center; gap: 12px; width: min(100%, 520px); box-sizing: border-box;
  margin: 0 auto; padding: 14px; background: #141b16; border: 1px solid #2b3830; border-radius: 20px;
}
.room-call-pane .room-control {
  display: inline-grid; place-items: center; width: 100%; max-width: 64px; min-width: 44px; height: 56px;
  padding: 0; color: #d4e2da; background: #202a23; border: 1px solid transparent; border-radius: 14px;
}
.room-control svg { display: block; width: 25px; height: 25px; }
.room-call-pane .room-control.is-off { color: #becdc3; background: #1b221e; border-color: #2c3930; }
.room-call-pane .room-control.is-active, .room-call-pane .room-control[aria-pressed="true"] { color: #0c2a17; background: #a3f0bd; border-color: #b9f8cd; }
.room-call-pane .room-control[aria-expanded="true"] { color: #a5f4c0; background: #294433; border-color: #6b9c7c; }
.room-call-pane .room-control.room-leave { color: #fff5f7; background: #c82443; border-color: #e44463; }
.room-call-pane .room-control.room-leave:hover { background: #de2f51; border-color: #ff6f8a; }

.room-more-panel { order: 4; flex: 0 1 auto; display: grid; gap: 14px; max-height: min(34dvh, 340px); overflow: auto; overscroll-behavior: contain; padding: 15px; border: 1px solid #354a3c; border-radius: 14px; background: #111c15; scrollbar-width: thin; }
.room-more-panel h4 { color: #d2eadb; font-size: .87rem; }
.room-more-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-member-list { color: #c2d9cb; font-size: .81rem; line-height: 1.6; overflow-wrap: anywhere; }
.room-watch-pane { order: 3; flex: 0 1 auto; display: grid; gap: 9px; min-height: 0; max-height: min(38dvh, 350px); overflow: auto; }
.room-watch-pane h4 { font-size: .85rem; color: #d0e9d9; line-height: 1.4; }
.room-watch-options { min-width: 0; padding-top: 6px; border-top: 1px solid #304537; }
.room-watch-options summary { display: flex; align-items: center; min-height: 44px; color: #d1f4dd; font-size: .85rem; font-weight: 650; cursor: pointer; }
.room-watch-options summary::after { content: "⌄"; margin-left: auto; padding-left: 12px; color: #91b39d; font-size: 1.1rem; }
.room-watch-options[open] summary::after { transform: rotate(180deg); }
.room-watch-options > :not(summary) { margin-top: 12px; }
.room-more-panel .hint, .room-privacy { color: #9fb5a7; font-size: .78rem; line-height: 1.5; }
.room-privacy summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: #c0d6c9; }
.room-privacy summary::after { content: "⌄"; margin-left: auto; padding-left: 12px; color: #91b39d; font-size: 1.1rem; }
.room-privacy[open] summary::after { transform: rotate(180deg); }
.room-privacy p { padding: 6px 0 4px; }
.room-actions, .room-host-controls form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-host-controls { display: grid; gap: 12px; min-width: 0; }
.room-volume { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: #c4dece; font-size: .83rem; }
.room-volume input[type="range"], .room-host-controls input[type="range"] { flex: 1 1 110px; min-width: 0; max-width: 100%; min-height: 44px; padding: 0; border: 0; background: transparent; accent-color: #9aefb8; }
.room-host-controls :is(select, input[type="search"]) { flex: 1 1 160px; min-width: 0; max-width: 100%; }
.room-host-controls select { flex-basis: 100%; }
.room-party-player { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: min(36dvh, 360px); object-fit: contain; background: #030705; border-radius: 10px; }

.room-resume-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px; border: 1px solid #385141; border-radius: 16px; background: #111c15; color: #e6f6ec; }
.room-resume-copy { display: grid; gap: 5px; min-width: 0; }
.room-resume-copy strong { font-size: .94rem; overflow-wrap: anywhere; }
.room-resume-copy p { margin: 0; color: #a6c3b1; font-size: .81rem; line-height: 1.5; }
.room-resume-card .room-button { flex: 0 0 auto; color: #092114; background: #a0edb9; border-color: #a0edb9; }
#communityHub .cm-voice .cm-stage-body:has([data-cm-chat][hidden]) { grid-template-columns: minmax(0, 1fr); }

.room-focus-dialog {
  width: min(1000px, calc(100vw - 40px)); height: min(90dvh, 920px); max-width: none; max-height: 90dvh;
  margin: auto; padding: 0; overflow: hidden; color: #eef8f1; background: #0d110e;
  border: 1px solid #3a4a3f; border-radius: 22px; box-shadow: 0 24px 80px #000a; color-scheme: dark;
}
.room-focus-dialog[open] { display: flex; }
.room-focus-dialog::backdrop { background: #030805d9; backdrop-filter: none; -webkit-backdrop-filter: none; }
.room-focus-body { display: flex; flex: 1; min-width: 0; min-height: 0; width: 100%; height: 100%; }
.room-focus-dialog .room-call-pane { flex: 1; min-height: 0; width: 100%; height: 100%; margin: 0; padding: 20px 24px; border: 0; border-radius: 0; }
.room-focus-dialog .room-stage { flex: 1 1 0; }
.room-focus-dialog .room-notice { max-height: min(18dvh, 96px); overflow: auto; }
@supports (container-type: size) {
  .room-focus-dialog .room-stage { container-type: size; }
  .room-focus-dialog .room-tiles[data-count="1"] { width: min(100%, 160cqh, 720px); }
  .room-focus-dialog .room-tiles:is([data-count="3"], [data-count="4"]) { width: min(100%, calc(160cqh - 7.2px)); }
}
@media (hover: hover) and (pointer: fine) {
  .room-button:not(:disabled):hover, .room-icon-button:not(:disabled):hover { border-color: #7fa58d; }
  .room-control:not(:disabled):not(.room-leave):hover { outline: 1px solid #95b9a1; outline-offset: 1px; }
}
@media (max-width: 700px) {
  .room-call-pane, #communityHub section.room-call-pane { padding: 14px; gap: 12px; border-radius: 14px; }
  .room-call-heading { gap: 3px; }
  .room-call-pane .room-call-heading h3 { font-size: .98rem; }
  .room-community-name { font-size: .66rem; }
  .room-top-actions { gap: 5px; }
  .room-join-actions { flex-direction: column; align-items: stretch; }
  .room-lobby { padding-top: 18px; }
  .room-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .room-tiles:is([data-count="1"], [data-count="2"]) { grid-template-columns: minmax(0, 1fr); }
  .room-tiles[data-count="1"] > :is(.room-peer, .room-self) { aspect-ratio: 1; }
  .room-tiles[data-count="2"] { max-width: 560px; }
  .room-avatar { width: clamp(64px, 23vw, 120px); font-size: 2.2rem; }
  .room-tiles:not([data-count="1"]):not([data-count="2"]) .room-avatar { width: clamp(48px, 14vw, 76px); font-size: 1.6rem; }
  .room-toolbar { padding: 12px; gap: 10px; border-radius: 19px; }
  .room-call-pane .room-control { height: 56px; border-radius: 14px; }
  .room-focus-dialog { inset: 0; width: 100%; height: 100dvh; max-width: 100%; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .room-focus-dialog .room-call-pane {
    padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 12px; border-radius: 0;
  }
  .room-focus-dialog .room-stage { padding: 4px 0; }
  .room-focus-dialog .room-toolbar { width: 100%; max-width: 520px; }
  @supports (container-type: size) {
    .room-focus-dialog .room-tiles[data-count="1"] { width: min(100%, 100cqh, 620px); }
    .room-focus-dialog .room-tiles[data-count="2"] { width: min(100%, calc(80cqh - 8px), 560px); }
    .room-focus-dialog .room-tiles:is([data-count="3"], [data-count="4"]) { width: min(100%, calc(160cqh - 6px)); }
  }
}
@media (max-width: 480px) {
  #roomDock { justify-content: space-between; gap: 5px; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  #roomDock .room-status { display: none; }
  #roomDock .room-button { flex: 0 0 auto; font-size: .76rem; padding-inline: 8px; }
  #roomDock .room-return { flex: 1 1 72px; max-width: none; }
  .room-resume-card { align-items: stretch; flex-direction: column; gap: 12px; }
}
@media (max-width: 360px) {
  .room-call-top { gap: 8px; }
  .room-toolbar { gap: 6px; padding: 10px 8px; }
  .room-call-pane .room-control { min-width: 44px; height: 48px; border-radius: 12px; }
  .room-control svg { width: 23px; height: 23px; }
  .room-person-label { bottom: 9px; padding: 5px 8px; font-size: .75rem; }
}
@media (max-height: 520px) and (min-width: 701px) {
  .room-focus-dialog { width: min(1000px, calc(100vw - 20px)); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
  .room-focus-dialog .room-call-pane { gap: 8px; padding: 10px 16px; }
  .room-focus-dialog .room-toolbar { padding: 8px 12px; }
  .room-focus-dialog .room-control { height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .room-call-pane *, #roomDock *, .room-focus-dialog { scroll-behavior: auto; transition: none; animation: none; }
}
