/*
  Readiness layer.
  Loads after styles.css. One headline and one fact under it; content as
  hairline rows on a single calm card; a circle on the left carries state;
  at most one action per row; detail opens in place; color only for state.
*/

/* ---------- Tokens: calm surfaces, each theme keeps its own tint ---------- */

:root,
body[data-theme="house"] {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --surface-strong: #fffdf8;
  --soft: #f1eadb;
  --line: #e6ddcb;
  --ink: #2a2014;
  --muted: #6d5f4b;
  --accent: #8a5a12;
  --accent-soft: #f3e6cc;
  --info: #8a5a12;
  --info-soft: #f3e6cc;
}

body[data-theme="hall"] {
  --bg: #f3f4f2;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --soft: #eef0ed;
  --line: #e1e4df;
  --ink: #1d2320;
  --muted: #5f6864;
  --accent: #3d5f8c;
  --accent-soft: #e4ebf3;
  --info: #3d5f8c;
  --info-soft: #e4ebf3;
  --success: #3f6b4a;
  --success-soft: #e3eee5;
}

body[data-theme="paper"] {
  --bg: #f5f3f0;
  --surface: #fffefc;
  --surface-strong: #fffefc;
  --soft: #efebe6;
  --line: #e5e0da;
  --ink: #2b2320;
  --muted: #6c635d;
  --accent: #8a5540;
  --accent-soft: #f2e4dc;
  --info: #8a5540;
  --info-soft: #f2e4dc;
}

body[data-theme="night"] {
  --bg: #f7f1e8;
  --surface: #fffaf3;
  --surface-strong: #fffaf3;
  --soft: #f2e8d8;
  --line: #eadfcf;
  --ink: #2a1a0d;
  --muted: #6c5538;
  --accent: #9a6424;
  --accent-soft: #f4e4cc;
  --info: #9a6424;
  --info-soft: #f4e4cc;
}

body[data-theme="house-dark"] {
  --bg: #17130d;
  --surface: #211b13;
  --surface-strong: #211b13;
  --soft: #2b2319;
  --line: #3a3022;
  --ink: #f4ead6;
  --muted: #bfae8e;
  --accent: #d8b46c;
  --accent-soft: #3a2f1c;
  --info: #d8b46c;
  --info-soft: #3a2f1c;
}

body[data-theme="hall-dark"] {
  --bg: #13171b;
  --surface: #1b2025;
  --surface-strong: #1b2025;
  --soft: #232a30;
  --line: #2e363d;
  --ink: #e9ece8;
  --muted: #a4aca8;
  --accent: #8eb0d8;
  --accent-soft: #24303d;
  --info: #8eb0d8;
  --info-soft: #24303d;
}

body[data-theme="paper-dark"] {
  --bg: #171514;
  --surface: #211e1c;
  --surface-strong: #211e1c;
  --soft: #2b2724;
  --line: #38322e;
  --ink: #f1e9df;
  --muted: #b8aa9c;
  --accent: #d9a288;
  --accent-soft: #3a2c25;
  --info: #d9a288;
  --info-soft: #3a2c25;
}

body[data-theme="night-dark"] {
  --bg: #16110c;
  --surface: #201912;
  --surface-strong: #201912;
  --soft: #2a2118;
  --line: #3a2d20;
  --ink: #f3e7c9;
  --muted: #c3a978;
  --accent: #e8a23a;
  --accent-soft: #3a2a16;
  --info: #e8a23a;
  --info-soft: #3a2a16;
}

body[data-theme] {
  --rail-bg: var(--bg);
  --rail-ink: var(--ink);
  --rail-active-bg: var(--soft);
  --rail-active-ink: var(--ink);
  --line-strong: color-mix(in srgb, var(--line), var(--ink) 18%);
  --card-radius: var(--radius-card);
  --radius-card: 12px;
  --row-radius: var(--radius);
  --hairline: 1px solid var(--line);
  --shadow: none;
  --frame-wide: 760px;
  --frame-standard: 760px;
  --frame-reading: 680px;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Shared material ---------- */

body[data-theme] h1,
body[data-theme] h2 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

body[data-theme] .eyebrow {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-caption);
  font-weight: 400;
  color: var(--muted);
}

body[data-theme] :is(.tool-button, .tiny-button, .send-button, .reaction, .text-icon-button, .icon-button) {
  border-radius: var(--row-radius);
  box-shadow: none;
}

body[data-theme] :is(.tool-button, .tiny-button) {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

body[data-theme] :is(.tool-button, .tiny-button):hover {
  background: var(--soft);
}

body[data-theme] .send-button,
body[data-theme] .primary-button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
}

body[data-theme] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  border: 1px solid var(--line-strong);
  border-radius: var(--row-radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

body[data-theme] :is(input, select, textarea):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 55%);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* ---------- Shell: one navigation column ---------- */

@media (min-width: 781px) {
  .app-shell,
  .app-shell:is(*) {
    grid-template-columns: 216px minmax(0, 1fr);
  }

  .app-shell .sidebar,
  .app-shell.tablet-nav-open .sidebar,
  .tablet-nav-toggle {
    display: none;
  }

  .app-shell > .view-panel:not(.hidden) {
    grid-column: 2;
    grid-row: 1;
    width: min(100%, 760px);
    max-width: 760px;
    justify-self: center;
    margin: 0;
    padding: 32px 32px 64px;
    border: 0;
    background: transparent;
  }

  .app-shell > .view-panel > .chat-header {
    padding-right: 0;
  }
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 12px 16px;
  gap: 0;
  border-right: var(--hairline);
  background: var(--bg);
  color: var(--ink);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 16px;
  margin: 0;
  border: 0;
}

.rail-logo {
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.rail-logo-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}

.rail .rail-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-body);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.rail-destinations {
  display: grid;
  gap: 2px;
  align-content: start;
}

.rail .search-wrap {
  display: block;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

.rail .search-wrap .search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.rail .search-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  font-size: var(--text-caption);
  background: var(--surface);
}

.rail .search-results {
  position: absolute;
  z-index: 30;
  left: 12px;
  width: min(440px, 80vw);
  border: var(--hairline);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.rail .channel-list,
.rail .rail-group {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

.rail .channel-list #channelList,
.rail .channel-list .community-destinations {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

.rail-divider {
  display: block;
  height: 0;
  margin: 10px 10px;
  border-top: var(--hairline);
}

.rail :is(.channel-button, .rail-button),
.rail .channel-list .channel-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--row-radius);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-body-compact);
  font-weight: 400;
  text-align: left;
  box-shadow: none;
}

