/* STUC styles shared by the chat page (/c/{id}), the old home page, the
   profile page and the join page's language picker. The private pages' look
   (TO-0125) comes from private.css: its --p-* tokens and the twelve seat
   colours (--c0..c11-*, [data-color]) are defined there once; the chat page
   (body.p-chat) maps the legacy tokens below onto them, so the old pages keep
   their colours until they are redesigned (TO-0126, TO-0127). */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #dbeafe;
  --color-primary-soft-text: #1e40af;
  --color-error: #b42318;
  --bg-error: #fef2f2;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-tint: #fee2e2;
  --bg-page: #f3f4f8;
  --bg-card: #ffffff;
  --bg-chip: #f3f4f8;
  --bg-system: #e4e7ee;
  --text: #171a22;
  --text-secondary: #444750;
  --text-muted: #646875;
  --text-faint: #6f7380;
  --border: #d9dce5;
  --border-light: #e1e4eb;
  --pane-trans-bg: #e0f2fe;
  --focus-ring: #2563eb;
  --bar-warn-bg: #fef3c7;
  --bar-warn-text: #78350f;
  --bar-ok-bg: #dcfce7;
  --bar-ok-text: #14532d;
  --text-on-primary: #ffffff;
  --shadow-rgb: 23, 26, 34;
  --error-rgb: 179, 35, 24;
  --color-online: #16a34a;
  /* System fonts only; the script fallbacks keep Thai, Khmer, Lao, Myanmar,
     Devanagari, Tamil, Arabic and CJK from showing as boxes (LANGUAGES-SPEC
     §6). The server-rendered pages use the same names (scriptFontFallbacks). */
  --font-sans: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", "Leelawadee UI", "Khmer Sangam MN", "Noto Sans Khmer", "Lao Sangam MN", "Noto Sans Lao", "Myanmar Sangam MN", "Noto Sans Myanmar", "Kohinoor Devanagari", "Nirmala UI", "Noto Sans Devanagari", "Tamil Sangam MN", "Noto Sans Tamil", "Geeza Pro", "Noto Naskh Arabic", "PingFang SC", "PingFang TC", "Hiragino Sans", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
}

/* Explicit dark page values for pages that pin data-theme="dark". */
[data-theme="dark"] {
  --bg-page: #111318;
  --bg-card: #1a1d24;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-primary: #60a5fa; --color-primary-hover: #93c5fd;
    --color-primary-soft: #172554; --color-primary-soft-text: #bfdbfe;
    --color-error: #fca5a5; --bg-error: #450a0a;
    --bg-page: #111318; --bg-card: #1a1d24; --bg-chip: #272b34; --bg-system: #303540;
    --text: #f3f4f6; --text-secondary: #d1d5db; --text-muted: #a1a1aa; --text-faint: #a1a1aa;
    --border: #3b414d; --border-light: #343a46; --pane-trans-bg: #172554;
    --focus-ring: #93c5fd; --bar-warn-bg: #422006; --bar-warn-text: #fde68a;
    --bar-ok-bg: #052e16; --bar-ok-text: #86efac; --color-online: #4ade80;
    --shadow-rgb: 0, 0, 0; --error-rgb: 252, 165, 165; --text-on-primary: #ffffff;
  }
}

/* The chat page takes the private design tokens (TO-0125): one mapping, so
   both themes follow private.css. */
