/* =====================================================================
   PrivChat design system
   - One set of tokens (colour, type, radius, shadow, motion) drives every component.
   - Theme (dark/light), accent colour and text size are attributes on <html>, set before
     first paint by theme-boot.js and persisted in localStorage.
   - Layouts: phone (<=760px), tablet (761-1199px), desktop (>=1200px, with details panel).
   ===================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px; --r-full: 999px;
  --ease: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.2, .9, .3, 1.25);
  --t-fast: .14s; --t: .22s; --t-slow: .38s;
  --head-h: 62px;
  --sb-w: 360px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);

  --danger: #ff5c7a; --ok: #34d399; --warn: #fbbf24;
  --accent: #7c5cff; --accent-2: #a35cff;
}

/* accent palettes */
[data-accent="violet"] { --accent: #7c5cff; --accent-2: #a35cff; }
[data-accent="blue"]   { --accent: #3b82f6; --accent-2: #6366f1; }
[data-accent="teal"]   { --accent: #0fb5a6; --accent-2: #0ea5e9; }
[data-accent="green"]  { --accent: #22b45e; --accent-2: #10b981; }
[data-accent="pink"]   { --accent: #ec4899; --accent-2: #f43f5e; }
[data-accent="orange"] { --accent: #f97316; --accent-2: #f59e0b; }

/* dark theme (default) */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d14; --panel: #0f131c; --surface: #151a25; --surface-2: #1b2130; --surface-3: #252c3d;
  --border: #1f2635; --border-2: #2c3447;
  --text: #e9edf5; --text-2: #a4adc2; --text-3: #6f7891;
  --peer: #1b2131; --peer-text: #e9edf5; --chat-bg: #0b0f17;
  --overlay: rgba(4, 6, 12, .64);
  --sh-1: 0 1px 2px rgba(0,0,0,.3); --sh-2: 0 10px 30px rgba(0,0,0,.38); --sh-3: 0 30px 80px rgba(0,0,0,.55);
  --sh-bubble: 0 1px 1px rgba(0,0,0,.25);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f7; --panel: #ffffff; --surface: #ffffff; --surface-2: #f2f4f9; --surface-3: #e7eaf3;
  --border: #e4e8f0; --border-2: #d4dae6;
  --text: #0f1422; --text-2: #5a6378; --text-3: #8b93a7;
  --peer: #ffffff; --peer-text: #0f1422; --chat-bg: #f1f3f8;
  --overlay: rgba(15, 20, 34, .38);
  --sh-1: 0 1px 2px rgba(20,30,60,.08); --sh-2: 0 10px 30px rgba(20,30,60,.12); --sh-3: 0 30px 80px rgba(20,30,60,.22);
  --sh-bubble: 0 1px 1px rgba(20,30,60,.08);
}

/* tokens derived from the accent; re-declared on .celebrating so festival colours flow through */
:root, .celebrating {
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent) 38%, transparent);
  --accent-fg: color-mix(in srgb, var(--accent) 72%, #ffffff);
  --own: linear-gradient(135deg, var(--accent), var(--accent-2));
  --own-text: #ffffff;
}
[data-theme="light"] { --accent-fg: color-mix(in srgb, var(--accent) 86%, #000000); }

/* text size (everything typographic is in rem) */
html { font-size: 15px; }
html[data-font="small"] { font-size: 14px; }
html[data-font="large"] { font-size: 16.5px; }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 1rem; line-height: 1.42; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; touch-action: manipulation; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-fg); }
img { max-width: 100%; }
svg.ico, .icon-btn svg, .logo svg { width: 22px; height: 22px; display: block; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-ring); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--border-2); }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* overflow is clipped at every level so off-screen panels (the phone slide-over chat) never widen the page */
html { overflow: hidden; }
#app { height: var(--vvh, 100dvh); width: 100%; position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow: hidden; }
.main-screen { overflow: hidden; }

/* ---------------------------------------------------------------- primitives */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border-radius: var(--r-md); font-weight: 600; font-size: .95rem; background: var(--surface-2); color: var(--text);
  border: 1px solid transparent; transition: transform var(--t-fast) var(--ease), filter var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--own); color: #fff; box-shadow: 0 6px 18px var(--accent-ring); }
.btn.primary:hover { box-shadow: 0 10px 26px var(--accent-ring); transform: translateY(-1px); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
.link { color: var(--accent-fg); font-weight: 600; font-size: .9rem; }
.link:hover { text-decoration: underline; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-full); display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); flex: none; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.active { color: var(--accent-fg); background: var(--accent-soft); }

.muted { color: var(--text-2); }
.small { font-size: .82rem; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: 1px 6px; border-radius: var(--r-xs); }
.kbd { display: inline-block; min-width: 22px; text-align: center; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-2); border-bottom-width: 2px; background: var(--surface-2); font-size: .75rem; font-weight: 600; color: var(--text-2); }

input[type="text"], input[type="password"], input[type="search"], input:not([type]), textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 14px;
  outline: none; color: var(--text); font-size: .95rem; transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1); opacity: .6; }
label { display: block; font-size: .82rem; color: var(--text-2); font-weight: 600; }
label input, label textarea, label select { margin-top: 6px; font-weight: 400; }
label small { display: block; margin-top: 6px; font-weight: 400; color: var(--text-3); font-size: .78rem; }

/* toggle rows */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); font-weight: 500; font-size: .95rem; color: var(--text); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch small { display: block; color: var(--text-3); font-weight: 400; font-size: .8rem; margin-top: 2px; }
.switch input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--surface-3); position: relative; flex: none; margin: 0; cursor: pointer; transition: background var(--t) var(--ease); border: 0; padding: 0; box-shadow: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform var(--t) var(--ease-spring); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }

/* segmented controls & tabs share one look */
.tabs, .seg { display: flex; background: var(--surface-2); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.tabs button, .seg button { flex: 1; min-height: 36px; padding: 0 10px; border-radius: var(--r-sm); font-weight: 600; font-size: .88rem; color: var(--text-2); transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.tabs button:hover, .seg button:hover { color: var(--text); }
.tabs button.active, .seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1), 0 0 0 1px var(--border); }

