/* Sanctuary design system tokens, shared with Melo, MochiStream and Sanctuary SSO (sanctuary-frontend theme/Color.kt + theme/Theme.kt) */
:root {
  color-scheme: dark;
  /* Surfaces */
  --eclipse: #0b0a10;
  --midnight: #15131c;
  --onyx: #1b1924;
  --slate: #221f2c;
  --graphite: #2e2a38;
  --smoke: #3a3645;
  /* Primary */
  --champagne: #d7b673;
  --champagne-soft: #eed9b0;
  --champagne-deep: #463620;
  /* Text */
  --pearl: #ede8f2;
  --mist: #a29daf;
  --whisper: #6e6979;
  /* Accents */
  --lavender: #b8a8c9;
  --jade: #8fb69e;
  --coral: #e89a92;
  --amber: #e0a868;
  --online: #7bc79a;

  /* Material roles */
  --bg: var(--eclipse);
  --surface: var(--midnight);
  --surface-container: var(--onyx);
  --surface-container-high: var(--slate);
  --surface-container-highest: var(--smoke);
  --outline: var(--graphite);
  --outline-variant: var(--slate);
  --text: var(--pearl);
  --muted: var(--mist);
  --subtle: var(--whisper);
  --accent: var(--champagne);
  --on-accent: var(--eclipse);
  --active-tint: color-mix(in srgb, var(--champagne-deep) 35%, transparent);

  /* Dimens */
  --corner-lg: 20px;
  --corner-md: 14px;
  --corner-sm: 8px;
  --card-gradient: linear-gradient(180deg, var(--surface-container), var(--surface));
  --luxe-gradient: linear-gradient(135deg, color-mix(in srgb, var(--champagne-deep) 55%, transparent), color-mix(in srgb, var(--slate) 55%, transparent));

  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --emoji-font: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  --sidebar-w: 288px;
  --members-w: 256px;
  --head-h: 64px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 20px; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .4; }
input, textarea { color: var(--text); }
::selection { background: color-mix(in srgb, var(--champagne) 40%, transparent); color: var(--pearl); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--graphite) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--graphite); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Logo: Mochi's champagne tile, with a speech bubble in place of the letter */
.logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; min-width: 0; }
.logo-mark { width: 40px; height: 40px; display: inline-grid; place-items: center; background: var(--champagne); color: var(--eclipse); border-radius: 12px; flex-shrink: 0; }
.logo-mark svg { width: 26px; height: 26px; }
.logo-mark.large { width: 56px; height: 56px; border-radius: 16px; }
.logo-mark.large svg { width: 36px; height: 36px; }
.logo-word { font-size: 17px; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; color: var(--pearl); }
.logo-word span { font-weight: 300; color: var(--mist); }

/* Buttons, shared with Melo and Sanctuary SSO */
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; flex-shrink: 0; border: 0; border-radius: 12px; background: transparent; color: var(--pearl); transition: background .18s, color .18s; }
.icon-button:hover { background: var(--surface-container); color: var(--champagne); }
.icon-button.active { color: var(--champagne); }
.icon-button.tiny { width: 26px; height: 26px; border-radius: 8px; color: var(--mist); }
.icon-button.small { width: 30px; height: 30px; border-radius: 9px; }
.icon-button [data-icon] { display: grid; place-items: center; }
.btn { border: 1px solid transparent; border-radius: 999px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 12px 22px; font-size: 14px; font-weight: 600; letter-spacing: .4px; transition: background .18s, border-color .18s, color .18s; white-space: nowrap; }
.btn-primary { color: var(--on-accent); background: var(--champagne); }
.btn-primary:hover { background: var(--champagne-soft); }
.btn-secondary { color: var(--pearl); background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); backdrop-filter: blur(12px); }
.btn-secondary:hover { background: rgba(255,255,255,.18); }
.btn-outline { border-color: var(--outline); background: transparent; color: var(--mist); font-weight: 500; padding: 10px 18px; }
.btn-outline:hover { color: var(--pearl); border-color: var(--smoke); }
.btn-compact { padding: 7px 14px; font-size: 13px; gap: 6px; }
.btn-danger { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 40%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--coral) 12%, transparent); }
.btn-danger-solid { color: var(--eclipse); background: var(--coral); }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--coral) 80%, white); }
.btn-block { width: 100%; padding: 14px 22px; }
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::after { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.link-button { border: 0; background: none; padding: 0; color: var(--champagne); font-weight: 500; }
.link-button:hover { color: var(--champagne-soft); text-decoration: underline; }

.eyebrow { color: var(--champagne); font-size: 12px; letter-spacing: 2px; font-weight: 500; line-height: 1.5; text-transform: uppercase; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--graphite); border-top-color: var(--champagne); animation: spin .85s linear infinite; }
.spinner.small { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.initial-loading, .page-loading { flex: 1; display: grid; place-items: center; min-height: 200px; }

/* Avatars: the profile picture, or initials on champagne, as on auth.sk96.uk */
.avatar { --size: 36px; position: relative; width: var(--size); height: var(--size); flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 50%; background: var(--champagne-deep); color: var(--champagne-soft); font-weight: 600; font-size: calc(var(--size) * .38); letter-spacing: .5px; user-select: none; line-height: 1; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.presence { position: absolute; right: -2px; bottom: -2px; width: calc(var(--size) * .3); height: calc(var(--size) * .3); min-width: 10px; min-height: 10px; border-radius: 50%; border: 3px solid var(--surface); background: var(--whisper); box-sizing: content-box; }
.presence.online { background: var(--online); }
.presence.idle { background: var(--amber); }
.presence.offline { background: var(--smoke); }

/* ---- Layout ------------------------------------------------------------------------------------------ */
.app-shell { height: 100dvh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto; isolation: isolate; }
.main { position: relative; min-width: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--bg); overflow: hidden; }
/* A soft champagne glow behind the page, like the hero wash in Melo and Mochi */
.main::before { content: ''; position: absolute; inset: -30vh -10vw auto; height: 60vh; z-index: 0; pointer-events: none; background: radial-gradient(55% 55% at 50% 0%, color-mix(in srgb, var(--champagne-deep) 30%, transparent), transparent 70%); }
.main > * { position: relative; z-index: 1; }
body.signed-out .sidebar, body.signed-out .members { display: none; }
body.signed-out .app-shell { grid-template-columns: 1fr; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; min-height: 0; height: 100dvh; background: var(--surface); border-right: 1px solid var(--outline-variant); padding-top: env(safe-area-inset-top); }
.sidebar-head { height: 72px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 20px; }
.sidebar-head .logo { margin-right: auto; }
.sidebar-close { display: none; }
.sidebar-tabs { margin: 0 14px 10px; }
.section-tabs { display: flex; gap: 2px; padding: 4px; flex-shrink: 0; background: var(--surface-container); border: 1px solid var(--outline-variant); border-radius: 12px; }
.section-tab { position: relative; flex: 1; height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; border: 0; background: transparent; border-radius: 9px; color: var(--mist); font-size: 14px; font-weight: 500; letter-spacing: .4px; white-space: nowrap; transition: background .18s, color .18s; }
.section-tab:hover { color: var(--pearl); }
.section-tab.active { color: var(--champagne); background: var(--active-tint); }
.tab-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--coral); color: var(--eclipse); font-size: 11px; font-weight: 700; font-style: normal; display: inline-grid; place-items: center; line-height: 1; }
.tab-badge.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; background: var(--pearl); }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 16px; }
.sidebar-empty { padding: 24px 14px; color: var(--whisper); text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }

.category { margin-top: 14px; }
.category.loose { margin-top: 0; }
.category-head { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 2px; margin-bottom: 4px; border-radius: 8px; }
.category-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; padding: 6px 4px; border: 0; background: none; color: var(--mist); font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; text-align: left; }
.category-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-toggle svg { transition: transform .18s; flex-shrink: 0; }
.category-toggle:hover { color: var(--pearl); }
.category.collapsed .category-toggle svg { transform: rotate(-90deg); }
.category.collapsed .hidden-in-collapsed { display: none; }
.channel-row { position: relative; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 8px 0 12px; margin: 1px 0; border-radius: 10px; color: var(--whisper); font-size: 14.5px; font-weight: 500; letter-spacing: .2px; transition: background .15s, color .15s; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.channel-row svg { flex-shrink: 0; color: var(--whisper); }
.channel-row:hover { background: var(--surface-container); color: var(--mist); }
.channel-row.unread { color: var(--pearl); font-weight: 600; }
.channel-row.unread::before { content: ''; position: absolute; left: -10px; top: 50%; width: 4px; height: 8px; margin-top: -4px; border-radius: 0 4px 4px 0; background: var(--pearl); }
.channel-row.active { background: var(--active-tint); color: var(--champagne); }
.channel-row.active svg { color: var(--champagne); }
.channel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-action { display: none; width: 26px; height: 26px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--mist); }
.row-action:hover { color: var(--champagne); background: var(--surface-container-high); }
.channel-row:hover .row-action, .channel-row.active .row-action { display: grid; }
.count-badge { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--coral); color: var(--eclipse); font-size: 11px; font-weight: 700; font-style: normal; display: inline-grid; place-items: center; line-height: 1; flex-shrink: 0; }
.voice-users { display: flex; flex-direction: column; padding: 0 0 4px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--mist); font-size: 13.5px; text-align: left; min-width: 0; }
.voice-user:hover { background: var(--surface-container); color: var(--pearl); }
.voice-user > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-user .avatar { transition: box-shadow .35s ease; }
.voice-user.speaking .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--online); transition-duration: .15s; }
.voice-flags { display: inline-flex; gap: 4px; color: var(--whisper); align-items: center; }
.voice-flags .live { padding: 1px 5px; border-radius: 4px; background: var(--coral); color: var(--eclipse); font-size: 9px; letter-spacing: .5px; }
.drag-ghost { position: fixed; top: 0; left: 0; z-index: 100; pointer-events: none; opacity: .9; background: var(--slate); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.drag-source { opacity: .35; }
.drop-marker { height: 2px; margin: 0 6px; border-radius: 2px; background: var(--champagne); box-shadow: 0 0 8px var(--champagne); }

.dm-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 8px 8px; color: var(--mist); font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.dm-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 7px 10px; margin: 1px 0; border-radius: 12px; color: var(--mist); transition: background .15s, color .15s; }
.dm-row:hover { background: var(--surface-container); color: var(--pearl); }
.dm-row.active { background: var(--active-tint); color: var(--champagne); }
.dm-row.unread .dm-name { color: var(--pearl); font-weight: 600; }
.dm-row .presence { border-color: var(--surface); }
.dm-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dm-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-text small { color: var(--whisper); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; }
.group-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-container-high); color: var(--lavender); flex-shrink: 0; }

/* Voice connection panel and your own strip, at the foot of the sidebar */
.voice-panel { flex-shrink: 0; margin: 0 10px 8px; padding: 10px; border-radius: 16px; background: var(--card-gradient); border: 1px solid var(--outline-variant); animation: pop .2s ease-out; }
.voice-status { display: flex; align-items: center; gap: 10px; }
.voice-signal { color: var(--online); display: grid; }
.voice-status.connecting .voice-signal, .voice-status.reconnecting .voice-signal, .voice-status.poor .voice-signal { color: var(--amber); }
.voice-where { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.voice-where strong { color: var(--online); font-size: 13px; font-weight: 600; }
.voice-status.connecting strong, .voice-status.reconnecting strong, .voice-status.poor strong { color: var(--amber); }
.voice-where small { color: var(--mist); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-where:hover small { color: var(--pearl); text-decoration: underline; }
.icon-button.hangup { color: var(--coral); width: 36px; height: 36px; }
.icon-button.hangup:hover { background: color-mix(in srgb, var(--coral) 14%, transparent); color: var(--coral); }
.voice-buttons { display: flex; gap: 6px; margin-top: 8px; }
.voice-button { flex: 1; height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--outline); border-radius: 10px; background: transparent; color: var(--mist); font-size: 12.5px; font-weight: 500; }
.voice-button:hover { color: var(--pearl); background: var(--surface-container-high); }
.voice-button.on { color: var(--champagne); border-color: color-mix(in srgb, var(--champagne) 45%, transparent); background: var(--active-tint); }
.user-strip { flex-shrink: 0; display: flex; align-items: center; gap: 2px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--eclipse); border-top: 1px solid var(--outline-variant); }
.me-button { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.me-button:hover { background: var(--surface-container); }
.me-button .presence { border-color: var(--eclipse); }
.me-text { min-width: 0; display: flex; flex-direction: column; }
.me-text strong { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--whisper); font-size: 12px; }
.strip-button { width: 34px; height: 34px; color: var(--mist); }
.strip-button.off { color: var(--coral); }

/* Channel header */
.channel-head { height: var(--head-h); flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--outline-variant); background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(14px); padding-top: env(safe-area-inset-top); height: calc(var(--head-h) + env(safe-area-inset-top)); }
.menu-button { display: none; margin-left: -8px; }
.head-icon { color: var(--whisper); display: grid; flex-shrink: 0; }
.head-name { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .1px; }
.head-name[data-user] { cursor: pointer; }
.head-topic { min-width: 0; flex: 1; padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--outline); color: var(--mist); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.head-actions .icon-button { color: var(--mist); }
.head-actions .icon-button.active, .head-actions .icon-button:hover { color: var(--champagne); }
.head-search { height: 34px; width: 190px; display: flex; align-items: center; gap: 8px; margin-left: 8px; padding: 0 10px; border: 1px solid var(--outline-variant); border-radius: 10px; background: var(--surface-container); color: var(--whisper); font-size: 13px; transition: border-color .18s, width .2s; }
.head-search:hover { border-color: var(--outline); color: var(--mist); }
.head-search span { flex: 1; text-align: left; }
kbd { font: 600 11px var(--font); color: var(--whisper); padding: 2px 6px; border: 1px solid var(--outline); border-radius: 6px; white-space: nowrap; }

