/* xChat — one shared design system for the workspace, messages and dialogs. */
:root {
  color-scheme: light dark;
  --bg: #fff;
  --frame: #fff;
  --surface: rgba(255, 255, 255, .94);
  --surface-solid: #fff;
  --surface-2: #f7f9f9;
  --surface-3: #eff3f4;
  --surface-soft: rgba(15, 20, 25, .04);
  --surface-hover: rgba(15, 20, 25, .065);
  --text: #0f1419;
  --muted: #536471;
  --border: #eff3f4;
  --border-strong: #cfd9de;
  --accent: #1d9bf0;
  --action: #087bc1;
  --accent-foreground: #0067a6;
  --accent-hover: #066eae;
  --accent-text: #fff;
  --accent-soft: rgba(29, 155, 240, .1);
  --danger: #d52946;
  --success: #00875a;
  --ok: #00875a;
  --bubble-me: #087bc1;
  --bubble-me-text: #fff;
  --bubble-other: #eff3f4;
  --bubble-other-text: #0f1419;
  --shadow: 0 8px 32px rgba(15, 20, 25, .12);
  --focus: 0 0 0 3px rgba(29, 155, 240, .24);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000;
    --frame: #000;
    --surface: rgba(0, 0, 0, .92);
    --surface-solid: #000;
    --surface-2: #101214;
    --surface-3: #181b1e;
    --surface-soft: rgba(231, 233, 234, .055);
    --surface-hover: rgba(231, 233, 234, .09);
    --text: #e7e9ea;
    --muted: #8b98a5;
    --accent-foreground: #1d9bf0;
    --border: #22272b;
    --border-strong: #3a4249;
    --danger: #ff6b80;
    --success: #40c99b;
    --ok: #40c99b;
    --bubble-other: #202327;
    --bubble-other-text: #e7e9ea;
    --shadow: 0 8px 36px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .035);
  }
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; min-height: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; }
button, a, [role="button"] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, input, textarea, [contenteditable] { outline: none; }
button:focus-visible, a:focus-visible, [role="button"]:focus-visible,
[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled, button[aria-disabled="true"] { opacity: .45; }
input, textarea { accent-color: var(--accent); }
textarea { resize: vertical; }
::selection { background: rgba(29, 155, 240, .25); }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
.text-slate-500, .text-slate-400, .dark\:text-slate-400 { color: var(--muted) !important; }
.text-slate-900, .dark\:text-slate-100, .dark\:text-slate-200 { color: var(--text) !important; }
.border-slate-200, .dark\:border-white\/10 { border-color: var(--border) !important; }
.text-cyan-500 { color: var(--accent-foreground) !important; }
.text-rose-500 { color: var(--danger) !important; }
.font-black { font-weight: 750; }
.scrollbar { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scrollbar::-webkit-scrollbar { width: 5px; height: 5px; }
.scrollbar::-webkit-scrollbar-track { background: transparent; }
.scrollbar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* Workspace shell. The floating, draggable navigation remains available on every screen. */
.app-shell { height: 100%; height: 100dvh; width: 100%; max-width: 1320px; margin: auto; display: flex; overflow: hidden; }
.app-frame { position: relative; display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; height: 100%; overflow: hidden; background: var(--frame); border-inline: 1px solid var(--border); }
.app-content { flex: 1 1 auto; min-height: 0; overflow: hidden; }
#connection-status { flex-shrink: 0; }
.app-sidebar { flex: 0 0 246px; min-width: 0; display: flex; flex-direction: column; gap: 28px; padding: 22px 18px; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; width: fit-content; padding: 8px 12px; font-size: 25px; letter-spacing: -.06em; font-weight: 800; }
.sidebar-brand svg { width: 31px; height: 31px; }
.sidebar-brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-nav { display: flex; flex-direction: column; gap: 5px; }
.sidebar-link { display: flex; align-items: center; gap: 15px; width: fit-content; max-width: 100%; min-height: 50px; padding: 11px 14px; border-radius: 99px; font-size: 17px; font-weight: 500; text-align: left; transition: background .18s var(--ease); }
.sidebar-link > span { white-space: nowrap; }
.sidebar-link svg { width: 23px; height: 23px; }
.sidebar-link:hover { background: var(--surface-hover); }
.sidebar-link.active { font-weight: 750; }
.sidebar-link.active svg { color: var(--accent); }
.sidebar-link .nav-count { margin-left: auto; font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 1px 7px; border-radius: 99px; }
.sidebar-compose { margin: 14px 8px 0; min-height: 47px; }
.sidebar-footer { margin-top: auto; padding: 0 8px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.sidebar-profile { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 11px 10px; border-radius: 99px; text-align: left; transition: background .18s var(--ease); }
.sidebar-profile:hover { background: var(--surface-hover); }
.sidebar-profile > div { flex: 1; min-width: 0; }
.sidebar-profile b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.sidebar-profile small { display: block; color: var(--muted); font-size: 12px; }
.sidebar-bottom { margin-top: auto; }
.sidebar-caption { padding: 0 13px 19px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.sidebar-bottom .sidebar-profile { width: 100%; }
.sidebar-profile > span { flex: 1; }
.sidebar-profile > .avatar { flex: 0 0 auto; }
.brand-dot { color: var(--accent); }
.tab-count { margin-left: 4px; font-size: 11px; color: var(--muted); }
.nav-dock { position: fixed; z-index: 60; display: flex; align-items: center; gap: 4px; padding: 5px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); box-shadow: 0 4px 20px rgba(15, 20, 25, .12); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); user-select: none; -webkit-user-select: none; touch-action: none; }
.nav-dock-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 99px; background: transparent; color: var(--text); transition: background .16s, color .16s; }
.nav-dock-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.nav-dock-btn:active:not(:disabled) { background: var(--surface-hover); }
.nav-dock-btn:disabled { opacity: .25; }
.nav-drag-handle { display: grid; place-items: center; width: 22px; height: 40px; border-radius: 99px; color: var(--muted); cursor: grab; touch-action: none; }
.nav-drag-handle svg { width: 15px; height: 20px; }
.nav-drag-handle:hover { background: var(--surface-soft); }
.nav-drag-handle:active { cursor: grabbing; }
.nav-dock.dragging { box-shadow: 0 8px 28px rgba(15, 20, 25, .2); }

/* Reusable surfaces and controls. */
.glass { background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.panel { border: 1px solid var(--border); border-radius: 16px; background: var(--surface-solid); }
.panel-hover { transition: background .16s var(--ease), border-color .16s var(--ease); }
.panel-hover:hover { background: var(--surface-2); }
.input { width: 100%; min-width: 0; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-solid); color: var(--text); padding: 12px 14px; transition: border-color .15s, box-shadow .15s, background .15s; }
.input::placeholder { color: var(--muted); opacity: .85; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.input:disabled { opacity: .55; background: var(--surface-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 18px; border-radius: 99px; font-size: 14px; line-height: 1.25; font-weight: 700; white-space: nowrap; transition: background .16s, border-color .16s, opacity .16s; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--action); color: var(--accent-text); box-shadow: none; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-muted { background: var(--surface-3); color: var(--text); }
.btn-muted:hover:not(:disabled) { background: var(--surface-hover); }
.btn-danger { background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.btn:disabled { transform: none; }
.soft-ring { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.avatar { border-radius: 50%; font-weight: 650; box-shadow: none; letter-spacing: -.03em; user-select: none; }
.grid-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.grid-cards > * { min-width: 0; }

/* Inbox: a predictable timeline of conversations, with clear hierarchy. */
.home-page { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.home-inner { width: 100%; max-width: 920px; min-height: 100%; margin: auto; }
.home-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 29px 28px 23px; background: var(--frame); }
.home-heading { font-size: 29px; letter-spacing: -.05em; line-height: 1.2; font-weight: 800; }
.home-subtitle { margin-top: 7px; color: var(--muted); font-size: 13px; }
.icon-btn { display: grid; place-items: center; flex: 0 0 39px; width: 39px; height: 39px; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface-solid); color: var(--text); transition: background .16s; }
.icon-btn:hover { background: var(--surface-3); }
.home-eyebrow { color: var(--accent-foreground); font-size: 10px; line-height: 1; letter-spacing: .14em; text-transform: uppercase; font-weight: 750; margin-bottom: 9px; }
.home-searchbar { display: flex; align-items: center; gap: 12px; margin: 0 28px; padding: 0 15px; border: 1px solid transparent; border-radius: 99px; background: var(--surface-3); transition: border-color .16s, background .16s; }
.home-searchbar svg { width: 19px; height: 19px; color: var(--muted); }
.home-searchbar:focus-within { border-color: var(--accent); background: var(--bg); }
.home-searchbar:focus-within svg { color: var(--accent); }
.home-searchbar .input, .home-searchbar input { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 44px; padding: 10px 0; border: 0; border-radius: 0; background: transparent; color: var(--text); box-shadow: none; font-size: 14px; }
.home-searchbar input::placeholder { color: var(--muted); }
.home-searchbar kbd { display: grid; place-items: center; width: 21px; height: 21px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted); font-size: 11px; }
.home-filters { display: flex; align-items: stretch; gap: 8px; margin-top: 14px; padding: 0 15px; border-bottom: 1px solid var(--border); }
.home-filter { position: relative; min-height: 48px; flex: 1; padding: 12px 14px; text-align: center; color: var(--muted); font-size: 14px; font-weight: 650; transition: background .16s, color .16s; }
.home-filter:hover { background: var(--surface-soft); color: var(--text); }
.home-filter.active { color: var(--text); font-weight: 750; }
.home-filter.active:after { content: ""; position: absolute; left: 25%; right: 25%; bottom: 0; height: 4px; border-radius: 99px; background: var(--accent); }
.home-section-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 28px 10px; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .09em; text-transform: uppercase; }
.home-chat-list, #home-list.grid-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.home-chat-list { padding-bottom: 24px; }
.chat-card { min-width: 0; overflow: hidden; }
.home-chat-list .chat-card, #home-list .chat-card { padding: 19px 28px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.chat-card-row { display: flex; align-items: center; gap: 13px; width: 100%; min-width: 0; }
.chat-card-main { flex: 1 1 auto; min-width: 0; overflow: hidden; text-align: left; }
.chat-card-title-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chat-card-title { flex: 1 1 auto; min-width: 0; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.chat-card-time { flex: 0 0 auto; max-width: 5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.chat-card-kind { display: inline-flex; align-items: center; flex-shrink: 0; color: var(--muted); }
.chat-card-kind svg { width: 13px; height: 13px; }
.chat-last-text { display: block; width: 100%; max-width: 100%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; line-height: 1.5; margin-top: 4px; color: var(--muted); }
.chat-card.unread .chat-card-title { font-weight: 800; }
.chat-card.unread .chat-last-text { color: var(--text); font-weight: 550; }
.chat-last-text.has-unread { color: var(--text); font-weight: 550; }
.chat-type-icon { flex-shrink: 0; color: var(--muted); }
.saved-avatar { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.chat-unread-badge { display: grid; place-items: center; flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--action); color: #fff; font-size: 10px; font-weight: 750; }
#home-results:empty { display: none; }
#home-results:not(:empty) { padding: 18px 28px; border-bottom: 1px solid var(--border); }
#home-results .panel { border-radius: 14px; }
.search-results-list { display: grid; gap: 9px; }
.search-results-heading { margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 650; }

/* Message view and rich content. */
.chat-view { height: 100%; min-width: 0; display: flex; flex-direction: column; }
.chat-header { display: flex; flex-shrink: 0; align-items: center; gap: 12px; min-height: 76px; padding: 17px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-header b { font-size: 16px; font-weight: 750; }
.chat-header small { display: block; font-size: 12px; margin-top: 2px; }
.chat-menu-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--muted); transition: background .16s, color .16s; }
.chat-menu-btn:hover { background: var(--surface-soft); color: var(--text); }
.chat-menu-btn svg { width: 20px; height: 20px; }
.messages-list { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 24px; scrollbar-gutter: stable; }
.message-row { position: relative; display: flex; gap: 8px; min-width: 0; margin: 10px 0 0; scroll-margin: 80px; }
.message-row.grouped { margin-top: 3px; }
.message-row.mine { justify-content: flex-end; }
.message-row.other { justify-content: flex-start; }
.message-avatar-slot { display: flex; align-items: flex-end; justify-content: center; flex: 0 0 30px; width: 30px; }
.message-avatar-slot .avatar { width: 30px; height: 30px; font-size: 11px; }
.message-spacer { width: 30px; min-width: 30px; }
.message-stack { display: flex; flex-direction: column; min-width: 0; max-width: min(78%, 650px); }
.message-row.mine .message-stack { align-items: flex-end; }
.message-bubble { position: relative; isolation: isolate; min-width: 0; max-width: 100%; padding: 10px 14px 7px; border-radius: 19px; line-height: 1.55; overflow-wrap: anywhere; word-break: break-word; }
.message-row.mine .message-bubble, .message-bubble.mine { background: var(--bubble-me); color: var(--bubble-me-text); border-bottom-right-radius: 5px; }
.message-row.other .message-bubble, .message-bubble.other { background: var(--bubble-other); color: var(--bubble-other-text); border-bottom-left-radius: 5px; }
.message-row.mine.grouped .message-bubble { border-top-right-radius: 5px; }
.message-row.other.grouped .message-bubble { border-top-left-radius: 5px; }
.message-row.focused .message-bubble { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 3px; animation: highlight 1.1s var(--ease); }
.message-author { display: block; width: fit-content; max-width: 100%; margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent-foreground); font-size: 11px; font-weight: 750; }
.message-author:hover { text-decoration: underline; }
.message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 4px; color: inherit; opacity: .65; font-size: 10px; line-height: 1.35; white-space: nowrap; }
.message-meta svg { width: 13px; height: 13px; }
.message-body, .message-entity-content { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap; unicode-bidi: plaintext; text-align: start; }
.message-entity-content[dir="rtl"] { direction: rtl; }
.message-entity-content[dir="ltr"] { direction: ltr; }
.message-entity-content strong, .compose-bold { font-weight: 750; }
.message-entity-content em, .compose-italic { font-style: italic; }
.message-entity-content u, .compose-underline { text-decoration: underline; text-underline-offset: .15em; }
.message-entity-content del, .compose-strikethrough { text-decoration: line-through; opacity: .75; }
.message-entity-content a, .entity-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.mention { cursor: pointer; font-weight: 650; }
.mention:hover { text-decoration: underline; text-underline-offset: 3px; }
.reply-card { display: block; width: 100%; min-width: 0; max-width: 100%; margin: 0 0 7px; padding: 7px 10px; border-left: 3px solid var(--accent); border-radius: 7px; background: color-mix(in srgb, var(--text) 5%, transparent); text-align: start; cursor: pointer; }
.message-row.mine .reply-card { border-left-color: rgba(255, 255, 255, .75); background: rgba(255, 255, 255, .13); }
.reply-card b { display: block; color: inherit; font-size: 11px; font-weight: 750; }
.reply-text { display: block; min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; opacity: .75; }
.message-actions-anchor { position: absolute; inset: 0; pointer-events: none; }
.message-action-hit { position: absolute; top: 0; opacity: 0; pointer-events: auto; transition: opacity .15s; }
.message-action-hit.mine { right: 0; }
.message-action-hit.other { left: 38px; }
.message-action-hit button { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-solid); border: 1px solid var(--border); color: var(--muted); }
.message-row:hover .message-action-hit, .message-row:focus-within .message-action-hit, .message-row.focused .message-action-hit { opacity: 1; }
.system-message { display: flex; align-items: center; justify-content: center; width: 100%; margin: 17px 0; padding: 0; text-align: center; background: transparent; border: 0; pointer-events: none; }
.system-pill { display: inline-block; width: auto; min-width: 0; max-width: min(88%, 540px); padding: 4px 10px; border-radius: 8px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.55; white-space: normal; overflow-wrap: anywhere; pointer-events: auto; }
.system-pill .message-entity-content { display: inline; white-space: normal; unicode-bidi: normal; text-align: center; }
.system-pill .mention { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.system-pill .entity-inline-code { font: inherit; }
.message-date { display: flex; align-items: center; justify-content: center; margin: 20px 0 17px; color: var(--muted); text-align: center; font-size: 11px; }
.message-date span { padding: 4px 11px; border: 1px solid var(--border); border-radius: 99px; background: var(--frame); }
.entity-inline-code, .compose-code { display: inline; padding: 1px 4px; border: 0; border-radius: 4px; background: color-mix(in srgb, currentColor 8%, transparent); color: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .9em; font-weight: 500; cursor: copy; }
.entity-inline-code:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
.entity-code-copy, .entity-copy { display: none; }
.entity-pre, .compose-pre { display: block; min-width: 0; max-width: 100%; margin: 8px 0; overflow: hidden; border: 1px solid color-mix(in srgb, currentColor 13%, transparent); border-radius: 10px; background: color-mix(in srgb, currentColor 5%, transparent); white-space: normal; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.entity-pre, .entity-pre-head, .entity-pre code { direction: ltr; text-align: left; unicode-bidi: isolate; }
.entity-pre-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 31px; padding: 4px 8px; border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent); font-family: inherit; font-size: 10px; opacity: .8; }
.entity-pre-copy-label { display: inline-flex; align-items: center; }
.entity-pre-copy-label:before { content: "Code"; }
.entity-pre-copy-icon { display: grid; place-items: center; width: 26px; height: 24px; border-radius: 6px; color: inherit; }
.entity-pre-copy-icon:hover { background: color-mix(in srgb, currentColor 11%, transparent); }
.entity-pre code { display: block; max-width: 100%; padding: 11px 12px; overflow-x: auto; white-space: pre; font-family: inherit; font-size: 12px; line-height: 1.65; cursor: copy; }
.compose-pre { padding: 8px 10px; white-space: pre-wrap; }
.entity-blockquote, .compose-blockquote { display: flex; align-items: flex-start; gap: 7px; min-width: 0; margin: 7px 0; padding: 8px 10px; border-left: 3px solid color-mix(in srgb, currentColor 50%, transparent); border-radius: 5px 9px 9px 5px; background: color-mix(in srgb, currentColor 6%, transparent); color: inherit; }
.entity-blockquote > span:last-child { min-width: 0; }
.entity-quote-mark { font-size: 21px; line-height: 1; opacity: .4; }
.compose-blockquote { display: block; }
.entity-spoiler, .compose-spoiler { display: inline-block; position: relative; min-width: 1em; min-height: 1em; padding: 0 2px; border-radius: 4px; color: transparent; background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--text) 27%, transparent) 0 3px, color-mix(in srgb, var(--text) 13%, transparent) 3px 6px); cursor: pointer; }
.message-row.mine .entity-spoiler { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .35) 0 3px, rgba(255, 255, 255, .17) 3px 6px); }
.entity-spoiler span { filter: blur(5px); transition: filter .18s; }
.entity-spoiler.revealed { color: inherit; background: transparent; }
.entity-spoiler.revealed span { filter: none; }
.compose-text-link, .compose-text_link, .compose-url, .compose-email, .compose-phone-number, .compose-phone_number, .compose-mention { color: var(--accent-foreground); text-decoration: underline; text-underline-offset: 3px; }