.p-chat {
  --color-primary: var(--p-violet-fill);
  --color-primary-hover: var(--p-violet-ink);
  --color-primary-soft: var(--p-lavender);
  --color-primary-soft-text: var(--p-violet);
  --color-error: var(--p-red);
  --color-danger: var(--p-red);
  --color-danger-hover: var(--p-red);
  --color-danger-tint: var(--p-red-tint);
  --bg-error: var(--p-red-tint);
  --bg-page: var(--p-bg);
  --bg-card: var(--p-surface);
  --bg-chip: var(--p-chip);
  --bg-system: var(--p-chip);
  --text: var(--p-ink);
  --text-secondary: var(--p-body);
  --text-muted: var(--p-muted);
  --text-faint: var(--p-muted);
  --border: var(--p-line);
  --border-light: var(--p-line-2);
  --focus-ring: var(--p-violet);
  --color-online: var(--p-green);
  --text-on-primary: var(--p-on-violet);
  --font-sans: var(--p-font);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Elements styled with a display value would otherwise ignore [hidden]. */
[hidden] {
  display: none !important;
}

/* One keyboard focus ring for every button, link and field (TO-0021 DD-10). */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Whether copied guest links are public (TO-0041): a muted pill when the
   tunnel serves this workspace, a warning pill when links work only on this
   computer. Shared by the home session card and the chat header; it sizes to
   its text and truncates rather than widening a phone screen. */
.link-state {
  align-self: flex-start;
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: var(--bg-chip);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-state.local {
  border-color: var(--bar-warn-text);
  background-color: var(--bar-warn-bg);
  color: var(--bar-warn-text);
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (hover: hover) {
  .icon-button:hover { border-color: var(--color-primary); color: var(--color-primary); }
  .voice-play-button:hover { border-color: var(--color-primary); color: var(--color-primary); }
  .login-button:hover { background-color: var(--color-primary-hover); }
  .talk:hover, .open-session:hover { border-color: var(--color-primary); color: var(--color-primary); }
  .talk-accept:hover { background: var(--color-primary-hover); }
  .chat-row:hover { background: var(--p-chip); }
}

/* Modal overlay (chat ended, left, invalid link; home and profile prompts). */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(var(--shadow-rgb), 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}
/* In-page prompts and the removed notice cover the people panel (z-index 1002). */
#confirm-modal, #removed-overlay { z-index: 1003; }

.modal-content {
  background-color: var(--bg-card);
  padding: 24px;
  border-radius: 16px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 18px 40px rgba(var(--shadow-rgb), 0.15);
}

.modal-title {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.login-button {
  display: inline-block;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background-color: var(--color-primary);
  color: var(--text-on-primary);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* Host home: online list, request to talk, toasts (BETA-SPEC FR-R2–FR-R5;
   static/home.html). The page's own column styles stay in home.html. */
.online-card {
  gap: 8px;
}

.online-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.online-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.online-who {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.online-name {
  font-size: 16px;
  font-weight: 700;
}

.online-lang {
  font-size: 13px;
  color: var(--text-muted);
}

/* The dot blinks once a second while the peer is online. The tracker keeps
   a silent peer listed for up to OfflineAfter plus a sweep, so the dot says
   "listed", not "responding this instant". */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.dot.online {
  background: var(--color-online);
  animation: online-blink 1s step-start infinite;
}

@keyframes online-blink {
  50% {
    opacity: 0.2;
  }
}

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

.talk,
.open-session {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}

.talk:disabled {
  opacity: 0.5;
  cursor: default;
}

.open-session {
  display: inline-block;
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--bg-page);
}

.online-fallback[hidden] {
  display: none;
}

/* Talk prompt buttons inside the shared .modal-content. */
.talk-choices {
  display: flex;
  gap: 8px;
}

.talk-accept,
.talk-decline {
  flex: 1;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.talk-accept {
  border: none;
  background: var(--color-primary);
  color: var(--bg-page);
}

.talk-decline {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

/* Toasts: bottom-centre, stacked, removed after TOAST_MS. */
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 1001;
}

.toast {
  background: var(--text);
  color: var(--bg-page);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(var(--shadow-rgb), 0.2);
}

/* A link the browser would not copy, shown to copy by hand (TO-0030): it
   takes taps, unlike the other toasts, and stays up longer. */
.toast.toast-link {
  pointer-events: auto;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(92vw, 560px);
}
.toast-link input, .toast-link textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  resize: none;
}
.toasts {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
}
.toast { max-width: 100%; text-align: center; }

/* Language picker (langpicker.js, TO-0035): a dropdown under its button on
   laptops, a bottom sheet under 700 px; every row at least 44 px tall. */
.lp-anchor { position: relative; width: 100%; }
.lp-button { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; width: 100%; min-height: 48px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); color: var(--text); font: inherit; font-weight: 400; text-align: start; cursor: pointer; }
.lp-button::after { content: "▾"; margin-inline-start: auto; color: var(--text-muted); }
.lp-backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(var(--shadow-rgb), .45); }
.lp-panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1101; display: flex; flex-direction: column; min-width: 280px; max-height: min(420px, 70vh); overflow: hidden; background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(var(--shadow-rgb), .18); font-weight: 400; }
.lp-panel.lp-inline { position: static; min-width: 0; max-height: none; overflow: visible; border: 0; border-radius: 0; box-shadow: none; }
.lp-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 16px; font-weight: 700; }
.lp-close { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--text); font-size: 1.4rem; cursor: pointer; }
.lp-search { margin: 8px 12px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); color: var(--text); font: inherit; font-size: 16px; }
.lp-inline .lp-search { width: 100%; margin: 8px 0; }
.lp-list { overflow-y: auto; padding: 0 4px 8px; }
.lp-inline .lp-list { overflow: visible; padding: 0; }
.lp-heading { padding: 10px 12px 4px; color: var(--text-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.lp-menu { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-top: 1px solid var(--border-light); background: transparent; color: var(--text); font: inherit; font-weight: 700; text-align: start; cursor: pointer; }
.lp-menu::before { content: "▸"; margin-inline-end: 8px; }
.lp-menu[aria-expanded="true"]::before { content: "▾"; }
.lp-option { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.lp-option:hover { background: var(--bg-chip); }
.lp-option[aria-selected="true"] { background: var(--color-primary-soft); color: var(--color-primary-soft-text); }
.lp-active { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.lp-native { font-weight: 600; }
.lp-english { color: var(--text-muted); font-size: .88em; }
.lp-option[aria-selected="true"] .lp-english { color: inherit; }
.lp-beta { padding: 0 6px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-secondary); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.lp-empty { padding: 12px; color: var(--text-muted); }
@media (min-width: 700px) {
  .lp-backdrop { display: none; }
}
@media (max-width: 699px) {
  .lp-panel:not(.lp-inline) { position: fixed; top: auto; right: 0; bottom: 0; left: 0; min-width: 0; max-height: 80dvh; padding-bottom: env(safe-area-inset-bottom, 0px); border-radius: 16px 16px 0 0; }
}

/* ===================== Chat page (TO-0125) =====================
   Layout (PRIVATE-UI-REDESIGN-SPEC §8.1; the numbers are the ones app.js
   mirrors in HOST_RAIL_QUERY / GUEST_RAIL_QUERY):
   host  — phone under 760 px; 760–1099 px chat list · conversation,
           details behind the ⋯ button (TO-0147: a fixed page like the
           guest's, never a page that scrolls); from 1100 px chat list ·
           conversation · details.
   guest — phone under 820 px; 820–1179 px reserved ad column ·
           conversation, people behind the ⋯ button; from 1180 px ad column ·
           conversation · people.
   Any width with a height of 500 px or less uses the phone layout. */

.p-chat {
  overflow: hidden;
}

.chat-container {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  height: var(--chat-viewport-height, 100dvh);
  min-height: 0;
  max-height: var(--chat-viewport-height, 100dvh);
  overflow: hidden;
  background: var(--p-bg);
}

.chat-list,
.ad-rail {
  display: none;
}

.convo {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--p-surface);
}

/* Follow the keyboard pan. Phones translate the shell so its fixed toasts,
   sheets and overlays move above the keyboard with it (TO-0024 CV-2). A
   wider fixed-height layout would make the shell the containing block for
   its fixed layers under a transform (P-11), so touch tablets use a relative
   top offset there (host from 760 px, TO-0147: its page is fixed-height like
   the guest's), and a desktop pinch-zoom never shifts the shell. */
@media (max-width: 759px), (max-height: 500px) {
  .chat-container.viewport-shifted { transform: translateY(var(--chat-viewport-offset-top, 0px)); }
}
@media (min-width: 760px) and (max-width: 819px) and (min-height: 501px) {
  .chat-container.is-guest.viewport-shifted { transform: translateY(var(--chat-viewport-offset-top, 0px)); }
}
@media (min-width: 820px) and (min-height: 501px) and (hover: none) and (pointer: coarse) {
  .chat-container.is-guest.viewport-shifted { top: var(--chat-viewport-offset-top, 0px); }
}
@media (min-width: 760px) and (min-height: 501px) and (hover: none) and (pointer: coarse) {
  .chat-container.is-host.viewport-shifted { top: var(--chat-viewport-offset-top, 0px); }
}

/* --- Host chat list (left) --- */
.chat-list {
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 16px 12px;
  border-right: 1px solid var(--p-line-2);
  overflow: hidden;
}

.chat-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}

.list-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--p-ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.chat-list-error {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--p-red-tint);
  color: var(--p-red);
  font-size: 13px;
  line-height: 1.4;
}

.chat-search {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--p-line-2);
  border-radius: 10px;
  background: var(--p-bg);
  color: var(--p-ink);
  font: 14px var(--p-font);
}