.chips { display: flex; gap: 6px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { min-height: 30px; padding: 0 14px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); font-size: .82rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; transition: all var(--t-fast); }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent-soft); color: var(--accent-fg); border-color: var(--accent-ring); }
.chip .n { margin-left: 6px; font-size: .72rem; opacity: .8; }

.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex: none; display: block; }
.avatar.sm { width: 38px; height: 38px; }
.avatar.lg { width: 92px; height: 92px; }
.avatar.xl { width: 112px; height: 112px; }

.callout { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text); padding: 11px 14px; border-radius: var(--r-md); font-size: .88rem; }
.callout.info { background: var(--accent-soft); border-color: var(--accent-ring); }

.logo { width: 56px; height: 56px; border-radius: 18px; background: var(--own); display: grid; place-items: center; color: #fff; box-shadow: 0 10px 30px var(--accent-ring); }
.logo svg { width: 28px; height: 28px; }
.logo.big { width: 88px; height: 88px; border-radius: 28px; }
.logo.big svg { width: 42px; height: 42px; }

.boot { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 22px; background: var(--bg); z-index: 50; }
.boot .logo { animation: logo-float 3s ease-in-out infinite; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }

.toast { position: fixed; left: 50%; bottom: calc(28px + var(--sab)); transform: translateX(-50%); background: var(--surface-3); color: var(--text); padding: 12px 18px; border-radius: var(--r-md); box-shadow: var(--sh-2); z-index: 400; max-width: min(92vw, 460px); font-size: .9rem; font-weight: 500; animation: toast-in var(--t) var(--ease-spring); border: 1px solid var(--border-2); }
.toast.error { background: var(--danger); color: #fff; border-color: transparent; }
.toast.ok { background: var(--ok); color: #04281a; border-color: transparent; }

/* ---------------------------------------------------------------- auth */
.auth-screen { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(400px, .9fr); overflow: auto; background: var(--bg); }
.auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: 56px clamp(32px, 6vw, 88px); color: #fff;
  background: radial-gradient(900px 600px at 0% 0%, color-mix(in srgb, var(--accent-2) 55%, transparent), transparent 60%), radial-gradient(800px 600px at 100% 100%, color-mix(in srgb, var(--accent) 70%, transparent), transparent 60%), #0c0a1d; }
.auth-hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth-hero > * { position: relative; z-index: 1; }
.brand-row { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.3rem; letter-spacing: -.3px; margin-bottom: 48px; }
.brand-row .logo { width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.14); box-shadow: none; border: 1px solid rgba(255,255,255,.2); }
.brand-row .logo svg { width: 22px; height: 22px; }
.auth-hero h2 { font-size: clamp(2rem, 3.2vw, 3rem); line-height: 1.08; letter-spacing: -1px; margin: 0 0 16px; max-width: 560px; }
.auth-hero p { font-size: 1.05rem; opacity: .82; max-width: 520px; margin: 0 0 36px; }
.hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; max-width: 520px; }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-lg); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(6px); animation: fade-in .5s var(--ease) both; }
.hero-points li:nth-child(2) { animation-delay: .07s; } .hero-points li:nth-child(3) { animation-delay: .14s; } .hero-points li:nth-child(4) { animation-delay: .21s; }
.hero-points svg { width: 22px; height: 22px; flex: none; margin-top: 2px; opacity: .9; }
.hero-points b { display: block; font-size: .98rem; }
.hero-points span { font-size: .88rem; opacity: .8; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; min-height: 100%; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 30px 28px 24px; box-shadow: var(--sh-2); animation: rise .45s var(--ease) both; }
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo { margin: 0 auto; animation: logo-float 4s ease-in-out infinite; }
.brand h1 { margin: 14px 0 4px; font-size: 1.7rem; letter-spacing: -.5px; }
.brand p { margin: 0; color: var(--text-2); font-size: .92rem; }
.auth-card .tabs { margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form h3 { margin: 0; font-size: 1.1rem; }
.auth-form .btn.primary { min-height: 48px; margin-top: 4px; font-size: 1rem; }
.auth-msg { min-height: 20px; margin: 14px 0 0; color: var(--danger); font-size: .88rem; text-align: center; }
.auth-msg.ok { color: var(--ok); }
.auth-foot { margin: 14px 0 0; color: var(--text-3); font-size: .78rem; text-align: center; display: flex; gap: 8px; align-items: center; justify-content: center; }
.auth-foot svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- app shell */
.main-screen { --sb-cols: clamp(280px, var(--sb-w), 44vw); display: grid; grid-template-columns: var(--sb-cols) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); background: var(--bg); }
.sidebar, .chat, .details, .conv-list, .details-body, .chat-view { min-height: 0; }