.rail :is(.channel-button, .rail-button):hover {
  background: color-mix(in srgb, var(--soft), transparent 30%);
  color: var(--ink);
}

.rail :is(.channel-button, .rail-button):is(.active, [aria-current="page"]),
.rail .channel-list .channel-button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--line);
}

.rail .channel-list .community-nav-button[data-view="townsquare"] {
  margin-top: 0;
}

.rail .channel-list .community-nav-button[data-view="townsquare"]::before {
  display: none;
}

.rail :is(.badge, .nav-badge) {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-label);
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.rail-account {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding-top: 12px;
  border-top: var(--hairline);
}

.rail-account .rail-admin > .rail-button {
  border-top: 0;
}

.rail .theme-panel {
  border: 0;
  background: transparent;
}

.rail .theme-summary {
  min-height: 44px;
  padding: 6px 10px;
  border-radius: var(--row-radius);
  color: var(--ink);
  font-size: var(--text-body-compact);
  font-weight: 400;
}

.rail .theme-summary .nav-label {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.rail .rail-ikon-panel {
  display: none;
}

.rail .theme-option {
  border-radius: var(--row-radius);
  background: transparent;
  color: var(--ink);
}

.rail .theme-option.active {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.rail .theme-mode-row,
.rail .theme-mode-toggle {
  color: var(--ink);
}

.rail .theme-mode-toggle {
  border: 1px solid var(--line-strong);
  border-radius: var(--row-radius);
  background: var(--surface);
}

/* ---------- View headers ---------- */

.view-panel > .chat-header,
.chat > .chat-header {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  background: transparent;
}

.view-panel > .chat-header h2,
.view-panel > .chat-header h1 {
  font-size: var(--text-headline);
  line-height: 1.2;
  color: var(--ink);
}

.chat-header .eyebrow {
  margin-bottom: 2px;
}

.room-notify-control select {
  min-height: 44px;
}

/* ---------- Cards ---------- */

:is(
  #gatheringCard,
  .setup-checklist,
  .panel,
  .admin-panel,
  .profile-section-card,
  .notification-card,
  .care-card,
  .directory-card,
  .liturgy-card,
  .podcast-card,
  .prayer-card
) {
  border: var(--hairline);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: none;
}

/* ---------- Gathering card: a readiness checklist for members ---------- */

#gatheringCard.gathering-card {
  display: block;
  padding: 22px 24px 8px;
}

#gatheringCard .gathering-main {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

#gatheringCard .gathering-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
}

#gatheringCard .gathering-title-copy {
  display: grid;
  gap: 2px;
}

.gathering-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-caption);
}

#gatheringCard #gatheringTitle {
  margin: 0;
  font-size: var(--text-headline);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

#gatheringCard .gathering-status-text {
  justify-self: start;
  margin-top: 4px;
  padding: 1px 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--text-label);
  font-weight: 700;
}

#gatheringCard .gathering-title-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#gatheringCard .gathering-title-actions :is(.action-glyph, .tiny-button) {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--row-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-caption);
}

#gatheringCard #planGatheringButton {
  background: var(--surface);
  color: var(--ink);
}

#gatheringCard .gathering-time-block {
  display: block;
  margin: 2px 0 10px;
  padding: 0;
  border: 0;
}

#gatheringCard #gatheringMeta {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-body-compact);
}

#gatheringCard .gathering-weather {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

#gatheringCard .gathering-unscheduled {
  margin: 6px 0 0;
  color: var(--muted);
}

/* The RSVP row: one prompt, one segmented choice. */
#gatheringCard .gathering-rsvp-decision {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 12px 0;
  border: 0;
  border-top: var(--hairline);
  background: transparent;
}

.gathering-rsvp-prompt {
  color: var(--ink);
  font-size: var(--text-body-compact);
}

#gatheringCard #gatheringRsvps.rsvp-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--row-radius);
  overflow: hidden;
  background: var(--surface);
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-left: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--text-body-compact);
  font-weight: 400;
  box-shadow: none;
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp]:first-child {
  border-left: 0;
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp]:hover {
  background: var(--soft);
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp] strong {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-label);
  font-weight: 400;
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp].active-prayer-mark,
#gatheringCard #gatheringRsvps [data-gathering-rsvp][aria-pressed="true"] {
  background: var(--success-soft);
  color: var(--success);
  font-weight: 700;
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp].active-prayer-mark strong {
  color: var(--success);
}

#gatheringCard #gatheringRsvps [data-gathering-rsvp="no"].active-prayer-mark {
  background: var(--soft);
  color: var(--ink);
}

/* Place row: address and weather on the left, the map on the right. */
#gatheringCard .gathering-map-row {
  margin: 0;
  padding: 12px 0;
  border: 0;
  border-top: var(--hairline);
  background: transparent;
}

#gatheringCard .gathering-map-inset {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  grid-template-areas: "copy map" "actions map";
  align-items: start;
  gap: 4px 16px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#gatheringCard .gathering-map-mark {
  grid-area: map;
  width: 168px;
  height: 104px;
  margin: 0;
  border: var(--hairline);
  border-radius: var(--row-radius);
  overflow: hidden;
  background: var(--soft);
}

#gatheringCard .gathering-map-copy {
  grid-area: copy;
  display: grid;
  gap: 2px;
  padding-left: 32px;
  position: relative;
}

#gatheringCard .gathering-map-copy::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s7-6.2 7-12a7 7 0 1 0-14 0c0 5.8 7 12 7 12Z'/%3E%3Ccircle cx='12' cy='9' r='2.4'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

#gatheringCard .gathering-map-copy strong {
  font-size: var(--text-body-compact);
  font-weight: 700;
}

#gatheringCard .gathering-map-copy small {
  display: grid;
  color: var(--muted);
  font-size: var(--text-caption);
  line-height: 1.45;
}

#gatheringCard .gathering-map-actions {
  grid-area: actions;
  padding-left: 32px;
}

#gatheringCard[data-host-needed="true"] .gathering-map-inset {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "copy" "actions";
}

#gatheringCard[data-host-needed="true"] .gathering-map-mark {
  display: none;
}

#gatheringCard[data-host-needed="true"] .gathering-map-copy::before {
  border: 1.5px solid var(--warning);
  background: transparent;
}