.channel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-wrap { flex: 1; min-height: 0; display: flex; }
.main-empty { flex: 1; display: flex; flex-direction: column; padding: 12px; }
.main-empty .menu-button { align-self: flex-start; }
.empty-state { margin: auto; max-width: 420px; padding: 32px; display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--champagne); }
.empty-state h2 { color: var(--pearl); font-size: 22px; font-weight: 300; margin: 14px 0 6px; letter-spacing: -.3px; }
.empty-state p { color: var(--mist); margin: 0 0 18px; }

/* ---- Messages ------------------------------------------------------------------------------------------ */
.chat-pane { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; outline: none; }
.messages-inner { display: flex; flex-direction: column; justify-content: flex-end; min-height: 100%; padding: 16px 0 8px; }
.messages-loading, .messages-error { margin: auto; padding: 24px; color: var(--mist); display: flex; gap: 12px; align-items: center; }
.history-start { padding: 24px 24px 18px; margin-bottom: 8px; }
.history-start .history-icon { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-container-high); color: var(--champagne); }
.history-start h2 { font-size: 28px; font-weight: 300; letter-spacing: -.4px; margin: 14px 0 6px; }
.history-start p { margin: 0; color: var(--mist); max-width: 640px; }
.history-start p strong { color: var(--pearl); }
.day-divider, .unread-divider { display: flex; align-items: center; gap: 10px; margin: 18px 20px 6px; color: var(--whisper); font-size: 12px; font-weight: 600; letter-spacing: .4px; }
.day-divider::before, .day-divider::after, .unread-divider::before, .unread-divider::after { content: ''; flex: 1; height: 1px; background: var(--outline-variant); }
.unread-divider { color: var(--coral); }
.unread-divider::before { background: color-mix(in srgb, var(--coral) 60%, transparent); }
.unread-divider::after { display: none; }
.unread-divider span { padding: 1px 8px; border-radius: 6px; background: var(--coral); color: var(--eclipse); font-size: 10px; letter-spacing: .8px; text-transform: uppercase; }

.msg { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); padding: 2px 48px 2px 0; margin-top: 14px; transition: background .12s; }
.msg.grouped { margin-top: 0; }
.msg:hover, .msg.editing, .msg:focus-within { background: color-mix(in srgb, var(--onyx) 70%, transparent); }
.msg.mentioned { background: color-mix(in srgb, var(--champagne-deep) 28%, transparent); box-shadow: inset 3px 0 0 var(--champagne); }
.msg.mentioned:hover { background: color-mix(in srgb, var(--champagne-deep) 38%, transparent); }
.msg.pending { opacity: .55; }
.msg.failed .msg-text { color: var(--coral); }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 30% { background: color-mix(in srgb, var(--champagne) 22%, transparent); } }
.msg-gutter { display: flex; justify-content: center; padding-top: 2px; }
.msg-avatar { border: 0; padding: 0; background: none; border-radius: 50%; height: 40px; }
.msg-avatar:active { transform: translateY(1px); }
.hover-time { visibility: hidden; color: var(--whisper); font-size: 11px; line-height: 22px; }
.msg:hover .hover-time { visibility: visible; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-author { border: 0; padding: 0; background: none; color: var(--pearl); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.msg-author:hover { text-decoration: underline; }
.msg-head time { color: var(--whisper); font-size: 12px; white-space: nowrap; }
.pin-flag { color: var(--champagne); display: inline-grid; }
.msg-text { color: color-mix(in srgb, var(--pearl) 92%, transparent); font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; word-break: break-word; }
.msg-text .edited { margin-left: 4px; color: var(--whisper); font-size: 11px; }
.msg-text a.link { color: var(--champagne); }
.msg-text a.link:hover { text-decoration: underline; }
.msg-text strong { font-weight: 700; color: var(--pearl); }
.msg-text blockquote { margin: 4px 0; padding: 0 0 0 12px; border-left: 4px solid var(--smoke); color: var(--mist); }
.msg-text ul { margin: 4px 0; padding-left: 22px; }
.msg-text .md-heading { margin: 8px 0 4px; line-height: 1.25; color: var(--pearl); }
.msg-text h3.md-heading { font-size: 22px; } .msg-text h4.md-heading { font-size: 18px; } .msg-text h5.md-heading { font-size: 16px; }
.inline-code { font: 13px/1.4 var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--surface-container-high); color: var(--champagne-soft); }
.code-block { margin: 6px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--outline-variant); font: 13px/1.5 var(--mono); white-space: pre-wrap; overflow-x: auto; max-width: 100%; color: var(--pearl); }
.spoiler { background: var(--smoke); color: transparent; border-radius: 4px; cursor: pointer; transition: color .2s, background .2s; }
.spoiler * { visibility: hidden; }
.spoiler.revealed { background: var(--surface-container-high); color: inherit; cursor: auto; }
.spoiler.revealed * { visibility: visible; }
.mention { padding: 0 3px; border-radius: 4px; background: color-mix(in srgb, var(--champagne) 18%, transparent); color: var(--champagne-soft); font-weight: 500; cursor: pointer; }
.mention:hover { background: color-mix(in srgb, var(--champagne) 30%, transparent); }
.mention.me, .mention.everyone { background: color-mix(in srgb, var(--champagne) 30%, transparent); }
.emoji { font-family: var(--emoji-font); font-size: 1.25em; line-height: 1; vertical-align: -0.1em; }
img.emoji.custom { width: 1.4em; height: 1.4em; object-fit: contain; vertical-align: -0.35em; }
.jumbo .emoji { font-size: 44px; line-height: 52px; }
.jumbo img.emoji.custom { width: 48px; height: 48px; vertical-align: middle; }
.msg-reply { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; margin: 0 0 4px 36px; padding: 0 0 0 26px; border: 0; background: none; color: var(--mist); font-size: 13px; text-align: left; position: relative; min-width: 0; max-width: calc(100% - 36px); }
.msg-reply::before { content: ''; position: absolute; left: 0; top: 50%; width: 22px; height: 12px; border: 2px solid var(--smoke); border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.msg-reply strong { color: var(--pearl); font-weight: 600; flex-shrink: 0; }
.msg-reply span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-reply:hover span:last-child { color: var(--pearl); }
.msg-reply.deleted { font-style: italic; color: var(--whisper); }
.msg-actions { position: absolute; top: -18px; right: 16px; z-index: 3; display: none; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: var(--slate); border: 1px solid var(--outline); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-actions button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--mist); font-size: 17px; font-family: var(--emoji-font); }
.msg-actions button:hover { background: var(--surface-container-highest); color: var(--pearl); }
.msg-failed { color: var(--coral); font-size: 13px; }
.msg-failed button { border: 0; background: none; color: var(--champagne); padding: 0; text-decoration: underline; }
.msg.system { display: flex; align-items: center; gap: 12px; padding: 4px 48px 4px 28px; margin-top: 8px; color: var(--mist); font-size: 14px; }
.msg.system strong { color: var(--pearl); font-weight: 600; }
.msg.system time { color: var(--whisper); font-size: 12px; margin-left: 4px; }
.system-icon { width: 24px; display: grid; place-items: center; color: var(--whisper); flex-shrink: 0; }
.msg.call .system-icon { color: var(--jade); }
.msg.call.missed .system-icon { color: var(--coral); }
.msg.call.live .system-icon { color: var(--online); }
.msg.call .btn { margin-left: 8px; }
.msg-editor { margin: 4px 0; }
.msg-editor textarea { width: 100%; resize: none; min-height: 44px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--champagne); background: var(--surface-container); color: var(--pearl); font-size: 15px; line-height: 1.45; outline: none; }
.editor-hint { margin-top: 4px; font-size: 12px; color: var(--whisper); }
.editor-hint button { border: 0; background: none; padding: 0; color: var(--champagne); }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction { height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--outline-variant); background: var(--surface-container); color: var(--mist); font-size: 13px; transition: border-color .15s, background .15s; }
.reaction span { font-family: var(--emoji-font); font-size: 16px; line-height: 1; }
.reaction img { width: 18px; height: 18px; object-fit: contain; }
.reaction b { font-weight: 600; }
.reaction:hover { border-color: var(--smoke); }
.reaction.mine { border-color: color-mix(in srgb, var(--champagne) 60%, transparent); background: var(--active-tint); color: var(--champagne-soft); }
.reaction.add { display: none; color: var(--whisper); }
.msg:hover .reaction.add { display: inline-flex; }

