/* Communication workspace on the established plates, not a replacement theme. */
body:has(.room-workspace) #main,
body:has(.room-directory-layout) #main {
  width: min(96rem, calc(100% - var(--gutter-l) - var(--gutter-r)));
  max-width: calc(100% - var(--gutter-l) - var(--gutter-r));
}
/* Below 1100px main is not centred (page-craft.css centres it from there), so taking the gutters off its width
   as well as padding it by them left a second gutter on the right only: 16px left, 48px right at 320 (QA, Nov 20).
   main's own padding is the gutter here. */
@media (max-width: 1099.98px) {
  body:has(.room-workspace) #main,
  body:has(.room-directory-layout) #main {
    width: 100%;
    max-width: 100%;
  }
}
.room-workspace,
.room-directory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}
.room-navigation {
  min-width: 0;
  font-family: var(--font-sans);
}
.room-navigation-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-fg);
  font-weight: 600;
}
.room-navigation-toggle svg {
  width: 1.1rem;
}
.room-navigation-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-surface);
}
.room-navigation details:not([open]) .room-navigation-body {
  display: none;
}
.room-navigation details[open] .room-navigation-body {
  display: flex;
}
.room-global-navigation,
.room-list-navigation {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.room-global-navigation button,
.room-list-button {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) 1rem;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  text-align: left;
}
.room-global-navigation button svg {
  width: 1rem;
  height: 1rem;
}
.room-list-button {
  grid-template-columns: minmax(0, 1fr) 1rem;
}
.room-list-button span {
  overflow-wrap: anywhere;
}
.room-list-button svg {
  width: 1rem;
}
.room-global-navigation button:hover,
.room-list-button:hover {
  background: var(--color-raised);
  color: var(--color-fg);
}
.room-global-navigation button[aria-current],
.room-list-button[aria-current] {
  border-color: var(--color-gilt);
  background: var(--color-raised);
  color: var(--color-fg);
  font-weight: 600;
}
.room-main,
.room-directory-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.room-primary,
.room-primary-heading {
  min-width: 0;
}
.room-primary-heading {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.room-primary-heading h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.room-header {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}
.room-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
}
.room-header-actions button {
  min-height: 44px;
}
.room-activity {
  min-width: 0;
}
.room-activity-grid {
  display: grid;
  gap: 1.25rem;
}
/* Opening a room scrolls .room-header to block start (room-workspace.tsx); html's scroll-padding-top already
   counts --mast-h, so the header adds only its own gap. */