.sidebar { position: relative; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--border); min-width: 0; padding-top: var(--sat); padding-left: var(--sal); }
.sb-head { display: flex; align-items: center; gap: 6px; height: var(--head-h); padding: 0 10px 0 14px; flex: none; }
.avatar-btn { flex: none; border-radius: 50%; position: relative; }
.avatar-btn img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: block; box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent-ring); transition: box-shadow var(--t); }
.avatar-btn:hover img { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.sb-title { flex: 1; min-width: 0; line-height: 1.2; margin-left: 6px; }
.sb-title strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-title span { color: var(--text-3); font-size: .78rem; }
.sb-search { position: relative; padding: 2px 14px 10px; flex: none; }
.sb-search svg { position: absolute; left: 27px; top: 50%; margin-top: -5px; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.sb-search input { padding-left: 40px; height: 42px; border-radius: var(--r-full); background: var(--surface-2); border-color: transparent; }
.sb-search input:focus { border-color: var(--accent); }
.banner { margin: 0 14px 10px; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); font-size: .82rem; text-align: center; padding: 7px; border-radius: var(--r-sm); font-weight: 600; flex: none; }
.install-banner { margin: 0 14px 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent-ring); display: flex; align-items: center; gap: 10px; font-size: .88rem; animation: rise .3s var(--ease); flex: none; }
.install-banner .ic { width: 36px; height: 36px; border-radius: 11px; background: var(--own); display: grid; place-items: center; color: #fff; flex: none; }
.install-banner .ic svg { width: 18px; height: 18px; }
.install-banner .t { flex: 1; min-width: 0; }
.install-banner .t small { display: block; color: var(--text-2); font-size: .78rem; }
.install-banner .btn { min-height: 32px; padding: 0 12px; font-size: .82rem; }

.conv-list { flex: 1; overflow-y: auto; padding: 2px 8px 90px; overscroll-behavior: contain; }
.conv { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px; border-radius: var(--r-md); text-align: left; position: relative; transition: background var(--t-fast); animation: fade-in .28s var(--ease) both; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
.conv.active::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--accent); }
.conv .av { position: relative; flex: none; }
.conv .dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 2.5px solid var(--panel); display: none; }
.conv.online .dot { display: block; animation: pulse-dot 2.4s ease-in-out infinite; }
.conv.active .dot { border-color: var(--surface); }
.conv .body { flex: 1; min-width: 0; }
.conv .top, .conv .bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv .name { font-weight: 600; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { color: var(--text-3); font-size: .74rem; flex: none; }
.conv.unread .time { color: var(--accent-fg); font-weight: 600; }
.conv .bottom { margin-top: 3px; }
.conv .preview { flex: 1; min-width: 0; color: var(--text-2); font-size: .87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.conv .preview svg { width: 15px; height: 15px; flex: none; }
.conv .preview .muted { color: var(--text-3); }
.conv .preview .draft { color: var(--danger); font-weight: 600; }
.conv .preview .typing-txt { color: var(--ok); font-style: italic; }
.conv.unread .preview { color: var(--text); font-weight: 500; }
.conv .flags { display: flex; align-items: center; gap: 5px; flex: none; }
.conv .flags svg { width: 15px; height: 15px; color: var(--text-3); }
.conv .badge { background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; animation: pop-in .3s var(--ease-spring); }
.conv.muted-conv .badge { background: var(--text-3); }
.conv-empty { padding: 48px 24px; text-align: center; color: var(--text-2); display: grid; justify-items: center; gap: 14px; }
.conv-empty p { margin: 0; }
.conv-empty p b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }
.empty-ic { width: 64px; height: 64px; border-radius: 22px; background: var(--accent-soft); color: var(--accent-fg); display: grid; place-items: center; }
.empty-ic svg { width: 30px; height: 30px; }
.conv-list .none { text-align: center; color: var(--text-3); font-size: .88rem; padding: 30px 10px; }

.fab { display: none; position: absolute; right: calc(18px + var(--sar)); bottom: calc(20px + var(--sab)); width: 58px; height: 58px; border-radius: 20px; background: var(--own); color: #fff; place-items: center; box-shadow: 0 12px 30px var(--accent-ring), var(--sh-2); z-index: 3; transition: transform var(--t) var(--ease-spring); }
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(.92); }

.sb-resizer { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 6; }
.sb-resizer::after { content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background var(--t-fast); }
.sb-resizer:hover::after, .resizing .sb-resizer::after { background: var(--accent); }
.resizing, .resizing * { cursor: col-resize !important; user-select: none !important; }

/* ---------------------------------------------------------------- chat pane */
.chat { display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--chat-bg); }
.chat-empty { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px; color: var(--text-2); gap: 4px; }
.empty-art { position: relative; margin-bottom: 18px; }
.empty-art::before { content: ""; position: absolute; inset: -40px; border-radius: 50%; background: radial-gradient(circle, var(--accent-soft), transparent 70%); }
.empty-art .logo { position: relative; animation: logo-float 5s ease-in-out infinite; }
.chat-empty h2 { color: var(--text); margin: 0 0 6px; font-size: 1.45rem; letter-spacing: -.3px; }
.chat-empty p { margin: 0; max-width: 400px; }
.feature-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0 6px; }
.feature-chips span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--border); font-size: .82rem; color: var(--text-2); }
.feature-chips svg { width: 15px; height: 15px; color: var(--accent-fg); }
.chat-empty .hint { margin-top: 14px; font-size: .8rem; color: var(--text-3); }

.chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 4px; height: calc(var(--head-h) + var(--sat)); padding: var(--sat) calc(10px + var(--sar)) 0 10px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--border); flex: none; z-index: 4; }
.chat-head .back { display: none; }
.peer-btn { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; text-align: left; padding: 6px 8px; border-radius: var(--r-md); transition: background var(--t-fast); }
.peer-btn:hover { background: var(--surface-2); }
.peer-btn img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex: none; }
.peer-text { min-width: 0; line-height: 1.25; }
.peer-text strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-text span { color: var(--text-3); font-size: .8rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--t); }
.peer-text span.online { color: var(--ok); }
.msg-search { display: flex; gap: 6px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border); flex: none; animation: slide-down var(--t) var(--ease); }
.msg-search > svg { width: 18px; height: 18px; color: var(--text-3); margin-left: 4px; }
.msg-search input { flex: 1; padding: 8px 12px; border-radius: var(--r-full); }
.msg-search span { color: var(--text-3); font-size: .82rem; min-width: 44px; text-align: center; }

.messages-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px clamp(12px, 3.5vw, 40px) 10px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; background: var(--chat-bg); transition: background var(--t-slow); }
.messages::before { content: ""; flex: 1; }
.messages > * { width: 100%; max-width: 920px; margin-left: auto; margin-right: auto; }
.messages > .msg { width: auto; max-width: min(72%, 620px); margin-left: 0; margin-right: 0; }
.messages > .msg.own { margin-left: auto; }
@media (min-width: 1500px) { .messages > .msg { max-width: 620px; } .messages > .msg:not(.own) { margin-left: max(0px, calc((100% - 920px) / 2)); } .messages > .msg.own { margin-right: max(0px, calc((100% - 920px) / 2)); } }