#gatheringCard .gathering-map-link {
  position: absolute;
  inset: 0;
}


/* Family RSVPs and disclosures are rows too. */
#gatheringCard .gathering-family-rsvp {
  margin: 0;
  padding: 12px 0;
  border: 0;
  border-top: var(--hairline);
  background: transparent;
}

#gatheringCard .gathering-disclosures {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

#gatheringCard .gathering-disclosure {
  margin: 0;
  padding: 0;
  border: 0;
  border-top: var(--hairline);
  border-radius: 0;
  background: transparent;
}

#gatheringCard .gathering-disclosure > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 0 0 32px;
  position: relative;
  border: 0;
  background: transparent;
  font-size: var(--text-body-compact);
  font-weight: 400;
}

#gatheringCard .gathering-disclosure > summary::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='8' r='3.2'/%3E%3Cpath d='M3 20a6 6 0 0 1 12 0'/%3E%3Cpath d='M16 5.2a3 3 0 0 1 0 5.6'/%3E%3Cpath d='M18 14.4A6 6 0 0 1 21 20'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

#gatheringDetailsDisclosure > summary::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 4h7l4 4v12H7Z'/%3E%3Cpath d='M9 13h6'/%3E%3Cpath d='M9 17h5'/%3E%3C/svg%3E") !important;
}

#gatheringCard .gathering-disclosure > summary > span {
  flex: 1;
}

#gatheringCard .gathering-disclosure > summary small {
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

#gatheringCard .gathering-disclosure > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin: 0 4px 4px 0;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--motion-fast) var(--ease-out);
}

#gatheringCard .gathering-disclosure[open] > summary::after {
  margin-bottom: -2px;
  transform: rotate(-135deg);
}

#gatheringCard .gathering-disclosure > :not(summary) {
  padding: 0 0 14px 32px;
}

#gatheringCard .gathering-rsvp-people {
  border: 0;
  background: transparent;
}

.gathering-reconfirm,
.gathering-time-block > .gathering-reconfirm {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--row-radius);
  background: var(--warning-soft);
  color: var(--ink);
}

/* ---------- Setup checklist ---------- */

.setup-checklist {
  padding: 16px 20px;
}

.setup-checklist :is(button, a, .setup-item) {
  border-radius: var(--row-radius);
}

/* ---------- Room conversation as quiet rows ---------- */

.chat {
  gap: 16px;
}

.chat > .spotlight {
  border: 0;
  background: transparent;
  padding: 0;
}

#chatView .messages {
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#chatView .message-date-separator {
  margin: 20px 0 4px;
  color: var(--muted);
  font-size: var(--text-label);
  text-transform: none;
  letter-spacing: 0;
}

#chatView .message-date-separator::before,
#chatView .message-date-separator::after {
  border-color: var(--line);
  background: var(--line);
}

#chatView .message-thread {
  padding: 16px 0;
  border: 0;
  border-bottom: var(--hairline);
  border-radius: 0;
  background: transparent;
}

#chatView .message-thread .message-bubble,
.message-bubble {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.message {
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
}

.message .avatar,
.avatar {
  border-radius: 50%;
  box-shadow: none;
  font-weight: 700;
}

.message > .avatar,
.message > .member-profile-trigger > .avatar,
.message > .member-profile-trigger {
  width: 32px;
  height: 32px;
  font-size: var(--text-label);
}

.message-head {
  gap: 8px;
  margin-bottom: 2px;
}

.message-author,
.message-head .member-profile-trigger {
  font-weight: 700;
  font-size: var(--text-body-compact);
}

.message-time {
  color: var(--muted);
  font-size: var(--text-label);
}

.message-text {
  font-size: var(--text-body-compact);
  line-height: 1.55;
}

.message-actions {
  gap: 2px;
  margin-top: 4px;
  opacity: 0.8;
}

.message-actions .reaction {
  border: 0;
  background: transparent;
}

.message-actions .reaction:not(.message-action) {
  border: var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
}

#chatView .message-replies {
  margin-left: 44px;
}

#chatView .message-replies > .message {
  padding-block: 12px;
}

.thread-summary {
  margin-left: 44px;
}

#composer {
  margin-top: 8px;
  padding: 0;
  border: 0;
}

#composer .composer-heading {
  display: none;
}

#composer .message-field textarea {
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--card-radius);
  background: var(--surface);
}

#composer .send-button {
  min-width: 72px;
}

/* ---------- Everything else takes the same rows ---------- */

.view-panel :is(.panel-heading, .section-heading) {
  border: 0;
}

.view-panel :is(.people-list, .directory-list, .notification-list, .care-list, .prayer-request-list) > * {
  border-radius: 0;
  box-shadow: none;
}

.section-switcher {
  border-bottom: var(--hairline);
}

.section-switcher :is(button, a) {
  border-radius: 0;
  font-weight: 400;
}

.section-switcher :is(button, a).active,
.section-switcher :is(button, a)[aria-current="page"] {
  font-weight: 700;
}

/* ---------- Phone: light top bar, bottom tabs ---------- */

.tab-bar {
  display: none;
}

@media (max-width: 780px) {
  .app-shell {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .app-shell .sidebar,
  .sidebar {
    border-bottom: var(--hairline);
    background: color-mix(in srgb, var(--bg), transparent 6%);
    color: var(--ink);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
  }

  .sidebar .brand-block,
  .sidebar .mobile-home-button,
  .sidebar .mobile-home-title,
  .sidebar .mobile-menu-caret,
  .sidebar .account-toggle {
    color: var(--ink);
  }

  .sidebar .mobile-home-title {
    font-size: var(--text-title);
    font-weight: 700;
  }

  .sidebar :is(.mobile-search-toggle, .account-toggle) {
    border: 0;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
  }

  .mobile-nav {
    border-top: var(--hairline);
    background: var(--bg);
  }

  .mobile-nav :is(.mobile-nav-button, .channel-button) {
    border-radius: var(--row-radius);
    color: var(--ink);
    font-weight: 400;
  }

  .mobile-nav :is(.mobile-nav-button, .channel-button):is(.active, [aria-current="page"]) {
    background: var(--surface);
    font-weight: 700;
  }

  .app-shell > .view-panel:not(.hidden) {
    padding: 16px 16px 24px;
  }

  #gatheringCard.gathering-card {
    padding: 18px 16px 4px;
  }

  #gatheringCard .gathering-rsvp-decision {
    display: grid;
    gap: 8px;
  }

  #gatheringCard #gatheringRsvps.rsvp-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #gatheringCard #gatheringRsvps [data-gathering-rsvp] {
    padding: 0 8px;
  }

  #gatheringCard .gathering-map-inset {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

  #gatheringCard .gathering-map-mark {
    width: 112px;
    height: 84px;
  }

  .tab-bar {
    position: fixed;
    z-index: 25;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: var(--hairline);
    background: color-mix(in srgb, var(--bg), transparent 4%);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
  }

  body.locked .tab-bar,
  .app-shell.mobile-room-menu-open .tab-bar {
    display: none;
  }

  .tab-bar-button {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-height: 48px;
    padding: 4px 0;
    border: 0;
    border-radius: var(--row-radius);
    background: transparent;
    color: var(--muted);
    font-size: var(--text-label);
    font-weight: 400;
  }

  .tab-bar-button.active,
  .tab-bar-button[aria-current="page"] {
    color: var(--ink);
    font-weight: 700;
  }

  .tab-bar-icon {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #composer {
    bottom: auto;
  }
}