.room-header {
  scroll-margin-top: 0.75rem;
}
#room-heading {
  scroll-margin-top: calc(var(--mast-h) + 0.75rem);
  scroll-margin-bottom: calc(var(--tabbar-h, 64px) + env(safe-area-inset-bottom) + 0.75rem);
}
.room-context {
  align-self: start;
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-surface);
  scroll-margin-top: calc(var(--mast-h) + 0.75rem);
  scroll-margin-bottom: calc(var(--tabbar-h, 64px) + env(safe-area-inset-bottom) + 0.75rem);
}
.room-context[data-open="false"] {
  display: none;
}
.room-context-panel[hidden] {
  display: none;
}
.room-context-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}
.room-context-heading button {
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}
.room-context .room-members {
  border: 0;
  padding: 0;
  background: transparent;
}
.room-members li {
  min-width: 0;
}
.room-directory-heading {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.directory-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.directory-types button {
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-line);
  border-radius: 5px;
  background: var(--color-surface);
  color: var(--color-fg);
}
.directory-types button:hover {
  background: var(--color-raised);
}
.directory-types button.is-selected {
  border-color: var(--color-gilt);
  background: var(--color-raised);
  font-weight: 600;
}
.directory-content {
  min-width: 0;
}
.directory-content > .flex.gap-8 {
  gap: 1rem;
}
@media (max-width: 79.99rem) {
  .room-main {
    display: contents;
  }
  .room-main > .room-primary {
    order: 0;
  }
  .room-main > .room-call {
    order: 1;
  }
  .room-main > .room-activity {
    order: 3;
  }
  .room-main > :not(.room-primary):not(.room-call):not(.room-activity) {
    order: 4;
  }
  .room-context {
    order: 2;
  }
  .room-context .room-chat {
    height: auto;
    max-height: 22rem;
  }
  .room-context .room-chat-transcript {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 16rem;
  }
}
@media (min-width: 80rem) {
  .room-workspace,
  .room-directory-layout {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 1.25rem;
  }
  .room-navigation {
    position: sticky;
    top: calc(var(--mast-h) + 0.75rem);
    max-height: calc(100svh - var(--mast-h) - 1.5rem);
    overflow-y: auto;
  }
  .room-navigation-toggle {
    display: flex;
  }
  .room-navigation-body[data-open="true"] {
    display: flex;
  }
}
@media (min-width: 80rem) {
  .room-workspace:has(> .room-context[data-open="true"]) {
    grid-template-columns: auto minmax(0, 1fr) minmax(16rem, 20rem);
  }
}
html:has(.room-settings-backdrop) {
  overflow: hidden;
  scrollbar-gutter: stable;
}
/* The same call parts, with video taking the available stage and a common toolbar. */
.room-chat {
  min-width: 0;
}
.room-context .room-chat {
  height: min(65svh, 38rem);
  gap: 0.65rem;
}
.room-chat-transcript {
  flex: 1 1 12rem;
  min-height: 8rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  min-width: 0;
}
.room-chat-transcript:focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: -2px;
}
.room-chat-form {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
  align-items: center;
}
.room-chat-input {
  min-width: 0;
  flex: 1;
}
.room-chat-form button {
  flex-shrink: 0;
  min-height: 44px;
}
.room-chat-line {
  max-width: 100%;
}
.room-call {
  padding: clamp(0.75rem, 2vw, 1.125rem);
  border-color: color-mix(in srgb, var(--color-gilt) 32%, var(--color-line));
}
.room-call[data-phase="live"] {
  background: color-mix(in srgb, var(--color-surface) 92%, black);
}
.room-main .call-tiles,
[data-group-live] .call-tiles {
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}
.room-main .call-tiles video,
.room-main .call-tiles canvas,
[data-group-live] .call-tiles video,
[data-group-live] .call-tiles canvas {
  width: 100%;
  aspect-ratio: 16/9;
  max-height: min(65svh, 44rem);
  object-fit: cover;
  border: 1px solid var(--color-line);
  border-radius: 5px;
}
.call-camera-off {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}
.call-camera-off-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16/9;
  max-height: min(65svh, 44rem);
  border: 1px solid var(--color-line);
  border-radius: 5px;
  background: var(--color-raised);
  color: var(--color-gilt);
}
.call-camera-off-avatar svg {
  width: 3rem;
  height: 3rem;
}
.call-camera-off figcaption {
  font-size: 0.875rem;
  color: var(--color-muted);
}
.room-call .call-live[data-pane="chat"] .call-camera-off {
  display: none;
}
.call-frame .call-controls {
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-raised);
}
.room-settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgb(0 0 0 / 0.7);
}
.room-settings-dialog {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 80;
  width: min(30rem, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1rem, 3vw, 1.75rem);
  border-left: 1px solid var(--color-gilt);
  background: var(--color-surface);
  color: var(--color-fg);
  box-shadow: -18px 0 40px rgb(0 0 0 / 0.35);
}
.room-settings-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.room-settings-close {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--color-line);
  border-radius: 5px;
  color: var(--color-fg);
}
.room-settings-close:hover {
  background: var(--color-raised);
}
.room-settings-close svg {
  width: 1.15rem;
}
.room-settings-fields {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
@media (min-width: 48rem) {
  .room-call .call-live:has([data-call-lines]) {
    grid-template-areas: "stage chat" "controls chat";
  }
  .room-call .call-stage {
    grid-area: stage;
  }
  .room-call .call-chat {
    grid-area: chat;
  }
  .room-call .call-controls {
    grid-area: controls;
  }
}
@media (min-width: 80rem) {
  [data-group-live]:has([data-phase="live"]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
    align-items: start;
    gap: 1rem;
  }
}

/* Inner room layouts use their own width, not the width of the full browser. */
@media (max-width: 79.99rem) {
  .room-browse {
    grid-template-columns: minmax(0, 1fr);
  }
}
.room-main {
  container: room-work / inline-size;
}
.room-activity-aside {
  display: none;
}
.room-activity-compact {
  display: flex;
  min-width: 0;
}
.room-composer {
  min-width: 0;
}
.room-composer-types {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
@container room-work (min-width: 56rem) {
  .room-activity-grid {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem);
    gap: 1.5rem;
  }
  .room-activity-aside {
    display: flex;
  }
  .room-activity-compact {
    display: none;
  }
}

/* Compact discovery and disclosure menus. */
.menu-count {
  margin-inline-start: auto;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}
.menu-summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--color-fg);
}
.menu-summary {
  font-weight: 600;
}
/* The count sits beside its heading, not across a wide row (Josh: no gap over 120px). */
.category-section-summary .menu-count {
  margin-inline-start: 0;
}
.discovery-filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 0.75rem;
  min-width: 0;
  align-items: start;
}
.menu-filter {
  min-width: 0;
}
:is(
  .room-filter-summary,
  .category-section-summary,
  .menu-summary
):focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: -2px;
  box-shadow: 0 0 0 4px var(--color-surface);
}
.group-discovery-filter {
  padding: var(--space-3);
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-surface);
}
.group-discovery-filter [role="search"] {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.625rem;
}
.category-section {
  border-top: 1px solid var(--color-line);
}
.category-section:first-of-type {
  border-top: 0;
}
.category-section-summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  color: var(--color-fg);
  padding-block: 0.5rem;
}
.category-title {
  margin: 0;
  color: var(--color-fg);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 500;
}
.category-section-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.25rem 0.15rem 0.75rem;
}
/* A short window (1024x470 with a bookmarks bar, Josh, Nov 27) left the list a sliver under the mast; 14rem keeps
   the filter and a few rooms in view, and the list still scrolls inside. */