.chat-list-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  color: var(--p-ink);
  text-decoration: none;
}

.chat-row[aria-current="page"] {
  background: var(--p-lavender);
}

.chat-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--sw-tint, var(--p-lavender));
  color: var(--sw-text, var(--p-violet));
  font-size: 15px;
  font-weight: 600;
}

.chat-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.chat-row-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.chat-row-name,
.chat-row-preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-row-name {
  font-size: 14px;
  font-weight: 600;
}

.chat-row-time {
  flex: 0 0 auto;
  color: var(--p-muted);
  font-size: 11px;
}

.chat-row-preview {
  color: var(--p-body);
  font-size: 13px;
}

.chat-list-empty {
  padding: 12px;
  color: var(--p-muted);
  font-size: 13px;
}

/* Message search hits (TO-0044) under the chat rows. */
.search-hits {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  padding-top: 8px;
  border-top: 1px solid var(--p-line-2);
}

.search-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--p-ink);
  text-decoration: none;
}

.search-hit:hover {
  background: var(--p-chip);
}

.search-hit-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.search-hit-sender,
.search-hit-chat {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-hit-sender {
  font-size: 13px;
  font-weight: 600;
}

.search-hit-time,
.search-hit-chat {
  flex: 0 0 auto;
  color: var(--p-muted);
  font-size: 11px;
}

.search-hit-text {
  color: var(--p-body);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.search-hit-text mark {
  border-radius: 3px;
  background: var(--p-lavender);
  color: var(--p-ink);
  font-weight: 600;
}

/* A hit's window and live history while they are apart (TO-0044). */
.history-gap {
  display: flex;
  justify-content: center;
  min-height: 44px;
  margin: 8px 0;
  padding: 8px;
  border-top: 1px dashed var(--p-line);
  border-bottom: 1px dashed var(--p-line);
}

.history-gap[aria-busy="true"] {
  border-color: var(--p-violet-line);
}

.message-card.is-search-hit {
  border-radius: var(--p-r-card);
  outline: 2px solid var(--p-violet-line);
  outline-offset: 4px;
}

.chat-list-me {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 0 0 4px;
  border-top: 1px solid var(--p-line-2);
}

.list-me-avatar {
  width: 34px;
  height: 34px;
  overflow: hidden;
}

.list-me-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-me-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.list-me-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.list-me-lang {
  color: var(--p-muted);
  font-size: 12px;
}

.list-me-action {
  border-color: transparent;
  color: var(--p-body);
}

/* --- Reserved guest ad column (TO-0128 fills it) --- */
.ad-rail {
  border-right: 1px solid var(--p-line-2);
}

/* Reserved phone ad banner row: takes no room until TO-0128 mounts it. */
.phone-ad-slot:empty {
  display: none;
}

/* --- Conversation header --- */
.chat-header {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--p-line-2);
  background: var(--p-surface);
}
.chat-header {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 100%;
  min-width: 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.chat-title {
  overflow: hidden;
  color: var(--p-ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.session-subtitle {
  overflow: hidden;
  color: var(--p-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.online-count {
  color: var(--p-green-ink);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.back-button {
  border-color: transparent;
  margin-left: -6px;
}

/* Invite a guest (host): the primary button; icon-only on phones. Its
   classes stay icon-button for the TO-0057 label pin. */
#copy-link-button {
  gap: 6px;
  width: auto;
  height: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-color: var(--p-violet-fill);
  border-radius: var(--p-r-btn);
  background: var(--p-violet-fill);
  color: var(--p-on-violet);
  font: 600 14px/1.2 var(--p-font);
}

@media (hover: hover) {
  #copy-link-button:hover { border-color: var(--p-violet-ink); background: var(--p-violet-ink); color: var(--p-on-violet); }
}

.invite-label {
  display: none;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.header-tools .link-state {
  align-self: center;
  flex: 0 1 auto;
}

.lang-chips {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.lang-chips .p-chip {
  min-height: 38px;
}

.language-open,
.toggle-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
}

/* Touch screens: every header chip and tool keeps a 44 px target
   (MR §12, §14); the desktop look stays compact for mouse pointers. */
@media (pointer: coarse) {
  .lang-chips .p-chip,
  .language-open,
  .toggle-button {
    min-height: 44px;
  }
}

/* "Show originals" (TO-0021): pressed = originals visible. */
.toggle-button[aria-pressed="true"] {
  background: var(--p-lavender);
  border-color: var(--p-violet-line);
  color: var(--p-violet);
}

/* Color picker panel under the header, opened from the own row. */
.color-picker {
  position: absolute;
  top: calc(100% - 6px);
  left: 16px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 44px);
  gap: 8px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(var(--shadow-rgb), 0.16);
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--sw-tint);
  background: var(--sw-accent);
  cursor: pointer;
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text);
}

.swatch:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Connection bar (TO-0021, F-6): amber while reconnecting, green for 2 s
   after a reconnect. */
.connection-bar {
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.connection-bar.reconnecting {
  background: var(--bar-warn-bg);
  color: var(--bar-warn-text);
}

.connection-bar.connected {
  background: var(--bar-ok-bg);
  color: var(--bar-ok-text);
  animation: bar-fade 2s ease-in forwards;
}

@keyframes bar-fade {
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.notice-banner {
  padding: 8px 16px;
  background-color: var(--bg-error);
  color: var(--color-error);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

/* Keep the first-send agreement readable without crowding the composer. */
.account-ai-consent {
  flex-shrink: 0;
  display: grid;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--p-bg-2);
  font-size: 0.9rem;
  line-height: 1.5;
}

.account-ai-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.account-ai-consent-label input {
  flex-shrink: 0;
  margin-top: 4px;
}

.account-ai-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.account-ai-consent-actions button {
  min-height: 44px;
  padding: 8px 12px;
}

/* --- Message list --- */
.messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  background: var(--p-bg-2);
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

/* System lines, day dividers and the joined notice: centred pills. */
.system-line,
.day-separator,
.joined-notice {
  align-self: center;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--p-chip);
  color: var(--p-muted);
  font-size: 12px;
  text-align: center;
}

.day-separator {
  font-weight: 600;
}

.joined-notice {
  padding: 6px 14px;
  background: var(--p-success-bg);
  color: var(--p-success-text);
  font-size: 13px;
}

/* Messages (MR §10, spec §6): received = optional avatar beside the sender
   line, the bubble and the time; translation first under the reader's
   language label, then the original under "ORIGINAL · <LANGUAGE>"; own =
   only what was typed, violet. Below 900 px the original stacks under the
   translation; from 900 px they sit side by side in the bubble (Known
   trap 2). */
.message-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.message-card.own {
  align-self: flex-end;
  align-items: flex-end;
  max-width: 82%;
}

.message-card.other {
  align-self: flex-start;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 3px;
  max-width: 90%;
}

.bubble-head {
  display: contents;
}

.avatar {
  display: none;
}

.sender-tag {
  padding-left: 4px;
  color: var(--p-ink);
  font-size: 12px;
  font-weight: 600;
}

.sender-lang {
  color: var(--p-muted);
  font-weight: 400;
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--p-r-bubble) var(--p-r-bubble) var(--p-r-bubble) var(--p-r-bubble-tail);
}

.translation-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.trans-label,
.original-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trans-label {
  color: var(--p-violet);
}

.original-label {
  color: var(--p-muted);
}

.translation {
  color: inherit;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

.message-card.own .translation {
  padding: 9px 12px;
  border-radius: var(--p-r-bubble) var(--p-r-bubble) var(--p-r-bubble-tail) var(--p-r-bubble);
}

.translation-error {
  color: var(--p-red);
  font-style: italic;
}

/* TO-0116: a translation the model flagged prohibited (reader side only),
   directly under the translation text. */
.translation-flag {
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bar-warn-bg);
  color: var(--bar-warn-text);
  font-size: 0.8em;
}

.original-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-top: 7px;
  border-top: 1px solid var(--p-line-2);
}

.original {
  color: var(--p-body);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.translation, .original { overflow-wrap: anywhere; }

/* Time under the bubble. */
.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px;
  color: var(--p-muted);
  font-size: 11px;
}

/* Grouped runs: only the newest bubble of a run keeps the squared tail. */
.message-card.other.group-start .msg-body,
.message-card.other.group-middle .msg-body { border-bottom-left-radius: var(--p-r-bubble); }
.message-card.own.group-start .translation,
.message-card.own.group-middle .translation { border-bottom-right-radius: var(--p-r-bubble); }
.message-card.group-start,
.message-card.group-middle { margin-bottom: -8px; }
.message-card.group-start > .msg-meta,
.message-card.group-middle > .msg-meta { display: none; }

/* Seen by (stuc-mobile-parity-gaps TO-0033): the count of other seats that
   read the reader's own message follows its time; hidden at 0. */
.msg-seen {
  color: var(--p-muted);
  white-space: nowrap;
}

/* Outbox (TO-0042): a sent message waits as a faded own bubble reading
   "Sending…" at the bottom of the log until the server acks it; one not
   acked in time turns into an error bubble whose status is a retry button.
   The wrapper takes no box, so its bubbles share the log's gap. */
.outbox {
  display: contents;
}

.message-card.pending {
  opacity: 0.7;
}

.message-card.own.unsent {
  opacity: 1;
}

.message-card.own.unsent .translation {
  background: var(--bg-error);
  border: 1px dashed var(--color-error);
  color: var(--color-error);
}

.message-card.own.unsent .msg-meta {
  color: var(--color-error);
}

.outbox-status {
  font-style: italic;
}

.outbox-retry {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* Replies (stuc-mobile-parity-gaps TO-0021): the quote sits above the
   bubble in the reader's language; the Reply action follows the time; the
   line above the composer stays until the reply is sent or dismissed. */
.reply-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 100%;
  min-width: 0;
  padding: 4px 10px;
  border-left: 3px solid var(--p-violet-line);
  border-radius: var(--p-r-btn);
  background: var(--p-chip);
  color: var(--p-body);
  font-size: 13px;
  line-height: 1.35;
}

.message-card.own > .reply-quote {
  align-self: flex-end;
}

.reply-quote-name,
.reply-bar-name {
  color: var(--p-violet-ink);
  font-weight: 600;
}

.reply-quote-text,
.reply-quote-original,
.reply-bar-text {
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.reply-quote-original {
  color: var(--p-muted);
}

.reply-quote.is-unavailable .reply-quote-text {
  color: var(--p-muted);
  font-style: italic;
}

.msg-reply {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--p-violet-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Reactions (stuc-mobile-parity-gaps TO-0028): the chips sit under the
   bubble, the reader's own outlined; React follows Reply and opens the six
   emoji in a row under the time. */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 4px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--p-line);
  border-radius: var(--p-r-chip);
  background: var(--p-chip);
  color: var(--p-body);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
}

button.reaction-chip {
  cursor: pointer;
}

.reaction-chip.is-mine {
  border-color: var(--p-violet);
  background: var(--p-lavender);
  color: var(--p-violet-ink);
  font-weight: 600;
}

.msg-react {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--p-violet-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.reaction-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--p-line);
  border-radius: var(--p-r-chip);
  background: var(--p-surface);
}

.reaction-choice {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: var(--p-r-chip);
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.reaction-choice[aria-pressed="true"] {
  background: var(--p-lavender);
}

.message-card.own > .msg-reactions,
.message-card.own > .reaction-picker {
  align-self: flex-end;
}

.message-card.other > .msg-reactions,
.message-card.other > .reaction-picker {
  justify-self: start;
}

/* Grouping hides timestamps, but every stored message must remain reactable. */
.message-card.group-start > .msg-meta.has-react-control,
.message-card.group-middle > .msg-meta.has-react-control { display: flex; }
.message-card.group-start > .msg-meta.has-react-control > .msg-time,
.message-card.group-middle > .msg-meta.has-react-control > .msg-time,
.message-card.group-start > .msg-meta.has-react-control > .msg-reply,
.message-card.group-middle > .msg-meta.has-react-control > .msg-reply { display: none; }

/* Edit and delete (stuc-mobile-parity-gaps TO-0039): Edit and Delete follow
   React on the reader's own messages; "Edited" comes before the time; a
   deleted message reads "Message deleted" in muted italics. The Editing
   line above the composer is the reply line's. */
.msg-edit,
.msg-delete {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--p-violet-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.msg-delete {
  color: var(--color-error);
}

/* Four actions, the time and Seen by do not fit one line of an own bubble
   on a phone: the row wraps, right-aligned like the bubble. */
.message-card.own > .msg-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.message-card.group-start > .msg-meta.has-edited,
.message-card.group-middle > .msg-meta.has-edited { display: flex; }

.msg-edited {
  color: var(--p-muted);
  font-style: italic;
  white-space: nowrap;
}

.translation.is-deleted {
  color: var(--p-muted);
  font-style: italic;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 4px 4px 4px 10px;
  border-left: 3px solid var(--p-violet);
  border-radius: var(--p-r-btn);
  background: var(--p-chip);
  color: var(--p-body);
  font-size: 13px;
}

.reply-bar[hidden] {
  display: none;
}

.reply-bar-lines {
  flex: 1;
  min-width: 0;
}

/* Originals toggle off (TO-0021): the original and its label go; the
   sender line still names the language. */
.hide-originals .original-wrap {
  display: none;
}

.hide-originals .reply-quote-original {
  display: none;
}

.hide-originals .trans-label {
  display: none;
}

/* Voice "Play in <language>" button. */
.voice-play-button {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  margin-top: 4px;
  padding: 6px 12px;
  border: 1px solid var(--p-line);
  border-radius: 999px;
  background: var(--p-surface);
  color: var(--p-ink);
  font: 600 13px var(--p-font);
  cursor: pointer;
}

.message-card.own .voice-play-button {
  align-self: flex-end;
}

.voice-message {
  margin: 4px 0;
}

.jump-latest {
  position: absolute; z-index: 5; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  min-width: 44px; min-height: 44px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--bg-card); color: var(--text); box-shadow: 0 4px 16px rgba(var(--shadow-rgb), .18);
  font: 600 .85rem var(--font-sans); cursor: pointer;
}

/* --- Composer --- */
.chat-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--p-line-2);
  background: var(--p-surface);
}
.chat-footer {
  padding-right: max(10px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(10px, env(safe-area-inset-left, 0px));
}

/* Typing line above the composer; keeps its height so the composer does
   not jump when someone starts or stops typing. */
.typing-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.4rem;
  padding: 0 4px;
  color: var(--p-muted);
  font-size: 13px;
}

.typing-line[data-active="false"] .typing-dots {
  display: none;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--p-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.message-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 134px;
  height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--p-line);
  border-radius: 12px;
  background: var(--p-bg);
  color: var(--p-ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  resize: none;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.message-input:focus {
  border-color: var(--p-violet);
}

.send-button,
.ptt-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.send-button {
  background: var(--p-violet-fill);
  color: var(--p-on-violet);
}

/* Offline (reconnecting): send is disabled until the socket rejoins. */
.send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Push-to-talk mic button: hold to speak. No scroll, text selection or
   long-press menu may take the gesture away from the pointer handlers. */
.ptt-button {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--p-chip);
  color: var(--p-ink);
}

.ptt-button.recording {
  background-color: var(--color-error);
  color: var(--p-on-violet);
  animation: ptt-pulse 1s infinite;
}

/* Voice status line above the composer (TO-0043, TO-0048): Recording…
   while the talk button is held, then Transcribing… and Translating…; a
   hint or an error that hides itself. It wraps, so a long error fits a phone. */
.ptt-listening {
  padding: 0 4px;
  color: var(--p-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.ptt-listening[data-kind="error"] {
  color: var(--color-error);
}

@keyframes ptt-pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--error-rgb), 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(var(--error-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--error-rgb), 0); }
}

