/* Buttons */
.btn { height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); flex: none; }
.btn:disabled { cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn.grow { flex: 1; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-done { background: var(--bubble-theirs); color: var(--muted); border-color: var(--hairline); }
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-md); border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 18px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; line-height: 1; }
.icon-btn:hover { background: var(--bubble-theirs); }
.back { width: 44px; height: 44px; font-size: 22px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.link:hover { color: var(--accent-dark); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .search input, .composer input { height: 44px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0 14px; font-size: 15px; color: var(--ink); background: var(--bg); width: 100%; }
.field input:focus-visible, .dialog-search input:focus-visible { border-color: var(--accent); outline-offset: 2px; }
.hint { font-size: 12.5px; color: var(--muted); }
.alert { display: flex; align-items: center; gap: var(--space-2); background: var(--danger-bg); color: var(--danger-text); border-radius: var(--radius-sm); padding: 10px var(--space-3); font-size: 13.5px; font-weight: 500; }
.search { height: 40px; border-radius: var(--radius-md); background: var(--field); border: 1px solid var(--hairline); display: flex; align-items: center; gap: var(--space-2); padding: 0 14px; color: var(--muted); }
.search input { border: 0; background: transparent; height: 100%; padding: 0; font-size: 13.5px; }
.search input:focus-visible { outline: none; }
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer input { height: 46px; background: var(--field); border-color: var(--hairline); padding: 0 18px; font-size: 14.5px; flex: 1; }
.send { width: 46px; height: 46px; border-radius: var(--radius-md); border: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.send:disabled { opacity: 0.5; cursor: default; }

/* Segmented tabs */
.seg { display: flex; background: var(--bubble-theirs); border-radius: var(--radius-md); padding: 3px; }
.seg button { flex: 1; height: 34px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: var(--space-2); cursor: pointer; }
.seg button[aria-selected='true'] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.auth-card .seg { padding: 4px; }
.auth-card .seg button { height: 38px; }

/* Avatars, presence, badges */
.avatar-wrap { position: relative; flex: none; }
.avatar { width: var(--size, 42px); height: var(--size, 42px); border-radius: 50%; color: var(--av-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: calc(var(--size, 42px) * 0.36); flex: none; }
.av-0 { background: var(--av-0); } .av-1 { background: var(--av-1); } .av-2 { background: var(--av-2); } .av-3 { background: var(--av-3); } .av-4 { background: var(--av-4); }
.dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; }
.dot-on { background: var(--online); box-shadow: 0 0 0 2px var(--dot-ring, #fff); }
.dot-off { background: var(--dot-ring, #fff); border: 2px solid var(--muted); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* List rows */
.chat-row { display: flex; gap: var(--space-3); padding: 11px var(--space-3); border-radius: var(--radius-sm); align-items: center; border: 0; background: transparent; width: 100%; text-align: left; cursor: pointer; color: inherit; min-height: 64px; }
.chat-row:hover { background: rgba(0, 0, 0, 0.03); }
.chat-row[aria-current='true'] { background: var(--bg); box-shadow: inset 3px 0 0 #e2e2e2, 0 0 0 1px #e2e2e2; }
.row-body { flex: 1; min-width: 0; }
.row-top, .row-bottom { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; }
.row-bottom { margin-top: 2px; }
.row-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { font-size: 12px; color: var(--muted); flex: none; }
.row-prev { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-row.unread .row-time { color: var(--accent); font-weight: 700; }
.chat-row.unread .row-prev { color: var(--ink); font-weight: 600; }
.chat-row[aria-current='true'] .row-prev { color: var(--accent); }

.group-head { font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px var(--space-3) var(--space-1); }
.contact-row { position: relative; display: flex; align-items: center; gap: 10px; padding: var(--space-2) var(--space-3); min-height: 56px; border-radius: var(--radius-sm); }
.contact-row.hl { background: var(--accent-wash); }
.contact-status { font-size: 12.5px; color: var(--muted); }
.contact-status.on { color: var(--online-text); font-weight: 500; }
.menu { position: absolute; right: var(--space-3); top: 100%; margin-top: -6px; z-index: 5; background: var(--bg); border: 1px solid #e2e2e2; border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14); padding: 0; }
.menu button { border: 0; background: none; padding: 12px 14px; min-height: 44px; font-size: 13.5px; font-weight: 600; color: var(--danger-text); cursor: pointer; width: 100%; text-align: left; }

/* Empty / loading states */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; padding: 0 var(--space-6); }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-tint); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.empty-icon.big { width: 64px; height: 64px; border-radius: var(--radius-lg); background: var(--bubble-theirs); font-size: 28px; }
.empty-title { font-weight: 700; font-size: 15px; }
.empty-title.big { font-size: 18px; }
.empty-text { font-size: 13.5px; color: var(--muted); line-height: 1.5; max-width: 280px; }
.skel-row { display: flex; gap: var(--space-3); padding: 11px var(--space-3); align-items: center; animation: sh 1.4s infinite; }
.skel { background: var(--hairline); border-radius: var(--radius-tail); }
.skel.circle { border-radius: 50%; }
@keyframes sh { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Chat header + messages */
.head-name { font-weight: 700; font-size: 16px; }
.head-status { font-size: 13px; color: var(--muted); font-weight: 500; }
.head-status.on { color: var(--online-text); }
.day { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 var(--space-2); }
.msg { display: flex; flex-direction: column; margin-top: 3px; }
.msg.first { margin-top: 10px; }
.msg.mine { align-items: flex-end; }
.msg.theirs { align-items: flex-start; }
.bubble { max-width: 68%; padding: 9px 14px; font-size: 14.5px; line-height: 1.4; background: var(--bubble-theirs); color: var(--ink); border-radius: var(--radius-lg); overflow-wrap: anywhere; white-space: pre-wrap; }
.mine .bubble { background: var(--accent); color: #fff; }
.theirs:not(.first) .bubble { border-top-left-radius: var(--radius-tail); }
.theirs:not(.last) .bubble { border-bottom-left-radius: var(--radius-tail); }
.mine:not(.first) .bubble { border-top-right-radius: var(--radius-tail); }
.mine:not(.last) .bubble { border-bottom-right-radius: var(--radius-tail); }
.meta { font-size: 12px; color: var(--muted); margin: 4px 4px 0; }
.older { align-self: center; font-size: 12px; color: var(--muted); padding: var(--space-2); }

/* Dialogs */
.scrim { position: fixed; inset: 0; background: rgba(22, 22, 22, 0.45); display: flex; align-items: center; justify-content: center; padding: var(--space-4); z-index: 20; }
.dialog { --dot-ring: #fff; width: 100%; max-width: 440px; max-height: min(600px, 100%); background: var(--bg); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); overflow: hidden; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-title { font-size: 18px; font-weight: 700; margin: 0; }
.dialog-search { height: 44px; border: 2px solid var(--accent); border-radius: var(--radius-md); padding: 0 14px; display: flex; align-items: center; gap: var(--space-2); color: var(--muted); }
.dialog-search:focus-within { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.dialog-search input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 15px; color: var(--ink); background: transparent; height: 100%; }
.dialog-body { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; min-height: 120px; }
.dialog-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.dialog-msg { text-align: center; padding: 28px 0; display: flex; flex-direction: column; gap: var(--space-1); }
.dialog-foot { font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--hairline); padding-top: var(--space-3); }
.user-row { display: flex; align-items: center; gap: var(--space-3); padding: 6px 10px; min-height: 52px; border-radius: var(--radius-sm); border: 0; background: transparent; width: 100%; text-align: left; color: inherit; }
button.user-row { cursor: pointer; }
.user-row:hover { background: var(--accent-wash); }
div.user-row:hover { background: transparent; }
.user-name { font-size: 14.5px; font-weight: 600; }
.user-sub { font-size: 12.5px; color: var(--muted); }
.user-row .btn { height: 36px; min-width: 76px; font-size: 13.5px; }

@media (max-width: 760px) {
  .btn, .icon-btn { min-height: 44px; }
  .seg button { height: 40px; }
  .search { height: 44px; }
  .search input { font-size: 16px; }
  .scrim { align-items: flex-end; padding: 0; }
  .dialog { max-width: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 85%; }
  .dialog-search input { font-size: 16px; }
  .chat-row { min-height: 68px; }
}

/* Phase 5: banner, message states, typing */
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 22px; background: var(--warning-bg); color: #5c4300; font-size: 13.5px; font-weight: 600; border-bottom: 1px solid #f0dca0; }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #5c4300; border-top-color: transparent; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg.sending .bubble { opacity: 0.6; }
.msg.failed .bubble { outline: 2px solid var(--danger); outline-offset: 1px; }
.failed-meta { display: flex; align-items: center; gap: var(--space-2); color: var(--danger-text); font-weight: 600; }
.retry { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--danger); background: var(--bg); color: var(--danger-text); font-size: 12px; font-weight: 700; cursor: pointer; }
.head-status.typing, .row-prev.typing, .chat-row[aria-current='true'] .row-prev.typing { color: var(--accent); font-weight: 500; }
.typing-dots .bubble { display: flex; gap: 5px; align-items: center; padding: 12px 14px; }
.typing-dots .bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing-dots .bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots .bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
@media (max-width: 760px) { .banner { padding: 10px var(--space-4); } .retry { min-height: 44px; } }

/* Phase 6: non-contact banner under the chat header */
.contact-banner { display: flex; align-items: center; gap: var(--space-2); padding: 0 22px; min-height: 40px; background: var(--accent-wash); color: var(--accent-dark); font-size: 13.5px; border-bottom: 1px solid #d9e3fa; }
.banner-link { border: 0; background: transparent; color: var(--accent-dark); font-family: inherit; font-size: 13.5px; font-weight: 700; text-decoration: underline; padding: 0; min-height: 28px; cursor: pointer; }
.banner-link:disabled { opacity: 0.6; cursor: default; }
@media (max-width: 760px) { .contact-banner { padding: 0 var(--space-4); min-height: 44px; } .banner-link { min-height: 44px; } }

/* Phase 7: blocking */
.head-menu { position: relative; flex: none; }
.head-menu .menu { right: 0; top: 100%; margin-top: 4px; min-width: 160px; }
.icon-btn.bordered { border-color: var(--hairline); }
.menu .neutral { color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-text); }
.block-banner { display: flex; align-items: center; gap: var(--space-2); padding: 0 22px; min-height: 40px; background: var(--bubble-theirs); color: var(--ink); font-size: 13.5px; border-bottom: 1px solid var(--hairline); }
.block-banner .banner-link { color: var(--accent-dark); }
.dialog-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.dialog-actions .btn { height: 42px; }
.composer input:disabled { cursor: not-allowed; }
@media (max-width: 760px) { .block-banner { padding: 0 var(--space-4); min-height: 44px; } }

/* Phase 8: groups */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mem-btn { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--hairline); background: transparent; color: var(--muted); font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; flex: none; }
.mem-btn[aria-expanded='true'] { background: var(--accent-tint); color: var(--accent-dark); }
.sender { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 3px 4px; }
.members-panel { width: 260px; flex: none; border-left: 1px solid var(--hairline); padding: 20px; display: flex; flex-direction: column; gap: 14px; background: var(--sidebar); overflow-y: auto; --dot-ring: var(--sidebar); }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-title { font-size: 15px; font-weight: 700; margin: 0; }
.member-row { display: flex; align-items: center; gap: 10px; }
.member-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: 12px; color: var(--muted); }
.role-pill { font-size: 11.5px; font-weight: 700; color: var(--accent-dark); background: var(--accent-tint); border-radius: var(--radius-full); padding: 3px 8px; flex: none; }
.member-x { width: 32px; height: 32px; min-height: 0; font-size: 14px; }
.panel-actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-1); }
.btn-leave { color: var(--danger-text); border-color: #e8bcbc; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 12px; border-radius: var(--radius-full); background: var(--accent-tint); color: var(--accent-dark); font-size: 13.5px; font-weight: 600; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; }
.name-box { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 14px; }
.name-box span { color: var(--muted); font-size: 13px; }
.name-box input { border: 0; outline: 0; font-size: 15px; font-weight: 500; font-family: inherit; color: var(--ink); padding: 0; background: transparent; }
.name-box:focus-within { border-color: var(--accent); outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #8a8a8a; background: var(--bg); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; flex: none; }
.check.on { background: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) { .mem-btn { min-height: 44px; } .member-x { width: 44px; height: 44px; } .members-panel { position: absolute; inset: 0; width: auto; z-index: 10; border-left: 0; } }

/* Phase 9: Sent / Seen (text label in the same style as the design's "· Delivered") */
.receipt { display: inline-flex; align-items: center; color: var(--muted); }
.receipt.seen { color: var(--accent); }

/* Phase 9 UI from design/Chat Status Icons.dc.html: meta line status, info button, Message info panel, context menu */
.meta { display: flex; align-items: center; gap: 4px; }
.msg.mine .meta { justify-content: flex-end; }
.bubble-row { display: flex; flex-direction: row-reverse; align-items: center; gap: var(--space-2); max-width: 100%; }
.bubble-row .bubble { max-width: min(480px, 55vw); }
.bubble.selected { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.msg-info { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; flex: none; opacity: 0; transition: opacity 0.1s; }
.msg:hover .msg-info, .msg-info:focus-visible, .bubble.selected + .msg-info { opacity: 1; }
.bubble.selected + .msg-info { color: var(--accent); }
@media (hover: none) { .msg-info { display: none; } }
.info-panel { width: 320px; flex: none; border-left: 1px solid var(--hairline); background: var(--sidebar); display: flex; flex-direction: column; overflow-y: auto; --dot-ring: var(--sidebar); }
.info-head { height: 72px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--hairline); font-size: 16px; }
.info-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 20px; }
.info-bubble { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.info-bubble .bubble { background: var(--accent); color: #fff; max-width: 250px; font-size: 14px; border-top-right-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-tail); }
.info-card { background: var(--bg); border: 1px solid var(--hairline); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.info-card.tight { padding: 4px 14px; gap: 0; }
.info-card-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.info-count { margin-left: auto; color: var(--muted); font-weight: 600; }
.info-person { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.info-line { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.info-line + .info-line { border-top: 1px solid var(--hairline); }
.info-line.muted .info-label { color: var(--muted); }
.info-label { font-size: 14px; font-weight: 600; }
.info-time { font-size: 12.5px; color: var(--muted); }
.info-ico { display: inline-flex; color: var(--muted); }
.info-ico.seen { color: var(--accent); }
.ctx-menu { position: fixed; z-index: 30; width: 180px; background: var(--bg); border: 1px solid #e2e2e2; border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14); padding: 4px; display: flex; flex-direction: column; }
.ctx-menu button { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; text-align: left; }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--accent-wash); color: var(--accent-dark); }
.ctx-gap { width: 16px; flex: none; }
@media (max-width: 760px) { .info-panel { position: absolute; inset: 0; width: auto; z-index: 10; border-left: 0; } .bubble-row .bubble { max-width: 80vw; } .ctx-menu button { height: 48px; } }

/* Phase 10: audio calls (values from design/Chat Calls.dc.html) */
.call-btn { width: 40px; height: 40px; border-radius: var(--radius-md); border: 1px solid var(--hairline); background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; flex: none; }
.call-btn:hover:not(:disabled) { background: var(--accent-tint); color: var(--accent-dark); border-color: var(--border); }
.call-btn:focus-visible { border: 2px solid var(--accent); color: var(--accent); outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.call-btn:disabled { background: var(--bg); color: #c4c4c4; cursor: default; }
.rot135 { transform: rotate(135deg); }

.call-scrim { position: fixed; inset: 0; background: rgba(22, 22, 22, 0.45); display: flex; align-items: center; justify-content: center; padding: var(--space-4); z-index: 40; }
.call-card { width: 100%; max-width: 360px; background: var(--bg); border-radius: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.14); padding: 32px 24px 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.call-avatar { position: relative; width: 96px; height: 96px; margin-bottom: 14px; }
.call-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: ringpulse 1.6s infinite; }
@keyframes ringpulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.5); opacity: 0; } }
.call-title { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.call-title.sm { font-size: 18px; }
.call-sub { font-size: 14px; color: var(--muted); }
.call-pill { margin-top: 24px; height: 52px; padding: 0 28px; border-radius: var(--radius-full); border: 0; font-family: inherit; font-size: 15px; font-weight: 700; color: #fff; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.call-pill.danger, .call-btn-lg.danger { background: var(--danger); }
.call-card.error { padding: 28px 24px 24px; gap: 8px; }
.err-ico { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.err-ico.danger { background: var(--danger-bg); color: var(--danger-text); }
.err-ico.warning { background: var(--warning-bg); color: #5c4300; }
.err-body { font-size: 14px; color: var(--muted); line-height: 1.5; }
.err-actions { display: flex; gap: 10px; margin-top: 14px; width: 100%; }
.err-actions .btn { flex: 1; height: 44px; font-size: 14.5px; }

.call-popup { position: fixed; top: 16px; right: 16px; width: 360px; max-width: calc(100vw - 24px); background: var(--bg); border: 1px solid var(--hairline); border-radius: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.14); padding: 20px; display: flex; flex-direction: column; gap: 18px; z-index: 45; }
.popup-who { display: flex; align-items: center; gap: 14px; min-width: 0; }
.popup-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.popup-name { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.popup-actions { display: flex; gap: 10px; }
.call-btn-lg { flex: 1; height: 48px; border-radius: 12px; border: 0; color: #fff; font-family: inherit; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.call-btn-lg.go { background: var(--call-green); }
.call-btn-lg:disabled { opacity: 0.7; cursor: default; }

.call-bar { display: flex; align-items: center; gap: var(--space-3); padding: 8px 22px; min-height: 64px; background: var(--call-green); flex: none; }
.call-bar.floating { position: fixed; top: 0; left: 0; right: 0; z-index: 30; }
.app.with-call-bar { padding-top: 64px; } /* makes room for the fixed bar */
.bar-avatars { display: flex; align-items: center; flex: none; }
.bar-peer .avatar { box-shadow: 0 0 0 2px var(--call-green); }
.bar-peer.speaking .avatar { box-shadow: 0 0 0 3px var(--call-green), 0 0 0 5px #fff; animation: speakpulse 1.4s infinite; }
@keyframes speakpulse { 0%, 100% { box-shadow: 0 0 0 3px var(--call-green), 0 0 0 5px #fff; } 50% { box-shadow: 0 0 0 3px var(--call-green), 0 0 0 8px rgba(255, 255, 255, 0.35); } }
.bar-me { margin-left: -6px; }
.bar-me .avatar { box-shadow: 0 0 0 2px var(--call-green); }
.bar-text { flex: 1; min-width: 0; color: #fff; }
.bar-label { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-timer { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.18); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.bar-btn[aria-pressed='true'] { background: #fff; color: var(--call-green-ink); }
.bar-btn.hang { background: var(--danger); }
.bar-btn:focus-visible, .call-pill:focus-visible, .call-btn-lg:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent); }

.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--call-green); flex: none; }

/* call entries in the message list */
.call-entry-wrap { display: flex; justify-content: center; margin: 10px 0; }
.call-entry { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 14px; border-radius: var(--radius-full); background: var(--bubble-theirs); border: 1px solid var(--hairline); color: var(--ink); font-size: 13.5px; max-width: 100%; flex-wrap: wrap; justify-content: center; }
.call-entry.bad { background: var(--danger-bg); color: var(--danger-text); border-color: #f5c9c9; }
.call-label { font-weight: 600; }
.call-sub { color: var(--muted); font-weight: 400; font-size: inherit; }
.call-entry.bad .call-sub { color: inherit; opacity: 0.85; }
.call-back { margin-left: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--danger-text); background: var(--bg); color: var(--danger-text); font-family: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }

@media (max-width: 760px) {
  .call-btn { min-height: 44px; width: 44px; }
  .call-bar { padding: 8px var(--space-4); }
  .call-popup { top: 8px; right: 12px; left: 12px; width: auto; max-width: none; }
  .call-btn-lg { height: 52px; }
  .call-back { min-height: 44px; padding: 0 14px; }
}
@media (prefers-reduced-motion: reduce) { .call-ring, .bar-peer.speaking .avatar { animation: none; } }

/* ---------- Phase 11/12: group calls and video (design/Chat Calls.dc.html, design/Chat Video Calls.dc.html) ---------- */
.call-btn-lg.plain { background: var(--bg); color: var(--ink); border: 1px solid var(--border); font-weight: 600; font-size: 14.5px; }
.popup-label { display: flex; align-items: center; gap: 6px; }
.err-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; width: 100%; }
.err-stack .btn { height: 46px; font-size: 14.5px; }
.call-card.cam { max-width: 380px; }
.call-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(92vw, 440px); background: rgba(22, 22, 22, 0.92); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 12px; z-index: 60; }

/* "Join call" banner */
.join-banner { display: flex; align-items: center; gap: 12px; padding: 8px 22px; min-height: 52px; background: var(--call-green-tint); border-bottom: 1px solid var(--call-green-line); flex: none; }
.join-banner[hidden], .stage [hidden] { display: none !important; }
.join-text { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-size: 14px; color: var(--call-green-ink); font-weight: 600; }
.join-names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.join-timer { font-variant-numeric: tabular-nums; white-space: nowrap; }
.join-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--call-green); flex: none; }
.join-btn { height: 36px; padding: 0 16px; border-radius: var(--radius-md); border: 0; background: var(--call-green); color: #fff; font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; flex: none; }
.join-btn:disabled { opacity: 0.55; cursor: default; }

/* group audio panel (inside the chat, under the header) */
.call-bar.group-panel { flex-direction: column; align-items: stretch; gap: 18px; padding: 20px 22px; background: var(--stage); min-height: 0; }
.gp-head { display: flex; justify-content: space-between; align-items: center; color: #fff; gap: 12px; }
.gp-label { font-size: 13px; font-weight: 600; opacity: 0.85; }
.gp-timer { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gp-count { font-size: 13px; font-weight: 600; text-align: right; }
.gp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gp-tile { background: #262626; border-radius: 14px; padding: 18px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 150px; box-sizing: border-box; min-width: 0; }
.gp-tile.speaking .avatar { box-shadow: 0 0 0 3px #262626, 0 0 0 6px var(--speaking); }
.gp-name { color: #fff; font-size: 14px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-muted { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: #ffb4b4; }
.gp-state { font-size: 12px; color: #9aa1ab; }
.gp-spk { font-size: 12px; font-weight: 600; color: var(--speaking); }
.gp-actions { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.gp-btn { height: 48px; padding: 0 20px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, 0.18); color: #fff; font-family: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.gp-btn[aria-pressed='true'] { background: #fff; color: var(--ink); }
.gp-btn.leave { background: var(--danger); font-weight: 700; }
.gp-btn:disabled { opacity: 0.6; cursor: default; }
.gp-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent); }
.bar-btn.off { background: #fff; color: var(--ink); }
.bar-btn:disabled { opacity: 0.6; cursor: default; }

/* video screen: fixed over the whole app */
.stage { position: fixed; inset: 0; z-index: 35; background: var(--stage); color: #fff; overflow: hidden; display: flex; }
.stage-tiles { position: absolute; inset: 60px 16px 88px; display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: minmax(0, 1fr); gap: 12px; transition: right 0.15s; }
.stage[data-count='1'] .stage-tiles { grid-template-columns: 1fr; }
.stage[data-count='3'] .tile:last-child { grid-column: span 2; }
.stage:has(.stage-panel:not([hidden])) .stage-tiles { right: 276px; }
.tile { position: relative; overflow: hidden; box-sizing: border-box; background: var(--stage-tile); border-radius: 14px; border: 3px solid transparent; min-height: 0; min-width: 0; }
.tile.speaking { border-color: var(--speaking); }
.tile-video { position: absolute; inset: 0; background: #1b1e22; }
.tile-video video { width: 100%; height: 100%; object-fit: cover; display: block; background: #1b1e22; }
.tile.mirror .tile-video video { transform: scaleX(-1); }
.tile-av { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: var(--stage-tile); }
.tile.novideo .tile-av { display: flex; }
.tile-av .avatar { --size: 88px !important; }
.tile-name { position: absolute; left: 10px; bottom: 10px; background: rgba(22, 22, 22, 0.78); color: #fff; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; max-width: calc(100% - 60px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.local .tile-name { display: none; }
.tile-mute { position: absolute; right: 10px; bottom: 10px; width: 28px; height: 28px; border-radius: 50%; background: var(--danger); color: #fff; display: none; align-items: center; justify-content: center; }
.tile.muted .tile-mute { display: flex; }

/* 1:1: remote fills the screen, local is a small preview you can drag */
.stage[data-mode='one'] .stage-tiles { inset: 0; display: block; }
.stage[data-mode='one'] .tile { position: absolute; inset: 0; border-radius: 0; border-width: 0; }
.stage[data-mode='one'] .tile.local { inset: auto; width: 200px; height: 132px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.85); z-index: 2; cursor: grab; touch-action: none; transition: left 0.15s, top 0.15s, right 0.15s, bottom 0.15s; }
.stage[data-mode='one'] .tile.local.dragging { transition: none; cursor: grabbing; }
.stage[data-mode='one'] .tile.local .tile-av .avatar { --size: 48px !important; }
.stage[data-mode='one'] .tile.local .tile-mute { width: 24px; height: 24px; bottom: 6px; right: 6px; }
.stage[data-mode='one'][data-pip='br'] .tile.local:not(.dragging) { right: 16px; bottom: 96px; }
.stage[data-mode='one'][data-pip='bl'] .tile.local:not(.dragging) { left: 16px; bottom: 96px; }
.stage[data-mode='one'][data-pip='tr'] .tile.local:not(.dragging) { right: 14px; top: 64px; }
.stage[data-mode='one'][data-pip='tl'] .tile.local:not(.dragging) { left: 14px; top: 64px; }

.stage-chip { position: absolute; top: 16px; left: 16px; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(22, 22, 22, 0.78); font-size: 13.5px; box-sizing: border-box; max-width: calc(100% - 32px); z-index: 3; }
.chip-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-timer { font-variant-numeric: tabular-nums; opacity: 0.9; white-space: nowrap; }
.stage-bar { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 12px; padding: 10px; border-radius: 999px; background: rgba(22, 22, 22, 0.82); z-index: 3; }
.stg-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0; display: flex; align-items: center; justify-content: center; flex: none; background: rgba(255, 255, 255, 0.18); color: #fff; cursor: pointer; }
.stg-btn.off { background: #fff; color: var(--ink); }
.stg-btn.on { background: var(--accent); color: #fff; }
.stg-btn.hang { background: var(--danger); }
.stg-btn:disabled { opacity: 0.6; cursor: default; }
.stg-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent); }
.stage-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 260px; background: var(--sidebar); color: var(--ink); border-left: 1px solid var(--hairline); display: flex; flex-direction: column; z-index: 4; }
.panel-head { display: flex; justify-content: space-between; align-items: center; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--hairline); font-size: 15px; }
.panel-x { border: 0; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer; width: 36px; height: 36px; }
.panel-list { padding: 8px 12px; display: flex; flex-direction: column; overflow-y: auto; }
.panel-row { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.panel-who { flex: 1; min-width: 0; }
.panel-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-st { font-size: 12.5px; color: var(--muted); }
.panel-st.spk { color: var(--online-text); font-weight: 600; }
.stage-toast { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: min(92vw, 460px); background: rgba(255, 255, 255, 0.96); color: var(--ink); font-size: 14px; padding: 10px 12px 10px 16px; border-radius: 12px; z-index: 5; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3); }
.stage-toast button { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 28px; height: 28px; font-size: 14px; }
body.in-stage { overflow: hidden; }

@media (max-width: 760px) {
  .join-banner { padding: 8px var(--space-4); }
  .join-btn { min-height: 44px; }
  .call-bar.group-panel { padding: 16px var(--space-4); }
  .gp-grid { grid-template-columns: repeat(2, 1fr); }
  .gp-btn { height: 52px; }
  .stage-tiles { inset: 64px 10px 108px; gap: 8px; }
  .stage:has(.stage-panel:not([hidden])) .stage-tiles { right: 10px; }
  .stage-panel { left: 0; width: auto; top: 64px; }
  .tile-av .avatar { --size: 64px !important; }
  .stage[data-mode='one'] .stage-tiles { inset: 0; }
  .stage[data-mode='one'] .tile.local { width: 92px; height: 128px; }
  .stage[data-mode='one'] .tile.local .tile-av .avatar { --size: 44px !important; }
  .stage[data-mode='one'][data-pip='br'] .tile.local:not(.dragging), .stage[data-mode='one'][data-pip='bl'] .tile.local:not(.dragging) { bottom: 112px; }
  .stage-bar { left: 0; right: 0; bottom: 0; transform: none; border-radius: 0; justify-content: center; gap: 14px; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); background: rgba(22, 22, 22, 0.72); }
  .stg-btn { width: 56px; height: 56px; }
  .stage-chip { top: 16px; left: 14px; }
}
/* phones turned sideways: very little height, so the controls and the preview shrink */
@media (max-height: 500px) and (orientation: landscape) {
  .stage-tiles { inset: 52px 10px 68px; }
  .stage[data-mode='one'] .stage-tiles { inset: 0; }
  .stage-bar { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .stg-btn { width: 44px; height: 44px; }
  .stage-chip { top: 10px; height: 30px; }
  .stage[data-mode='one'] .tile.local { width: 112px; height: 80px; }
  .stage[data-mode='one'][data-pip='tr'] .tile.local:not(.dragging), .stage[data-mode='one'][data-pip='tl'] .tile.local:not(.dragging) { top: 52px; }
  .stage[data-mode='one'][data-pip='br'] .tile.local:not(.dragging), .stage[data-mode='one'][data-pip='bl'] .tile.local:not(.dragging) { bottom: 68px; }
  .tile-av .avatar { --size: 48px !important; }
}
@media (prefers-reduced-motion: reduce) { .stage-tiles, .tile.local { transition: none !important; } }
.stage[data-mode='one'] .tile:not(.local) .tile-name { bottom: 92px; }
@media (max-width: 760px) { .stage[data-mode='one'] .tile:not(.local) .tile-name { bottom: 100px; left: 14px; } }

/* Phase 13: shared-session notice */
.session-notice { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.session-notice[hidden] { display: none; }
.session-card { width: 100%; max-width: 360px; background: var(--bg); border-radius: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.14); padding: 28px 24px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; border: 1px solid var(--hairline); }

/* ---------- Phase 14: display names and the Settings dialog (design/Chat Settings.dc.html, 7a/7b) ---------- */
.row-handle { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top .row-name { flex: 0 1 auto; }
.contact-status .handle { color: var(--muted); font-weight: 400; }
.sender-wrap { display: flex; align-items: baseline; gap: 6px; margin: 0 0 3px 4px; min-width: 0; }
.sender-wrap .sender { margin: 0; }
button.sender-btn { border: 0; background: transparent; padding: 0; font-family: inherit; cursor: pointer; text-align: left; min-height: 24px; }
button.sender-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sender-handle { font-size: 12px; color: var(--muted); font-weight: 400; }
.sender-handle[hidden] { display: none; }

.dialog.settings { max-width: 520px; }
.settings-body { gap: 0; overflow-y: auto; }
.settings-nav { display: flex; border-bottom: 1px solid var(--hairline); margin-bottom: var(--space-3); }
.settings-tab { flex: 1; min-height: 44px; border: 0; border-bottom: 2px solid transparent; background: transparent; font-family: inherit; font-size: 14.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.settings-tab[aria-selected='true'] { color: var(--accent); border-bottom-color: var(--accent); }
.settings-form { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 2px; }
.settings-who { display: flex; align-items: center; gap: var(--space-3); margin-bottom: 6px; }
.settings-who-text { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.settings-label { font-size: 13px; font-weight: 700; margin-top: 8px; }
.settings-input { height: 44px; box-sizing: border-box; border: 2px solid var(--accent); border-radius: var(--radius-md); padding: 0 14px; font-size: 15px; font-family: inherit; color: var(--ink); outline: 2px solid var(--accent-ring); outline-offset: 2px; background: var(--bg); }
.settings-input.invalid { border-color: var(--danger); outline-color: transparent; }
.settings-msg { min-height: 20px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.settings-msg.error { color: var(--danger-text); font-size: 13px; font-weight: 500; }
.settings-hint { font-size: 12.5px; color: var(--muted); }
.settings-readonly { height: 44px; box-sizing: border-box; border: 1px solid var(--hairline); background: var(--field); border-radius: var(--radius-md); padding: 0 14px; display: flex; align-items: center; justify-content: space-between; font-size: 15px; color: var(--muted); }
.settings-lock { display: inline-flex; }
.settings-actions { margin-top: var(--space-3); }
.settings-actions .btn { height: 44px; padding: 0 18px; border-radius: var(--radius-md); font-size: 14.5px; }
.settings-save:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--muted); }
@media (max-width: 760px) {
  .scrim:has(.dialog.settings) { align-items: flex-end; padding: 0; }
  .dialog.settings { max-width: none; border-radius: 16px 16px 0 0; max-height: 92%; padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .settings-input, .settings-readonly { height: 48px; }
  .settings-actions { flex-direction: column-reverse; }
  .settings-actions .btn { width: 100%; height: 48px; }
  button.sender-btn { min-height: 32px; }
}

/* ---------- Phase 15: Audio & Video settings and the in-call devices popover (design/Chat Settings.dc.html, 7a/7f) ---------- */
.dialog.settings { max-height: min(720px, 100%); }
@media (min-width: 761px) {
  .dialog.settings-wide { max-width: 736px; }
  .settings-wide .settings-body { flex-direction: row; gap: 24px; min-height: 360px; }
  .settings-wide .settings-nav { flex-direction: column; width: 160px; flex: none; border: 0; margin: 0; gap: 4px; }
  .settings-wide .settings-tab { flex: none; height: 44px; text-align: left; padding: 0 12px; border: 0; border-radius: 8px; }
  .settings-wide .settings-tab[aria-selected='true'] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px #e2e2e2; }
  .settings-wide .settings-pane { flex: 1; min-width: 0; }
}
.av { display: flex; flex-direction: column; gap: 16px; }
.av-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.av-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.av-field { display: flex; flex-direction: column; gap: 6px; }
.av-field .settings-label { margin-top: 0; }
.settings-select { height: 44px; width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0 12px; font-size: 14.5px; font-family: inherit; color: var(--ink); background: var(--bg); }
.settings-select:disabled { background: var(--field); color: var(--muted); }
.meter { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-top: 2px; }
.meter-bars { display: flex; gap: 3px; flex: 1; min-width: 0; }
.meter-bar { width: 6px; height: 14px; border-radius: 2px; background: #e2e2e2; flex: none; }
.meter-bar.on { background: var(--call-green); }
.meter-word { font-size: 12px; margin-left: auto; white-space: nowrap; }
.av-test { align-self: flex-start; height: 40px; gap: 8px; }
.av-preview { position: relative; height: 150px; border-radius: var(--radius-md); border: 1px solid var(--hairline); background: #23262b; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.av-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.av-video:not([src]):not(:has(*)) { background: transparent; }
.av-preview-label { position: absolute; font-family: ui-monospace, monospace; font-size: 12px; color: #9aa1ab; pointer-events: none; }
.av-preview-label:empty { display: none; }
.av-toggles { border: 1px solid var(--hairline); border-radius: var(--radius-md); }
.av-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--hairline); cursor: pointer; min-height: 52px; }
.av-toggle:last-child { border-bottom: 0; }
.av-toggle-title { font-size: 14px; font-weight: 600; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: #c9c9c9; position: relative; flex: none; cursor: pointer; margin: 0; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.av-perm { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; background: var(--warning-bg); border: 1px solid var(--warning-line); border-radius: var(--radius-md); color: #5c4300; font-size: 14px; line-height: 1.45; }
.av-perm-title { font-weight: 700; }
.av-note:empty { display: none; }

.device-popover { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); width: 340px; max-width: calc(100vw - 24px); max-height: calc(100vh - 120px); overflow-y: auto; background: var(--bg); color: var(--ink); border: 1px solid var(--hairline); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); padding: 14px 16px 16px; z-index: 48; }
.pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 15px; }
.pop-body { display: flex; flex-direction: column; gap: 12px; }
.pop-field { display: flex; flex-direction: column; gap: 6px; }
.pop-field .settings-label { margin-top: 0; }
.pop-more { align-self: flex-start; font-size: 14px; }
@media (max-width: 760px) {
  .av-cols { grid-template-columns: 1fr; gap: 16px; }
  .settings-select { height: 48px; }
  .av-preview { height: 190px; }
  .av-toggle { min-height: 56px; }
  .device-popover { left: 0; right: 0; bottom: 0; transform: none; width: auto; max-width: none; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); max-height: 80vh; }
}

/* ---------- Phase 16: minimised call (design/Chat Settings.dc.html, 7c) ---------- */
.call-btn.is-disabled, .join-btn.is-disabled { background: var(--bg); color: #c4c4c4; cursor: default; }
.join-btn.is-disabled { background: #cfd8d2; color: #fff; }
.stage-min, .stage-expand { position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; background: rgba(22, 22, 22, 0.78); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 5; }
.stage:has(.stage-panel:not([hidden])) .stage-min { right: 276px; }
.stage-expand { display: none; width: 36px; height: 36px; top: 8px; right: 8px; border-radius: 8px; background: rgba(22, 22, 22, 0.78); }
.stage-min:focus-visible, .stage-expand:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent); }
.chip-return { display: none; }

/* the same screen, shrunk: the video elements are not moved, so nothing is interrupted */
.stage.mini { inset: auto; width: 300px; height: auto; flex-direction: column; border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); cursor: grab; touch-action: none; transition: none; }
.stage.mini[data-mini-pos='br'] { right: 20px; bottom: 92px; }
.stage.mini[data-mini-pos='bl'] { left: 20px; bottom: 92px; }
.stage.mini[data-mini-pos='tr'] { right: 20px; top: 76px; }
.stage.mini[data-mini-pos='tl'] { left: 20px; top: 76px; }
.stage.mini.dragging { right: auto; bottom: auto; cursor: grabbing; }
.stage.mini .stage-tiles { position: relative; inset: auto; right: auto !important; height: 169px; width: 100%; display: block; }
.stage.mini .tile { display: none; border-radius: 0; border-width: 0; }
.stage.mini .tile[data-mini] { display: block; position: absolute; inset: 0; width: auto; height: auto; }
.stage.mini .tile[data-mini].local .tile-name { display: block; }
.stage.mini .tile-av .avatar { --size: 56px !important; }
.stage.mini .stage-chip { top: 8px; left: 8px; height: 26px; padding: 0 10px; font-size: 12px; gap: 8px; max-width: calc(100% - 60px); }
.stage.mini .stage-min, .stage.mini .stage-panel, .stage.mini .stage-toast, .stage.mini .stg-full-only { display: none !important; }
.stage.mini .stage-expand { display: flex; }
.stage.mini .stage-bar { position: static; transform: none; width: 100%; border-radius: 0; justify-content: center; gap: 12px; padding: 10px; background: var(--stage); }
.stage.mini .stg-btn { width: 44px; height: 44px; }
@media (max-width: 760px) {
  .stage.mini, .stage.mini[data-mini-pos] { inset: 0 0 auto 0; width: auto; height: 56px; flex-direction: row; align-items: center; border-radius: 0; background: var(--call-green); box-shadow: none; cursor: pointer; padding: 0 12px; gap: 8px; z-index: 36; }
  .stage.mini .stage-tiles, .stage.mini .stage-expand { display: none; }
  .stage.mini .stage-chip { position: static; flex: 1; background: transparent; height: auto; padding: 0; font-size: 15px; max-width: none; }
  .stage.mini .chip-return { display: inline; font-weight: 700; }
  .stage.mini .chip-return::after { content: ' \00b7'; }
  .stage.mini .chip-name { display: none; }
  .stage.mini .chip-timer { opacity: 1; font-weight: 700; }
  .stage.mini .stage-bar { position: static; width: auto; background: transparent; padding: 0; gap: 8px; }
  .stage.mini .stg-btn { width: 44px; height: 44px; background: rgba(255, 255, 255, 0.2); }
  .stage.mini .stg-btn.off { background: #fff; color: var(--call-green-ink); }
  .stage.mini .stg-btn.hang { background: var(--danger); }
  .stage.mini .stg-cam, .stage.mini #call-pip { display: none; }
  .app.with-mini-bar { padding-top: 56px; }
  .stage-min { top: 16px; right: 14px; }
}
.stage.mini[data-group='0'] .tile-name { display: none; } /* in a 1:1 the chip already names them */

/* ---------- Phase 18: in-app toasts (basic) ---------- */
.toasts { position: fixed; top: 64px; right: 16px; width: 320px; max-width: calc(100vw - 24px); display: flex; flex-direction: column; gap: 8px; z-index: 44; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: stretch; background: var(--bg); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18); overflow: hidden; }
.toast-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: transparent; text-align: left; font-family: inherit; color: var(--ink); cursor: pointer; }
.toast-text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.toast-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-sub { font-weight: 400; font-size: 12px; color: var(--muted); }
.toast-body { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-count { font-size: 12px; font-weight: 600; color: var(--accent); }
.toast-x { border: 0; background: transparent; color: var(--muted); width: 36px; cursor: pointer; font-size: 14px; }
@media (max-width: 760px) { .toasts { top: 8px; left: 12px; right: 12px; width: auto; } }