/* ---------- Pass 2: order, cards per view, checklist rows ---------- */

.rail .channel-name,
.mobile-nav .channel-name {
  font-weight: inherit;
}

/* The RSVP question comes straight after the date, then place, then people. */
#gatheringCard .gathering-main {
  display: flex;
  flex-direction: column;
}

#gatheringCard .gathering-title-row { order: 1; }
#gatheringCard .gathering-time-block { order: 2; }
#gatheringCard .gathering-rsvp-decision { order: 3; }
#gatheringCard .gathering-family-rsvp { order: 4; }
#gatheringCard .gathering-map-row { order: 5; }

#gatheringCard .gathering-rsvp-decision,
#gatheringCard[data-has-location="true"] .gathering-rsvp-decision,
#gatheringCard[data-host-needed="true"] .gathering-rsvp-decision {
  grid-column: auto;
  grid-row: auto;
  align-self: auto;
}

#gatheringCard #gatheringRsvps.rsvp-row,
#gatheringCard[data-has-location="true"] #gatheringRsvps.rsvp-row,
#gatheringCard[data-host-needed="true"] #gatheringRsvps.rsvp-row {
  grid-template-columns: repeat(3, minmax(0, auto));
  grid-template-rows: auto;
  flex: none;
  gap: 0;
  padding: 0;
}

/* Views: each group of content sits on one calm card. */
:is(
  .directory-panel,
  .care-compose-disclosure,
  .prayer-request-panel,
  .birthday-panel,
  .notification-panel,
  .delivery-disclosure,
  .archive-list-panel,
  .archive-detail-panel,
  .profile-section,
  .podcast-library,
  .help-card,
  .liturgy-list-panel,
  .prayer-card,
  .admin-section > details,
  .admin-section > section,
  .admin-overview-panel
) {
  margin: 0 0 16px;
  padding: 20px 24px;
  border: var(--hairline);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: none;
}

.view-panel :is(
  .prayer-list-grid,
  .notification-grid,
  .archive-grid,
  .profile-form,
  .help-grid,
  .admin-grid,
  .liturgies-grid
) {
  gap: 16px;
  border: 0;
  background: transparent;
  padding: 0;
}

.profile-form > .profile-section {
  margin: 0;
}

/* Cards inside a card become rows. */
:is(.directory-panel, .prayer-request-panel, .notification-panel, .archive-list-panel, .liturgy-list-panel)
  :is(.care-card, .directory-card, .notification-card, .archive-card, .liturgy-card, .member-card, .family-card) {
  border: 0;
  border-top: var(--hairline);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.view-panel .panel-heading {
  margin-bottom: 8px;
  padding: 0;
  border: 0;
}

.view-panel .panel-heading :is(h2, h3) {
  font-size: var(--text-title);
}

/* Setup: the same readiness rows, with open circles for what's left. */
.setup-checklist {
  display: block;
  padding: 18px 24px 6px;
}

.setup-checklist-section {
  display: block;
}

.setup-checklist-copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: var(--text-title);
}

.setup-checklist-actions {
  display: grid;
  gap: 0;
}

.setup-step-group {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: var(--hairline);
}

.setup-checklist .setup-step {
  position: relative;
  display: grid;
  flex: 1;
  gap: 1px;
  min-height: 56px;
  padding: 8px 28px 8px 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.setup-checklist .setup-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -9px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.setup-checklist .setup-step::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-top: 1.5px solid var(--muted);
  border-right: 1.5px solid var(--muted);
  transform: rotate(45deg);
}

.setup-checklist .setup-step strong {
  font-size: var(--text-body-compact);
  font-weight: 400;
}

.setup-checklist .setup-step span {
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

.setup-checklist .setup-step.setup-step-secondary {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
}

.setup-checklist .setup-step.setup-step-secondary::before,
.setup-checklist .setup-step.setup-step-secondary::after {
  display: none;
}

/* Polls: quiet bars, color only on your own choice. */
.poll-option {
  border: var(--hairline);
  border-radius: var(--row-radius);
  background: linear-gradient(90deg, var(--soft) 0 var(--poll-pct, 0%), var(--surface) var(--poll-pct, 0%) 100%);
  color: var(--ink);
}

.poll-option.active {
  border-color: color-mix(in srgb, var(--success), var(--line) 50%);
  background: linear-gradient(90deg, var(--success-soft) 0 var(--poll-pct, 0%), var(--surface) var(--poll-pct, 0%) 100%);
  color: var(--ink);
}

.poll-option.active :is(small, .poll-voters) {
  color: var(--muted);
}

.poll-voters,
.poll-option small,
.message-poll-total {
  font-weight: 400;
}

.message-poll {
  border: var(--hairline);
  border-radius: var(--card-radius);
  background: var(--surface);
}

/* Header controls stay quiet. */
.chat-header .room-notify-control > span {
  color: var(--muted);
  font-weight: 400;
}

.chat-header :is(.tool-button, .tiny-button).action-glyph {
  border-color: transparent;
  background: transparent;
}

@media (max-width: 780px) {
  .app-shell .sidebar :is(#mobileSearchToggle, #accountToggle),
  .app-shell .sidebar .brand-block .mobile-search-toggle {
    border: 0;
    border-radius: var(--row-radius);
    background: transparent;
    box-shadow: none;
    color: var(--ink);
  }

  .chat-header .room-notify-control > span {
    display: none;
  }

  :is(
    .directory-panel,
    .care-compose-disclosure,
    .prayer-request-panel,
    .birthday-panel,
    .notification-panel,
    .delivery-disclosure,
    .archive-list-panel,
    .archive-detail-panel,
    .profile-section,
    .podcast-library,
    .help-card,
    .liturgy-list-panel,
    .prayer-card,
    .admin-section > details,
    .admin-section > section,
    .admin-overview-panel
  ) {
    padding: 16px;
  }

  .setup-checklist {
    padding: 16px 16px 4px;
  }
}

/* ---------- Pass 3 ---------- */

#chatView.chat {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#chatView > #gatheringCardSlot:empty {
  display: none;
}

#chatView .messages > :first-child.message-date-separator,
#chatView .messages > .message-date-separator:first-child {
  margin-top: 8px;
}