/* Composer stays stable while typing, selecting formatting, or replying. */
.composer-shell { flex: 0 0 auto; padding: 13px 24px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--frame); }
.composer-card { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 22px; transition: border-color .16s, box-shadow .16s; }
.composer-card:focus-within { border-color: var(--border-strong); }
.composer-box { position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 7px; background: transparent; }
.composer-editor { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 44px; max-height: min(180px, 28dvh); overflow-y: auto; padding: 11px 9px; color: var(--text); font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; unicode-bidi: plaintext; }
.composer-editor:empty:before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.composer-editor[dir="rtl"] { direction: rtl; text-align: right; }
.composer-editor[dir="ltr"] { direction: ltr; text-align: left; }
.composer-actions { display: flex; flex-direction: row; align-items: center; align-self: flex-end; justify-content: flex-end; gap: 5px; padding-bottom: 1px; }
.send-btn, .format-toggle-btn { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
.send-btn { background: var(--action); color: #fff; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.format-toggle-btn { background: transparent; color: var(--accent-foreground); transition: background .16s; }
.format-toggle-btn:hover { background: var(--accent-soft); }
.format-toggle-btn.active { background: var(--accent-soft); color: var(--accent-foreground); }
.send-btn svg, .format-toggle-btn svg { width: 19px; height: 19px; }
.composer-reply, .composer-edit { min-width: 0; padding: 11px 16px; border-bottom: 1px solid var(--border); border-radius: 21px 21px 0 0; background: var(--accent-soft); }
.composer-reply b, .composer-edit b { color: var(--accent-foreground); font-size: 11px; }
.composer-hint { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; padding: 0 3px; color: var(--muted); font-size: 10px; }
.composer-toolbar { display: none; }
.blocked-note { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 18px 20px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.blocked-note svg { width: 16px; height: 16px; }
.format-popover { z-index: 80; width: min(304px, calc(100vw - 32px)); max-height: min(360px, 50dvh); padding: 9px; overflow-y: auto; border: 1px solid var(--border-strong); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.format-popover.inline { position: absolute; right: 0; bottom: calc(100% + 10px); }
.format-popover.floating { position: fixed; }
.format-popover-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 6px 10px; color: var(--muted); font-size: 11px; font-weight: 650; }
.format-popover-head b { font-weight: 650; }
.format-close { display: none; }
.format-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.format-tool { display: grid; grid-template-columns: 25px minmax(0, 1fr); align-items: center; gap: 7px; min-height: 42px; min-width: 0; padding: 7px; border: 1px solid transparent; border-radius: 9px; background: var(--surface-soft); color: var(--text); text-align: left; transition: background .15s, border-color .15s; }
.format-tool:hover { background: var(--surface-hover); }
.format-tool span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 6px; background: var(--surface-solid); border: 1px solid var(--border); font-size: 12px; font-weight: 700; }
.format-tool span svg { width: 15px; height: 15px; }
.format-tool b { overflow: hidden; font-size: 11px; line-height: 1.2; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.format-tool.active-format { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-foreground); }
.format-tool.danger { color: var(--danger); }

/* Drawers, menus, profiles and account screens. */
.drawer { position: fixed; inset: 0; z-index: 70; padding: max(36px, env(safe-area-inset-top)) 20px 30px; overflow-y: auto; background: rgba(0, 0, 0, .48); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); overscroll-behavior: contain; }
.drawer > .glass { padding: 24px; border-radius: 24px; background: var(--surface-solid); }
.drawer h3 { letter-spacing: -.035em; }
.tab-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 88px; cursor: pointer; }
.tab-card:hover .tab-close { opacity: 1; }
.tab-close { display: grid; place-items: center; flex-shrink: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); transition: color .15s, background .15s; }
.tab-close:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.action-menu { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); }
.message-menu { min-width: 210px; }
.action-menu button { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 10px 12px; border-radius: 10px; color: inherit; font-size: 13px; font-weight: 550; }
.action-menu button:hover { background: var(--surface-soft); }
.action-menu button svg { width: 17px; height: 17px; }
.action-menu .danger { color: var(--danger); }
.action-menu .danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.profile-hero { position: relative; overflow: hidden; border: 1px solid var(--border); background: var(--surface-solid); }
.profile-hero:before { content: ""; display: block; position: absolute; inset: 0 0 auto; height: 95px; background: var(--surface-3); pointer-events: none; }
.profile-hero > :not(.profile-menu) { position: relative; }
.profile-hero > .profile-menu { position:absolute; top:1rem; right:1rem; left:auto; }
.message-receipt { display:inline-flex; align-items:center; margin-inline-start:4px; }
.message-receipt.is-read { color:var(--accent,#1d9bf0); }
.message-receipt svg + svg { margin-inline-start:-7px; }
.message-receipt small { margin-inline-start:3px; }
.profile-hero .avatar { outline: 5px solid var(--surface-solid); }
.profile-hero h2 { font-size: 28px; letter-spacing: -.04em; }
.member-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 12px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-solid); transition: background .15s; }
.member-row:hover { background: var(--surface-2); }
.member-row b { font-size: 14px; font-weight: 650; }
.member-tools { display: flex; align-items: center; gap: 7px; }
.member-action { position: static; display: grid; place-items: center; width: 33px; height: 33px; border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--muted); }
.member-action:hover { color: var(--text); background: var(--surface-hover); }
.status-pill { position: static; background: var(--surface-soft); border: 1px solid var(--border); font-size: 10px; }
.settings-tab { min-height: 43px; padding: 11px 17px; border-radius: 99px; color: var(--muted); font-size: 14px; font-weight: 650; transition: background .15s, color .15s; }
.settings-tab.active { background: var(--accent-soft); color: var(--accent-foreground); }
.settings-tab:not(.active):hover { background: var(--surface-soft); color: var(--text); }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.session-row b { font-size: 14px; font-weight: 650; }
.session-row p { margin-top: 4px; overflow-wrap: anywhere; font-size: 12px; }
.username-field { position: relative; }
.username-field:before { content: "@"; position: absolute; top: 50%; left: 15px; z-index: 1; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.username-field .input { padding-left: 32px; }
.auth-page { min-height: 100%; overflow-y: auto; background: var(--bg); }
.auth-wrap { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 28px 18px; }
.auth-card { width: 100%; max-width: 440px; padding: 32px; border: 1px solid var(--border); border-radius: 24px; background: var(--surface-solid); }
.auth-logo { display: grid; place-items: center; width: 60px; height: 60px; margin: 0 auto; border-radius: 18px; background: var(--text); color: var(--bg); }
.auth-logo svg { width: 30px; height: 30px; }
.auth-title { font-size: 40px; line-height: 1.1; letter-spacing: -.065em; font-weight: 800; }
.auth-subtitle { max-width: 330px; margin-inline: auto; color: var(--muted); font-size: 13px; line-height: 1.7; }
.auth-switch { padding: 4px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); }
.auth-switch button { min-height: 39px; padding: 9px 14px; border-radius: 99px; color: var(--muted); font-size: 13px; font-weight: 650; transition: background .16s, color .16s; }
.auth-switch button.active { background: var(--text); color: var(--bg); }
.auth-card .btn-primary { min-height: 46px; margin-top: 6px; }
.alert-item { position: relative; display: block; padding: 13px 42px 13px 16px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); font-size: 13px; cursor: pointer; overflow-wrap: anywhere; }
.alert-item:after { content: "×"; display: grid; place-items: center; position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; font-size: 19px; color: var(--muted); }
.alert-item:hover:after { background: var(--surface-soft); }
.alert-item b { font-weight: 700; }
.alert-item.bg-rose-500 { border-left: 3px solid var(--danger); }
.alert-item.bg-emerald-500 { border-left: 3px solid var(--success); }