.room-navigation-body {
  max-height: min(32rem, max(14rem, calc(100svh - var(--mast-h) - 5rem)));
  overflow-y: auto;
  overflow-x: hidden;
  scroll-padding-block: 0.5rem;
}
/* The label stays when the list is closed: an icon and a count alone were an unlabelled control (Josh, Nov 20). */
.room-navigation-toggle {
  width: fit-content;
  min-width: 44px;
}
:is(.room-navigation, .category-section, .group-discovery-filter)
  > details
  > summary::before,
.room-navigation > details > summary::before,
.group-discovery-filter > summary::before {
  content: "›";
  color: var(--color-gilt);
  font-size: 1rem;
}
.details-open[open] > summary::before {
  transform: rotate(90deg);
}
@media (min-width: 80rem) {
  .room-navigation details[open] {
    width: 13rem;
  }
  .room-navigation details[open] .room-navigation-toggle {
    width: 100%;
  }
}
.more-dialog {
  width: min(22rem, calc(100vw - 2rem));
  max-height: calc(100svh - 6rem);
  overflow-y: auto;
}
.more-dialog .menu-filter {
  margin-bottom: 0.75rem;
}
@media (max-width: 47.99rem) {
  .category-title {
    font-size: 1.25rem;
  }
}

/* A church's website and its men's and women's rooms, under the room name. */
/* Inline, so a wrapped address keeps the new-tab mark beside its last word. */
.room-website {
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
}
.room-website a {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-gilt);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--color-gilt) 45%, transparent);
  text-underline-offset: 0.2em;
}
.room-website a:hover {
  color: var(--color-fg);
  text-decoration-color: var(--color-fg);
}
.room-website-icon {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  margin-inline-start: 0.3rem;
  vertical-align: -0.1em;
}
.church-rooms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  min-width: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-line);
}
.church-rooms-label {
  font-size: 0.8125rem;
  color: var(--color-muted);
}
.church-room-link {
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-fg);
  font-size: 0.875rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: start;
}
.church-room-link:hover {
  border-color: var(--color-gilt);
  background: var(--color-raised);
}
.church-room-link:focus-visible,
.room-website a:focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: 2px;
}
.church-rooms-note {
  flex-basis: 100%;
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* The room's actions as a two-row toolbar wherever one row does not fit
   (Josh, Nov 22): on phones, and in the narrow middle column of a wide screen
   when both side panels are open. "All rooms" and Settings share the top row;
   Chat and Members split the second row evenly, so nothing is left alone on a
   line. A room with only one of the two gives it the whole row. On phones a tap
   on either also scrolls to the panel below (room-workspace.tsx). */
.room-action-short {
  display: none;
}
@media (max-width: 47.99rem) {
  .room-header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.5rem;
  }
  .room-header-actions > button {
    min-width: 0;
    width: 100%;
  }
  .room-header-actions > [data-action="all"],
  .room-header-actions > [data-action="settings"] {
    grid-row: 1;
    width: auto;
    padding-inline: 0.25rem;
  }
  .room-header-actions > [data-action="all"] {
    grid-column: 1;
    justify-self: start;
  }
  .room-header-actions > [data-action="settings"] {
    grid-column: 2;
    justify-self: end;
  }
  .room-header-actions > [data-action="chat"] {
    grid-row: 2;
    grid-column: 1;
  }
  .room-header-actions > [data-action="members"] {
    grid-row: 2;
    grid-column: 2;
  }
  .room-header-actions[data-panels="1"] > [data-action="chat"],
  .room-header-actions[data-panels="1"] > [data-action="members"] {
    grid-column: 1 / -1;
  }
  .room-action-long {
    display: none;
  }
  .room-action-short {
    display: inline;
  }
}
@media (min-width: 80rem) {
  @container room-work (max-width: 35rem) {
    .room-header-actions {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      width: 100%;
      gap: 0.5rem;
    }
    .room-header-actions > button {
      min-width: 0;
      width: 100%;
    }
    .room-header-actions > [data-action="all"],
    .room-header-actions > [data-action="settings"] {
      grid-row: 1;
      width: auto;
      padding-inline: 0.25rem;
    }
    .room-header-actions > [data-action="all"] {
      grid-column: 1;
      justify-self: start;
    }
    .room-header-actions > [data-action="settings"] {
      grid-column: 2;
      justify-self: end;
    }
    .room-header-actions > [data-action="chat"] {
      grid-row: 2;
      grid-column: 1;
    }
    .room-header-actions > [data-action="members"] {
      grid-row: 2;
      grid-column: 2;
    }
    .room-header-actions[data-panels="1"] > [data-action="chat"],
    .room-header-actions[data-panels="1"] > [data-action="members"] {
      grid-column: 1 / -1;
    }
    .room-action-long {
      display: none;
    }
    .room-action-short {
      display: inline;
    }
  }
}

/* The panel takes focus when a tap brings it into view; show that only to keyboards. */
.room-context:focus {
  outline: none;
}
.room-context:focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: 2px;
}