/* wallpapers (class added to .messages; also used for the settings swatches) */
.wp-dusk { background: linear-gradient(160deg, #1b1035, #2a1b4a 60%, #121a33) !important; }
.wp-ocean { background: linear-gradient(160deg, #081a2c, #0d3b4f 60%, #0b2a3a) !important; }
.wp-forest { background: linear-gradient(160deg, #0b2017, #16402a 60%, #0f2b20) !important; }
.wp-rose { background: linear-gradient(160deg, #33101f, #5a1a3a 60%, #2a0f1f) !important; }
.wp-dots { background-color: var(--chat-bg) !important; background-image: radial-gradient(color-mix(in srgb, var(--text-3) 35%, transparent) 1px, transparent 1px) !important; background-size: 18px 18px !important; }
.wp-aurora { background: radial-gradient(700px 400px at 10% 0%, var(--accent-soft), transparent 70%), radial-gradient(600px 400px at 100% 100%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%), var(--chat-bg) !important; }
[data-theme="light"] .wp-dusk { background: linear-gradient(160deg, #e9e3ff, #f3eeff 60%, #e4ecff) !important; }
[data-theme="light"] .wp-ocean { background: linear-gradient(160deg, #dbf1ff, #e8f8ff 60%, #d5efff) !important; }
[data-theme="light"] .wp-forest { background: linear-gradient(160deg, #e0f4e6, #edf9f1 60%, #d9f1e1) !important; }
[data-theme="light"] .wp-rose { background: linear-gradient(160deg, #ffe2ec, #fff0f5 60%, #ffdde8) !important; }

.day-sep { position: sticky; top: 8px; z-index: 2; align-self: center; width: auto !important; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); color: var(--text-2); font-size: .74rem; font-weight: 600; padding: 4px 12px; border-radius: var(--r-full); margin: 12px auto 8px !important; box-shadow: var(--sh-1); border: 1px solid var(--border); }
.sys-note { align-self: center; width: auto !important; max-width: min(88%, 460px) !important; text-align: center; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border); color: var(--text-2); font-size: .8rem; padding: 8px 14px; border-radius: var(--r-md); margin: 10px auto !important; display: flex; gap: 8px; align-items: center; justify-content: center; animation: fade-in .4s both; }
.sys-note svg { width: 15px; height: 15px; flex: none; color: var(--accent-fg); }
.unread-sep { text-align: center; font-size: .76rem; font-weight: 700; color: var(--accent-fg); margin: 12px auto 8px !important; display: flex; align-items: center; gap: 12px; text-transform: uppercase; letter-spacing: .6px; }
.unread-sep::before, .unread-sep::after { content: ""; flex: 1; height: 1px; background: var(--accent-ring); }

/* messages */
.msg { display: flex; flex-direction: column; align-items: flex-start; position: relative; }
.msg.own { align-items: flex-end; }
.msg.grp-start { margin-top: 10px; }
.msg.new { animation: msg-in .3s var(--ease-spring) both; transform-origin: bottom left; }
.msg.own.new { transform-origin: bottom right; }
.bubble {
  position: relative; max-width: 100%; background: var(--peer); color: var(--peer-text); padding: 7px 12px 8px;
  border-radius: var(--r-lg); border-bottom-left-radius: var(--r-xs); font-size: 1rem; line-height: 1.38;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--sh-bubble); transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast);
}
.msg:not(.own):not(.grp-start) .bubble { border-top-left-radius: var(--r-xs); }
.msg.own .bubble { background: var(--own); color: var(--own-text); border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-xs); }
.msg.own:not(.grp-start) .bubble { border-top-right-radius: var(--r-xs); }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble code { background: rgba(0,0,0,.2); }
.msg:not(.own) .bubble code { background: var(--surface-3); }
.bubble svg { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }
.bubble.media { padding: 3px; overflow: hidden; }
.bubble.media .caption { padding: 6px 9px 3px; }
.bubble.emoji-only { background: transparent !important; box-shadow: none; font-size: 2.9rem; line-height: 1.15; padding: 0 2px; }
.bubble.deleted { color: var(--text-3) !important; font-style: italic; background: transparent !important; border: 1px dashed var(--border-2); box-shadow: none; }
.bubble.error { color: var(--danger); font-style: italic; }
.bubble.cel { box-shadow: 0 0 0 2px rgba(255,214,10,.35), 0 8px 22px rgba(255,170,0,.22); }
.bubble .fwd { display: block; font-size: .76rem; opacity: .75; font-style: italic; margin-bottom: 3px; }
.bubble .fwd svg { width: 13px; height: 13px; vertical-align: -2px; }
.msg.highlight .bubble { box-shadow: 0 0 0 3px var(--warn); }
@media (hover: hover) { .msg:hover .bubble:not(.emoji-only):not(.deleted) { box-shadow: var(--sh-2); } }

/* time + ticks live inside the bubble */
.bubble .meta { float: right; position: relative; top: 4px; display: inline-flex; align-items: center; gap: 3px; margin: 6px -3px 0 12px; font-size: .68rem; line-height: 1; font-style: normal; color: var(--text-3); white-space: nowrap; user-select: none; -webkit-user-select: none; }
.msg.own .bubble .meta { color: rgba(255,255,255,.75); }
.bubble .meta svg { width: 15px; height: 15px; vertical-align: 0; }
.bubble .meta .edited { font-style: italic; margin-right: 2px; }
.meta .ticks { display: inline-flex; }
.meta .ticks.read { color: #a5f3fc; }
[data-theme="light"] .msg:not(.own) .meta .ticks.read { color: var(--accent); }
.meta .ticks.sending { opacity: .55; }
.meta .ticks.failed { color: #ffd1da; font-weight: 800; }
.bubble.media .meta { float: none; top: 0; display: flex; justify-content: flex-end; margin: 3px 7px 3px; }
.bubble.overlay-meta .meta { position: absolute; top: auto; right: 9px; bottom: 9px; margin: 0; padding: 4px 8px; border-radius: var(--r-full); background: rgba(0,0,0,.48); color: #fff !important; backdrop-filter: blur(4px); }
.bubble.emoji-only .meta { float: none; top: 0; display: flex; justify-content: flex-end; margin: 0 2px; color: var(--text-3) !important; }
.bubble.deleted .meta { color: var(--text-3) !important; }

.quote { display: block; background: rgba(0,0,0,.16); border-left: 3px solid rgba(255,255,255,.75); border-radius: var(--r-sm); padding: 6px 10px; margin: 2px 0 6px; font-size: .86rem; cursor: pointer; white-space: normal; }
.msg:not(.own) .quote { background: var(--accent-soft); border-left-color: var(--accent); }
.quote strong { display: block; font-size: .78rem; opacity: .9; }
.msg:not(.own) .quote strong { color: var(--accent-fg); }
.quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; opacity: .85; }
.reactions { display: flex; gap: 4px; margin: -7px 8px 3px; flex-wrap: wrap; position: relative; z-index: 1; }
.reaction { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-full); padding: 1px 8px; font-size: .82rem; display: inline-flex; gap: 4px; align-items: center; box-shadow: var(--sh-1); cursor: pointer; animation: pop-in .28s var(--ease-spring); transition: transform var(--t-fast); }
.reaction:active { transform: scale(.9); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }

/* media inside bubbles */
.img-wrap { display: block; position: relative; border-radius: calc(var(--r-lg) - 3px); overflow: hidden; background: var(--surface-3); max-width: 100%; min-width: 140px; min-height: 80px; cursor: zoom-in; }
.img-wrap img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: cover; opacity: 0; transition: opacity var(--t-slow) var(--ease); }
.img-wrap img.loaded { opacity: 1; }
.img-wrap .thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 1; filter: blur(12px); transform: scale(1.15); transition: opacity var(--t-slow); }
.img-wrap .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); font-size: .78rem; font-weight: 600; }
.img-wrap .ph svg { width: 26px; height: 26px; animation: ph-pulse 1.4s ease-in-out infinite; }
.img-wrap .ph small { display: block; margin-top: 4px; }
.gif-wrap img { max-height: 280px; }
.view-card, .file-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 220px; cursor: pointer; border-radius: calc(var(--r-lg) - 3px); }
.view-card .ic, .file-card .ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); flex: none; }
.file-card .ic { border-radius: var(--r-md); }
.msg:not(.own) .view-card .ic, .msg:not(.own) .file-card .ic { background: var(--accent-soft); color: var(--accent-fg); }
.view-card .ic svg, .file-card .ic svg { width: 22px; height: 22px; vertical-align: 0; }
.view-card strong, .file-card strong { display: block; font-size: .92rem; }
.file-card strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.view-card span, .file-card span { font-size: .8rem; opacity: .8; }
.view-card.spent { opacity: .7; cursor: default; }
.audio-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 240px; }
.audio-card .play { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; flex: none; font-size: .8rem; font-weight: 800; }
.msg:not(.own) .audio-card .play { background: var(--accent); color: #fff; }
.audio-card .play svg { width: 18px; height: 18px; vertical-align: 0; margin-left: 2px; }
.audio-card .bar { flex: 1; height: 4px; background: rgba(255,255,255,.3); border-radius: 2px; position: relative; overflow: hidden; }
.msg:not(.own) .audio-card .bar { background: var(--surface-3); }
.audio-card .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: currentColor; border-radius: 2px; }
.audio-card .dur { font-size: .76rem; opacity: .85; min-width: 34px; text-align: right; }

/* gestures & extras */
.msg .swipe-reply { position: absolute; top: 50%; left: -40px; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--accent-fg); display: grid; place-items: center; transform: translateY(-50%) scale(0); transition: transform var(--t-fast); pointer-events: none; }
.msg.own .swipe-reply { left: auto; right: -40px; }
.msg .swipe-reply svg { width: 16px; height: 16px; }
.msg.swiping .bubble { transition: none; }
.heart-pop { position: absolute; left: 50%; top: 50%; font-size: 64px; pointer-events: none; animation: heart-pop .8s var(--ease-spring) forwards; z-index: 3; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.cel-replay { position: absolute; top: -10px; right: -8px; width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #ffd166, #ff7b00); color: #3a2000; font-size: 13px; display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0,0,0,.3); animation: twinkle 1.8s ease-in-out infinite; z-index: 2; }
.msg:not(.own) .cel-replay { right: auto; left: -8px; }

.typing { position: absolute; left: clamp(12px, 3.5vw, 40px); bottom: 10px; background: var(--peer); padding: 11px 14px; border-radius: var(--r-lg); border-bottom-left-radius: var(--r-xs); display: flex; gap: 4px; box-shadow: var(--sh-2); z-index: 3; animation: rise var(--t) var(--ease); }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
.scroll-down { position: absolute; right: clamp(14px, 3vw, 32px); bottom: 14px; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); color: var(--text-2); display: grid; place-items: center; box-shadow: var(--sh-2); z-index: 3; border: 1px solid var(--border); animation: pop-in .25s var(--ease-spring); }
.scroll-down svg { width: 20px; height: 20px; transform: rotate(-90deg); }
.scroll-down:hover { color: var(--text); }

.reply-bar { display: flex; align-items: center; gap: 12px; padding: 9px 14px; background: var(--panel); border-top: 1px solid var(--border); flex: none; animation: slide-up var(--t) var(--ease); }
.reply-bar .ico { color: var(--accent-fg); }
.reply-text { flex: 1; min-width: 0; font-size: .86rem; border-left: 3px solid var(--accent); padding-left: 10px; }
.reply-text strong { display: block; color: var(--accent-fg); font-size: .8rem; }
.reply-text span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.blocked-bar { padding: 14px; text-align: center; background: var(--panel); border-top: 1px solid var(--border); color: var(--text-2); font-size: .9rem; flex: none; padding-bottom: calc(14px + var(--sab)); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px calc(12px + var(--sar)) calc(10px + var(--sab)) calc(12px + var(--sal)); background: var(--panel); border-top: 1px solid var(--border); flex: none; }
.composer > .icon-btn { margin-bottom: 2px; }
.composer-box { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 24px; padding: 3px 4px; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-box .icon-btn { width: 38px; height: 38px; }
.composer-box textarea, .composer-box textarea:focus { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; resize: none; max-height: 160px; padding: 9px 4px; line-height: 1.38; border-radius: 0; font-size: 1rem; }
.composer .icon-btn.gif { font-size: .66rem; font-weight: 800; letter-spacing: .6px; width: auto; height: 26px; padding: 0 7px; margin: 0 4px 7px 2px; border-radius: 7px; border: 2px solid currentColor; }
.composer .icon-btn.round { width: 44px; height: 44px; background: var(--surface-2); }
.composer .icon-btn.round:hover { background: var(--surface-3); }
.composer .icon-btn.send { background: var(--own); color: #fff; box-shadow: 0 6px 16px var(--accent-ring); animation: pop-in .22s var(--ease-spring); }
.composer .icon-btn.send:hover { background: var(--own); transform: scale(1.05); }
.composer .icon-btn.send svg { margin-left: 2px; }
.record-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px calc(12px + var(--sab)); background: var(--panel); border-top: 1px solid var(--border); flex: none; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 25%, transparent); }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { flex: 1; color: var(--text-2); font-size: .88rem; }

/* ---------------------------------------------------------------- details panel (wide screens) */
.details { display: flex; flex-direction: column; min-width: 0; background: var(--panel); border-left: 1px solid var(--border); padding-top: var(--sat); animation: panel-in var(--t) var(--ease); }
.details-head { display: flex; align-items: center; gap: 8px; height: var(--head-h); padding: 0 10px 0 18px; border-bottom: 1px solid var(--border); flex: none; }
.details-head h3 { flex: 1; margin: 0; font-size: 1rem; }
.details-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }

/* ---------------------------------------------------------------- overlays */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade var(--t-fast) ease; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); width: 100%; max-width: 460px; max-height: calc(100dvh - 40px); overflow: auto; box-shadow: var(--sh-3); animation: modal-in var(--t) var(--ease-spring); overscroll-behavior: contain; }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 12px 8px 22px; position: sticky; top: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); z-index: 2; }
.modal-head h3 { margin: 0; font-size: 1.12rem; flex: 1; letter-spacing: -.2px; }
.modal-body { padding: 8px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-body p { margin: 0; }
.modal-body h4 { margin: 4px 0 -8px 4px; font-size: .74rem; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); font-weight: 700; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.section { background: var(--surface-2); border-radius: var(--r-lg); padding: 4px 16px; border: 1px solid var(--border); }
.section.pad { padding: 14px 16px; display: grid; gap: 14px; }
.section .list-item { border-bottom-color: var(--border-2); }
.section > label:not(.switch) { padding: 10px 0; }
.field-label { font-size: .82rem; color: var(--text-2); font-weight: 600; margin-bottom: 8px; display: block; }
.profile-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 4px 0 2px; }
.profile-hero h2 { margin: 8px 0 0; font-size: 1.3rem; letter-spacing: -.3px; }
.profile-hero .id { color: var(--text-2); font-size: .88rem; }
.profile-hero p { color: var(--text-2); max-width: 320px; }
.profile-hero .avatar { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--accent-ring); }
.hero-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.hero-actions button { display: grid; justify-items: center; gap: 6px; min-width: 78px; padding: 10px 8px; border-radius: var(--r-md); background: var(--surface-2); color: var(--accent-fg); font-size: .78rem; font-weight: 600; border: 1px solid var(--border); transition: background var(--t-fast); }
.hero-actions button:hover { background: var(--surface-3); }
.hero-actions svg { width: 20px; height: 20px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); text-align: left; width: 100%; transition: opacity var(--t-fast); }
.list-item:last-child { border-bottom: 0; }
button.list-item:hover .t strong { color: var(--accent-fg); }
.list-item .t { flex: 1; min-width: 0; }
.list-item .t strong { display: block; font-size: .95rem; font-weight: 600; transition: color var(--t-fast); }
.list-item .t span { color: var(--text-3); font-size: .8rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item.danger, .list-item.danger .t strong { color: var(--danger) !important; }
.list-item.danger .ic { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.list-item .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; flex: none; color: var(--accent-fg); }
.list-item .ic svg { width: 19px; height: 19px; }
.list-item > svg { width: 18px; height: 18px; color: var(--accent-fg); }
.safety { font-family: var(--mono); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 10px; background: var(--surface-2); padding: 16px; border-radius: var(--r-lg); text-align: center; font-size: .95rem; letter-spacing: 1px; border: 1px solid var(--border); }
.recovery-key { font-family: var(--mono); background: var(--surface-2); padding: 16px; border-radius: var(--r-lg); text-align: center; font-size: 1.05rem; letter-spacing: 1px; word-break: break-all; user-select: all; border: 1px dashed var(--border-2); }

.menu { position: fixed; z-index: 170; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-3); min-width: 220px; padding: 6px; animation: menu-in var(--t-fast) var(--ease); transform-origin: top left; }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border-radius: var(--r-sm); font-size: .92rem; transition: background var(--t-fast); }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu button.danger svg { color: var(--danger); }
.menu button svg { width: 18px; height: 18px; color: var(--text-2); }
.menu .react-row { display: flex; gap: 2px; padding: 4px 4px 8px; justify-content: space-between; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .react-row button { width: auto; padding: 5px 7px; font-size: 1.35rem; border-radius: var(--r-sm); transition: transform var(--t-fast) var(--ease-spring), background var(--t-fast); }
.menu .react-row button:hover { transform: scale(1.25); background: transparent; }
/* menus can open from inside the image viewer (z 160), so they sit above it */
.menu-backdrop { position: fixed; inset: 0; z-index: 169; }
/* sheets sit at z 120, so their tap-to-close layer must be BELOW them (menus/backdrops at 149-150 stay above sheets) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 119; background: transparent; }

/* bottom sheets (attach, emoji, gif, wishes) - anchored above the composer on desktop by JS */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 120; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--sh-3); padding: 10px 14px calc(16px + var(--sab)); animation: slide-up var(--t) var(--ease); max-height: 72dvh; display: flex; flex-direction: column; }
.sheet.anchored { right: auto; border-radius: var(--r-xl); padding-bottom: 14px; max-height: min(460px, 70dvh); animation: menu-in var(--t) var(--ease); transform-origin: bottom left; }
.sheet.anchored .sheet-grip { display: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-2); margin: 0 auto 12px; flex: none; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; padding: 4px 0; }
.attach-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .8rem; font-weight: 500; color: var(--text); padding: 10px 0; border-radius: var(--r-md); transition: background var(--t-fast), transform var(--t-fast); }
.attach-grid button:hover { background: var(--surface-2); }
.attach-grid button:active { transform: scale(.94); }
.attach-grid .ic { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; color: #fff; box-shadow: var(--sh-1); }
.attach-grid .ic svg { width: 24px; height: 24px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; overflow-y: auto; }
.emoji-grid button { font-size: 1.6rem; padding: 6px 0; border-radius: var(--r-sm); line-height: 1; transition: transform var(--t-fast) var(--ease-spring), background var(--t-fast); }
.emoji-grid button:hover { background: var(--surface-2); transform: scale(1.18); }
.gif-search { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.gif-search .tabs { margin: 0; flex: 1; }
.gif-grid { columns: 2; column-gap: 6px; overflow-y: auto; flex: 1; min-height: 200px; }
@media (min-width: 900px) { .gif-grid { columns: 3; } }
.gif-grid img { width: 100%; display: block; border-radius: var(--r-sm); margin-bottom: 6px; cursor: pointer; background: var(--surface-3); break-inside: avoid; transition: transform var(--t-fast), opacity var(--t-fast); }
.gif-grid img:hover { transform: scale(.98); opacity: .9; }
.gif-grid .note { column-span: all; color: var(--text-2); font-size: .88rem; text-align: center; padding: 22px 10px; }
.wish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; overflow-y: auto; padding: 2px; }
.wish-grid button { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: .86rem; line-height: 1.25; transition: border-color var(--t-fast), transform var(--t-fast); }
.wish-grid button:hover { border-color: var(--accent); transform: translateY(-1px); }
.wish-grid .we { font-size: 1.7rem; flex: none; }
.wish-grid b { display: block; font-size: .88rem; }
.wish-grid span { color: var(--text-3); font-size: .76rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.preview-img { max-height: 46dvh; width: 100%; object-fit: contain; border-radius: var(--r-lg); background: var(--surface-2); }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opts label { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border: 1px solid var(--border-2); border-radius: var(--r-md); cursor: pointer; text-align: center; font-size: .8rem; color: var(--text); transition: border-color var(--t-fast), background var(--t-fast); }
.opts label input { position: absolute; opacity: 0; pointer-events: none; }
.opts label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opts label b { font-size: 1.2rem; }

/* appearance pickers */
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--sw1), var(--sw2)); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); transition: transform var(--t-fast) var(--ease-spring); position: relative; }
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 3px var(--surface-2), 0 0 0 5px var(--text); }
.wp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.wp-swatch { height: 58px; border-radius: var(--r-md); border: 2px solid var(--border-2); font-size: .74rem; font-weight: 600; color: var(--text); display: flex; align-items: flex-end; padding: 6px 8px; background: var(--chat-bg); transition: border-color var(--t-fast), transform var(--t-fast); }
.wp-swatch:hover { transform: translateY(-1px); }
.wp-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: .9rem; align-items: center; }