.composer-hint {
  display: none;
  padding-left: 58px;
  color: var(--p-muted);
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .typing-dots span,
  .connection-bar.connected,
  .ptt-button.recording,
  #participants-sheet .participant-sheet {
    animation: none;
  }
}

/* --- People and details panel: a slide-in on phones, a panel on wide
   screens (the same queries as app.js HOST_RAIL_QUERY / GUEST_RAIL_QUERY). */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1002; display: flex; align-items: flex-end; justify-content: center;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); background: var(--p-scrim);
}
.participant-sheet {
  width: min(100%, 480px); max-height: min(78dvh, 640px); overflow-y: auto; padding: 20px 18px 24px;
  background: var(--p-surface); color: var(--p-ink); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px var(--p-shadow);
}
#participants-sheet { justify-content: flex-start; align-items: stretch; }
#participants-sheet .participant-sheet {
  display: flex; flex-direction: column; gap: 16px;
  width: min(86vw, 340px); height: 100%; max-height: none; border-radius: 0 20px 20px 0; animation: people-slide-in .18s ease-out;
}
@keyframes people-slide-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.sheet-heading { display: flex; align-items: center; gap: 10px; }
.sheet-heading h2 { flex: 1 1 auto; font-size: 15px; font-weight: 600; }
.sheet-count { color: var(--p-muted); font-size: 13px; }
.sheet-close { border-color: transparent; font-size: 1.4rem; }
.participants-list { display: flex; flex-direction: column; gap: 6px; }
.participant-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 52px; text-align: left; border: 0; background: transparent; color: inherit; }
.participant-profile-trigger { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.participant-avatar { width: 36px; height: 36px; }
.participant-initials { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.participant-picture { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.participant-details { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.participant-name { overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.participant-language { color: var(--p-muted); font-size: 12px; }
.participant-color-button,
.participant-remove-button { min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--p-body); font: 600 13px var(--p-font); cursor: pointer; }
.participant-remove-button { display: inline-flex; align-items: center; justify-content: center; color: var(--p-muted); }
.participant-remove-button, .sheet-close { min-width: 44px; min-height: 44px; }
@media (hover: hover) {
  .participant-color-button:hover, .participant-remove-button:hover { background: var(--p-chip); }
}
.invite-seats { min-height: 46px; }
.guest-note {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--p-bg);
  color: var(--p-body);
  font-size: 13px;
  line-height: 1.5;
}
.about-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--p-lavender);
  color: var(--p-ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.about-card strong {
  color: var(--p-violet);
  font-size: 13px;
}
.panel-end {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--p-line-2);
}
.panel-end:not(:has(> :not([hidden]))) { display: none; }
.end-button { width: 100%; }
.end-note { color: var(--p-muted); font-size: 12px; text-align: center; }
.end-error { color: var(--p-red); font-size: 13px; line-height: 1.4; }
.end-error a { color: var(--p-violet); font-weight: 600; }

/* In-page confirm (End, Leave, Remove): never window.confirm. */
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.confirm-text { margin-top: 8px; color: var(--p-body); font-size: 15px; line-height: 1.5; text-align: left; }
#confirm-modal .modal-title { text-align: left; font-size: 20px; }

.language-sheet, .profile-sheet { width: min(100%, 480px); }
/* Keep the chat picker centered; only its options scroll, never its search. */
#language-sheet {
  align-items: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
#language-sheet .language-sheet {
  display: flex; flex-direction: column;
  max-height: 100%; max-height: min(640px, calc(100dvh - 24px));
  overflow: hidden; border-radius: 20px;
}
#language-sheet .sheet-heading, #language-sheet .language-progress, #language-sheet .language-error { flex-shrink: 0; }
.language-choices { display: flex; flex-direction: column; min-height: 0; }
#language-choices .lp-inline { min-height: 0; overflow: hidden; }
#language-choices .lp-search { flex-shrink: 0; }
#language-choices .lp-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.language-retry { min-height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); color: var(--text); font: 600 .9rem var(--font-sans); text-align: left; cursor: pointer; }
.language-progress { margin: 12px 0; color: var(--text-secondary); }
.language-error { margin: 12px 0; color: var(--color-error); }
/* Profile card (TO-0138): heading name, a 72 px avatar, the reading
   language, the full name only when it differs. Laptop: near the top. */
.profile-avatar-slot { display: flex; justify-content: center; margin-top: 16px; }
.profile-avatar { width: 72px; height: 72px; font-size: 26px; }
.profile-avatar .participant-picture { width: 72px; height: 72px; }
.profile-language { margin-top: 12px; text-align: center; color: var(--p-muted); }
.profile-full-name { margin-top: 6px; text-align: center; font-size: 1.05rem; font-weight: 700; }
.profile-full-name[hidden], .profile-language[hidden] { display: none; }
@media (min-width: 600px) {
  /* Operator 2026-10-13: the card appears above the chat; the rest of the window is not dimmed or redrawn.
     The backdrop stays (transparent) so one click anywhere closes the card. */
  #profile-sheet { align-items: flex-start; padding-top: max(10vh, 48px); background: transparent; }
  #profile-sheet .profile-sheet { border-radius: 20px; border: 1px solid var(--p-line-2); box-shadow: 0 16px 48px var(--p-shadow); }
}
.modal-content.p-dialog { text-align: center; }

/* --- Wider screens --- */

/* Translation | original side by side inside the bubble from 900 px
   (Known trap 2); below it they stack. */
@media (min-width: 900px) {
  .msg-body.has-original {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 18px;
  }

  .msg-body.has-original .original-wrap {
    padding-top: 0;
    padding-left: 16px;
    border-top: none;
    border-left: 2px solid var(--p-line-2);
  }

  .hide-originals .msg-body.has-original {
    display: flex;
  }
}

/* Desktop conversation: bigger type, avatars beside received messages, the
   Enter hint, the full Invite label (host from 760 px, guest from 820 px). */
@media (min-width: 760px) and (min-height: 501px) {
  .is-host .invite-label { display: inline; }
  .is-host .back-button { display: none; }
}
@media (min-width: 820px) and (min-height: 501px) {
  .is-guest .back-button { display: none; }
}
@media (max-width: 819px), (max-height: 500px) {
  .is-guest .leave-button { display: none; }
}
@media (min-width: 760px) and (min-height: 501px) {
  .chat-header { padding: 14px 24px 12px; }
  .header-tools { overflow: visible; flex-wrap: wrap; }
  .chat-title { font-size: 19px; }
  .session-subtitle { font-size: 13px; }
  .messages-container { padding: 24px; gap: 18px; }
  .message-card.own { max-width: min(560px, 80%); }
  .message-card.other { grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; max-width: min(760px, 92%); }
  .avatar {
    display: inline-flex; align-items: center; justify-content: center;
    grid-column: 1; grid-row: 1 / span 3; align-self: end;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--sw-tint, var(--p-lavender)); color: var(--sw-text, var(--p-violet));
    font-size: 13px; font-weight: 600;
  }
  .sender-tag, .message-card.other > .msg-body, .message-card.other > .msg-meta, .message-card.other > .voice-play-button { grid-column: 2; }
  .message-card.other > .msg-reactions, .message-card.other > .reaction-picker { grid-column: 2; }
  .sender-tag { font-size: 13px; }
  .msg-body { padding: 12px 16px; border-radius: 18px 18px 18px 6px; }
  .translation { font-size: 16px; line-height: 1.45; }
  .original { font-size: 15px; line-height: 1.45; }
  .message-card.own .translation { padding: 11px 15px; }
  .msg-meta { font-size: 12px; }
  .chat-footer { padding: 14px 24px 16px; gap: 8px; }
  .message-form { gap: 10px; }
  .message-input { min-height: 50px; padding: 13px 14px; border-radius: 14px; }
  .send-button, .ptt-button { width: 50px; height: 50px; border-radius: 14px; }
  .composer-hint { display: block; }
  .jump-latest { bottom: 110px; }
}
@media (hover: none) {
  .composer-hint { display: none; }
}