.setup-checklist .setup-step {
  justify-items: start;
  text-align: left;
}

@media (max-width: 780px) {
  #chatView > .chat-header {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 -4px;
  }

  #chatView > .chat-header > div:first-child {
    display: none;
  }

  #gatheringCard #gatheringRsvps.rsvp-row,
  #gatheringCard[data-has-location="true"] #gatheringRsvps.rsvp-row,
  #gatheringCard[data-host-needed="true"] #gatheringRsvps.rsvp-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Admin and calendar actions move below the details on a phone. */
  #gatheringCard .gathering-title-row {
    display: contents;
  }

  #gatheringCard .gathering-title-copy { order: 1; }

  #gatheringCard .gathering-title-actions {
    order: 9;
    justify-content: flex-start;
    padding: 12px 0;
    border-top: var(--hairline);
  }

  #gatheringCard .gathering-disclosures + * {
    order: 10;
  }
}

#chatView.chat > .chat-header { order: 0; }
#chatView.chat > #gatheringCardSlot,
#chatView.chat > .gathering-card { order: 1; }
#chatView.chat > .setup-checklist { order: 2; }
#chatView.chat > .spotlight { order: 3; }
#chatView.chat > .pinned-panel { order: 4; }
#chatView.chat > .message-toolbar { order: 5; }
#chatView.chat > .messages { order: 6; }
#chatView.chat > .composer-home,
#chatView.chat > .composer { order: 7; }

#chatView .setup-checklist .setup-step {
  justify-items: start;
  text-align: left;
}

#gatheringCard .gathering-rsvp-decision > #gatheringRsvps {
  width: 100%;
}

@media (min-width: 781px) {
  #gatheringCard .gathering-rsvp-decision > #gatheringRsvps {
    width: auto;
  }
}

#chatView .setup-checklist .setup-step {
  justify-content: start;
  align-content: center;
}

@media (max-width: 780px) {
  #gatheringCard .gathering-rsvp-decision,
  #gatheringCard[data-has-location="true"] .gathering-rsvp-decision,
  #gatheringCard[data-host-needed="true"] .gathering-rsvp-decision {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- This is me: readiness summary ---------- */

.profile-readiness {
  margin: 0 0 16px;
  padding: 20px 24px 8px;
  border: var(--hairline);
  border-radius: var(--card-radius);
  background: var(--surface);
}

.readiness-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.readiness-title {
  font-size: var(--text-headline);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.readiness-count {
  color: var(--muted);
  font-size: var(--text-caption);
}

.readiness-bar {
  height: 4px;
  margin: 12px 0 4px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  overflow: hidden;
}

.readiness-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width var(--motion-standard) var(--ease-out);
}

.readiness-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.readiness-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-top: var(--hairline);
}

.readiness-list > .readiness-row:first-child {
  border-top: 0;
}

.readiness-mark {
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.readiness-row.is-done .readiness-mark {
  border: 0;
  background: var(--success-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233f6b4a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4.5 4.5L19 7'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.readiness-label {
  flex: 1;
  font-size: var(--text-body-compact);
}

.readiness-value {
  min-width: 0;
  max-width: 55%;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-caption);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.readiness-action {
  min-height: 44px;
  flex: none;
}

@media (max-width: 780px) {
  .profile-readiness {
    padding: 16px 16px 4px;
  }

  .readiness-value {
    max-width: 45%;
  }

  .readiness-action {
    min-height: 44px;
  }
}

#profileView .profile-form > .profile-section,
#profileView > .profile-section {
  padding: 20px 24px;
}

#profileView .avatar-large {
  width: 88px;
  height: 88px;
  font-size: var(--text-headline);
}

#profileAccountHome .session-block {
  margin: 0 0 16px;
  padding: 0 4px 16px;
}

@media (max-width: 780px) {
  #profileView .profile-form > .profile-section,
  #profileView > .profile-section {
    padding: 16px;
  }
}

/* ---------- Liturgy row: read the order of service in place ---------- */

#gatheringLiturgyDisclosure > summary::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 4v16'/%3E%3Cpath d='M7 8h10'/%3E%3Cpath d='M8 20h8'/%3E%3C/svg%3E") !important;
}

/* The liturgy row replaces the icon button. */
#gatheringCard #gatheringLiturgyButton {
  display: none;
}

.gathering-liturgy-body {
  display: grid;
  gap: 10px;
}

.gathering-liturgy-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gathering-liturgy-status {
  flex: 1;
  color: var(--muted);
  font-weight: 400;
  font-size: var(--text-caption);
}

.gathering-liturgy-status.is-error {
  color: var(--danger);
}

.gathering-liturgy-scroll {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-height: min(70vh, 640px);
  padding: 12px;
  overflow: auto;
  border: var(--hairline);
  border-radius: var(--row-radius);
  background: var(--soft);
  overscroll-behavior: contain;
}

.gathering-liturgy-scroll .pdf-reader-page {
  margin: 0;
  max-width: 100%;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--line);
}

.gathering-liturgy-scroll .pdf-reader-page canvas {
  display: block;
  max-width: 100%;
}

.gathering-liturgy-scroll .pdf-reader-page-number {
  padding: 4px 0;
  color: var(--muted);
  font-size: var(--text-label);
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
  background: var(--soft);
}

@media (max-width: 780px) {
  #gatheringCard .gathering-liturgy-disclosure > :not(summary) {
    padding-left: 0;
  }

  .gathering-liturgy-actions {
    flex-wrap: wrap;
  }

  .gathering-liturgy-status {
    flex-basis: 100%;
  }

  .gathering-liturgy-scroll {
    padding: 6px;
    max-height: 70vh;
  }
}