/* Attachments, GIFs, stickers */
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; align-items: flex-start; }
.media-image { display: block; padding: 0; border: 0; background: var(--surface-container); border-radius: 12px; overflow: hidden; max-width: 100%; cursor: zoom-in; }
.media-single .media-image { max-height: 320px; }
.media-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-single .media-image { min-width: 64px; min-height: 64px; }
.media-single .media-image img { object-fit: contain; }
.media-mosaic { display: grid; gap: 4px; width: min(420px, 100%); grid-template-columns: repeat(2, 1fr); border-radius: 12px; overflow: hidden; }
.media-mosaic .media-image { border-radius: 0; aspect-ratio: 1; }
.media-mosaic.count-3 .media-image:first-child { grid-row: span 2; aspect-ratio: auto; }
.media-mosaic.count-5 { grid-template-columns: repeat(3, 1fr); }
.media-video { max-width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
.media-video video { display: block; width: 100%; height: 100%; max-height: 360px; background: #000; }
.media-video:not([style]) { width: 400px; aspect-ratio: 16/9; }
.file-card { display: flex; align-items: center; gap: 12px; width: min(420px, 100%); padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--card-gradient); border: 1px solid var(--outline-variant); color: var(--champagne); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { color: var(--champagne-soft); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { text-decoration: underline; }
.file-meta small { color: var(--whisper); font-size: 12px; }
.file-meta audio { width: 100%; margin-top: 8px; height: 36px; }
.gif-embed { position: relative; margin-top: 6px; max-width: 100%; border-radius: 12px; overflow: hidden; background: var(--surface-container); }
.gif-embed img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gif-embed:not([style]) { width: 300px; aspect-ratio: 4/3; }
.gif-badge { position: absolute; left: 8px; bottom: 8px; padding: 1px 6px; border-radius: 5px; background: rgba(11,10,16,.7); color: var(--pearl); font-size: 10px; font-weight: 700; letter-spacing: .6px; opacity: 0; transition: opacity .2s; }
.gif-embed:hover .gif-badge { opacity: 1; }
.sticker-embed { margin-top: 4px; }
.sticker-embed img { display: block; width: 160px; height: 160px; object-fit: contain; }

/* Voice notes */
.voice-note { display: flex; align-items: center; gap: 10px; width: min(380px, 100%); padding: 8px 12px 8px 8px; border-radius: 999px; background: var(--card-gradient); border: 1px solid var(--outline-variant); }
.voice-play { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--champagne); color: var(--eclipse); }
.voice-play:hover { background: var(--champagne-soft); }
.voice-wave { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.voice-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: var(--smoke); transition: background .1s; }
.voice-wave i.lit { background: var(--champagne); }
.voice-time { color: var(--mist); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 34px; }
.voice-speed { border: 1px solid var(--outline); background: transparent; border-radius: 999px; color: var(--mist); font-size: 11px; font-weight: 600; padding: 2px 7px; }
.voice-speed:hover { color: var(--pearl); }

.jump-present { position: absolute; left: 50%; bottom: calc(var(--composer-h, 84px) + 30px); z-index: 4; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: 999px; background: var(--champagne); color: var(--eclipse); font-size: 13px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: pop .2s ease-out; }
.typing-line { height: 22px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 22px; color: var(--mist); font-size: 12.5px; overflow: hidden; white-space: nowrap; }
.typing-line strong { color: var(--pearl); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--mist); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; } .typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

/* Composer */
.composer { flex-shrink: 0; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 14px 14px 0 0; background: var(--slate); color: var(--mist); font-size: 13px; }
.reply-bar span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar strong { color: var(--pearl); }
.ping-toggle { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--whisper); font-size: 12px; font-weight: 700; }
.ping-toggle.on { color: var(--champagne); }
.upload-tray { display: flex; gap: 10px; padding: 12px; overflow-x: auto; background: var(--surface-container); border: 1px solid var(--outline-variant); border-bottom: 0; border-radius: 14px 14px 0 0; }
.composer.replying .upload-tray { border-radius: 0; }
.upload-item { position: relative; flex-shrink: 0; width: 140px; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--outline-variant); }
.upload-thumb { height: 96px; display: grid; place-items: center; border-radius: 8px; overflow: hidden; background: var(--surface-container-high); color: var(--champagne); }
.upload-thumb img, .upload-thumb video { width: 100%; height: 100%; object-fit: cover; }
.upload-name { display: block; margin-top: 6px; font-size: 12px; color: var(--mist); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { height: 3px; margin-top: 6px; border-radius: 3px; background: var(--graphite); overflow: hidden; }
.upload-progress i { display: block; height: 100%; width: 0; background: var(--champagne); transition: width .2s; }
.upload-item.done .upload-progress i { background: var(--jade); }
.upload-item.error { border-color: color-mix(in srgb, var(--coral) 60%, transparent); }
.upload-item.error .upload-progress i { background: var(--coral); width: 100% !important; }
.upload-remove { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(11,10,16,.75); color: var(--coral); }
.composer-box { display: flex; align-items: flex-end; gap: 2px; min-height: 52px; padding: 6px 8px; border-radius: 16px; background: var(--surface-container); border: 1px solid var(--outline-variant); transition: border-color .18s; }
.composer-box:focus-within { border-color: color-mix(in srgb, var(--champagne) 55%, transparent); }
.composer.replying .composer-box, .upload-tray:not([hidden]) + .composer-box { border-top-left-radius: 0; border-top-right-radius: 0; }
.composer-box textarea { flex: 1; min-width: 0; min-height: 38px; max-height: 40vh; resize: none; border: 0; outline: none; background: transparent; padding: 9px 6px; color: var(--pearl); font-size: 15px; line-height: 20px; }
.composer-box textarea::placeholder { color: var(--whisper); }
.composer-tools { display: flex; align-items: center; gap: 2px; }
.composer-button { width: 38px; height: 38px; display: grid; place-items: center; flex-shrink: 0; border: 0; border-radius: 10px; background: transparent; color: var(--mist); transition: color .15s, background .15s; }
.composer-button:hover { color: var(--champagne); background: var(--surface-container-high); }
.composer-button.attach { width: 34px; height: 34px; margin: 2px 2px 2px 0; border-radius: 50%; background: var(--surface-container-highest); color: var(--pearl); }
.composer-button.send { display: none; background: var(--champagne); color: var(--eclipse); border-radius: 50%; }
.composer-button.send:hover { background: var(--champagne-soft); color: var(--eclipse); }
.composer.has-content .composer-button.send { display: grid; }
.composer.has-content [data-record] { display: none; }
.recorder { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 8px; border-radius: 16px; background: var(--surface-container); border: 1px solid color-mix(in srgb, var(--coral) 50%, transparent); }
.recorder .icon-button { color: var(--coral); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--coral); animation: blink 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--pearl); font-weight: 600; min-width: 40px; }
.rec-wave { flex: 1; height: 30px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.rec-wave i { width: 3px; flex-shrink: 0; border-radius: 2px; background: var(--champagne); }
.recorder .composer-button.send.live { display: grid; }

/* Autocomplete, the expression picker, menus and popovers */
.autocomplete { position: fixed; z-index: 70; max-height: 340px; overflow-y: auto; padding: 6px; border-radius: 16px; background: var(--slate); border: 1px solid var(--outline); box-shadow: 0 20px 60px rgba(0,0,0,.55); animation: pop .12s ease-out; }
.ac-head { padding: 4px 10px 6px; color: var(--whisper); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.ac-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--pearl); text-align: left; }
.ac-item.active, .ac-item:hover { background: var(--surface-container-highest); }
.ac-item small { margin-left: auto; color: var(--whisper); font-size: 12px; }
.ac-icon { width: 24px; display: grid; place-items: center; color: var(--mist); }
.ac-char { width: 24px; text-align: center; font-family: var(--emoji-font); font-size: 20px; }
.ac-emoji { width: 24px; height: 24px; object-fit: contain; }