/* Host from 760 px (TO-0147): the guest's fixed page — the window never
   scrolls; chat list · conversation, People here in the slide-in below
   1100 px. In the People column the names list is the part that scrolls;
   the ad slot (private.css) and the End block below it keep their place
   however many names are listed, and the End block keeps its height while
   its buttons are still hidden (before the joined frame). */
@media (min-width: 760px) and (min-height: 501px) {
  .chat-container.is-host { grid-template-columns: 260px minmax(0, 1fr); }
  .is-host .chat-list { display: flex; }
  .is-host #participants-sheet .participant-sheet { overflow: hidden; }
  .is-host #participants-sheet .participants-list { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
  .is-host #participants-sheet .panel-end { display: flex; flex: none; min-height: 89px; margin-top: 0; }
  .is-host #participants-sheet .panel-end:not(:has(> :not([hidden]))) { border-top-color: transparent; }
}
/* Short windows (under 700 px tall): the carousel would squeeze the names
   list to nothing, so the whole column scrolls instead (the ad then follows
   the list, as before TO-0147). */
@media (min-width: 760px) and (min-height: 501px) and (max-height: 699px) {
  .is-host #participants-sheet .participant-sheet { overflow-y: auto; }
  .is-host #participants-sheet .participants-list { flex: none; overflow: visible; }
}