/* The gathering card belongs to the this-is-it room only. */
.app-shell:not(:is([data-channel="plans"], [data-channel="gathering"])) #chatView > #gatheringCard.gathering-card {
  display: none;
}

/* Reading a PDF deserves more width than a list does. */
@media (min-width: 1121px) {
  .app-shell > #liturgiesView.view-panel:not(.hidden) {
    width: min(100%, 1040px);
    max-width: 1040px;
  }
}

/* ---------- This is who: people as rows ---------- */

.directory-panel .panel-heading > :is(span, small):last-child,
#directoryMapCount,
#directoryFamilyCount,
#directoryCount {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

.directory-map-summary small {
  color: var(--muted);
  font-weight: 400;
}

.directory-panel .directory-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 16px;
  padding: 14px 0;
  border: 0;
  border-top: var(--hairline);
  background: transparent;
}

.directory-panel .directory-row .directory-avatar .avatar,
.directory-panel .directory-avatar {
  width: 36px;
  height: 36px;
  font-size: var(--text-label);
}

.directory-panel .directory-profile-button {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
}

.directory-panel .directory-profile-button strong {
  display: block;
  font-size: var(--text-body-compact);
}

.directory-panel .directory-profile-button span span,
.directory-panel .directory-family-line {
  display: block;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

.directory-label {
  display: block;
  color: var(--muted);
  font-size: var(--text-label);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.directory-panel :is(.directory-primary-link, .directory-address-link) {
  color: var(--ink);
  font-size: var(--text-caption);
}

.directory-panel .directory-address-link em {
  display: block;
  color: var(--accent);
  font-style: normal;
}

.member-family-card {
  padding: 14px 0;
  border: 0;
  border-top: var(--hairline);
  background: transparent;
}

.member-family-person {
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--soft);
}

@media (max-width: 780px) {
  .directory-panel .directory-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}

/* ---------- Household RSVPs as quiet check rows ---------- */

#gatheringCard .gathering-family-rsvp > span:first-child {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
  text-transform: none;
}

#gatheringCard .gathering-family-rsvp-list {
  display: grid;
  gap: 0;
}

#gatheringCard .gathering-family-rsvp-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 4px 0;
  border: 0;
  border-top: var(--hairline);
  border-radius: 0;
  background: transparent;
}

#gatheringCard .gathering-family-rsvp-choice:first-child {
  border-top: 0;
}

#gatheringCard .gathering-family-rsvp-choice.is-protected,
#gatheringCard .gathering-family-rsvp-choice.is-disabled {
  background: transparent;
  opacity: 1;
}

#gatheringCard .gathering-family-rsvp-name {
  flex: 1;
  font-size: var(--text-body-compact);
  font-weight: 400;
}

#gatheringCard .gathering-family-rsvp-choice small {
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

#gatheringCard .gathering-family-rsvp-check {
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
}

#gatheringCard .gathering-family-rsvp-input:checked + .gathering-family-rsvp-check {
  border: 0;
  background: var(--success-soft);
}

#gatheringCard .gathering-family-rsvp-choice.is-protected .gathering-family-rsvp-check,
#gatheringCard .gathering-family-rsvp-input:disabled + .gathering-family-rsvp-check {
  border-style: dashed;
}

#gatheringCard .gathering-family-rsvp-check {
  min-width: 20px;
  min-height: 20px;
}

#gatheringCard .gathering-family-rsvp-input:checked + .gathering-family-rsvp-check::after {
  border-color: var(--success);
}

#gatheringCard .gathering-family-rsvp-input:focus-visible + .gathering-family-rsvp-check {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.member-directory .directory-avatar .avatar,
.directory-panel .directory-avatar .avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: var(--text-label);
  line-height: 1;
}

.member-directory .directory-contact,
.member-directory .directory-address {
  padding-top: 0;
  border-top: 0;
}

.directory-map-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.directory-map-summary > div {
  flex: 1;
}

.directory-map-summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin: 0 4px 4px 0;
  border: 0;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  border-radius: 0;
  transform: rotate(45deg);
  transition: transform var(--motion-fast) var(--ease-out);
}

.directory-map-panel[open] > .directory-map-summary::after {
  content: "";
  margin-bottom: -2px;
  transform: rotate(-135deg);
}

/* ---------- Pass 4: remaining views ---------- */

/* Counts are facts, not badges. */
.view-panel .panel-heading > span:last-child {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

#listenView .podcast-library,
#adminView .admin-planner-section {
  padding: 20px 24px;
  border: var(--hairline);
  border-radius: var(--card-radius);
  background: var(--surface);
}

/* Planner steps are rows on the one planner card. */
#adminView .admin-planner-section > .admin-panel {
  margin: 0;
  padding: 0;
  border: 0;
  border-top: var(--hairline);
  border-radius: 0;
  background: transparent;
}

#adminView .admin-planner-section > .admin-panel:first-child {
  border-top: 0;
}

#adminView .admin-collapsible-summary {
  min-height: 56px;
}

.archive-list-item {
  border-radius: var(--row-radius);
}

.archive-list-item.active {
  background: var(--soft);
}

@media (max-width: 780px) {
  #listenView .podcast-library,
  #adminView .admin-planner-section {
    padding: 16px;
  }
}

/* ---------- Admin planner: the readiness checklist ---------- */

#adminView #adminOverview.admin-overview-panel {
  margin: 0;
  padding: 0 0 8px;
  border: 0;
  background: transparent;
}

.planner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.planner-head-copy {
  display: grid;
  gap: 2px;
}

#adminOverview .planner-date {
  margin: 0;
  font-size: var(--text-headline);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.planner-days {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-body-compact);
}

.planner-count {
  display: grid;
  justify-items: end;
  flex: none;
}

.planner-count strong {
  font-size: var(--text-headline);
  font-weight: 700;
  line-height: 1.2;
}

.planner-count span {
  color: var(--muted);
  font-size: var(--text-caption);
}

#adminOverview .readiness-bar {
  margin: 14px 0 6px;
}

#adminOverview .gathering-readiness {
  margin: 0 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-caption);
  font-weight: 400;
}

.planner-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.planner-row {
  border-top: var(--hairline);
}

.planner-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 0;
}

.planner-row-label {
  flex: 1;
  font-size: var(--text-body-compact);
}

.planner-row-detail {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-caption);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planner-row .readiness-mark {
  flex: none;
}