/* Loading and failure states occupy the same space as the eventual content. */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; min-height: 300px; padding: 45px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 6px; border-radius: 19px; background: var(--accent-soft); color: var(--accent); }
.empty-icon svg { width: 27px; height: 27px; }
svg.empty-icon { display: block; padding: 15px; flex-shrink: 0; }
.empty-title { color: var(--text); font-size: 21px; line-height: 1.35; font-weight: 750; letter-spacing: -.035em; }
.empty-description { max-width: 340px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.empty-state .btn { margin-top: 11px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 6px; }
.skeleton:after { position: absolute; inset: 0; content: ""; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg) 65%, transparent), transparent); animation: shimmer 1.7s ease-in-out infinite; }
.skeleton-avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; }
.skeleton-line { height: 11px; width: 65%; }
.skeleton-line.short { width: 34%; height: 13px; }
.skeleton-line.long { width: 78%; }
.skeleton-row { display: flex; align-items: center; gap: 13px; min-height: 94px; padding: 19px 28px; border-bottom: 1px solid var(--border); }
.skeleton-row > div:not(.skeleton-avatar) { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 11px; }
.skeleton-row > .skeleton:last-child { width: 30px; height: 8px; flex: 0 0 30px; }
.skeleton-row:nth-child(2n) .skeleton-line.long { width: 56%; }
.skeleton-row:nth-child(3n) .skeleton-line.short { width: 43%; }
.message-skeleton-list { width: 100%; }
.message-skeleton { display: flex; flex-direction: column; gap: 9px; width: 57%; max-width: 350px; min-height: 61px; margin: 18px 0; padding: 15px; border-radius: 18px 18px 18px 4px; background: var(--surface-2); }
.message-skeleton.mine { width: 43%; margin-left: auto; border-radius: 18px 18px 4px 18px; }
.message-skeleton:nth-child(3n) { width: 68%; height: 94px; }
.loading-screen { height: 100%; min-height: 0; width: 100%; max-width: 900px; margin: auto; border-inline: 1px solid var(--border); }
.boot-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 100%; padding: 32px 20px; }
.boot-brand { display: flex; align-items: center; gap: 12px; font-size: 33px; font-weight: 800; letter-spacing: -.06em; }
.boot-skeleton { width: min(100%, 490px); margin-top: 22px; overflow: hidden; border: 1px solid var(--border); border-radius: 20px; }
.boot-skeleton .skeleton-row:last-of-type { border-bottom: 0; }
.loading-header { display: flex; align-items: center; gap: 12px; height: 98px; padding: 24px 28px; border-bottom: 1px solid var(--border); }
.loading-brand { font-size: 24px; letter-spacing: -.05em; font-weight: 800; }
.loading-spinner { display: inline-block; width: 17px; height: 17px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.inline-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; color: var(--muted); font-size: 12px; }
.connectivity-banner { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 35px; padding: 8px 16px; background: var(--accent-soft); color: var(--accent-foreground); font-size: 12px; text-align: center; }
.connectivity-banner.offline { background: var(--surface-3); color: var(--muted); }
.connectivity-banner svg { width: 15px; height: 15px; }
.connectivity-banner button { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.load-error { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 18px 24px; color: var(--muted); font-size: 13px; text-align: center; }
.load-error svg { width: 18px; height: 18px; color: var(--danger); }
.load-error .btn { min-height: 34px; padding: 7px 14px; font-size: 12px; }
.empty-state.load-error > svg.empty-icon { width: 58px; height: 58px; color: var(--accent-foreground); }
.empty-state.load-error .btn { min-height: 42px; padding: 10px 18px; font-size: 14px; }
.message-status { display: inline-flex; align-items: center; gap: 3px; }
.message-status.failed { color: var(--danger); opacity: 1; }
.message-row.pending { opacity: .72; }
.scroll-bottom-btn { position: absolute; right: 24px; bottom: 128px; z-index: 8; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface-solid); color: var(--accent); box-shadow: var(--shadow); }