.picker { position: fixed; z-index: 75; width: min(420px, calc(100vw - 16px)); height: min(460px, calc(100dvh - 16px)); display: flex; flex-direction: column; border-radius: 20px; background: var(--slate); border: 1px solid var(--outline); box-shadow: 0 24px 70px rgba(0,0,0,.6); overflow: hidden; animation: pop .15s ease-out; }
.picker.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; height: min(70dvh, 520px); border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
.picker-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0 10px; }
.picker-tab { height: 34px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--mist); font-weight: 600; font-size: 13.5px; letter-spacing: .3px; }
.picker-tab:hover { color: var(--pearl); }
.picker-tab[aria-selected="true"] { background: var(--active-tint); color: var(--champagne); }
.picker-close { margin-left: auto; width: 34px; height: 34px; color: var(--mist); }
.picker-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.picker-loading { padding: 28px 16px; display: grid; place-items: center; }
.picker-empty { padding: 28px 16px; color: var(--whisper); text-align: center; line-height: 1.5; }
.expression-grid .picker-empty, .media-grid .picker-empty { grid-column: 1 / -1; column-span: all; }
.picker-search { display: flex; align-items: center; gap: 8px; height: 40px; margin: 8px 10px; padding: 0 6px 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--outline-variant); color: var(--whisper); }
.picker-search:focus-within { border-color: var(--champagne); }
.picker-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--pearl); }
.picker-search.wide { margin: 0 0 12px; }
.picker-search.big { height: 50px; font-size: 16px; }
.tone-button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; font-family: var(--emoji-font); font-size: 18px; }
.tone-button:hover { background: var(--surface-container-high); }
.tone-row { display: flex; gap: 4px; justify-content: flex-end; padding: 0 10px 6px; }
.tone-row button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--surface); font-family: var(--emoji-font); font-size: 18px; }
.emoji-layout { flex: 1; min-height: 0; display: flex; }
.emoji-nav { width: 44px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; overflow-y: auto; border-right: 1px solid var(--outline-variant); }
.emoji-nav button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--whisper); }
.emoji-nav button:hover { color: var(--champagne); background: var(--surface-container-high); }
.emoji-scroll { flex: 1; min-width: 0; overflow-y: auto; padding: 0 8px 8px; }
.emoji-scroll h3 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 8px 4px 6px; background: var(--slate); color: var(--mist); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-cell { height: 38px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; font-family: var(--emoji-font); font-size: 24px; line-height: 1; }
.emoji-cell:hover { background: var(--surface-container-highest); }
.emoji-cell img { width: 28px; height: 28px; object-fit: contain; }
.emoji-preview { display: flex; align-items: center; gap: 10px; height: 46px; flex-shrink: 0; padding: 0 14px; background: var(--onyx); color: var(--mist); font-weight: 500; }
.emoji-preview-char { font-family: var(--emoji-font); font-size: 26px; width: 30px; display: grid; place-items: center; }
.emoji-preview-char img { width: 28px; height: 28px; object-fit: contain; }
.media-head { display: flex; flex-direction: column; }
.mini-tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.mini-tabs button { flex: 1; height: 30px; border: 1px solid var(--outline); border-radius: 9px; background: transparent; color: var(--mist); font-size: 12.5px; font-weight: 600; }
.mini-tabs button[aria-selected="true"] { color: var(--champagne); border-color: color-mix(in srgb, var(--champagne) 45%, transparent); background: var(--active-tint); }
.media-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 10px; }
.media-grid { columns: 2; column-gap: 6px; }
.media-grid.sticker { columns: 3; }
.media-tile { display: block; width: 100%; margin: 0 0 6px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--surface); break-inside: avoid; min-height: 60px; }
.media-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-grid.sticker .media-tile { background: transparent; aspect-ratio: 1 !important; }
.media-grid.sticker .media-tile img { object-fit: contain; }
.media-tile:hover { outline: 2px solid var(--champagne); outline-offset: -2px; }
.media-more { display: grid; place-items: center; padding: 8px; }
.media-foot { display: flex; align-items: center; justify-content: flex-end; min-height: 44px; padding: 6px 10px; background: var(--onyx); }
.powered { color: var(--whisper); font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; }