.planner-row[data-mark="done"] .readiness-mark {
  border: 0;
  background: var(--success-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233f6b4a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4.5 4.5L19 7'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.planner-row[data-mark="review"] .readiness-mark {
  border-color: var(--warning);
}

.planner-row[data-mark="paused"] .readiness-mark {
  border-style: dashed;
}

.planner-row-body {
  padding: 0 0 16px 32px;
}

/* Host and place */
.planner-place {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  gap: 16px;
  align-items: start;
}

.planner-place-copy {
  display: grid;
  gap: 2px;
  font-size: var(--text-caption);
  color: var(--muted);
}

.planner-place-copy strong {
  color: var(--ink);
  font-size: var(--text-body-compact);
  font-weight: 700;
}

.planner-place-weather {
  margin-top: 6px;
}

.planner-map {
  position: relative;
  display: block;
  width: 176px;
  height: 112px;
  overflow: hidden;
  border: var(--hairline);
  border-radius: var(--row-radius);
  background: var(--soft);
}

.planner-map-tiles {
  position: absolute;
  left: calc(50% - var(--map-x));
  top: calc(50% - var(--map-y));
  width: 768px;
  height: 768px;
}

.planner-map-tiles img {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
}

.planner-map-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.planner-map-credit {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 0 3px;
  background: rgba(255, 255, 255, 0.8);
  color: #333333;
  font-size: var(--text-map-attribution);
}

#adminOverview .host-offer-list {
  display: grid;
  gap: 0;
  margin-top: 8px;
}

#adminOverview .host-offer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border: 0;
  border-top: var(--hairline);
  background: transparent;
}

#adminOverview .host-offer-row > div {
  display: grid;
}

#adminOverview .host-offer-row span {
  color: var(--muted);
  font-size: var(--text-caption);
}

/* RSVPs */
.planner-rsvp-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 32px;
}

.planner-rsvp-stack {
  display: grid;
  align-content: start;
  gap: 12px;
}

.planner-rsvp-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.planner-rsvp-pill {
  display: inline-block;
  margin: 0 0 4px;
  padding: 1px 10px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  color: var(--muted);
  font-size: var(--text-caption);
}

.planner-rsvp-pill[data-status="going"] {
  background: var(--success-soft);
  color: var(--success);
}

.planner-rsvp-pill[data-status="maybe"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.planner-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.planner-person .avatar {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: var(--text-label);
  line-height: 1;
}

.planner-person-name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-body-compact);
}

.planner-person-name small,
.planner-person-aside,
.planner-person-empty {
  color: var(--muted);
  font-size: var(--text-caption);
}

.planner-noreply {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--row-radius);
  background: var(--soft);
  font-size: var(--text-caption);
}

.planner-noreply .tiny-button {
  flex: none;
}

.planner-notes {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--text-caption);
}

.planner-foot {
  display: flex;
  justify-content: flex-end;
  padding: 10px 0 12px;
  border-top: var(--hairline);
}

/* RSVPs live in the checklist; the separate attendance editor is not needed. */
#adminView #gatheringAttendance {
  display: none;
}

@media (max-width: 780px) {
  .planner-row-body {
    padding-left: 0;
  }

  .planner-place {
    grid-template-columns: minmax(0, 1fr) 120px;
  }

  .planner-map {
    width: 120px;
    height: 96px;
  }

  .planner-rsvp-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .planner-noreply {
    display: grid;
    justify-items: start;
  }

  .planner-row-detail {
    max-width: 50%;
  }
}

#adminView #adminOverview h3.planner-date {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-headline);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

#adminView #adminOverview .tiny-button {
  text-decoration: none;
}

#adminView .admin-grid > *,
#adminView .admin-planner-section > *,
#adminView #adminOverview,
.planner-row-head > * {
  min-width: 0;
}

@media (max-width: 780px) {
  .planner-row-detail {
    white-space: normal;
  }
}

.planner-row-head > .planner-row-label {
  flex: 1 0 auto;
  min-width: auto;
}

/* ---------- Caring and Now: state circles on every row ---------- */

/* The headline carries the count, so the duplicate count badge goes. */
.prayer-request-panel > .panel-heading > #prayerRequestCount,
.notification-panel > .panel-heading > #notificationCount {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.care-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.care-card-head .care-mark {
  flex: none;
  margin-top: 2px;
}

.care-mark[data-mark="done"] {
  border: 0;
  background: var(--success-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233f6b4a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4.5 4.5L19 7'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.prayer-request-panel .care-card .care-details,
.prayer-request-panel .care-card .care-gesture-row,
.prayer-request-panel .care-card .prayer-request-footer,
.prayer-request-panel .care-card [data-care-comments-slot] {
  margin-left: 32px;
}

.prayer-request-panel .care-card {
  padding: 14px 0;
}

.notification-panel .notification-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
  padding: 12px 0;
  border: 0;
  border-top: var(--hairline);
  border-radius: 0;
  background: transparent;
}

.notification-panel .notification-item > :not(.notice-mark) {
  grid-column: 2;
}

.notice-mark {
  grid-column: 1;
  grid-row: 1 / span 3;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
}

.notice-mark .action-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notification-item.unread .notice-mark {
  background: var(--accent-soft);
  color: var(--accent);
}

.notification-item.unread strong {
  font-weight: 700;
}

.notification-item:not(.unread) strong {
  font-weight: 400;
}

/* ---------- Who's coming and thread summaries ---------- */

.rsvp-avatar-stack {
  display: inline-flex;
  flex: none !important;
}

.rsvp-avatar-stack:empty {
  display: none;
}

.rsvp-avatar-stack .avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: -6px;
  border: 2px solid var(--surface);
  font-size: var(--text-label);
  line-height: 1;
}

.rsvp-avatar-stack .avatar:first-child {
  margin-left: 0;
}

.thread-summary .thread-reply-names::before {
  content: "· ";
}

.thread-summary .thread-reply-names {
  margin-left: -8px;
  color: var(--muted);
}

/* ---------- Space: compact card internals ---------- */

#gatheringCard .gathering-family-rsvp {
  display: block;
  padding: 10px 0 6px;
}

#gatheringCard .gathering-family-rsvp-choice {
  min-height: 40px;
  padding: 2px 0;
}

#gatheringCard .gathering-family-rsvp-choice small {
  margin-left: auto;
}

#gatheringCard .gathering-map-mark {
  height: 88px;
}

