:root {
  --app-height: 100dvh;
  --bg: #0e141b;
  --bg-soft: #111923;
  --panel: #171d25;
  --panel-2: #1b2838;
  --panel-3: #223044;
  --surface: #202b3b;
  --surface-hover: #29384d;
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.14);
  --text: #f2f5f8;
  --text-soft: #c7d5e0;
  --muted: #7f92a6;
  --accent: #66c0f4;
  --accent-2: #1a9fff;
  --accent-dark: #17608a;
  --green: #75b022;
  --danger: #e35e63;
  --warning: #e3a94d;
  --shadow: 0 20px 60px rgba(0,0,0,.38);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --rail-width: 84px;
  --sidebar-width: 360px;
  --mobile-nav-height: 68px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--text); }
body { position: fixed; inset: 0; min-height: 100%; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
button, a, input, textarea, select { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { box-shadow: 0 0 0 3px rgba(102,192,244,.28); }
button { border: 0; cursor: pointer; }
img { max-width: 100%; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }
.mobile-only { display: none !important; }

.app-root, .workspace { width: 100%; height: var(--app-height); min-height: 0; overflow: hidden; }
.workspace { display: grid; grid-template-columns: var(--rail-width) minmax(0,1fr); background: radial-gradient(circle at 85% 0%, rgba(27,95,145,.12), transparent 34%), var(--bg); }
.app-main { min-width: 0; min-height: 0; overflow: hidden; }
.view { width: 100%; height: 100%; min-height: 0; }

.fm-logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg,#66c0f4,#1a78b8 55%,#16344e); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 9px 22px rgba(0,0,0,.28); color: white; font-weight: 900; letter-spacing: -.06em; }
.fm-logo span { transform: translateX(-1px); }
.fm-logo-xl { width: 92px; height: 92px; border-radius: 26px; font-size: 28px; }
.overline { display: block; color: var(--accent); font-size: 11px; line-height: 1; letter-spacing: .16em; font-weight: 800; text-transform: uppercase; }

.auth-screen { position: relative; height: var(--app-height); overflow: auto; background: #0d141c; }
.auth-backdrop { position: fixed; inset: 0; background: radial-gradient(circle at 22% 24%, rgba(102,192,244,.2), transparent 32%), radial-gradient(circle at 82% 76%, rgba(26,159,255,.12), transparent 34%), linear-gradient(135deg,#0a1118,#172331); pointer-events: none; }
.auth-shell { position: relative; z-index: 1; width: min(1120px,calc(100% - 48px)); min-height: 100%; margin: 0 auto; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 56px; padding: 48px 0; }
.auth-brand-panel { padding: 24px; }
.auth-brand-copy { margin-top: 34px; max-width: 580px; }
.auth-brand-copy h1 { margin: 14px 0 18px; font-size: clamp(42px,6vw,72px); line-height: .98; letter-spacing: -.05em; }
.auth-brand-copy p { margin: 0; max-width: 540px; color: var(--text-soft); font-size: 18px; line-height: 1.65; }
.auth-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.auth-pills span { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); color: var(--text-soft); font-size: 13px; }
.auth-card { width: 100%; max-width: 470px; justify-self: end; padding: 34px; border: 1px solid var(--line-strong); border-radius: 22px; background: rgba(23,29,37,.93); backdrop-filter: blur(22px); box-shadow: var(--shadow); }
.mobile-auth-logo { display: none; align-items: center; gap: 12px; margin-bottom: 26px; }
.mobile-auth-logo div:last-child { display: flex; flex-direction: column; }
.mobile-auth-logo small { color: var(--muted); }
.auth-card-header h2 { margin: 10px 0 8px; font-size: 30px; letter-spacing: -.035em; }
.auth-card-header p { margin: 0; color: var(--muted); line-height: 1.5; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 26px 0 22px; border-radius: 10px; background: #0e151e; }
.auth-tab { min-height: 42px; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 700; }
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.form-stack { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; }
.field > span { color: var(--text-soft); font-size: 13px; font-weight: 700; }
.field input, .field textarea, .select-control, .search-box input, .composer textarea { width: 100%; border: 1px solid var(--line-strong); background: #0d141d; color: var(--text); border-radius: 9px; }
.field input, .select-control { height: 44px; padding: 0 13px; }
.field textarea { min-height: 90px; padding: 12px 13px; resize: vertical; }
.field input:hover, .field textarea:hover, .select-control:hover, .search-box:hover { border-color: rgba(102,192,244,.35); }
.field input:focus, .field textarea:focus, .select-control:focus, .search-box:focus-within, .composer:focus-within { border-color: var(--accent); }
.form-error { min-height: 20px; margin-top: 14px; color: #ff8589; font-size: 13px; }
.announcement-banner { margin: 18px 0 0; padding: 12px 14px; border: 1px solid rgba(227,169,77,.35); border-radius: 9px; background: rgba(227,169,77,.08); color: #f1cf94; font-size: 13px; line-height: 1.45; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 750; transition: transform .14s ease, background .14s ease, border-color .14s ease, opacity .14s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .45; cursor: default; transform: none; }
.button-large { min-height: 48px; }
.button-small { min-height: 32px; padding: 0 11px; font-size: 12px; }
.button-primary { background: linear-gradient(180deg,#2ea7ec,#1679b8); color: white; border-color: rgba(255,255,255,.1); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.button-primary:hover { background: linear-gradient(180deg,#48b8f8,#1b8bce); }
.button-secondary { background: var(--surface); color: var(--text-soft); border-color: var(--line-strong); }
.button-secondary:hover { background: var(--surface-hover); color: white; }
.button-danger { background: rgba(227,94,99,.12); color: #ff9599; border-color: rgba(227,94,99,.3); }
.button-danger:hover { background: rgba(227,94,99,.2); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row.end { justify-content: flex-end; margin-top: 22px; }

.app-rail { display: flex; flex-direction: column; min-height: 0; padding: 14px 10px calc(14px + env(safe-area-inset-bottom)); border-right: 1px solid var(--line); background: #111821; }
.rail-brand { display: grid; place-items: center; width: 100%; height: 58px; background: transparent; }
.rail-nav { display: grid; gap: 6px; margin-top: 18px; }
.rail-button { position: relative; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border-radius: 11px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
.rail-button .nav-icon { font-size: 22px; line-height: 1; }
.rail-button:hover { color: var(--text-soft); background: rgba(255,255,255,.035); }
.rail-button.active { color: var(--accent); background: rgba(102,192,244,.1); }
.nav-badge { position: absolute; top: 7px; right: 7px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: #d94146; color: white; font-size: 10px; }
.rail-bottom { margin-top: auto; display: grid; gap: 6px; }
.rail-profile { display: grid; place-items: center; gap: 4px; padding: 7px 2px; border-radius: 11px; background: transparent; }
.rail-profile:hover { background: rgba(255,255,255,.035); }
.rail-profile > span { width: 62px; overflow: hidden; text-overflow: ellipsis; color: var(--text-soft); font-size: 10px; white-space: nowrap; }
.rail-logout { min-height: 52px; }

.view-chats { display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr); min-height: 0; }
.chat-sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #151d27; }
.sidebar-header { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 13px; }
.sidebar-header h2 { margin: 7px 0 0; font-size: 23px; letter-spacing: -.035em; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.035); color: var(--text-soft); font-size: 20px; }
.icon-button:hover { background: var(--surface-hover); color: white; }
.icon-button-accent { background: linear-gradient(180deg,#2ea7ec,#1679b8); color: white; border-color: transparent; }
.sidebar-announcement { margin: 0 14px 12px; padding: 10px 12px; border-left: 3px solid var(--accent); border-radius: 5px 8px 8px 5px; background: rgba(102,192,244,.07); color: var(--text-soft); font-size: 12px; line-height: 1.4; }
.search-box { min-height: 42px; display: flex; align-items: center; gap: 8px; margin: 0 14px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #0e151e; color: var(--muted); }
.search-box.wide { margin: 0; min-width: min(480px,100%); }
.search-box input { height: 40px; padding: 0; border: 0; background: transparent; }
.sidebar-filter-row { display: flex; gap: 7px; padding: 12px 14px 10px; overflow-x: auto; scrollbar-width: none; }
.sidebar-filter-row::-webkit-scrollbar { display: none; }
.filter-chip { min-height: 30px; padding: 0 11px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.filter-chip:hover { background: rgba(255,255,255,.04); color: var(--text-soft); }
.filter-chip.active { background: rgba(102,192,244,.12); color: var(--accent); }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 8px 16px; scrollbar-color: #34465b transparent; }
.chat-item { width: 100%; min-height: 74px; display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 10px; border-radius: 10px; background: transparent; text-align: left; }
.chat-item:hover { background: rgba(255,255,255,.035); }
.chat-item.active { background: linear-gradient(90deg,rgba(42,104,148,.48),rgba(35,70,100,.36)); box-shadow: inset 3px 0 0 var(--accent); }
.chat-item-copy { min-width: 0; }
.chat-item-title-row { display: flex; align-items: center; gap: 6px; }
.chat-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.chat-item-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.chat-item-preview { display: block; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.chat-item-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; padding: 3px 0; }
.unread-pill { min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; border-radius: 999px; background: var(--accent-2); color: white; font-size: 10px; font-weight: 800; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #647588; }
.online-dot.online { background: #6dc64e; box-shadow: 0 0 0 3px rgba(109,198,78,.13); }
.avatar { position: relative; overflow: hidden; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg,#344961,#1e2b3a); color: var(--text-soft); font-weight: 850; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-small { width: 36px; height: 36px; font-size: 11px; }
.avatar-medium { width: 46px; height: 46px; font-size: 13px; }
.avatar-profile { width: 112px; height: 112px; font-size: 28px; }
body.compact-chats .chat-item { min-height: 60px; padding-top: 6px; padding-bottom: 6px; }
body.compact-chats .chat-item .avatar { width: 40px !important; height: 40px !important; }

.conversation-pane { position: relative; min-width: 0; min-height: 0; background: radial-gradient(circle at 50% -20%,rgba(43,103,145,.18),transparent 44%), #101720; }
.conversation-placeholder { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.conversation-placeholder h2 { margin: 24px 0 8px; font-size: 28px; }
.conversation-placeholder p { margin: 0 0 22px; color: var(--muted); }
.conversation-content { height: 100%; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto auto auto auto auto; }
.conversation-header { min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(19,27,37,.88); backdrop-filter: blur(14px); }
.conversation-heading { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conversation-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.conversation-heading span { color: var(--muted); font-size: 12px; }
.conversation-actions { margin-left: auto; display: flex; gap: 7px; }
.conversation-search-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #141d27; }
.conversation-search-bar input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #0d141c; color: var(--text); }
.conversation-search-bar span { color: var(--muted); font-size: 12px; }
.messages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; padding: 22px clamp(14px,3vw,36px); scrollbar-color: #34465b transparent; }
.message-day { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted); font-size: 11px; font-weight: 700; }
.message-day::before, .message-day::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.message { position: relative; display: grid; grid-template-columns: 38px minmax(0,1fr); gap: 10px; max-width: 900px; margin: 0 auto 12px; padding: 7px 42px 7px 8px; border-radius: 10px; }
.message:hover { background: rgba(255,255,255,.025); }
.message.highlight { background: rgba(102,192,244,.12); animation: messageFlash 1.6s ease; }
.message-avatar { width: 38px; height: 38px; }
.message-body { min-width: 0; }
.message-header { display: flex; align-items: baseline; gap: 8px; }
.message-author { color: var(--accent); font-size: 13px; font-weight: 800; }
.message-time { color: #66778b; font-size: 10px; }
.message-edited { color: #66778b; font-size: 10px; }
.message-text { margin-top: 3px; color: #e5ebf0; line-height: 1.52; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-text.deleted { color: #758597; font-style: italic; }
.message-actions { position: absolute; top: 5px; right: 7px; display: flex; gap: 3px; opacity: 0; transform: translateY(3px); transition: .14s ease; }
.message:hover .message-actions, .message:focus-within .message-actions { opacity: 1; transform: none; }
.message-action { width: 30px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: #253448; color: var(--muted); font-size: 13px; }
.message-action:hover { background: #33465f; color: white; }
.message-status { margin-top: 3px; color: #688098; font-size: 10px; }
.message-attachments { display: grid; gap: 8px; margin-top: 8px; max-width: 620px; }
.image-attachment { display: block; width: fit-content; max-width: 100%; padding: 0; border-radius: 10px; overflow: hidden; background: #0a1016; }
.image-attachment img { display: block; max-width: min(560px,100%); max-height: 430px; object-fit: contain; cursor: zoom-in; }
.file-attachment { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; align-items: center; min-width: min(440px,100%); padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(34,48,68,.72); }
.file-type-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; background: rgba(102,192,244,.12); color: var(--accent); font-size: 10px; font-weight: 900; }
.file-attachment-copy { min-width: 0; }
.file-attachment-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.file-attachment-copy span { color: var(--muted); font-size: 10px; }
.file-download { color: var(--accent); font-size: 12px; text-decoration: none; }
.typing-indicator { min-height: 22px; padding: 0 clamp(14px,3vw,36px); color: var(--muted); font-size: 11px; }
.jump-to-bottom { position: absolute; right: 24px; bottom: 98px; z-index: 3; min-height: 36px; padding: 0 13px; border-radius: 999px; background: var(--surface-hover); color: var(--text-soft); box-shadow: var(--shadow); }
.context-bar, .file-draft, .upload-panel { margin: 0 clamp(12px,2vw,24px) 7px; border: 1px solid var(--line); border-radius: 10px; background: #172230; }
.context-bar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-left: 3px solid var(--accent); }
.context-bar > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.context-bar strong, .context-bar small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-bar strong { color: var(--accent); font-size: 12px; }
.context-bar small { max-width: 500px; color: var(--muted); font-size: 11px; }
.context-icon { color: var(--accent); font-size: 19px; }
.file-draft { min-height: 66px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 8px; }
.file-draft-preview { width: 50px; height: 50px; overflow: hidden; border-radius: 7px; background: #0b1118; }
.file-draft-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-draft-copy { min-width: 0; }
.file-draft-copy strong, .file-draft-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-draft-copy strong { font-size: 12px; }
.file-draft-copy span { color: var(--muted); font-size: 10px; margin-top: 4px; }
.upload-panel { padding: 10px; }
.upload-header { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.progress { height: 6px; margin: 8px 0; overflow: hidden; border-radius: 99px; background: #0c131b; }
.progress div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg,var(--accent-dark),var(--accent)); transition: width .18s ease; }
.composer { min-height: 68px; display: grid; grid-template-columns: 42px minmax(0,1fr) 44px; align-items: end; gap: 8px; padding: 10px clamp(12px,2vw,24px) calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(18,26,36,.94); }
.composer textarea { min-height: 44px; max-height: 150px; padding: 11px 13px; resize: none; line-height: 1.45; }
.composer-button, .composer-send { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 9px; }
.composer-button { border: 1px solid var(--line); background: var(--surface); color: var(--text-soft); font-size: 21px; }
.composer-send { background: linear-gradient(180deg,#2ea7ec,#1679b8); color: white; font-size: 17px; }

.page-view { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: clamp(20px,3vw,38px); padding-bottom: calc(38px + env(safe-area-inset-bottom)); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; max-width: 1440px; margin: 0 auto 24px; }
.page-header h1, .panel-heading h1 { margin: 8px 0 6px; font-size: clamp(28px,3vw,40px); letter-spacing: -.045em; }
.page-header p { margin: 0; color: var(--muted); }
.page-toolbar { max-width: 1440px; margin: 0 auto 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.select-control { min-width: 160px; }
.files-summary { max-width: 1440px; margin: 0 auto 14px; color: var(--muted); font-size: 12px; }
.files-grid { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill,minmax(250px,1fr)); gap: 12px; }
.file-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.file-card-preview { height: 156px; display: grid; place-items: center; overflow: hidden; background: #0b1118; }
.file-card-preview img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; transition: transform .2s ease; }
.file-card:hover .file-card-preview img { transform: scale(1.025); }
.file-card-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 16px; background: rgba(102,192,244,.1); color: var(--accent); font-size: 13px; font-weight: 900; }
.file-card-body { padding: 12px; }
.file-card-body strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-body span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.file-card-actions { display: flex; gap: 8px; margin-top: 12px; }

.settings-layout { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 24px; }
.settings-nav { display: flex; flex-direction: column; gap: 5px; align-self: start; position: sticky; top: 0; }
.settings-nav-button, .admin-nav-button { min-height: 44px; padding: 0 13px; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; font-weight: 700; }
.settings-nav-button:hover, .admin-nav-button:hover { background: rgba(255,255,255,.035); color: var(--text-soft); }
.settings-nav-button.active, .admin-nav-button.active { background: rgba(102,192,244,.11); color: var(--accent); }
.settings-content { min-width: 0; }
.settings-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: clamp(18px,3vw,28px); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-heading h2, .panel-heading h3 { margin: 0 0 6px; }
.panel-heading p { margin: 0; color: var(--muted); }
.profile-card { display: flex; align-items: center; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.profile-card-copy { display: flex; flex-direction: column; gap: 6px; }
.profile-card-copy strong { font-size: 22px; }
.profile-card-copy span { color: var(--muted); }
.avatar-upload-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 0; }
.avatar-upload-card h3 { margin: 0 0 7px; }
.avatar-upload-card p { max-width: 620px; margin: 0; color: var(--muted); line-height: 1.5; }
.avatar-editor { display: grid; grid-template-columns: minmax(0,420px) minmax(220px,1fr); gap: 22px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #101720; }
.avatar-crop-stage { aspect-ratio: 1; overflow: hidden; border-radius: 50%; border: 2px solid rgba(102,192,244,.5); background: #080d12; touch-action: none; cursor: grab; }
.avatar-crop-stage:active { cursor: grabbing; }
.avatar-crop-stage canvas { width: 100%; height: 100%; display: block; }
.avatar-controls label { display: grid; gap: 10px; color: var(--text-soft); font-weight: 700; }
.avatar-controls input[type="range"] { width: 100%; accent-color: var(--accent); }
.avatar-controls p { color: var(--muted); line-height: 1.5; }
.status-line { min-height: 20px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.setting-list { border-top: 1px solid var(--line); }
.setting-row { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.setting-row > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.setting-row strong { font-size: 14px; }
.setting-row span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 46px; display: block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: absolute; inset: 0; display: block; border: 1px solid #405064; border-radius: 999px; background: #263343; transition: background .18s ease,border-color .18s ease; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; display: block; border-radius: 50%; background: #c7d5e0; box-shadow: 0 1px 4px rgba(0,0,0,.35); transition: transform .18s ease,background .18s ease; }
.switch input:checked + .switch-track { background: #1a8fd0; border-color: #44b4f3; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: white; }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(102,192,244,.25); }
.about-brand { display: flex; align-items: center; gap: 22px; padding: 12px 0 28px; }
.about-brand h2 { margin: 0 0 7px; font-size: 30px; }
.about-brand p { margin: 0; color: var(--muted); }
.about-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.about-grid > div { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #111923; }
.about-grid span, .about-grid strong { display: block; }
.about-grid span { color: var(--muted); font-size: 11px; }
.about-grid strong { margin-top: 7px; }

.admin-view { display: grid; grid-template-columns: 230px minmax(0,1fr); min-height: 0; }
.admin-sidebar { min-height: 0; padding: 28px 14px; border-right: 1px solid var(--line); background: #141c26; }
.admin-sidebar header { padding: 0 12px 18px; }
.admin-sidebar h2 { margin: 8px 0 0; }
.admin-sidebar nav { display: grid; gap: 4px; }
.admin-content { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: clamp(20px,3vw,38px); }
.admin-mobile-header { display: none; }
.admin-panel { max-width: 1420px; margin: 0 auto; }
.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.stat-card span, .stat-card strong, .stat-card small { display: block; }
.stat-card span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { margin-top: 9px; font-size: 25px; letter-spacing: -.035em; }
.stat-card small { margin-top: 6px; color: var(--muted); }
.admin-grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.card h3 { margin: 0 0 16px; }
.admin-list { display: grid; gap: 9px; }
.admin-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.admin-row-main { min-width: 0; display: flex; align-items: center; gap: 12px; }
.admin-row-copy { min-width: 0; }
.admin-row-copy strong, .admin-row-copy span { display: block; }
.admin-row-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-copy span { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.admin-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.toolbar-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-inline .search-box { margin: 0; }
.log-list { display: grid; gap: 7px; }
.log-item { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.02); }
.log-item time { color: var(--muted); font-size: 10px; }
.log-copy { min-width: 0; }
.log-copy strong { display: block; font-size: 12px; }
.log-copy span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.log-list.compact .log-item { grid-template-columns: 1fr; }
.cleanup-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.storage-file-list { display: grid; gap: 8px; }
.storage-file-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; }
.storage-file-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.storage-file-row span { color: var(--muted); font-size: 10px; }
.settings-form { max-width: 780px; display: grid; gap: 18px; }

.empty-state { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 26px; text-align: center; color: var(--muted); }
.empty-state.compact { min-height: 240px; }
.empty-state strong { margin-top: 12px; color: var(--text-soft); }
.empty-state p { max-width: 340px; margin: 7px 0 17px; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: rgba(102,192,244,.1); color: var(--accent); font-size: 25px; }
.toast-stack { position: fixed; z-index: 100; top: calc(18px + env(safe-area-inset-top)); right: 18px; width: min(360px,calc(100% - 28px)); display: grid; gap: 9px; pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: rgba(28,40,55,.97); box-shadow: var(--shadow); animation: toastIn .2s ease; }
.toast-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: rgba(102,192,244,.12); color: var(--accent); }
.toast-copy { min-width: 0; }
.toast-copy strong, .toast-copy span { display: block; }
.toast-copy strong { font-size: 12px; }
.toast-copy span { margin-top: 3px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-close { background: transparent; color: var(--muted); font-size: 17px; }

.modal-backdrop { position: fixed; z-index: 110; inset: 0; display: grid; place-items: center; padding: max(16px,env(safe-area-inset-top)) 16px max(16px,env(safe-area-inset-bottom)); background: rgba(4,7,10,.72); backdrop-filter: blur(9px); }
.modal { width: min(620px,100%); max-height: min(760px,calc(var(--app-height) - 32px)); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 16px; background: #18222f; box-shadow: var(--shadow); animation: modalIn .18s ease; }
.modal.modal-wide { width: min(820px,100%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 8px 0 0; font-size: 23px; }
.modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px; }
.modal-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #141d28; }
.modal-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; margin-bottom: 16px; border-radius: 10px; background: #0e151e; }
.modal-tab { min-height: 40px; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 700; }
.modal-tab.active { background: var(--surface); color: var(--text); }
.user-picker { display: grid; gap: 7px; margin-top: 12px; }
.user-picker-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.02); cursor: pointer; }
.user-picker-row:hover { background: rgba(255,255,255,.04); }
.user-picker-row input { accent-color: var(--accent); }
.user-picker-row > div:last-child { min-width: 0; }
.user-picker-row strong { display: block; }
.user-picker-row span { color: var(--muted); font-size: 11px; }
.confirm-copy { color: var(--text-soft); line-height: 1.55; }
.confirm-warning { margin-top: 12px; padding: 12px; border: 1px solid rgba(227,94,99,.25); border-radius: 8px; background: rgba(227,94,99,.08); color: #ff9da1; font-size: 12px; }
.image-lightbox { position: fixed; z-index: 120; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(18px,env(safe-area-inset-top)) 18px max(18px,env(safe-area-inset-bottom)); background: rgba(0,0,0,.92); }
.image-lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; }
.image-lightbox > .icon-button { position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px; }
.image-lightbox > .button { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); }
.mobile-nav { display: none; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes modalIn { from { opacity: 0; transform: scale(.975) translateY(6px); } }
@keyframes messageFlash { 0%,100% { background: rgba(102,192,244,.12); } 45% { background: rgba(102,192,244,.28); } }
body.no-motion *, body.no-motion *::before, body.no-motion *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }

@media (max-width: 1100px) {
  :root { --rail-width: 72px; --sidebar-width: 330px; }
  .rail-button > span:last-of-type, .rail-profile > span { display: none; }
  .rail-button { min-height: 56px; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .admin-grid-two { grid-template-columns: 1fr; }
  .auth-shell { gap: 24px; }
}

@media (max-width: 820px) {
  :root { --mobile-nav-height: 66px; }
  body { background: var(--panel); }
  .mobile-only { display: inline-grid !important; }
  .workspace { display: block; padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  .app-rail { display: none; }
  .app-main { height: calc(var(--app-height) - var(--mobile-nav-height) - env(safe-area-inset-bottom)); }
  .view-chats { display: block; position: relative; }
  .chat-sidebar, .conversation-pane { position: absolute; inset: 0; width: 100%; border: 0; transition: transform .2s ease, opacity .2s ease; }
  .chat-sidebar { z-index: 1; }
  .conversation-pane { z-index: 2; transform: translateX(100%); opacity: 0; pointer-events: none; }
  .view-chats.mobile-conversation-open .chat-sidebar { transform: translateX(-24%); opacity: .3; pointer-events: none; }
  .view-chats.mobile-conversation-open .conversation-pane { transform: none; opacity: 1; pointer-events: auto; }
  .sidebar-header { padding-top: calc(14px + env(safe-area-inset-top)); min-height: calc(80px + env(safe-area-inset-top)); }
  .conversation-header { padding-top: calc(8px + env(safe-area-inset-top)); min-height: calc(68px + env(safe-area-inset-top)); }
  .chat-list { padding-bottom: 20px; }
  .chat-item { min-height: 72px; }
  .conversation-placeholder { display: none; }
  .messages { padding: 16px 10px; }
  .message { grid-template-columns: 34px minmax(0,1fr); gap: 8px; padding-right: 8px; }
  .message-avatar { width: 34px; height: 34px; }
  .message-actions { position: static; opacity: 1; transform: none; margin-top: 5px; justify-content: flex-end; }
  .message-action { width: 28px; height: 26px; }
  .image-attachment img { max-height: 54vh; }
  .file-attachment { min-width: 0; grid-template-columns: 38px minmax(0,1fr) auto; }
  .composer { padding-left: 8px; padding-right: 8px; }
  .composer textarea { font-size: 16px; }
  .jump-to-bottom { right: 12px; bottom: 90px; }
  .mobile-nav { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); padding: 5px 7px env(safe-area-inset-bottom); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; border-top: 1px solid var(--line); background: rgba(17,24,33,.97); backdrop-filter: blur(16px); }
  .mobile-nav-button { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 9px; background: transparent; color: var(--muted); }
  .mobile-nav-button > span { font-size: 20px; line-height: 1; }
  .mobile-nav-button small { font-size: 10px; font-weight: 700; }
  .mobile-nav-button.active { color: var(--accent); background: rgba(102,192,244,.08); }
  .mobile-nav-button .nav-badge { top: 2px; right: 15%; }
  .page-view { padding: calc(18px + env(safe-area-inset-top)) 14px 28px; }
  .page-header { display: block; }
  .page-header > .button { margin-top: 14px; }
  .page-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .page-toolbar .search-box { grid-column: 1/-1; }
  .select-control { min-width: 0; width: 100%; }
  .files-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .file-card-preview { height: 126px; }
  .settings-layout { display: block; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav-button { flex: 0 0 auto; white-space: nowrap; }
  .settings-panel { padding: 17px; }
  .avatar-upload-card { align-items: flex-start; flex-direction: column; }
  .avatar-editor { grid-template-columns: 1fr; }
  .setting-row { min-height: 84px; }
  .about-grid { grid-template-columns: 1fr; }
  .admin-view { display: block; }
  .admin-sidebar { display: none; }
  .admin-content { height: 100%; padding: calc(14px + env(safe-area-inset-top)) 12px 28px; }
  .admin-mobile-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
  .admin-mobile-header h1 { margin: 0; font-size: 23px; }
  .admin-mobile-header .select-control { width: auto; max-width: 190px; }
  .panel-heading { flex-direction: column; }
  .toolbar-inline { width: 100%; }
  .toolbar-inline .search-box { flex: 1; }
  .admin-row { grid-template-columns: 1fr; }
  .admin-row-actions { justify-content: flex-start; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .log-item { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: min(88vh,calc(var(--app-height) - env(safe-area-inset-top))); border-radius: 18px 18px 0 0; border-left: 0; border-right: 0; border-bottom: 0; animation: modalMobileIn .2s ease; }
  .modal-body { padding: 16px; }
  .modal-footer { padding-left: 16px; padding-right: 16px; }
  .toast-stack { top: calc(10px + env(safe-area-inset-top)); right: 10px; width: calc(100% - 20px); }
}

@media (max-width: 560px) {
  .auth-shell { width: 100%; min-height: var(--app-height); display: flex; align-items: center; padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom)); }
  .auth-brand-panel { display: none; }
  .auth-card { max-width: none; padding: 24px 18px; border-radius: 16px; }
  .mobile-auth-logo { display: flex; }
  .auth-card-header h2 { font-size: 27px; }
  .files-grid { grid-template-columns: 1fr; }
  .file-card { display: grid; grid-template-columns: 110px minmax(0,1fr); }
  .file-card-preview { height: 100%; min-height: 120px; }
  .file-card-body { min-width: 0; }
  .avatar-profile { width: 92px; height: 92px; }
  .profile-card { gap: 14px; }
  .button-row.end { justify-content: stretch; }
  .button-row.end .button { flex: 1; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 13px; }
  .stat-card strong { font-size: 21px; }
  .conversation-actions .icon-button:first-child { display: none; }
  .jump-to-bottom span { display: none; }
  .context-bar small { max-width: 230px; }
}

@keyframes modalMobileIn { from { opacity: 0; transform: translateY(24px); } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* Friends Messenger v2.3 interaction polish */
.search-icon-button svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast-stack { z-index: 1300; }
.modal-backdrop { z-index: 1100; }
.image-lightbox { z-index: 1200; }
.toast { pointer-events: auto; }

.messages { padding-left: clamp(12px,3vw,34px); padding-right: clamp(12px,3vw,34px); }
.message { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; margin: 0 0 12px; padding: 0; border-radius: 0; }
.message:hover { background: transparent; }
.message.other { justify-content: flex-start; padding-right: clamp(30px,12vw,160px); }
.message.mine { justify-content: flex-end; padding-left: clamp(30px,12vw,160px); }
.message-body { min-width: 64px; max-width: min(760px,78%); padding: 9px 12px 8px; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; background: #1a2633; box-shadow: 0 3px 12px rgba(0,0,0,.12); }
.message.mine .message-body { order: 2; border-color: rgba(102,192,244,.22); border-radius: 14px 14px 4px 14px; background: linear-gradient(145deg,#245476,#1c405c); }
.message.mine .message-avatar { display: none; }
.message.mine .message-author { display: none; }
.message.mine .message-header { justify-content: flex-end; }
.message.mine .message-status { text-align: right; color: #a9c5d8; }
.message-actions { position: static; align-self: center; display: flex; gap: 3px; opacity: 0; transform: translateY(3px); transition: .14s ease; }
.message.mine .message-actions { order: 1; }
.message.other .message-actions { order: 3; }
.message:hover .message-actions, .message:focus-within .message-actions { opacity: 1; transform: none; }
.message.highlight .message-body { box-shadow: 0 0 0 2px rgba(102,192,244,.38), 0 3px 12px rgba(0,0,0,.12); }
.message-reply-preview { max-width: 100%; }
.message-attachments { max-width: 100%; }
.image-attachment img { max-width: min(560px,70vw); }

.composer { position: relative; grid-template-columns: 42px 42px minmax(0,1fr) 44px; }
.composer textarea { min-height: 44px; max-height: none; overflow-y: hidden; resize: none; scrollbar-width: none; field-sizing: content; }
.composer textarea::-webkit-scrollbar { display: none; }
.emoji-toggle.active { color: white; border-color: rgba(102,192,244,.45); background: rgba(102,192,244,.15); }
.emoji-picker { position: absolute; z-index: 15; left: clamp(54px,calc(2vw + 54px),80px); bottom: calc(100% + 8px); width: min(360px,calc(100vw - 30px)); max-height: 240px; overflow-y: auto; display: grid; grid-template-columns: repeat(8,1fr); gap: 4px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 12px; background: #1a2633; box-shadow: var(--shadow); overscroll-behavior: contain; }
.emoji-item { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; background: transparent; font-size: 22px; }
.emoji-item:hover, .emoji-item:focus-visible { background: rgba(102,192,244,.13); }
.blocked-users-list { display: grid; gap: 9px; }
.blocked-user-row { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.blocked-user-row strong, .blocked-user-row span { display: block; }
.blocked-user-row span { margin-top: 3px; color: var(--muted); font-size: 11px; }

@media (max-width: 820px) {
  .message.other { padding-right: 18px; }
  .message.mine { padding-left: 18px; }
  .message-body { max-width: 84%; }
  .message-actions { opacity: 1; transform: none; }
  .emoji-picker { left: 8px; right: 8px; bottom: calc(100% + 6px); width: auto; grid-template-columns: repeat(7,1fr); }
}
@media (max-width: 560px) {
  .conversation-actions .icon-button:first-child { display: inline-grid; }
  .message.other { padding-right: 8px; }
  .message.mine { padding-left: 8px; }
  .message-body { max-width: 88%; padding: 8px 10px 7px; }
  .message-avatar { width: 31px; height: 31px; }
  .message-actions { gap: 2px; }
  .message-action { width: 27px; height: 27px; }
  .composer { grid-template-columns: 40px 40px minmax(0,1fr) 42px; gap: 6px; }
  .composer-button, .composer-send { width: 40px; height: 40px; }
  .emoji-picker { grid-template-columns: repeat(6,1fr); max-height: min(260px,38vh); }
  .blocked-user-row { grid-template-columns: 36px minmax(0,1fr); }
  .blocked-user-row .button { grid-column: 1/-1; width: 100%; }
}



/* Friends Messenger v2.3 fixes */
.emoji-toggle svg { width: 21px; height: 21px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transform: none; }
.message-reply-preview { width: 100%; min-width: 0; display: grid; grid-template-columns: 3px minmax(0,1fr) 18px; align-items: center; gap: 8px; margin: 0 0 7px; padding: 7px 8px 7px 7px; overflow: hidden; border: 1px solid rgba(102,192,244,.15); border-radius: 9px; background: rgba(5,13,20,.28); color: inherit; text-align: left; }
.message-reply-preview:hover { background: rgba(102,192,244,.09); border-color: rgba(102,192,244,.28); }
.message-reply-accent { align-self: stretch; width: 3px; border-radius: 999px; background: var(--accent); }
.message-reply-copy { min-width: 0; display: block; }
.message-reply-copy strong, .message-reply-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-reply-copy strong { color: var(--accent); font-size: 11px; line-height: 1.2; }
.message-reply-copy span { margin-top: 3px; color: var(--text-soft); font-size: 12px; line-height: 1.25; }
.message-reply-preview svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.message.mine .message-reply-preview { background: rgba(7,24,36,.27); border-color: rgba(255,255,255,.12); }
.message.mine .message-reply-copy strong { color: #a9ddfb; }
.message.mine .message-reply-copy span { color: #d8e8f2; }
@media (max-width: 820px) { .composer { padding-bottom: 10px; } }
html.ios-standalone, html.ios-standalone body, html.ios-standalone .app-root, html.ios-standalone .workspace { min-height: -webkit-fill-available; }
html.ios-standalone .mobile-nav { padding-bottom: max(env(safe-area-inset-bottom), 5px); }
html.ios-standalone .composer { padding-bottom: 10px; }

/* Friends Messenger v2.4 — mobile palette and attachment source menu */
.attachment-toggle.active { color: white; border-color: rgba(102,192,244,.45); background: rgba(102,192,244,.15); }
.attachment-menu { position: absolute; z-index: 16; left: clamp(12px,2vw,24px); bottom: calc(100% + 8px); width: 285px; display: grid; gap: 4px; padding: 7px; border: 1px solid var(--line-strong); border-radius: 13px; background: #202b3b; box-shadow: var(--shadow); }
.attachment-menu > button { width: 100%; min-height: 58px; display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; background: transparent; color: var(--text); text-align: left; }
.attachment-menu > button:hover, .attachment-menu > button:focus-visible { background: var(--surface-hover); }
.attachment-menu > button > span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.attachment-menu strong { font-size: 13px; }
.attachment-menu small { color: var(--muted); font-size: 11px; }
.attachment-source-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; background: rgba(102,192,244,.1); color: var(--accent); }
.attachment-source-icon svg { width: 21px; height: 21px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 820px) {
  body { background: var(--bg); }
  .workspace { background: radial-gradient(circle at 85% 0%, rgba(27,95,145,.12), transparent 34%), var(--bg); }
  .app-main { background: transparent; }
  .chat-sidebar { background: linear-gradient(180deg,#182433 0%,#151d27 100%); }
  .conversation-pane { background: radial-gradient(circle at 50% -20%,rgba(43,103,145,.18),transparent 44%),#101720; }
  .mobile-nav { background: rgba(21,29,39,.97); }
  .page-view, .admin-content { background: transparent; }
  .attachment-menu { position: fixed; left: 10px; right: 10px; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 10px); width: auto; max-width: none; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; padding: 8px; border-radius: 15px; background: rgba(32,43,59,.98); backdrop-filter: blur(18px); }
  .attachment-menu > button { min-width: 0; min-height: 86px; grid-template-columns: 1fr; justify-items: center; gap: 7px; padding: 9px 5px; text-align: center; }
  .attachment-menu > button > span:last-child { align-items: center; }
  .attachment-menu small { display: none; }
}
@media (max-width: 420px) {
  .attachment-menu { left: 7px; right: 7px; gap: 4px; }
  .attachment-menu > button { min-height: 80px; }
  .attachment-source-icon { width: 36px; height: 36px; }
}


/* Friends Messenger v2.5 — voice messages */
.voice-toggle svg { width: 21px; height: 21px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.voice-toggle.active { color: #ff7d7d; border-color: rgba(255,100,100,.45); background: rgba(255,90,90,.12); }
.voice-panel { margin: 0 clamp(12px,2vw,24px) 7px; min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: #172230; box-shadow: 0 8px 28px rgba(0,0,0,.16); }
.voice-recording-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.voice-recording-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #ff5e65; box-shadow: 0 0 0 5px rgba(255,94,101,.12); animation: voicePulse 1.2s ease-in-out infinite; }
.voice-recording.paused .voice-recording-dot { animation: none; opacity: .45; }
.voice-recording-time { min-width: 42px; color: #ff9ca1; font-variant-numeric: tabular-nums; }
.voice-live-waveform, .voice-waveform, .voice-bars { min-width: 0; display: flex; align-items: center; gap: 2px; height: 34px; overflow: hidden; }
.voice-live-waveform { flex: 1; }
.voice-live-waveform i, .voice-waveform i, .voice-bars i { width: 3px; min-height: 4px; height: calc(5px + var(--voice-level) * 25px); flex: 1 1 3px; max-width: 5px; border-radius: 99px; background: currentColor; opacity: .72; }
.voice-live-waveform { color: #78c9f7; }
.voice-panel-actions { display: flex; align-items: center; gap: 7px; }
.voice-draft-main { flex: 1; min-width: 0; }
.voice-draft-main .voice-waveform { color: var(--accent); }
.voice-draft-main > span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.voice-round-button, .voice-play { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(180deg,#31a9ed,#167bb9); color: white; font-size: 14px; }
.voice-player { position: relative; width: min(470px,100%); min-height: 58px; display: grid; grid-template-columns: 40px minmax(110px,1fr) auto auto auto auto; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(135deg,rgba(36,54,75,.92),rgba(25,37,52,.92)); }
.message.mine .voice-player { background: linear-gradient(135deg,rgba(30,83,116,.64),rgba(24,55,77,.78)); border-color: rgba(102,192,244,.28); }
.voice-player.playing { border-color: rgba(102,192,244,.5); }
.voice-track { position: relative; min-width: 0; height: 38px; display: flex; align-items: center; }
.voice-bars { position: absolute; inset: 0; color: #6d8299; pointer-events: none; }
.voice-player.playing .voice-bars { color: #6d8299; }
.voice-bars i.played { background: var(--accent); opacity: .98; box-shadow: 0 0 5px rgba(102,192,244,.18); }
.voice-seek { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.voice-time { min-width: 36px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.voice-speed { min-width: 34px; height: 27px; border-radius: 7px; background: rgba(255,255,255,.06); color: var(--text-soft); font-size: 10px; font-weight: 800; }
.voice-new-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.voice-player.unlistened .voice-new-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(102,192,244,.1); }
.voice-download { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); text-decoration: none; }
.voice-download:hover { color: white; background: rgba(255,255,255,.06); }
.composer { grid-template-columns: 42px 42px 42px minmax(0,1fr) 44px; }
@keyframes voicePulse { 0%,100%{transform:scale(.9);opacity:.75} 50%{transform:scale(1.12);opacity:1} }
@media (max-width: 820px) {
  .voice-panel { margin-left: 8px; margin-right: 8px; flex-wrap: wrap; }
  .voice-recording-main { flex-basis: 100%; }
  .voice-panel-actions { width: 100%; justify-content: flex-end; }
  .voice-player { grid-template-columns: 38px minmax(90px,1fr) auto auto auto; gap: 6px; padding: 7px; }
  .voice-download { display: none; }
  .composer { grid-template-columns: 40px 40px 40px minmax(0,1fr) 42px; }
}
@media (max-width: 430px) {
  .composer { grid-template-columns: 36px 36px 36px minmax(0,1fr) 40px; gap: 5px; }
  .composer-button { width: 36px; height: 40px; }
  .voice-player { grid-template-columns: 36px minmax(72px,1fr) auto auto; }
  .voice-new-dot { display: none; }
  .voice-panel-actions .button { padding-left: 9px; padding-right: 9px; }
}



/* Friends Messenger v2.5.1 — voice progress and reply navigation */
.message.jump-target .message-body { animation: fmMessageJump 1.85s ease; }
@keyframes fmMessageJump {
  0%,100% { box-shadow: 0 3px 12px rgba(0,0,0,.12); }
  18%,55% { box-shadow: 0 0 0 3px rgba(102,192,244,.62), 0 0 24px rgba(102,192,244,.2); }
}
.message.mine.jump-target .message-body { animation-name: fmMessageJumpMine; }
@keyframes fmMessageJumpMine {
  0%,100% { box-shadow: 0 3px 12px rgba(0,0,0,.12); }
  18%,55% { box-shadow: 0 0 0 3px rgba(168,222,255,.7), 0 0 24px rgba(102,192,244,.25); }
}


/* Friends Messenger v3.0 — audio, video and screen-sharing calls */
.call-header-button svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.conversation-join-call { white-space: nowrap; }
.call-layer { position: fixed; inset: 0; z-index: 1450; display: grid; place-items: center; padding: max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); background: rgba(4,8,13,.82); backdrop-filter: blur(18px); }
.incoming-call { width: min(430px,100%); padding: 34px 28px 28px; display: flex; flex-direction: column; align-items: center; text-align: center; border: 1px solid rgba(102,192,244,.28); border-radius: 24px; background: linear-gradient(150deg,#1a2634,#101821); box-shadow: 0 28px 90px rgba(0,0,0,.5); }
.incoming-call-avatar { width: 104px; height: 104px; margin-bottom: 22px; font-size: 28px; box-shadow: 0 0 0 8px rgba(102,192,244,.08),0 14px 40px rgba(0,0,0,.28); animation: callAvatarPulse 1.7s ease-in-out infinite; }
.incoming-call h2 { margin: 9px 0 7px; font-size: 29px; }
.incoming-call p { min-height: 22px; margin: 0; color: var(--muted); }
.incoming-call-actions { display: flex; justify-content: center; gap: 44px; margin-top: 31px; }
.call-round-control,.call-control { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-soft); background: transparent; font-size: 11px; font-weight: 750; }
.call-round-control svg,.call-control svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.call-round-control svg { width: 60px; height: 60px; padding: 16px; border-radius: 50%; color: white; }
.call-control-accept svg { background: #43ad65; box-shadow: 0 9px 26px rgba(67,173,101,.3); }
.call-control-danger svg { background: #d95056; color: white; }
.call-window { width: min(1240px,100%); height: min(820px,100%); min-height: 480px; display: grid; grid-template-rows: auto minmax(0,1fr) auto; overflow: hidden; border: 1px solid rgba(255,255,255,.11); border-radius: 22px; background: #0b1118; box-shadow: 0 30px 100px rgba(0,0,0,.58); }
.call-window-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #141d27; }
.call-window-header h2 { margin: 5px 0 3px; font-size: 22px; }
.call-window-header p { margin: 0; color: var(--muted); font-size: 12px; }
.call-status-dot { margin: 0 7px; }
.call-participants { min-height: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); grid-auto-rows: minmax(0,1fr); gap: 8px; padding: 8px; background: radial-gradient(circle at 50% 0,rgba(36,81,116,.18),transparent 44%),#090e14; }
.call-participants.count-1 { grid-template-columns: 1fr; }
.call-participants.count-3 .call-tile:first-child { grid-row: 1 / span 2; }
.call-participants.has-screen { grid-template-columns: minmax(0,2.25fr) minmax(220px,.75fr); grid-template-rows: repeat(3,minmax(0,1fr)); }
.call-participants.has-screen .screen-tile { grid-row: 1 / -1; grid-column: 1; }
.call-tile { position: relative; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.075); border-radius: 13px; background: linear-gradient(145deg,#1b2837,#111923); }
.call-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s ease; }
.call-tile.has-video video { opacity: 1; }
.call-tile.screen-tile video { object-fit: contain; background: #05080c; }
.call-tile-placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.call-tile.has-video .call-tile-placeholder { opacity: 0; }
.call-avatar { width: clamp(74px,12vw,138px); height: clamp(74px,12vw,138px); font-size: clamp(20px,4vw,36px); box-shadow: 0 16px 44px rgba(0,0,0,.32); }
.call-tile-footer { position: absolute; z-index: 2; left: 10px; right: 10px; bottom: 9px; min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 1px 8px; padding: 8px 10px; border-radius: 9px; background: rgba(4,8,12,.64); backdrop-filter: blur(10px); }
.call-tile-footer strong,.call-tile-footer span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-tile-footer strong { font-size: 12px; }
.call-tile-footer span { color: #a9b6c5; font-size: 10px; }
.call-mic-state { grid-row: 1 / span 2; grid-column: 2; color: #69ca7f; font-style: normal; }
.call-mic-state.off { color: #ff777c; }
.call-tile.connection-failed { border-color: rgba(255,94,101,.55); }
.call-controls { min-height: 96px; display: flex; align-items: center; justify-content: center; gap: clamp(9px,2.2vw,28px); padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #141d27; }
.call-control { min-width: 74px; }
.call-control svg { width: 48px; height: 48px; padding: 12px; border-radius: 50%; background: rgba(255,255,255,.075); color: white; }
.call-control:hover svg { background: rgba(255,255,255,.13); }
.call-control.off svg { background: #d95056; }
.call-control.active svg { background: #238bc7; }
.call-control-danger svg { background: #d95056; transform: rotate(0deg); }
.call-mini { position: fixed; z-index: 1440; right: max(16px,env(safe-area-inset-right)); bottom: max(18px,calc(env(safe-area-inset-bottom) + 12px)); width: min(390px,calc(100% - 32px)); min-height: 64px; display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 11px; padding: 10px 13px; border: 1px solid rgba(102,192,244,.32); border-radius: 15px; background: #172331; color: var(--text); box-shadow: 0 16px 50px rgba(0,0,0,.42); text-align: left; }
.call-mini > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.call-mini strong,.call-mini small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-mini small { color: var(--muted); }
.call-mini-pulse { width: 12px; height: 12px; border-radius: 50%; background: #60c378; box-shadow: 0 0 0 6px rgba(96,195,120,.12); animation: callMiniPulse 1.4s ease-in-out infinite; }
.call-mini > b { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.call-mini-open { color: var(--muted); font-size: 10px; }
@keyframes callAvatarPulse { 0%,100%{transform:scale(.97)} 50%{transform:scale(1.025)} }
@keyframes callMiniPulse { 0%,100%{opacity:.55} 50%{opacity:1} }
@media (max-width: 820px) {
  .conversation-actions { gap: 4px; }
  .conversation-actions .icon-button { width: 34px; height: 36px; }
  .conversation-join-call { position: absolute; left: 50%; bottom: -36px; transform: translateX(-50%); z-index: 4; }
  .call-layer { padding: 0; background: #090e14; }
  .call-window { width: 100%; height: var(--app-height,100dvh); min-height: 0; border: 0; border-radius: 0; }
  .call-window-header { padding-top: max(12px,env(safe-area-inset-top)); }
  .call-participants { grid-template-columns: 1fr 1fr; }
  .call-participants.count-1 { grid-template-columns: 1fr; }
  .call-participants.count-3 .call-tile:first-child { grid-column: 1 / -1; grid-row: auto; }
  .call-participants.has-screen { grid-template-columns: 1fr; grid-template-rows: minmax(0,2.5fr) repeat(3,minmax(92px,.55fr)); overflow-y: auto; }
  .call-participants.has-screen .screen-tile { grid-row: auto; grid-column: auto; min-height: 54vh; }
  .call-controls { gap: 9px; min-height: 88px; padding-left: 8px; padding-right: 8px; }
  .call-control { min-width: 59px; }
  .call-control svg { width: 44px; height: 44px; }
  .call-control span { font-size: 9px; }
  .incoming-call { width: 100%; min-height: var(--app-height,100dvh); justify-content: center; border: 0; border-radius: 0; padding-bottom: calc(34px + env(safe-area-inset-bottom)); }
}
@media (max-width: 480px) {
  .conversation-actions .search-icon-button { display: none; }
  .call-participants { grid-template-columns: 1fr; overflow-y: auto; }
  .call-tile { min-height: 180px; }
  .call-participants.count-3 .call-tile:first-child { grid-column: auto; }
  .call-controls { justify-content: space-around; }
  .call-control { min-width: 52px; }
  .call-control svg { width: 42px; height: 42px; padding: 11px; }
  .call-mini-open { display: none; }
}