/* image viewer */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 160; display: flex; flex-direction: column; animation: fade var(--t) ease; }
.viewer-head { display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--sat)) 12px 10px; color: #fff; background: linear-gradient(rgba(0,0,0,.7), transparent); position: absolute; left: 0; right: 0; top: 0; z-index: 1; }
.viewer-head .icon-btn { color: #fff; }
.viewer-head .icon-btn:hover { background: rgba(255,255,255,.14); }
.viewer-head .t { flex: 1; min-width: 0; font-size: .92rem; font-weight: 600; }
.viewer-head .t span { display: block; font-size: .78rem; opacity: .7; font-weight: 400; }
.viewer-body { flex: 1; display: grid; place-items: center; overflow: hidden; padding: 64px 0 calc(72px + var(--sab)); }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; animation: zoom-in var(--t) var(--ease); }
.viewer-foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(14px + var(--sab)); color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.75)); display: flex; align-items: center; gap: 10px; }
.viewer-foot .cap { flex: 1; font-size: .92rem; }
.viewer-foot .warn { font-size: .8rem; color: #ffd27a; display: flex; gap: 6px; align-items: center; }
.viewer-foot svg { width: 16px; height: 16px; }
.viewer.secure .viewer-body img { pointer-events: none; }

/* ---------------------------------------------------------------- celebration mode */
.celebration { position: fixed; inset: 0; z-index: 300; pointer-events: none; animation: fade .4s; }
.celebration.out { animation: fade-out .6s forwards; }
.celebration canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cel-card { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(88vw, 420px); padding: 22px 22px 16px; text-align: center; color: #fff; pointer-events: auto; cursor: pointer; border-radius: 26px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--cel-bg1, #222) 80%, transparent), color-mix(in srgb, var(--cel-bg2, #333) 85%, transparent)); border: 1px solid rgba(255,255,255,.22); box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 60px color-mix(in srgb, var(--cel-a, #fff) 35%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: cel-in .7s var(--ease-spring) both; }
.cel-card.hide { animation: cel-out .5s ease forwards; pointer-events: none; }
.cel-card h2 { margin: 8px 0 4px; font-size: clamp(24px, 6vw, 34px); letter-spacing: -.3px; background: linear-gradient(90deg, #fff, var(--cel-a, #ffd166), #fff); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%; animation: shine 2.4s linear infinite; }
.cel-card p { margin: 0; font-size: 15px; opacity: .92; }
.cel-card small { display: block; margin-top: 8px; font-size: 13px; opacity: .8; }
.cel-card em { display: block; margin-top: 10px; font-size: 11px; opacity: .55; font-style: normal; letter-spacing: .5px; text-transform: uppercase; }
.cel-emojis { font-size: 40px; display: flex; justify-content: center; gap: 8px; }
.cel-emojis span { display: inline-block; animation: cel-bounce 1.4s ease-in-out infinite; }
.cel-diyas { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--sab)); display: flex; justify-content: space-evenly; font-size: clamp(30px, 7vw, 52px); }
.cel-diyas span { animation: flicker 1.2s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(255,170,0,.9)); }
.cel-fire { position: absolute; left: 50%; bottom: calc(10px + var(--sab)); transform: translateX(-50%); font-size: clamp(70px, 18vw, 130px); animation: flicker .9s ease-in-out infinite; filter: drop-shadow(0 0 30px rgba(255,100,0,.9)); }
body.celebrating { --accent: var(--cel-a); --accent-2: var(--cel-b); }
body.celebrating .sidebar, body.celebrating .chat-head, body.celebrating .composer, body.celebrating .messages { background: linear-gradient(180deg, color-mix(in srgb, var(--cel-bg1) 55%, var(--bg)), color-mix(in srgb, var(--cel-bg2) 45%, var(--bg))) !important; }
body.celebrating .chat-head { box-shadow: 0 2px 30px color-mix(in srgb, var(--cel-a) 35%, transparent); }
.sidebar, .chat-head, .composer { transition: background var(--t-slow) ease; }

/* ---------------------------------------------------------------- keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(24px); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes menu-in { from { opacity: 0; transform: scale(.95); } }
@keyframes panel-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes zoom-in { from { opacity: 0; transform: scale(.96); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .6; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes blink { 50% { opacity: .25; } }
@keyframes logo-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,.55); } 60% { box-shadow: 0 0 0 6px rgba(52,211,153,0); } }
@keyframes ph-pulse { 50% { opacity: .35; transform: scale(.9); } }
@keyframes heart-pop { 0% { transform: translate(-50%,-50%) scale(0); opacity: 0; } 25% { transform: translate(-50%,-50%) scale(1.2); opacity: 1; } 70% { transform: translate(-50%,-80%) scale(1); opacity: 1; } 100% { transform: translate(-50%,-140%) scale(.6); opacity: 0; } }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.15) rotate(15deg); } }
@keyframes shine { to { background-position: 200% 0; } }
@keyframes cel-in { from { opacity: 0; transform: translate(-50%, -40%) scale(.6); } }
@keyframes cel-out { to { opacity: 0; transform: translate(-50%, -60%) scale(.9); } }
@keyframes cel-bounce { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg) scale(1.1); } }
@keyframes flicker { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 12px rgba(255,170,0,.8)); } 50% { transform: scale(1.08) translateY(-2px); filter: drop-shadow(0 0 24px rgba(255,120,0,1)); } }

/* ---------------------------------------------------------------- responsive */
/* desktop: three columns when the details panel is open */
@media (min-width: 1200px) {
  .main-screen.show-details { grid-template-columns: var(--sb-cols) minmax(0, 1fr) 340px; }
}
@media (max-width: 1199px) {
  .details { display: none !important; }
}
/* tablet */
@media (max-width: 1100px) and (min-width: 761px) {
  .main-screen { --sb-cols: clamp(270px, var(--sb-w), 40vw); }
  .messages > .msg { max-width: 80%; }
}
/* hide hero on narrower screens; single centred card */
@media (max-width: 980px) {
  .auth-screen { grid-template-columns: 1fr; background: radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent), radial-gradient(700px 400px at 100% 110%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent), var(--bg); }
  .auth-hero { display: none; }
}
/* phone */
@media (max-width: 760px) {
  :root { --head-h: 58px; }
  input, textarea, select, .composer-box textarea, .composer-box textarea:focus { font-size: 16px; } /* no iOS zoom-on-focus */
  .main-screen { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; transition: transform var(--t-slow) var(--ease), opacity var(--t-slow); }
  .main-screen.show-chat .sidebar { transform: translateX(-22%); opacity: .4; }
  .chat { position: absolute; inset: 0; transform: translateX(100%); transition: transform var(--t-slow) var(--ease), box-shadow var(--t-slow); z-index: 5; }
  .main-screen.show-chat .chat { box-shadow: -10px 0 40px rgba(0,0,0,.25); }
  .main-screen.show-chat .chat { transform: none; }
  .chat-head .back { display: inline-flex; margin-left: -4px; }
  .chat-head #btn-info { display: none; }
  .chat-empty { display: none; }
  .sb-head #btn-new { display: none; }
  .fab { display: grid; }
  .sb-resizer { display: none; }
  .icon-btn { width: 44px; height: 44px; }
  .composer { gap: 6px; padding-left: calc(8px + var(--sal)); padding-right: calc(8px + var(--sar)); }
  .messages { padding: 12px 10px 8px; }
  .messages > .msg { max-width: 86%; }
  .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .bubble a { -webkit-touch-callout: default; }
  .img-wrap { max-width: min(76vw, 320px); }
  .typing { left: 10px; }
  .menu { min-width: 240px; }
  .menu button { padding: 12px 14px; font-size: .98rem; }
  .overlay { padding: 0; align-items: end; }
  .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; max-width: none; max-height: 92dvh; animation: slide-up var(--t) var(--ease); border-bottom: 0; padding-bottom: var(--sab); }
  .modal::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border-2); margin: 10px auto 0; }
  .modal-head { padding-top: 10px; }
  .modal-body { padding: 8px 18px 22px; }
  .cel-card { top: 40%; }
  .toast { bottom: calc(90px + var(--sab)); }
  .swatch { width: 40px; height: 40px; }
}
/* phone landscape / short screens */
@media (max-height: 520px) and (max-width: 1000px) {
  :root { --head-h: 50px; }
  .messages { padding-top: 8px; }
  .composer { padding-top: 6px; padding-bottom: calc(6px + var(--sab)); }
  .modal { max-height: 96dvh; }
  .fab { width: 50px; height: 50px; border-radius: 16px; }
}
@media (hover: none) {
  .conv:hover, .icon-btn:hover, .menu button:hover, .peer-btn:hover { background: inherit; }
  .icon-btn.active:hover { background: var(--accent-soft); }
  .conv.active:hover { background: var(--accent-soft); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* inline icons inside paragraph text in panels and dialogs */
.modal-body p svg, .details-body p svg { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; margin-right: 2px; }

/* install app */
.install-link { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 14px; min-height: 42px; border-radius: var(--r-md); border: 1px dashed var(--border-2); color: var(--accent-fg); font-weight: 600; font-size: .88rem; transition: background var(--t-fast), border-color var(--t-fast); }
.install-link:hover { background: var(--accent-soft); border-color: var(--accent-ring); }
.install-link svg { width: 18px; height: 18px; }
.install-hero { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--r-lg); background: var(--accent-soft); border: 1px solid var(--accent-ring); }
.install-hero .logo { width: 56px; height: 56px; padding: 0; overflow: hidden; background: none; box-shadow: 0 8px 20px var(--accent-ring); animation: logo-float 4s ease-in-out infinite; }
.install-hero .logo img { width: 56px; height: 56px; display: block; }
.install-hero b { display: block; font-size: 1.1rem; }
.install-hero span { color: var(--text-2); font-size: .85rem; }
.install-perks { display: grid; gap: 8px; }
.install-perks span { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--text); }
.install-perks svg { width: 18px; height: 18px; color: var(--accent-fg); flex: none; }
.install-how { display: grid; gap: 10px; }
.install-how .btn.primary { min-height: 50px; font-size: 1rem; }
.install-step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: .92rem; }
.install-step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--own); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.install-step svg { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; color: var(--accent-fg); }
.install-done { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--r-md); background: color-mix(in srgb, var(--ok) 14%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.install-done > svg { width: 26px; height: 26px; color: var(--ok); flex: none; }
.install-done b { display: block; }
.install-done span { color: var(--text-2); font-size: .85rem; }