@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes highlight { from { outline-color: var(--accent); } to { outline-color: color-mix(in srgb, var(--accent) 30%, transparent); } }
.animate-pop { animation: pop .2s var(--ease); }
.animate-fade { animation: fade .16s ease-out; }
.message-enter { animation: message-enter .2s var(--ease); }
@keyframes message-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 760px) {
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1150px) {
  .tab-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-frame { margin-right: 32px; }
}
@media (max-width: 1050px) {
  .app-sidebar { flex-basis: 84px; align-items: center; padding: 20px 12px; }
  .sidebar-brand { padding: 8px; }
  .sidebar-brand > span, .sidebar-brand > div, .sidebar-link > span, .sidebar-profile > div, .sidebar-profile > span:not(.avatar), .sidebar-profile > svg, .sidebar-footer, .sidebar-caption, .sidebar-compose > span { display: none; }
  .sidebar-nav { gap: 12px; }
  .sidebar-link { justify-content: center; width: 49px; height: 49px; padding: 12px; }
  .sidebar-link.active { background: var(--accent-soft); }
  .sidebar-profile { padding: 7px; }
  .sidebar-compose { width: 49px; padding: 0; margin-inline: 0; }
}
@media (max-width: 680px) {
  .app-shell { max-width: none; }
  .app-sidebar { display: none; }
  .app-frame { border: 0; }
  .home-header { padding: max(25px, env(safe-area-inset-top)) 18px 20px; }
  .home-heading { font-size: 27px; }
  .home-subtitle { max-width: 230px; font-size: 12px; }
  .home-eyebrow { font-size: 9px; }
  .home-searchbar { margin-inline: 18px; }
  .home-filters { margin-top: 12px; gap: 0; }
  .home-filter { padding-inline: 8px; }
  .home-section-label { padding: 16px 18px 8px; }
  .home-chat-list .chat-card, #home-list .chat-card, .skeleton-row { padding: 18px; }
  #home-results:not(:empty) { padding: 16px 18px; }
  .chat-card-row { gap: 11px; }
  .chat-card-time { font-size: 10px; }
  .chat-header { min-height: 70px; padding: max(14px, env(safe-area-inset-top)) 17px 14px; gap: 10px; }
  .chat-header b { font-size: 15px; }
  .messages-list { padding: 18px 14px; scrollbar-gutter: auto; }
  .message-row { gap: 6px; }
  .message-stack { max-width: min(84%, 560px); }
  .message-avatar-slot + .message-stack { max-width: calc(100% - 40px); }
  .message-bubble { padding: 9px 12px 7px; font-size: 14px; }
  .composer-shell { padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
  .composer-editor { font-size: 16px; min-height: 42px; padding: 9px 6px; }
  .composer-actions { gap: 1px; }
  .send-btn, .format-toggle-btn { flex-basis: 38px; width: 38px; height: 38px; min-width: 38px; min-height: 38px; }
  .composer-box { gap: 3px; padding: 6px; }
  .composer-card { border-radius: 23px; }
  .composer-hint { display: none; }
  .input { font-size: 16px; }
  .home-searchbar .input, .home-searchbar input { font-size: 16px; }
  .home-searchbar kbd { display: none; }
  .format-popover.inline { right: 0; bottom: calc(100% + 8px); max-height: 40dvh; }
  .drawer { padding: max(18px, env(safe-area-inset-top)) 12px 24px; }
  .drawer > .glass { padding: 18px; border-radius: 20px; }
  .tab-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tab-card { min-height: 78px; }
  .session-row { display: block; }
  .session-row .session-action { margin-top: 12px; width: 100%; }
  .member-row { gap: 8px; }
  .member-tools { gap: 4px; }
  .status-pill { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .auth-wrap { padding: 28px 20px; }
  .auth-card { padding: 24px 6px; border: 0; border-radius: 0; }
  .auth-title { font-size: 38px; }
  .loading-header { padding: 24px 18px; }
  .desktop-only { display: none !important; }
  .mobile-full { width: 100%; }
  .empty-state { min-height: 280px; }
}
@media (pointer: coarse) {
  .message-action-hit { opacity: 1; }
  .tab-close { min-width: 36px; min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton:after { display: none; }
  .loading-spinner { border-top-color: var(--accent); border-right-color: var(--accent); }
}

/* Focused controls for navigation, action sheets and public group previews. */
.tab-open { width: 100%; min-height: 60px; text-align: left; border-radius: 10px; }
.tab-open > span:last-child { flex: 1; }
.action-menu [role="menuitem"]:focus-visible { outline-offset: -2px; background: var(--accent-soft); }
.public-group-profile { max-width: 560px; margin: 32px auto; padding: 36px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.public-group-profile h1 { font-size: 28px; font-weight: 750; letter-spacing: -.04em; }
.group-description { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.chat-back { display: none; }
@media (max-width: 680px) {
  .chat-back { display: grid; flex: 0 0 32px; place-items: center; width: 32px; height: 38px; border-radius: 50%; }
  .chat-back:active { background: var(--surface-hover); }
  .public-group-profile { margin: 14px auto; padding: 28px 20px; }
  .action-menu { left: 12px !important; right: 12px; top: auto !important; bottom: max(12px, env(safe-area-inset-bottom)); width: auto; max-width: none; border-radius: 20px; padding: 8px; }
  .action-menu:before { content: ''; display: block; width: 32px; height: 4px; margin: 4px auto 8px; background: var(--border-strong); border-radius: 99px; }
  .action-menu button { min-height: 48px; padding-inline: 16px; font-size: 14px; }
}

.menu-overlay { background: rgba(15,20,25,.08); }
@media (max-width: 680px) { .menu-overlay { background: rgba(0,0,0,.45); } }

/* Settings and the tab switcher share a single responsive workspace language. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
.settings-page { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 72px; }
.workspace-header { display: flex; align-items: center; gap: 12px; padding: 30px 32px 25px; border-bottom: 1px solid var(--border); }
.workspace-header h1 { font-size: 28px; line-height: 1.25; letter-spacing: -.045em; font-weight: 750; }
.workspace-header p { margin-top: 6px; color: var(--muted); font-size: 13px; }
.workspace-kicker { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 650; letter-spacing: .12em; color: var(--muted); }
.mobile-settings-back { display: none; }
.settings-layout { display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 28px; padding: 28px; }
.settings-navigation { display: flex; flex-direction: column; align-self: start; gap: 5px; position: sticky; top: 22px; }
.settings-navigation .settings-link { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 46px; padding: 12px; border-radius: 12px; text-align: left; font-size: 13px; font-weight: 550; }
.settings-link > svg { width: 19px; height: 19px; }
.settings-link > span { flex: 1; }
.settings-link .settings-nav-arrow { width: 14px; height: 14px; opacity: 0; }
.settings-link.active .settings-nav-arrow { opacity: .8; }
.settings-navigation .settings-link.active { color: var(--text); background: var(--surface-3); font-weight: 700; }
.settings-link.active > svg:first-child { color: var(--accent-foreground); }
.settings-nav-footer { display: flex; gap: 9px; padding: 20px 12px; margin-top: 18px; border-top: 1px solid var(--border); min-width: 0; }
.settings-nav-footer > span:last-child { min-width: 0; }
.settings-nav-footer b, .settings-nav-footer small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.settings-nav-footer small { color: var(--muted); margin-top: 2px; }
.settings-content { min-width: 0; max-width: 760px; }
.settings-section { border: 1px solid var(--border); border-radius: 18px; padding: 28px; background: var(--surface-solid); }
.section-heading { position: relative; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid var(--border); }
.section-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 12px; color: var(--accent-foreground); background: var(--surface-2); }
.section-icon svg { width: 21px; height: 21px; }
.section-heading h2 { font-size: 21px; font-weight: 750; letter-spacing: -.035em; }
.section-heading > p { margin-top: 7px; padding-right: 20px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.section-refresh { position: absolute; top: 0; right: 0; width: 34px; height: 34px; flex-basis: 34px; }
.section-refresh svg { width: 16px; height: 16px; }
.settings-profile-preview { display: flex; align-items: center; gap: 17px; padding-bottom: 27px; }
.settings-profile-preview > div { min-width: 0; }
.settings-profile-preview b { display: block; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.settings-profile-preview span:not(.avatar), .settings-profile-preview small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.settings-profile-preview small { margin-top: 8px; font-size: 11px; }
.settings-form { display: grid; gap: 22px; }
.settings-field-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.field-label { display: flex; flex-direction: column; position: relative; gap: 8px; min-width: 0; color: var(--text); font-size: 12px; font-weight: 650; }
.field-label .input { min-height: 46px; padding: 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; font-weight: 400; }
.field-label .username-field { display: block; }
.field-label .username-field .input { padding-left: 32px; }
.field-label .optional-label { position: absolute; top: 0; right: 0; color: var(--muted); font-size: 10px; font-weight: 400; }
.field-hint { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.65; }
.profile-bio { resize: vertical; min-height: 106px; max-height: 260px; }
.password-field { position: relative; display: block; }
.password-field .input { padding-right: 48px; }
.password-toggle { position: absolute; right: 4px; top: 4px; bottom: 4px; display: grid; place-items: center; width: 38px; border-radius: 8px; color: var(--muted); }
.password-toggle:hover { background: var(--surface-3); color: var(--text); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle[aria-pressed="true"] { color: var(--accent-foreground); background: var(--accent-soft); }
.settings-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; border-top: 1px solid var(--border); padding-top: 22px; margin-top: 12px; }
.settings-actions > p { color: var(--muted); font-size: 11px; line-height: 1.6; flex: 1; min-width: 140px; }
.settings-actions .btn { min-height: 42px; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 23px 2px; font-size: 10px; }
.text-action { display: inline-flex; align-items: center; gap: 7px; color: var(--accent-foreground); font-size: 12px; font-weight: 650; min-height: 32px; }
.text-action.danger { color: var(--danger); }
.text-action:disabled { cursor: default; }
.settings-notice { margin-bottom: 18px; padding: 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.form-feedback:empty { display: none; }
.form-feedback { font-size: 12px; color: var(--success); line-height: 1.6; }
.form-feedback.is-error { color: var(--danger); }
.settings-tip { display: flex; align-items: flex-start; gap: 13px; padding: 18px; margin-top: 24px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.settings-tip > svg { width: 20px; height: 20px; margin-top: 2px; color: var(--accent-foreground); }
.settings-tip b { font-size: 12px; font-weight: 650; }
.settings-tip p { margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.75; }
.settings-tip .text-action { margin-top: 6px; }
.settings-fieldset { padding: 0; margin: 0 0 24px; min-width: 0; }
.settings-fieldset legend { margin-bottom: 5px; font-size: 12px; font-weight: 650; }
.theme-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 16px; }
.theme-option { position: relative; padding: 7px; border: 1px solid var(--border-strong); border-radius: 13px; cursor: pointer; min-width: 0; }
.theme-option > input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.theme-option:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-preview { display: flex; gap: 9px; height: 72px; padding: 11px; border-radius: 7px; background: #fff; border: 1px solid #e5e9ec; overflow: hidden; }
.theme-preview > i { display: block; width: 13px; height: 13px; flex: 0 0 13px; border-radius: 50%; background: #1d9bf0; }
.theme-preview > span { display: flex; flex-direction: column; gap: 7px; width: 100%; padding-top: 2px; }
.theme-preview > span > i { display: block; height: 5px; border-radius: 3px; background: #dbe2e6; }
.theme-preview > span > i:nth-child(2) { width: 70%; }
.theme-preview-dark { background: #101214; border-color: #30363b; }
.theme-preview-dark > span > i { background: #37414a; }
.theme-preview-system { background: linear-gradient(90deg,#fff 50%,#101214 50%); border-color: #64717b; }
.theme-preview-system > span > i { background: linear-gradient(90deg,#dbe2e6 30%,#37414a 30%); }
.theme-option-name { display: flex; align-items: center; justify-content: space-between; gap: 3px; padding: 10px 4px 4px; font-size: 12px; font-weight: 600; }
.theme-check { color: var(--accent-foreground); visibility: hidden; }
.theme-option:has(input:checked) .theme-check { visibility: visible; }
.preference-row { display: flex; position: relative; align-items: center; justify-content: space-between; gap: 22px; min-height: 82px; padding: 17px 0; border-bottom: 1px solid var(--border); }
.preference-row > div:first-child, .preference-toggle > span:first-child { min-width: 0; flex: 1; }
.preference-row label, .preference-row b { display: block; font-size: 12px; font-weight: 650; }
.preference-row p, .preference-row small { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.7; }
.preference-row output { padding: 5px 9px; border-radius: 7px; background: var(--surface-3); font-size: 12px; font-weight: 600; }
.preference-select { border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px; max-width: 140px; font-size: 12px; background: var(--bg); color: var(--text); }
.font-size-slider { display: block; width: 100%; height: 28px; margin: 13px 0 18px; accent-color: var(--accent); }
.appearance-message-preview { display: flex; gap: 10px; padding: 17px; margin-bottom: 8px; border-radius: 13px; background: var(--surface-2); }
.appearance-message-preview > span:last-child { padding: 10px 14px; border-radius: 15px 15px 15px 4px; background: var(--bubble-other); color: var(--text); font-size: var(--message-font-size,15px); }
.appearance-message-preview small { display: block; margin-top: 5px; font-size: 10px; color: var(--muted); }
.preview-avatar { display: grid; place-items: center; align-self: flex-end; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-foreground); }
.preference-toggle { cursor: pointer; }
.preference-toggle input { position: absolute; right: 0; opacity: 0; width: 44px; height: 44px; }
.switch-track { display: block; flex: 0 0 40px; width: 40px; height: 23px; border-radius: 99px; background: var(--border-strong); transition: background .15s; }
.switch-track:after { content: ''; display: block; width: 17px; height: 17px; margin: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0002; transition: transform .15s; }
.preference-toggle input:checked + .switch-track { background: var(--action); }
.preference-toggle input:checked + .switch-track:after { transform: translateX(17px); }
.preference-toggle input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 4px; }
.device-row { display: flex; align-items: flex-start; gap: 13px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.device-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; background: var(--surface-2); color: var(--muted); }
.device-icon svg { width: 21px; height: 21px; }
.device-details { min-width: 0; flex: 1; }
.device-details > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.device-details b { font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.device-details p { margin-top: 5px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.device-details small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.current-device { padding: 2px 7px; border-radius: 99px; background: color-mix(in srgb,var(--success) 10%,transparent); color: var(--success); font-size: 9px; font-weight: 600; white-space: nowrap; }
.blocked-person { display: flex; align-items: center; gap: 12px; padding: 17px 0; border-bottom: 1px solid var(--border); }
.blocked-person > div { flex: 1; min-width: 0; }
.blocked-person b, .blocked-person small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.blocked-person small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.blocked-person .btn { min-height: 36px; padding: 8px 12px; font-size: 11px; }
.settings-list-empty { padding: 35px 15px; display: flex; align-items: center; flex-direction: column; text-align: center; gap: 10px; }
.settings-list-empty > svg { width: 30px; height: 30px; margin-bottom: 5px; color: var(--muted); }
.settings-list-empty b { font-size: 14px; }
.settings-list-empty p { max-width: 250px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.settings-list-error { display: grid; justify-items: center; gap: 14px; padding: 25px 10px; font-size: 12px; color: var(--danger); text-align: center; }
/* The switcher is opened from the floating dock, never duplicated in the sidebar. */
.tabs-overlay { display: flex; align-items: flex-start; justify-content: center; padding: max(60px,7dvh) 24px 24px; }
.tabs-dialog { display: flex; flex-direction: column; width: min(100%,680px); max-height: min(790px,86dvh); border: 1px solid var(--border-strong); border-radius: 24px; background: var(--surface-solid); box-shadow: var(--shadow); overflow: hidden; }
.tabs-dialog-header { display: flex; align-items: center; gap: 13px; padding: 25px 25px 20px; }
.tabs-dialog-header > div { flex: 1; }
.tabs-dialog-header h2 { display: flex; align-items: center; gap: 10px; font-size: 23px; letter-spacing: -.04em; font-weight: 750; }
.tabs-dialog-header h2 > span { padding: 2px 7px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); font-size: 11px; letter-spacing: 0; }
.tabs-dialog-symbol { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface-2); color: var(--accent-foreground); }
.tabs-dialog-symbol svg { width: 23px; height: 23px; }
.tabs-dialog-header .icon-btn { border: 0; background: var(--surface-2); }
.tabs-shortcuts { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 25px 22px; }
.tabs-shortcuts button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 11px; min-height: 34px; border: 1px solid var(--border); border-radius: 8px; font-size: 11px; color: var(--muted); }
.tabs-shortcuts button:hover, .tabs-shortcuts button.active { background: var(--surface-3); color: var(--text); }
.tabs-search { padding: 17px 25px 0; border-block: 1px solid var(--border); background: var(--surface-2); }
.tabs-search > label { display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-solid); }
.tabs-search > label:focus-within { border-color: var(--accent); }
.tabs-search > label > svg { width: 17px; height: 17px; color: var(--muted); }
.tabs-search input { width: 100%; min-width: 0; padding: 12px 0; font-size: 12px; background: transparent; color: var(--text); }
.tabs-filters { display: flex; gap: 20px; margin-top: 13px; }
.tabs-filters button { position: relative; padding: 9px 2px 12px; font-size: 11px; color: var(--muted); }
.tabs-filters button.active { color: var(--text); font-weight: 700; }
.tabs-filters button.active:after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 4px; background: var(--accent); }
.tabs-results { flex: 1 1 auto; min-height: 120px; overflow-y: auto; padding: 8px 15px; }
.workspace-tab { display: flex; gap: 8px; align-items: center; border: 1px solid transparent; border-radius: 12px; margin-block: 3px; }
.workspace-tab:hover { background: var(--surface-2); }
.workspace-tab.active { border-color: var(--border); background: var(--surface-2); }
.workspace-tab .tab-open { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; width: auto; min-height: 70px; padding: 12px; text-align: left; }
.workspace-tab-icon { display: grid; place-items: center; width: 39px; height: 39px; flex: 0 0 39px; border: 1px solid var(--border); border-radius: 11px; color: var(--muted); background: var(--surface-solid); }
.workspace-tab-icon.is-pinned { color: var(--accent-foreground); background: var(--accent-soft); }
.workspace-tab-icon svg { width: 19px; height: 19px; }
.workspace-tab-text { flex: 1; min-width: 0; }
.workspace-tab-text b { display: block; font-size: 12px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.workspace-tab-text small { display: block; margin-top: 4px; font-size: 10px; color: var(--muted); }
.workspace-tab-actions { display: flex; align-items: center; gap: 1px; padding-right: 8px; }
.tab-icon-action { display: grid; place-items: center; width: 30px; height: 34px; flex: 0 0 30px; border-radius: 8px; color: var(--muted); }
.tab-icon-action:hover { background: var(--surface-3); color: var(--text); }
.tab-icon-action.active { color: var(--accent-foreground); background: var(--accent-soft); }
.tab-icon-action:disabled { opacity: .2; }
.tab-icon-action.tab-close:hover { color: var(--danger); background: color-mix(in srgb,var(--danger) 10%,transparent); }
.tab-unread { flex: 0 0 auto; padding: 2px 6px; border-radius: 99px; background: var(--action); color: white; font-size: 9px; }
.tabs-empty { display: flex; flex-direction: column; align-items: center; gap: 11px; padding: 40px 20px; text-align: center; }
.tabs-empty > svg { width: 33px; height: 33px; margin-bottom: 6px; color: var(--muted); }
.tabs-empty h3 { font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.tabs-empty p { max-width: 300px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.tabs-empty .btn { margin-top: 10px; }
.tabs-dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 25px; border-top: 1px solid var(--border); }
.tabs-dialog-footer > span { min-width: 0; color: var(--muted); font-size: 10px; }
.tabs-dialog-footer .text-action { font-size: 11px; }
.tabs-keyboard-hint { display: flex; justify-content: space-between; gap: 10px; padding: 0 25px 17px; font-size: 9px; color: var(--muted); }
/* Live device preferences affect actual conversations as well as their preview. */
.message-bubble, .composer-editor { font-size: var(--message-font-size,15px); }
:root[data-message-times="false"] .message-meta { display: none; }
:root[data-density="compact"] .home-chat-list .chat-card { padding-block: 12px; }
:root[data-density="compact"] .message-row { margin-top: 5px; }
:root[data-density="compact"] .message-bubble { padding: 7px 11px 6px; }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *:before, :root[data-motion="reduce"] *:after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
:root[data-motion="reduce"] .skeleton:after { display: none; }
@media (max-width: 1100px) {
  .settings-layout { grid-template-columns: 155px minmax(0,1fr); gap: 18px; padding: 22px; }
  .settings-section { padding: 23px; }
}
@media (max-width: 800px) {
  .workspace-header { padding: 23px 20px; }
  .settings-layout { display: block; padding: 0 20px; }
  .settings-navigation { display: flex; flex-direction: row; gap: 5px; top: 0; z-index: 4; padding: 13px 0; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); background: var(--surface-solid); }
  .settings-navigation .settings-link { flex: 0 0 auto; width: auto; min-height: 38px; gap: 7px; padding: 9px 12px; font-size: 12px; border-radius: 8px; }
  .settings-link > span { white-space: nowrap; }
  .settings-link > svg { width: 16px; height: 16px; }
  .settings-link .settings-nav-arrow, .settings-nav-footer { display: none; }
}
@media (max-width: 680px) {
  .workspace-header { padding: 25px 18px 20px; }
  .workspace-header h1 { font-size: 25px; }
  .mobile-settings-back { display: grid; width: 32px; flex-basis: 32px; border: 0; }
  .settings-layout { padding-inline: 14px; }
  .settings-section { padding: 21px 18px; border-radius: 15px; }
  .section-heading { padding-bottom: 21px; margin-bottom: 21px; }
  .section-heading h2 { font-size: 20px; }
  .section-icon { display: none; }
  .section-heading > p { font-size: 12px; }
  .settings-form { gap: 20px; }
  .settings-field-grid { grid-template-columns: minmax(0,1fr); }
  .field-label .input { font-size: 16px; }
  .settings-profile-preview .avatar { width: 60px; height: 60px; font-size: 21px; }
  .settings-profile-preview small { font-size: 10px; line-height: 1.5; }
  .settings-profile-preview b { font-size: 16px; }
  .settings-footer { font-size: 9px; gap: 10px; padding-bottom: 35px; }
  .settings-footer > span { max-width: 200px; line-height: 1.7; }
  .settings-actions > p { flex-basis: 100%; }
  .settings-actions > .btn { width: 100%; }
  .theme-options { gap: 7px; }
  .theme-option { padding: 5px; border-radius: 10px; }
  .theme-preview { height: 62px; padding: 8px; gap: 6px; }
  .theme-preview > i { flex-basis: 10px; width: 10px; height: 10px; }
  .theme-option-name { font-size: 11px; padding-inline: 2px; }
  .preference-row { gap: 16px; }
  .device-row { gap: 9px; flex-wrap: wrap; }
  .device-icon { width: 34px; height: 34px; flex-basis: 34px; }
  .device-revoke { margin-left: 43px; }
  .tabs-overlay { align-items: flex-end; padding: max(16px,env(safe-area-inset-top)) 10px max(12px,env(safe-area-inset-bottom)); }
  .tabs-dialog { width: 100%; max-height: 92dvh; border-radius: 22px; }
  .tabs-dialog-header { gap: 11px; padding: 21px 18px 18px; }
  .tabs-dialog-header h2 { font-size: 22px; }
  .tabs-dialog-header .icon-btn { width: 34px; height: 34px; flex-basis: 34px; }
  .tabs-shortcuts { gap: 6px; padding: 0 18px 18px; }
  .tabs-shortcuts button { flex: 1; padding: 8px 6px; font-size: 10px; min-width: 60px; }
  .tabs-shortcuts button:last-child { flex-basis: 100%; }
  .tabs-search { padding: 15px 18px 0; }
  .tabs-search input { font-size: 16px; }
  .tabs-results { padding-inline: 8px; }
  .workspace-tab { gap: 0; }
  .workspace-tab .tab-open { padding: 10px 8px; gap: 9px; min-height: 70px; }
  .workspace-tab-icon { width: 31px; height: 36px; flex-basis: 31px; border-radius: 9px; }
  .workspace-tab-icon svg { width: 17px; height: 17px; }
  .workspace-tab-actions { gap: 0; padding-right: 5px; }
  .tab-icon-action { width: 28px; height: 40px; flex-basis: 28px; }
  .workspace-tab .tab-close { min-width: 28px; min-height: 40px; }
  .tabs-dialog-footer { padding: 12px 18px; gap: 9px; }
  .tabs-dialog-footer .text-action { font-size: 10px; }
  .tabs-keyboard-hint { display: none; }
}

:root[data-theme="dark"] {
    --bg: #000;
    --frame: #000;
    --surface: rgba(0, 0, 0, .92);
    --surface-solid: #000;
    --surface-2: #101214;
    --surface-3: #181b1e;
    --surface-soft: rgba(231, 233, 234, .055);
    --surface-hover: rgba(231, 233, 234, .09);
    --text: #e7e9ea;
    --muted: #8b98a5;
    --accent-foreground: #1d9bf0;
    --border: #22272b;
    --border-strong: #3a4249;
    --danger: #ff6b80;
    --success: #40c99b;
    --ok: #40c99b;
    --bubble-other: #202327;
    --bubble-other-text: #e7e9ea;
    --shadow: 0 8px 36px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .035);
}