.menu-popover { position: fixed; z-index: 80; min-width: 210px; max-width: min(340px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow-y: auto; padding: 6px; border-radius: 16px; background: var(--slate); border: 1px solid var(--outline); box-shadow: 0 20px 60px rgba(0,0,0,.55); animation: pop .12s ease-out; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--pearl); font-size: 14px; text-align: left; }
.menu-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item svg { color: var(--mist); flex-shrink: 0; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-container-highest); outline: none; }
.menu-item.danger, .menu-item.danger svg { color: var(--coral); }
.menu-item.danger:hover { background: color-mix(in srgb, var(--coral) 14%, transparent); }
.menu-separator { height: 1px; margin: 5px 8px; background: var(--outline); }
.popover { position: fixed; z-index: 78; width: 300px; animation: pop .14s ease-out; }
.profile-card { border-radius: 20px; overflow: hidden; background: var(--surface); border: 1px solid var(--outline); box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.profile-banner { height: 70px; background: var(--luxe-gradient); }
.profile-avatar { margin: -44px 0 0 18px; display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 6px var(--surface); }
.profile-avatar .presence { border-color: var(--surface); border-width: 4px; }
.profile-body { padding: 10px 18px 18px; }
.profile-body h2 { margin: 0; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.profile-body h2 small { color: var(--whisper); font-size: 13px; font-weight: 400; }
.profile-status { margin: 2px 0 14px; color: var(--mist); }
.profile-actions { display: flex; gap: 8px; align-items: center; }

/* Members */
.members { width: var(--members-w); height: 100dvh; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--outline-variant); padding-top: env(safe-area-inset-top); }
.members-head { height: var(--head-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 20px; color: var(--mist); font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; border-bottom: 1px solid var(--outline-variant); }
.members-close { display: none; }
.members-scroll { flex: 1; overflow-y: auto; padding: 8px 10px 20px; }
.members-caption { padding: 14px 8px 6px; color: var(--whisper); font-size: 11.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.member { width: 100%; display: flex; align-items: center; gap: 12px; padding: 6px 8px; border: 0; border-radius: 12px; background: transparent; color: var(--pearl); text-align: left; }
.member:hover { background: var(--surface-container); }
.member.offline { opacity: .45; }
.member.offline:hover { opacity: 1; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.owner { color: var(--amber); display: inline-grid; vertical-align: -1px; }

/* ---- Calls ------------------------------------------------------------------------------------------- */
.channel-body.voice { flex-direction: row; }
.voice-area { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--eclipse); }
.voice-chat { display: none; width: 380px; flex-shrink: 0; border-left: 1px solid var(--outline-variant); background: var(--bg); }
.voice-chat.open { display: flex; }
.call-area { flex-shrink: 0; height: min(52vh, 520px); min-height: 260px; display: flex; flex-direction: column; background: var(--eclipse); border-bottom: 1px solid var(--outline-variant); }
.call-area .call-lobby { padding: 18px; }
.stage-wrap { flex: 1; min-height: 0; min-width: 0; display: flex; padding: 12px 12px 0; }
.call-stage { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stage-grid { --cols: 1; --tile-w: 320px; flex: 1; min-height: 0; min-width: 0; display: grid; gap: 10px; grid-template-columns: repeat(var(--cols), var(--tile-w)); grid-auto-rows: calc(var(--tile-w) * 9 / 16); justify-content: center; align-content: center; }
.stage-grid .tile { width: var(--tile-w); }
.stage-main { flex: 1; min-height: 0; min-width: 0; display: flex; }
.stage-main .tile { flex: 1; }
.stage-strip { height: 120px; flex-shrink: 0; display: flex; gap: 10px; overflow-x: auto; }
.stage-strip .tile { width: 200px; flex-shrink: 0; }
.tile { position: relative; min-height: 0; border-radius: 18px; overflow: hidden; background: var(--card-gradient); border: 1px solid var(--outline-variant); display: flex; box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; transition: box-shadow .35s ease, border-color .35s ease; }
.tile.speaking { border-color: transparent; box-shadow: 0 0 0 2px var(--online), 0 0 22px color-mix(in srgb, var(--online) 35%, transparent); transition-duration: .15s; }
.tile-avatar .avatar { transition: box-shadow .35s ease; }
.tile.speaking .tile-avatar .avatar { box-shadow: 0 0 0 4px color-mix(in srgb, var(--online) 55%, transparent), 0 10px 40px rgba(0,0,0,.4); transition-duration: .15s; }
.tile-media { flex: 1; min-width: 0; display: grid; place-items: center; }
.tile-video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.screen .tile-video { object-fit: contain; }
.tile-video.mirror { transform: scaleX(-1); }
.tile-avatar .avatar { box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.stage-strip .tile-avatar .avatar { --size: 48px !important; }
/* Someone being called: their picture greyed and breathing. Declined or no answer: much dimmer. */
.tile.waiting .tile-avatar .avatar { filter: grayscale(1); }
.tile.waiting.ringing .tile-avatar { animation: calling 1.8s ease-in-out infinite; }
@keyframes calling { 0%, 100% { opacity: .45; transform: scale(.96); } 50% { opacity: .9; transform: scale(1.04); } }
.tile.waiting.ringing .tile-avatar .avatar { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pearl) 25%, transparent); animation: calling-ring 1.8s ease-out infinite; }
@keyframes calling-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pearl) 30%, transparent); } 70%, 100% { box-shadow: 0 0 0 18px transparent; } }
.tile.waiting.declined, .tile.waiting.missed { opacity: .38; transition: opacity .4s ease; }
.tile.waiting.declined:hover, .tile.waiting.missed:hover { opacity: .7; }
.tile.waiting .tile-label svg { color: var(--mist); }
.tile-ring { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--outline); border-radius: 999px; background: rgba(11,10,16,.65); color: var(--pearl); font-size: 12px; font-weight: 600; }
.tile-ring:hover { border-color: var(--champagne); color: var(--champagne); }
.tile-label { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 60px); display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(11,10,16,.65); backdrop-filter: blur(8px); color: var(--pearl); font-size: 12.5px; font-weight: 500; }
.tile-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-label svg { color: var(--coral); flex-shrink: 0; }
.tile.screen .tile-label svg { color: var(--champagne); }
.tile-action { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 10px; background: rgba(11,10,16,.6); color: var(--pearl); opacity: 0; transition: opacity .15s; }
.tile:hover .tile-action, .tile-action:focus-visible { opacity: 1; }
.call-controls { flex-shrink: 0; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.round-button { width: 52px; height: 52px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-container-high); color: var(--pearl); transition: background .15s, color .15s, transform .1s; }
.round-button:hover { background: var(--surface-container-highest); }
.round-button:active { transform: scale(.95); }
.round-button.off { background: color-mix(in srgb, var(--coral) 18%, var(--slate)); color: var(--coral); }
.round-button.on { background: var(--champagne); color: var(--eclipse); }
.round-button.danger { background: var(--coral); color: var(--eclipse); width: 64px; border-radius: 999px; }
.round-button.danger:hover { background: color-mix(in srgb, var(--coral) 85%, white); }
.round-button.accept { background: var(--online); color: var(--eclipse); }
.call-lobby { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; gap: 4px; }
.lobby-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--luxe-gradient); color: var(--champagne); margin-bottom: 10px; }
.call-lobby h2 { margin: 0; font-size: 26px; font-weight: 300; letter-spacing: -.3px; }
.call-lobby p { margin: 6px 0 18px; color: var(--mist); max-width: 420px; }
.lobby-people { display: flex; margin-top: 16px; }
.lobby-person { margin-left: -10px; border-radius: 50%; box-shadow: 0 0 0 3px var(--eclipse); }
.lobby-person:first-child { margin-left: 0; }
.lobby-more { margin-left: 6px; align-self: center; color: var(--mist); font-weight: 600; }
.incoming { position: fixed; z-index: 85; right: 20px; bottom: 20px; width: 320px; padding: 18px; border-radius: 22px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--champagne) 35%, transparent); box-shadow: 0 30px 90px rgba(0,0,0,.6); animation: rise .25s ease-out; }
.incoming-who { display: flex; align-items: center; gap: 14px; }
.incoming-who .avatar { animation: ring 1.6s infinite; }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--online) 50%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
.incoming-who div { display: flex; flex-direction: column; min-width: 0; }
.incoming-who strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.incoming-who span { color: var(--mist); }
.incoming-actions { display: flex; justify-content: space-around; margin-top: 16px; }