/* Host from 1100 px: chat list · conversation · details (the guest's
   panel rules, from 1180 px for the guest). */
@media (min-width: 1100px) and (min-height: 501px) {
  .chat-container.is-host { grid-template-columns: 260px minmax(0, 1fr) 300px; }
  .is-host #participants-sheet { position: static; z-index: auto; display: block; min-height: 0; padding: 0; background: none; }
  .is-host #participants-sheet .participant-sheet {
    width: 100%; height: 100%; max-height: none; border-radius: 0; box-shadow: none; animation: none;
    border-left: 1px solid var(--p-line-2); padding: 20px;
  }
  .is-host #participants-sheet .sheet-close, .is-host #participants-open { display: none; }
}
@media (min-width: 1280px) and (min-height: 501px) {
  .chat-container.is-host { grid-template-columns: 280px minmax(0, 1fr) 320px; }
}

/* Guest from 820 px: the reserved ad column beside the conversation. */
@media (min-width: 820px) and (min-height: 501px) {
  .chat-container.is-guest { grid-template-columns: 300px minmax(0, 1fr); }
  .is-guest .ad-rail { display: block; }
}
/* The guest's ad column never shows on a host page (TO-0147 guard). */
.is-host .ad-rail { display: none; }

/* Guest from 1180 px: ad column · conversation · people (read-only). */
@media (min-width: 1180px) and (min-height: 501px) {
  .chat-container.is-guest { grid-template-columns: 324px minmax(0, 1fr) 300px; }
  .is-guest #participants-sheet { position: static; z-index: auto; display: block; min-height: 0; padding: 0; background: none; }
  .is-guest #participants-sheet .participant-sheet {
    width: 100%; height: 100%; max-height: none; border-radius: 0; box-shadow: none; animation: none;
    border-left: 1px solid var(--p-line-2); padding: 20px;
  }
  .is-guest #participants-sheet .sheet-close, .is-guest #participants-open, .is-guest #participants-sheet .panel-end { display: none; }
}