@media (max-width:680px) {
  .settings-page .workspace-header { padding-right: 150px; }
  .tab-icon-action { width: 36px; height: 44px; flex-basis: 36px; }
  .workspace-tab .tab-close { min-width: 36px; min-height: 44px; }
}

.app-shell { height: var(--app-height,100dvh); }
.tabs-overlay { height: var(--app-height,100dvh); }
.tabs-dialog { max-height: min(790px,calc(var(--app-height,100dvh) - 90px)); }
:root[data-keyboard="true"] .tabs-shortcuts, :root[data-keyboard="true"] .tabs-keyboard-hint { display: none; }
:root[data-keyboard="true"] .tabs-dialog-header { padding-block: 13px; }
:root[data-keyboard="true"] .tabs-dialog-header .workspace-kicker { display: none; }
:root[data-keyboard="true"] .tabs-results { min-height: 0; }
@media (max-width:680px) { .tabs-dialog { max-height: calc(var(--app-height,100dvh) - 28px); } }

/* Account administration */
.admin-user-row { display:flex; justify-content:space-between; gap:16px; padding-block:18px; border-bottom:1px solid var(--border,#536471); }
.admin-user-row>div { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.admin-user-row>div:first-child { display:grid; }
.admin-user-row small { color:var(--muted,#71767b); }
.admin-user-row .btn { font-size:12px; padding:8px 12px; }
@media(max-width:600px) { .admin-user-row { flex-direction:column; gap:12px; } }

#alerts { top:auto; bottom:max(24px,env(safe-area-inset-bottom)); pointer-events:none; }
#alerts .alert-item { pointer-events:auto; text-align:start; width:100%; }
body:has(.composer-shell) #alerts { bottom:calc(110px + env(safe-area-inset-bottom)); }

/* List separators belong between rows, never below the final item. */
.home-chat-list .chat-card:last-of-type, #home-list .chat-card:last-of-type,
.device-row:last-of-type, .blocked-person:last-of-type, .admin-user-row:last-of-type,
.skeleton-row:last-of-type { border-bottom: 0; }
.settings-section > .preference-row:not(:has(~ .preference-row)) { border-bottom: 0; }

/* Group creation stays above the current conversation. */
.group-overlay { position:fixed; inset:0; z-index:95; display:flex; justify-content:flex-end; padding:12px; background:rgb(0 0 0 / .4); backdrop-filter:blur(3px); animation:fade .18s ease; }
.group-panel { display:flex; flex-direction:column; width:min(460px,100%); height:calc(var(--app-height,100dvh) - 24px); border:1px solid var(--border); border-radius:22px; overflow:hidden; background:var(--surface-solid); color:var(--text); box-shadow:-12px 0 60px rgb(0 0 0 / .16); animation:group-slide-in .24s var(--ease); }
.group-panel-header { display:flex; gap:13px; align-items:center; flex-shrink:0; padding:28px 26px 24px; border-bottom:1px solid var(--border); }
.group-panel-symbol { display:grid; place-items:center; width:44px; height:44px; flex-shrink:0; border-radius:14px; background:var(--accent-soft); color:var(--accent-foreground); }
.group-panel-header>div { flex:1; min-width:0; }
.group-panel-header small { display:block; font-size:9px; font-weight:650; letter-spacing:.12em; color:var(--muted); }
.group-panel-header h2 { margin-top:5px; font-size:24px; font-weight:750; letter-spacing:-.04em; }
.group-panel-header .icon-btn { flex-shrink:0; }
.group-panel-form { display:flex; flex:1; flex-direction:column; min-height:0; }
.group-panel-fields { display:flex; flex:1; min-height:0; flex-direction:column; gap:24px; overflow-y:auto; overscroll-behavior:contain; padding:27px 26px; }
.group-panel-fields textarea { resize:vertical; min-height:115px; }
.group-options { padding-top:21px; border-top:1px solid var(--border); }
.group-options summary { display:flex; justify-content:space-between; align-items:center; gap:15px; color:var(--muted); cursor:pointer; font-size:13px; font-weight:650; list-style:none; }
.group-options summary::-webkit-details-marker { display:none; }
.group-options[open] summary>svg { transform:rotate(180deg); }
.group-options>div { display:grid; gap:22px; padding-top:22px; }
.group-panel-footer { flex-shrink:0; padding:18px 26px max(24px,env(safe-area-inset-bottom)); border-top:1px solid var(--border); background:var(--surface-solid); }
.group-panel-footer>p { color:var(--muted); font-size:11px; margin-bottom:14px; }
.group-panel-footer>div:last-child { display:flex; justify-content:flex-end; gap:10px; }
.group-panel-footer .form-feedback:empty { display:none; }
.group-panel-footer .form-feedback:not(:empty) { margin-bottom:14px; }
@keyframes group-slide-in { from { transform:translateX(100%); } to { transform:translateX(0); } }

/* Encryption setup: state first, optional details kept closed. */
.encryption-settings .section-heading { border-bottom:0; margin-bottom:20px; padding-bottom:0; }
.encryption-progress { display:flex; gap:6px; padding:0 0 24px; margin:0; list-style:none; }
.encryption-progress li { display:flex; align-items:center; gap:7px; flex:1; font-size:11px; color:var(--muted); font-weight:550; }
.encryption-progress li>span { display:grid; place-items:center; width:22px; height:22px; flex-shrink:0; border-radius:50%; border:1px solid var(--border-strong); font-size:10px; }
.encryption-progress li.complete { color:var(--accent-foreground); }
.encryption-progress li.complete>span { color:var(--accent-foreground); background:var(--accent-soft); border-color:transparent; }
.encryption-error { padding:12px 14px; margin-bottom:15px; font-size:12px; line-height:1.7; border-radius:10px; color:var(--danger); background:color-mix(in srgb,var(--danger) 6%,transparent); }
.encryption-error:empty { display:none; }
.encryption-card { border:1px solid var(--border); border-radius:17px; padding:22px; margin-bottom:17px; min-width:0; }
.encryption-card>header { display:flex; align-items:flex-start; gap:11px; margin-bottom:20px; }
.encryption-step-number { display:grid; place-items:center; width:29px; height:29px; flex-shrink:0; margin-top:1px; border-radius:9px; background:var(--surface-3); color:var(--muted); font-size:12px; font-weight:650; }
.encryption-card>header>div { flex:1; min-width:0; }
.encryption-card h3 { font-size:15px; font-weight:700; letter-spacing:-.02em; }
.encryption-card>header p { margin-top:5px; font-size:12px; line-height:1.7; color:var(--muted); }
.encryption-card>header .icon-btn { width:32px; height:32px; flex-shrink:0; }
.encryption-card h4 { font-size:14px; font-weight:650; margin-block:12px 6px; }
.encryption-key-summary>p, .encryption-verify>p, .encryption-chat-ready p { color:var(--muted); font-size:12px; line-height:1.8; }
.encryption-key-summary>.btn, .encryption-key-summary>.text-action { margin-top:18px; }
.encryption-status { display:inline-flex; align-items:center; gap:5px; padding:4px 8px; border-radius:7px; font-size:10px; color:var(--muted); background:var(--surface-3); }
.encryption-status.ready { color:var(--accent-foreground); background:var(--accent-soft); }
.encryption-checking { display:flex; align-items:center; gap:10px; padding:10px 0; font-size:12px; color:var(--muted); }
.encryption-fingerprint-details { margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }
.encryption-fingerprint-details summary, .encryption-limits summary { display:flex; align-items:center; justify-content:space-between; gap:10px; cursor:pointer; list-style:none; font-size:12px; font-weight:550; color:var(--muted); }
.encryption-fingerprint-details summary::-webkit-details-marker, .encryption-disclosure summary::-webkit-details-marker, .encryption-limits summary::-webkit-details-marker { display:none; }
.encryption-fingerprint-details[open] summary>svg, .encryption-disclosure[open] summary>svg, .encryption-limits[open] summary>svg { transform:rotate(180deg); }
.encryption-fingerprint-details>p { margin-top:12px; color:var(--muted); font-size:11px; line-height:1.7; }
.fingerprint-box { display:flex; align-items:flex-start; gap:9px; min-width:0; padding:13px; margin-top:13px; background:var(--surface-2); border:1px solid var(--border); border-radius:11px; }
.fingerprint-box code { flex:1; min-width:0; font:11px/1.9 ui-monospace,SFMono-Regular,monospace; overflow-wrap:anywhere; user-select:all; }
.fingerprint-box .icon-btn { width:29px; height:29px; flex-shrink:0; border:0; }
.encryption-backup-note { color:var(--muted); font-size:12px; line-height:1.8; margin-bottom:14px; }
.encryption-disclosure { border-top:1px solid var(--border); }
.encryption-disclosure summary { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 0; cursor:pointer; list-style:none; }
.encryption-disclosure summary>span { display:flex; align-items:center; gap:11px; min-width:0; }
.encryption-disclosure summary>span>svg { width:18px; height:18px; flex-shrink:0; color:var(--muted); }
.encryption-disclosure summary>svg { flex-shrink:0; color:var(--muted); }
.encryption-disclosure summary b { display:block; font-size:12px; font-weight:650; }
.encryption-disclosure summary small { display:block; color:var(--muted); font-size:11px; line-height:1.7; margin-top:4px; }
.encryption-disclosure form { padding:0 0 19px; }
.encryption-disclosure fieldset { display:grid; gap:14px; min-width:0; }
.encryption-disclosure .btn { justify-self:start; }
.encryption-disclosure input[type=file] { padding:7px; min-width:0; font-size:11px; }
.encryption-disclosure input::file-selector-button { padding:8px 10px; margin-right:8px; border:0; border-radius:7px; background:var(--surface-3); color:var(--text); font:inherit; cursor:pointer; }
.encryption-disclosure fieldset:disabled { opacity:.55; }
.encryption-complete-note { color:var(--accent-foreground); font-size:11px; line-height:1.7; }
.encryption-complete-note:empty { display:none; }
.encryption-waiting { margin-top:16px; padding:13px; border-radius:11px; background:var(--surface-2); color:var(--muted); font-size:12px; line-height:1.8; }
.encryption-verify { margin-top:18px; }
.encryption-confirm { display:flex; align-items:flex-start; gap:10px; padding:16px 0; font-size:12px; line-height:1.7; cursor:pointer; }
.encryption-confirm input { width:17px; height:17px; margin-top:2px; flex-shrink:0; accent-color:var(--accent); }
.encryption-chat-ready { display:flex; align-items:flex-start; gap:11px; padding:16px 0; }
.encryption-chat-ready>svg { width:22px; height:22px; color:var(--accent-foreground); flex-shrink:0; margin-top:2px; }
.encryption-chat-ready b { font-size:13px; font-weight:650; }
.encryption-chat-ready p { margin-top:5px; }
.encryption-limits { padding-top:5px; }
.encryption-limits p { color:var(--muted); font-size:11px; line-height:1.9; margin-top:12px; }
.encryption-card .field-hint { margin-top:8px; }
@media(max-width:600px) {
  .group-overlay { padding:8px; }
  .group-panel { width:min(420px,100%); height:calc(var(--app-height,100dvh) - 16px); border-radius:18px; }
  .group-panel-header { padding:23px 20px 20px; }
  .group-panel-fields { padding:24px 20px; gap:22px; }
  .group-panel-footer { padding-inline:20px; }
  .group-panel-footer>div:last-child .btn { flex:1; }
  .encryption-card { padding:17px; border-radius:14px; }
  .encryption-progress { gap:5px; }
  .encryption-progress li { font-size:10px; gap:5px; }
  .encryption-progress li>span { width:20px; height:20px; }
  .encryption-disclosure .btn { width:100%; }
  .fingerprint-box { padding:10px; gap:3px; }
}
@media(prefers-reduced-motion:reduce) { .group-panel,.group-overlay { animation:none; } }
:root[data-motion=reduce] .group-panel,:root[data-motion=reduce] .group-overlay { animation:none; }