.message-order-toggle {
  padding: 2px;
  border: var(--hairline);
  border-radius: var(--row-radius);
  background: var(--surface);
}

.message-order-toggle button {
  min-height: 32px;
  border-radius: 6px;
  font-weight: 400;
}

.message-order-toggle button.active {
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
}

.jump-latest {
  border-radius: var(--row-radius);
}

/* ---------- Space: wide screens ---------- */

@media (min-width: 1200px) {
  body[data-theme] {
    --frame-wide: 1160px;
    --frame-standard: 1160px;
  }

  /* Pages start beside the rail; spare width falls to the right. */
  .app-shell > .view-panel:not(.hidden),
  .app-shell[data-view] > .view-panel:not(.hidden),
  .app-shell > #liturgiesView.view-panel:not(.hidden) {
    width: min(100%, 1160px);
    max-width: 1160px;
    justify-self: start;
    margin-left: 0;
  }

  /* The room: the gathering on the left, the conversation beside it. */
  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat {
    display: grid;
    grid-template-columns: 440px minmax(0, 680px);
    grid-template-rows: auto auto auto auto auto 1fr;
    column-gap: 32px;
    row-gap: 0;
    align-items: start;
  }

  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > * {
    grid-column: 2;
    margin-bottom: 16px;
  }

  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > .chat-header {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > .setup-checklist { grid-row: 2; }
  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > .pinned-panel { grid-row: 3; }
  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > .message-toolbar { grid-row: 4; }
  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > .messages { grid-row: 5; }
  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > .composer-home { grid-row: 6; }

  /* The card scrolls with the page, so nothing inside it is ever clipped. */
  .app-shell[data-view="chat"]:is([data-channel="plans"], [data-channel="gathering"]) #chatView.chat > #gatheringCard {
    grid-column: 1;
    grid-row: 2 / 7;
    min-width: 0;
  }

  #chatView > #gatheringCard .gathering-disclosure,
  #chatView > #gatheringCard .gathering-disclosure > summary > * {
    min-width: 0;
  }

  /* In the side column the card stacks like the phone layout. */
  #chatView > #gatheringCard.gathering-card {
    padding: 18px 20px 4px;
  }

  #chatView > #gatheringCard .gathering-title-row {
    display: contents;
  }

  #chatView > #gatheringCard .gathering-title-copy { order: 1; }

  #chatView > #gatheringCard .gathering-title-actions {
    order: 9;
    justify-content: flex-start;
    padding: 12px 0;
    border-top: var(--hairline);
  }

  #chatView > #gatheringCard .gathering-rsvp-decision,
  #chatView > #gatheringCard[data-has-location="true"] .gathering-rsvp-decision,
  #chatView > #gatheringCard[data-host-needed="true"] .gathering-rsvp-decision {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  #chatView > #gatheringCard #gatheringRsvps.rsvp-row,
  #chatView > #gatheringCard[data-has-location="true"] #gatheringRsvps.rsvp-row,
  #chatView > #gatheringCard[data-host-needed="true"] #gatheringRsvps.rsvp-row {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #chatView > #gatheringCard #gatheringRsvps [data-gathering-rsvp] {
    padding: 0 8px;
  }

  #chatView > #gatheringCard .gathering-map-inset {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "copy" "map" "actions";
    gap: 10px;
  }

  #chatView > #gatheringCard .gathering-map-mark {
    width: 100%;
    height: 140px;
  }

  /* The liturgy reads better in the wide conversation column. */
  #chatView > #gatheringCard .gathering-liturgy-scroll {
    max-height: 60vh;
  }

  /* Other pages: groups of cards sit side by side. */
  #prayerListView .prayer-list-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: start;
  }

  #prayerListView .prayer-list-grid > .care-compose-disclosure,
  #prayerListView .prayer-list-grid > .prayer-request-form,
  #prayerListView .prayer-list-grid > .prayer-request-panel {
    grid-column: 1;
  }

  #prayerListView .prayer-list-grid > .birthday-panel {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  #notificationsView .notification-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: start;
  }

  #profileView > :not(.chat-header),
  #helpView > :not(.chat-header),
  #prayerView .prayer-card,
  #prayerView .office-tabs,
  #adminView .admin-grid {
    max-width: 820px;
  }
}

#gatheringCard .gathering-disclosure > summary > span:first-child {
  white-space: nowrap;
}

#gatheringCard #gatheringRsvpSummary {
  white-space: nowrap;
}

@media (max-width: 400px) {
  #gatheringCard .rsvp-avatar-stack {
    display: none;
  }
}

/* ---------- Gathering actions live on the eyebrow line ---------- */

#gatheringCard .gathering-title-row,
#chatView > #gatheringCard .gathering-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  order: 1;
}

#gatheringCard .gathering-title-copy,
#chatView > #gatheringCard .gathering-title-copy {
  display: contents;
}

#gatheringCard #gatheringEyebrow {
  grid-column: 1;
  grid-row: 1;
}

#gatheringCard #gatheringTitle {
  grid-column: 1 / -1;
  grid-row: 2;
}

#gatheringCard #gatheringStatus {
  grid-column: 1 / -1;
  grid-row: 3;
}

#gatheringCard .gathering-title-actions,
#chatView > #gatheringCard .gathering-title-actions {
  grid-column: 2;
  grid-row: 1;
  order: 0;
  justify-content: flex-end;
  padding: 0;
  border-top: 0;
}

/* ---------- Room notifications live in the phone's page menu ---------- */

.compact-notify-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-size: var(--text-caption);
}

.compact-notify-control[hidden] {
  display: none;
}

.compact-notify-control > span {
  color: var(--ink);
}

.compact-notify-control select {
  width: auto;
  min-width: 120px;
}

@media (max-width: 780px) {
  #chatView > .chat-header {
    display: none;
  }
}

/* ---------- Quick reactions: glyphs that carry their own counts ---------- */

.message-actions .quick-reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--row-radius);
  background: transparent;
  color: var(--muted);
}

.message-actions .quick-reaction:hover {
  background: var(--soft);
  color: var(--ink);
}

.message-actions .quick-reaction .action-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-actions .quick-reaction strong {
  color: inherit;
  font-size: var(--text-caption);
  font-weight: 700;
}

.message-actions .quick-reaction.is-mine {
  color: var(--accent);
}

.message-actions .quick-reaction.is-mine .action-icon {
  fill: color-mix(in srgb, var(--accent), transparent 72%);
}