/* Narrow phones. */
@media (max-width: 430px) {
  .chat-header { gap: 6px; padding-right: max(10px, env(safe-area-inset-right, 0px)); padding-left: max(10px, env(safe-area-inset-left, 0px)); }
  .header-top { gap: 4px; }
  .chat-title { font-size: 15px; }
  .session-subtitle { font-size: 11.5px; }
  .language-open, .toggle-button { padding: 0 10px; font-size: 12px; }
  .lang-chips .p-chip { padding: 0 10px; }
}

/* Short landscape: keep the title, tools and buttons on one header row so
   the log keeps the height (TO-0024 DD-10). */
@media (orientation: landscape) and (max-height: 500px) {
  .chat-header { flex-wrap: nowrap; gap: 4px 8px; padding-top: calc(4px + env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
  .header-top { flex: 1 1 auto; }
  .header-tools { flex: 0 1 auto; }
  .messages-container { padding-top: 6px; padding-bottom: 6px; }
  .chat-footer { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  .typing-line { min-height: 22px; }
}

/* Phones: the header line wraps rather than hiding the online count. */
@media (max-width: 819px) {
  .session-subtitle { white-space: normal; }
}

/* The guest's language radio group inside the chip strip (More… sits
   beside it). */
.lang-chip-group {
  display: inline-flex;
  gap: 2px;
}