/* ---- Dialogs (Mochi's party dialog surface), forms and settings ---------------------------------------------- */
.app-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 28px; border-radius: 22px; background: var(--surface); color: var(--text); border: 1px solid var(--outline-variant); box-shadow: 0 20px 90px rgba(0,0,0,.6); overflow: auto; }
.app-dialog.wide { width: min(760px, calc(100vw - 32px)); }
.app-dialog[open] { animation: rise .25s ease-out; }
.app-dialog::backdrop { background: rgba(11,10,16,.85); backdrop-filter: blur(9px); }
.dialog-close { position: absolute; top: 14px; right: 14px; }
.app-dialog h2 { margin: 6px 0 8px; font-size: 22px; font-weight: 600; line-height: 1.25; padding-right: 32px; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; }
.dialog-sub { margin: 24px 0 10px; font-size: 13px; font-weight: 600; color: var(--mist); letter-spacing: .6px; text-transform: uppercase; }
.dialog-lede { margin: 0 0 20px; color: var(--mist); line-height: 21px; overflow-wrap: anywhere; }
.dialog-actions { margin-top: 10px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dialog-actions.spread { justify-content: space-between; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span:first-child { font-size: 12px; color: var(--mist); letter-spacing: .4px; font-weight: 500; }
.hint { color: var(--whisper); font-size: 12px; font-style: normal; }
.control { width: 100%; height: 46px; background: var(--surface-container); border: 1px solid var(--outline-variant); border-radius: 12px; color: var(--pearl); padding: 0 14px; font-size: 15px; outline: none; transition: border-color .18s, background .18s; }
.control.area { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.control:hover { border-color: var(--outline); }
.control:focus { border-color: var(--champagne); }
.control::placeholder { color: var(--whisper); }
select.control { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mist) 50%), linear-gradient(135deg, var(--mist) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--pearl); cursor: pointer; line-height: 1.4; }
.check input { width: 18px; height: 18px; accent-color: var(--champagne); margin: 0; flex-shrink: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--corner-md); background: var(--active-tint); border: 1px solid color-mix(in srgb, var(--champagne) 25%, transparent); color: var(--pearl); line-height: 20px; }
.notice > svg { color: var(--champagne); flex-shrink: 0; margin-top: 1px; }
.notice .btn { margin-top: 10px; }
.kind-picker { display: flex; flex-direction: column; gap: 8px; }
.kind-option { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-container); border: 1px solid var(--outline-variant); cursor: pointer; color: var(--mist); }
.kind-option input { position: absolute; opacity: 0; pointer-events: none; }
.kind-option span { display: flex; flex-direction: column; }
.kind-option strong { color: var(--pearl); font-weight: 600; }
.kind-option small { color: var(--whisper); font-size: 12.5px; }
.kind-option:has(input:checked) { border-color: color-mix(in srgb, var(--champagne) 55%, transparent); background: var(--active-tint); color: var(--champagne); }
.kind-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.people-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: -4px 0 0; }
.people-list.short { max-height: 220px; }
.person-option { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 12px; cursor: pointer; }
.person-option:hover { background: var(--surface-container); }
.person-option input { width: 18px; height: 18px; accent-color: var(--champagne); margin: 0; }
.person-option:has(input:checked) { background: var(--active-tint); }
.result-list { display: flex; flex-direction: column; gap: 4px; max-height: min(60vh, 520px); overflow-y: auto; }
.result { display: flex; align-items: center; gap: 4px; border-radius: 14px; }
.result:hover { background: var(--surface-container); }
.result-main { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border: 0; background: none; text-align: left; color: var(--pearl); }
.result-text { min-width: 0; display: flex; flex-direction: column; }
.result-text > span:last-child { color: var(--mist); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result-meta { color: var(--whisper); font-size: 12px; }
.result-meta strong { color: var(--pearl); font-size: 14px; }
.switcher-dialog { padding: 18px; }
.switcher-dialog .dialog-close { display: none; }
.switch-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--pearl); text-align: left; }
.switch-item.active, .switch-item:hover { background: var(--surface-container-high); }
.switch-item small { margin-left: auto; color: var(--whisper); }
.switch-item .result-main { padding: 0; }
.switcher-hint { margin: 12px 4px 0; }
.app-dialog.settings-dialog { padding: 0; width: min(900px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px)); }
.settings-dialog #dialogBody { height: 100%; }
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100%; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 24px 12px; background: var(--onyx); border-right: 1px solid var(--outline-variant); overflow-y: auto; }
.settings-nav button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--mist); font-weight: 500; text-align: left; }
.settings-nav button:hover { color: var(--pearl); background: var(--surface-container-high); }
.settings-nav button.active { color: var(--champagne); background: var(--active-tint); }
.settings-body { padding: 28px 32px; overflow-y: auto; }
.settings-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
@media (max-width: 640px) { .settings-head { flex-direction: column; gap: 0; } .settings-head .btn { margin-bottom: 16px; } }
.account-card { display: flex; align-items: center; gap: 16px; padding: 18px; margin: 8px 0 18px; border-radius: 18px; background: var(--card-gradient); border: 1px solid var(--outline-variant); }
.account-card > div { display: flex; flex-direction: column; min-width: 0; }
.account-card strong { font-size: 18px; font-weight: 600; }
.account-card small { color: var(--mist); }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.camera-preview { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 16/9; max-width: 420px; border-radius: 16px; background: var(--surface-container); border: 1px solid var(--outline-variant); overflow: hidden; }
.camera-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: 0; }
.camera-preview.live video { opacity: 1; }
.camera-preview .btn { position: relative; z-index: 1; }
.camera-preview.live .btn { position: absolute; bottom: 10px; }
.expression-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.expression { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px 10px; border-radius: 16px; background: var(--card-gradient); border: 1px solid var(--outline-variant); text-align: center; min-width: 0; }
.expression img { width: 56px; height: 56px; object-fit: contain; }
.expression-grid.kind-sticker img, .expression-grid.kind-gif img { width: 100%; height: 100px; object-fit: contain; }
.expression-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.expression small { color: var(--whisper); font-size: 11.5px; }
.expression-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.expression:hover .expression-actions, .expression:focus-within .expression-actions { opacity: 1; }
.upload-preview { display: block; max-width: 160px; max-height: 160px; margin: 4px auto 0; border-radius: 12px; }
.lightbox-dialog { padding: 0; width: auto; max-width: calc(100vw - 32px); background: transparent; border: 0; box-shadow: none; overflow: visible; }
.lightbox-dialog .dialog-close { display: none; }
.lightbox { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100dvh - 110px); border-radius: 14px; object-fit: contain; background: var(--surface); }
.lightbox-bar { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--outline-variant); max-width: 100%; }
.lightbox-bar span { color: var(--mist); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

/* Sign-in (open mode, or a cookie that isn't reaching Kiko) */
.auth-page { flex: 1; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.auth-card { width: min(440px, 100%); padding: 36px; border-radius: 26px; background: var(--card-gradient); border: 1px solid var(--outline-variant); box-shadow: 0 30px 90px rgba(0,0,0,.45); animation: rise .3s ease-out; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { margin: 0; font-size: 28px; font-weight: 300; letter-spacing: -.4px; line-height: 1.2; }
.auth-card .lede { margin: 0 0 6px; color: var(--mist); line-height: 21px; }

/* Bits */
.offline-banner { position: fixed; z-index: 90; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--slate); border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); color: var(--amber); font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.offline-banner [data-icon] { display: grid; }
.drop-zone { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(11,10,16,.8); backdrop-filter: blur(6px); pointer-events: none; }
.drop-zone > div { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 56px; border-radius: 26px; border: 2px dashed var(--champagne); background: var(--surface); color: var(--champagne); }
.drop-zone strong { color: var(--pearl); font-size: 22px; font-weight: 600; }
.drop-zone small { color: var(--mist); font-size: 14px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(11,10,16,.6); backdrop-filter: blur(4px); }
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; color: var(--pearl); background: var(--slate); border: 1px solid color-mix(in srgb, var(--jade) 35%, transparent); border-radius: var(--corner-md); box-shadow: 0 14px 40px rgba(0,0,0,.5); font-size: 14px; font-weight: 500; max-width: 390px; opacity: 0; transform: translateY(24px); pointer-events: none; z-index: 99; transition: .23s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: color-mix(in srgb, var(--coral) 45%, transparent); }

/* ---- Smaller screens --------------------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .head-search { width: 40px; padding: 0; justify-content: center; }
  .head-search span, .head-search kbd { display: none; }
  .voice-chat { width: 320px; }
}
@media (max-width: 1080px) {
  /* Members slide over the page instead of taking a column. */
  .members { position: fixed; right: 0; top: 0; z-index: 58; box-shadow: -20px 0 60px rgba(0,0,0,.5); }
  .members-close { display: grid; }
}
@media (max-width: 860px) {
  :root { --head-h: 56px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(340px, 88vw); box-shadow: 20px 0 60px rgba(0,0,0,.5); transform: translateX(-100%); visibility: hidden; transition: transform .26s ease, visibility 0s linear .26s; }
  .sidebar.open { transform: none; visibility: visible; transition: transform .26s ease; }
  .sidebar-close { display: grid; }
  .menu-button { display: grid; }
  .channel-head { padding: 0 8px 0 14px; gap: 8px; }
  .head-topic { display: none; }
  .head-actions .members-toggle { display: grid; }
  .msg { grid-template-columns: 58px minmax(0, 1fr); padding-right: 12px; }
  .msg-reply { margin-left: 28px; }
  .msg-actions { display: none !important; }
  .msg.system { padding-left: 18px; padding-right: 12px; }
  .composer { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .voice-chat { position: fixed; inset: 0; z-index: 57; width: auto; border: 0; padding-top: calc(var(--head-h) + env(safe-area-inset-top)); }
  .call-area { height: 46vh; min-height: 220px; }
  .stage-strip { height: 96px; }
  .stage-strip .tile { width: 150px; }
  .round-button { width: 48px; height: 48px; }
  .round-button.danger { width: 58px; }
  .incoming { left: 12px; right: 12px; width: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .settings { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; padding: 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--outline-variant); }
  .settings-nav button { flex-shrink: 0; }
  .settings-nav button span { white-space: nowrap; }
  .settings-body { padding: 20px 18px; }
  .toast { left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: none; }
  .history-start h2 { font-size: 24px; }
}
@media (max-width: 640px) {
  .app-dialog { padding: 22px 18px; }
  .app-dialog.settings-dialog { padding: 0; margin: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .settings-dialog .settings-nav { padding-right: 60px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .settings-dialog .dialog-close { top: calc(14px + env(safe-area-inset-top)); right: 10px; z-index: 2; background: var(--onyx); box-shadow: -14px 0 14px var(--onyx); }
  .auth-card { padding: 26px 20px; }
  .members { width: min(300px, 86vw); }
}
@media (hover: none) {
  .row-action { display: none !important; }
  .reaction.add { display: none !important; }
  .tile-action { opacity: 1; }
  .expression-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001s !important; transition-duration: .001s !important; } }
