/* ============================================================================
   Synapex Chat - design system + components
   Used by index.html (sign in / create account) and app.html (the chat app).
   Theme: tokens on :root, dark overrides via [data-theme="dark"] or the OS setting.
   ============================================================================ */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  /* brand */
  --brand-1: #6366f1;       /* indigo */
  --brand-2: #8b5cf6;       /* violet */
  --brand-3: #06b6d4;       /* cyan */
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(99,102,241,.14), rgba(139,92,246,.14));
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-ink: #ffffff;
  --translate: #0891b2;        /* translated text accent */
  --translate-bg: rgba(6,182,212,.10);

  /* surfaces (light) */
  --bg: #f4f5fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eceef7;
  --bg-hover: rgba(99,102,241,.07);
  --bg-active: rgba(99,102,241,.13);
  --border: #e3e5f0;
  --border-strong: #cfd3e4;
  --ink: #161a2e;
  --ink-2: #4a5170;
  --ink-3: #8087a6;
  --ink-inv: #ffffff;

  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,.10);
  --ok-bg: rgba(16,185,129,.12);
  --warn-bg: rgba(245,158,11,.14);

  --bubble-me: linear-gradient(135deg, #6366f1, #7c5cf4);
  --bubble-me-ink: #fff;
  --bubble-them: #ffffff;
  --bubble-them-ink: var(--ink);

  --shadow-xs: 0 1px 2px rgba(20,24,60,.06);
  --shadow-sm: 0 2px 8px rgba(20,24,60,.08);
  --shadow-md: 0 10px 30px rgba(20,24,60,.12);
  --shadow-lg: 0 24px 60px rgba(20,24,60,.20);
  --ring: 0 0 0 3px rgba(99,102,241,.28);

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 26px; --r-pill: 999px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --sidebar-w: 340px;
  --info-w: 320px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c0e1a;
  --bg-elev: #141729;
  --bg-sunken: #0a0c16;
  --bg-hover: rgba(139,148,255,.09);
  --bg-active: rgba(139,148,255,.17);
  --border: #23273f;
  --border-strong: #31365a;
  --ink: #eceefb;
  --ink-2: #aab0d0;
  --ink-3: #6f769a;
  --accent: #8b8dfc;
  --accent-hover: #a2a4ff;
  --accent-ink: #0c0e1a;
  --translate: #22d3ee;
  --translate-bg: rgba(34,211,238,.10);
  --danger-bg: rgba(239,68,68,.16);
  --ok-bg: rgba(16,185,129,.16);
  --warn-bg: rgba(245,158,11,.16);
  --bubble-them: #1b1f38;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.45);
  --shadow-md: 0 12px 34px rgba(0,0,0,.55);
  --shadow-lg: 0 28px 70px rgba(0,0,0,.65);
  --ring: 0 0 0 3px rgba(139,141,252,.38);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e1a; --bg-elev: #141729; --bg-sunken: #0a0c16;
    --bg-hover: rgba(139,148,255,.09); --bg-active: rgba(139,148,255,.17);
    --border: #23273f; --border-strong: #31365a;
    --ink: #eceefb; --ink-2: #aab0d0; --ink-3: #6f769a;
    --accent: #8b8dfc; --accent-hover: #a2a4ff; --accent-ink: #0c0e1a;
    --translate: #22d3ee; --translate-bg: rgba(34,211,238,.10);
    --danger-bg: rgba(239,68,68,.16); --ok-bg: rgba(16,185,129,.16); --warn-bg: rgba(245,158,11,.16);
    --bubble-them: #1b1f38;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.4); --shadow-sm: 0 2px 10px rgba(0,0,0,.45);
    --shadow-md: 0 12px 34px rgba(0,0,0,.55); --shadow-lg: 0 28px 70px rgba(0,0,0,.65);
    --ring: 0 0 0 3px rgba(139,141,252,.38);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: rgba(99,102,241,.28); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
svg.ic { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.ic.sm { width: 16px; height: 16px; }
svg.ic.lg { width: 24px; height: 24px; }

/* thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: var(--r-md); font-weight: 600; font-size: 15px;
  transition: transform .12s var(--ease), box-shadow .2s, background .2s, opacity .2s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(99,102,241,.5), inset 0 1px 0 rgba(255,255,255,.25); filter: brightness(1.05); }
.btn-soft { background: var(--bg-active); color: var(--accent); }
.btn-soft:hover { background: var(--bg-hover); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn-outline { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--ink); }
.btn-outline:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn.loading::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--ink-2); transition: background .15s, color .15s, transform .12s; }
.icon-btn:hover { background: var(--bg-hover); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--bg-active); color: var(--accent); }
.icon-btn.sm { width: 32px; height: 32px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; align-items: baseline; }
.field > label .hint { font-weight: 500; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--bg-elev); color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; padding: 12px 14px; resize: none; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.invalid { border-color: var(--danger); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 46px; }
.input-wrap .suffix { position: absolute; right: 4px; top: 4px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238087a6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
.field-error { color: var(--danger); font-size: 13px; min-height: 0; }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: var(--r-md); padding: 10px 14px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }
.form-ok { background: var(--ok-bg); color: var(--ok); border-radius: var(--r-md); padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.switch { position: relative; width: 44px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--border-strong); transition: background .2s; }
.switch i::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: var(--ring); }
.range { width: 100%; accent-color: var(--accent); }

/* password strength */
.strength { display: flex; gap: 4px; margin-top: 8px; }
.strength i { flex: 1; height: 4px; border-radius: 4px; background: var(--border); transition: background .25s; }
.strength[data-level="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] i:nth-child(-n+2) { background: var(--warn); }
.strength[data-level="3"] i:nth-child(-n+3) { background: #84cc16; }
.strength[data-level="4"] i { background: var(--ok); }
.strength-note { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }

/* ---------- avatar ---------- */
.avatar { position: relative; width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .02em; background: var(--brand-grad); user-select: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-3); border: 2.5px solid var(--bg-elev); }
.avatar .dot.online { background: var(--ok); }
.avatar.group { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.vbadge { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--ok); color: #fff; vertical-align: -2px; margin-left: 4px; }
.vbadge svg { width: 10px; height: 10px; stroke-width: 3; }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); background: var(--bg-active); color: var(--accent); font-size: 12.5px; font-weight: 600; }
.chip.neutral { background: var(--bg-sunken); color: var(--ink-2); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.tr { background: var(--translate-bg); color: var(--translate); }
.langtag { display: inline-grid; place-items: center; min-width: 26px; height: 18px; padding: 0 5px; border-radius: 5px; background: var(--bg-sunken); color: var(--ink-2); font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--brand-grad); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- cards / panels ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.muted { color: var(--ink-3); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken), var(--bg-hover), var(--bg-sunken)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- toast ---------- */
#toasts { position: fixed; z-index: 1000; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: min(92vw, 440px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; animation: toastIn .3s var(--ease); max-width: 100%; }
:root[data-theme="dark"] .toast { background: #eceefb; color: #0c0e1a; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.96); } }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 500; background: rgba(8,10,24,.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { width: min(520px, 100%); max-height: min(88vh, 760px); display: flex; flex-direction: column; background: var(--bg-elev); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .28s var(--ease); border: 1px solid var(--border); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 8px; }
.modal-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.modal-body { padding: 8px 24px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---------- popover menu ---------- */
.menu { position: fixed; z-index: 600; min-width: 220px; max-width: 320px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; animation: pop .16s var(--ease); max-height: 70vh; overflow-y: auto; }
.menu button, .menu .menu-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); text-align: left; font-size: 14.5px; color: var(--ink); }
.menu button:hover { background: var(--bg-hover); }
.menu button .sub { display: block; font-size: 12.5px; color: var(--ink-3); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--border); margin: 6px 4px; }
.menu .menu-title { padding: 8px 12px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.menu button.selected { background: var(--bg-active); color: var(--accent); font-weight: 600; }

/* ============================================================================
   AUTH PAGE (index.html)
   ============================================================================ */
.auth-shell { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); overflow-y: auto; }
.auth-hero { position: relative; overflow: hidden; color: #fff; padding: 56px 64px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(1200px 700px at 10% -10%, #7c83ff 0%, transparent 60%), radial-gradient(900px 600px at 110% 20%, #c084fc 0%, transparent 55%), radial-gradient(800px 700px at 30% 120%, #06b6d4 0%, transparent 55%), #3b2fc9; }
.auth-hero::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1px); background-size: 26px 26px; mask-image: linear-gradient(180deg, rgba(0,0,0,.6), transparent 70%); pointer-events: none; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; position: relative; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.18); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.3); }
.brand-mark svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.auth-hero h1 { font-size: clamp(34px, 4vw, 54px); line-height: 1.04; font-weight: 800; letter-spacing: -.035em; margin: 0 0 18px; position: relative; max-width: 560px; }
.auth-hero .lede { font-size: 18px; line-height: 1.5; color: rgba(255,255,255,.86); max-width: 500px; position: relative; }
.hero-demo { position: relative; margin-top: 36px; display: flex; flex-direction: column; gap: 12px; max-width: 460px; }
.demo-bubble { align-self: flex-start; max-width: 85%; padding: 12px 16px; border-radius: 18px 18px 18px 4px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.26); backdrop-filter: blur(12px); font-size: 16px; opacity: 0; transform: translateY(10px); animation: demoIn 12s infinite; }
.demo-bubble small { display: block; margin-top: 4px; font-size: 12.5px; color: rgba(255,255,255,.75); }
.demo-bubble.me { align-self: flex-end; border-radius: 18px 18px 4px 18px; background: rgba(255,255,255,.92); color: #2b2a6b; border-color: transparent; }
.demo-bubble.me small { color: #6b6fb0; }
.demo-bubble:nth-child(1) { animation-delay: 0s; } .demo-bubble:nth-child(2) { animation-delay: 1.6s; } .demo-bubble:nth-child(3) { animation-delay: 3.6s; } .demo-bubble:nth-child(4) { animation-delay: 5.4s; }
@keyframes demoIn { 0% { opacity: 0; transform: translateY(10px); } 6%, 82% { opacity: 1; transform: none; } 92%, 100% { opacity: 0; transform: translateY(-6px); } }
.hero-points { position: relative; display: flex; gap: 22px; flex-wrap: wrap; font-size: 14px; color: rgba(255,255,255,.88); }
.hero-points span { display: inline-flex; align-items: center; gap: 8px; }
.auth-panel { display: grid; place-items: center; padding: 32px 24px; min-height: 100%; }
.auth-card { width: min(440px, 100%); }
.auth-card .brand-sm { display: none; }
.auth-title { font-size: 28px; font-weight: 800; letter-spacing: -.025em; margin-bottom: 6px; }
.auth-sub { color: var(--ink-3); margin-bottom: 24px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: var(--r-md); background: var(--bg-sunken); margin-bottom: 28px; position: relative; }
.tabs button { height: 40px; border-radius: 9px; font-weight: 600; color: var(--ink-3); position: relative; z-index: 1; transition: color .2s; }
.tabs button.active { color: var(--ink); }
.tabs .thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 9px; background: var(--bg-elev); box-shadow: var(--shadow-xs); transition: transform .3s var(--ease); }
.tabs[data-active="signup"] .thumb { transform: translateX(100%); }
.link-row { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 20px; font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; }
.stepper .s { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.stepper .s i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; background: var(--bg-sunken); color: var(--ink-3); transition: all .3s var(--ease); }
.stepper .s.active { color: var(--ink); }
.stepper .s.active i { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.4); }
.stepper .s.done i { background: var(--ok); color: #fff; }
.stepper .bar { flex: 1; height: 2px; background: var(--border); border-radius: 2px; position: relative; overflow: hidden; }
.stepper .bar::after { content: ""; position: absolute; inset: 0; background: var(--ok); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }
.stepper .bar.fill::after { transform: scaleX(1); }
.stepper .s span { display: none; }
.stepper .s.active span { display: inline; }
.step-pane { animation: stepIn .35s var(--ease); }
@keyframes stepIn { from { opacity: 0; transform: translateX(16px); } }
.step-actions { display: flex; gap: 10px; margin-top: 8px; }
.step-actions .btn-primary { flex: 1; }

/* photo step */
.photo-stage { display: grid; place-items: center; margin: 4px 0 18px; }
.photo-ring { position: relative; width: 208px; height: 208px; border-radius: 50%; background: var(--bg-sunken); border: 2px dashed var(--border-strong); display: grid; place-items: center; overflow: hidden; touch-action: none; transition: border-color .2s, background .2s; }
.photo-ring.drag { border-color: var(--accent); background: var(--bg-active); }
.photo-ring.has { border-style: solid; border-color: transparent; box-shadow: 0 0 0 4px var(--bg-elev), 0 0 0 6px var(--accent), var(--shadow-md); cursor: grab; }
.photo-ring canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.photo-empty { text-align: center; color: var(--ink-3); padding: 24px; pointer-events: none; }
.photo-empty svg { width: 40px; height: 40px; margin-bottom: 8px; stroke: var(--accent); }
.photo-tools { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.photo-zoom { display: flex; align-items: center; gap: 12px; margin: 0 24px 16px; color: var(--ink-3); }
.cam-box { position: relative; width: 100%; aspect-ratio: 4/3; border-radius: var(--r-lg); overflow: hidden; background: #000; margin-bottom: 14px; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* code step */
.code-row { display: flex; gap: 10px; justify-content: center; margin: 22px 0 8px; }
.code-row input { width: 52px; height: 64px; text-align: center; font-size: 28px; font-weight: 700; border-radius: var(--r-md); border: 1.5px solid var(--border); background: var(--bg-elev); transition: all .15s; caret-color: var(--accent); }
.code-row input:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; transform: translateY(-2px); }
.code-row input.filled { border-color: var(--accent); background: var(--bg-active); }
.code-row.shake { animation: shake .4s; }
.code-row.error input { border-color: var(--danger); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.success-burst { width: 92px; height: 92px; border-radius: 50%; margin: 8px auto 18px; display: grid; place-items: center; background: var(--ok-bg); position: relative; }
.success-burst svg { width: 44px; height: 44px; stroke: var(--ok); stroke-width: 2.6; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .6s .15s var(--ease) forwards; }
.success-burst::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 1.2s .1s ease-out; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes ping { from { opacity: .6; transform: scale(.7); } to { opacity: 0; transform: scale(1.25); } }
.id-card { display: flex; gap: 14px; padding: 16px; border-radius: var(--r-lg); background: var(--brand-grad-soft); border: 1px solid var(--border); margin-bottom: 16px; }
.id-card .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.id-points { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; font-size: 14px; color: var(--ink-2); }
.id-points li { display: flex; gap: 10px; align-items: flex-start; }
.id-points svg { color: var(--ok); margin-top: 2px; }

/* ============================================================================
   APP (app.html)
   ============================================================================ */
.app { position: fixed; inset: 0; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); background: var(--bg); }
.app.info-open { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--info-w); }

/* --- sidebar --- */
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--bg-elev); border-right: 1px solid var(--border); }
.side-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 8px; }
.side-head .me { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 4px; margin: -4px; border-radius: var(--r-md); text-align: left; }
.side-head .me:hover { background: var(--bg-hover); }
.side-head .me .mt { min-width: 0; flex: 1; }
.side-head .me .mt b { display: block; font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head .me .mt > span { display: block; font-size: 12.5px; color: var(--ink-3); }
.search { position: relative; padding: 8px 16px 12px; }
.search svg { position: absolute; left: 30px; top: 50%; transform: translateY(-62%); color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 42px; border-radius: var(--r-pill); border: 1.5px solid transparent; background: var(--bg-sunken); padding: 0 16px 0 42px; font-size: 14.5px; transition: all .15s; }
.search input:focus { outline: none; background: var(--bg-elev); border-color: var(--accent); box-shadow: var(--ring); }
.room-list { flex: 1; overflow-y: auto; padding: 4px 8px 88px; }
.room { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 10px; border-radius: var(--r-md); text-align: left; position: relative; transition: background .12s; }
.room:hover { background: var(--bg-hover); }
.room.active { background: var(--bg-active); }
.room .meta { flex: 1; min-width: 0; }
.room .row1 { display: flex; align-items: baseline; gap: 8px; }
.room .title { flex: 1; font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .time { font-size: 11.5px; color: var(--ink-3); flex: 0 0 auto; }
.room .row2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.room .preview { flex: 1; font-size: 13.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room.unread .title, .room.unread .preview { color: var(--ink); font-weight: 700; }
.room .oncall { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--ok); }
.room .oncall::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); } 100% { box-shadow: 0 0 0 9px rgba(16,185,129,0); } }
.empty { display: grid; place-items: center; text-align: center; color: var(--ink-3); padding: 40px 28px; gap: 10px; }
.empty .art { width: 84px; height: 84px; border-radius: 26px; background: var(--brand-grad-soft); display: grid; place-items: center; color: var(--accent); margin-bottom: 4px; }
.empty .art svg { width: 38px; height: 38px; }
.empty h3 { color: var(--ink); font-size: 18px; }
.fab { position: absolute; left: calc(var(--sidebar-w) - 76px); bottom: 20px; z-index: 5; width: 56px; height: 56px; border-radius: 18px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 26px rgba(99,102,241,.5); transition: transform .15s var(--ease); }
.fab:hover { transform: translateY(-2px) scale(1.04); }

/* --- conversation --- */
.convo { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.convo-empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 32px; background: radial-gradient(700px 400px at 50% 30%, var(--bg-active), transparent 70%); }
.convo-empty .art { width: 120px; height: 120px; border-radius: 36px; background: var(--brand-grad); display: grid; place-items: center; color: #fff; margin: 0 auto 22px; box-shadow: 0 20px 50px rgba(99,102,241,.4); }
.convo-empty .art svg { width: 56px; height: 56px; }
.convo-empty h2 { font-size: 26px; letter-spacing: -.02em; margin-bottom: 8px; }
.convo-empty p { max-width: 380px; color: var(--ink-3); margin: 0 auto 22px; }
.convo-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-elev); border-bottom: 1px solid var(--border); min-height: 68px; }
.convo-head .who { flex: 1; min-width: 0; text-align: left; border-radius: var(--r-md); padding: 4px 6px; margin: -4px -6px; }
.convo-head .who:hover { background: var(--bg-hover); }
.convo-head .who > b { display: block; font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-head .who > span { display: block; font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-head .back { display: none; }
.lang-pill { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 10px; border-radius: var(--r-pill); background: var(--translate-bg); color: var(--translate); font-size: 13px; font-weight: 700; }
.join-banner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--ok-bg); color: var(--ok); font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); animation: fade .3s; }
.join-banner .btn { margin-left: auto; height: 34px; background: var(--ok); color: #fff; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px 8px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; overscroll-behavior: contain; }
.msgs.no-smooth { scroll-behavior: auto; }
.day-sep { align-self: center; margin: 14px 0 10px; padding: 4px 12px; border-radius: var(--r-pill); background: var(--bg-sunken); color: var(--ink-3); font-size: 12px; font-weight: 600; }
.sys-msg { align-self: center; margin: 8px 0; padding: 5px 14px; border-radius: var(--r-pill); background: var(--bg-sunken); color: var(--ink-3); font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.sys-msg.sys-call { background: var(--ok-bg); color: var(--ok); }
.msg { display: flex; gap: 10px; max-width: min(78%, 640px); margin-top: 2px; }
.msg.enter { animation: msgIn .28s var(--ease); }
.msg.first { margin-top: 12px; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .av { width: 32px; align-self: flex-end; flex: 0 0 auto; }
.msg:not(.last) .av .avatar, .msg.me .av { visibility: hidden; }
.msg.me .av { display: none; }
.bubble { position: relative; padding: 9px 14px 8px; border-radius: 18px; background: var(--bubble-them); color: var(--bubble-them-ink); box-shadow: var(--shadow-xs); border: 1px solid var(--border); min-width: 64px; word-break: break-word; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-ink); border-color: transparent; box-shadow: 0 4px 14px rgba(99,102,241,.28); }
.msg:not(.me) .bubble { border-bottom-left-radius: 6px; }
.msg.me .bubble { border-bottom-right-radius: 6px; }
.msg:not(.me):not(.first) .bubble { border-top-left-radius: 8px; }
.msg.me:not(.first) .bubble { border-top-right-radius: 8px; }
.bubble .sender { display: block; font-size: 12.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bubble .txt { white-space: pre-wrap; font-size: 15px; line-height: 1.45; }
.bubble .orig { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-strong); font-size: 13px; color: var(--ink-3); white-space: pre-wrap; display: flex; gap: 8px; align-items: flex-start; }
.msg.me .bubble .orig { border-top-color: rgba(255,255,255,.35); color: rgba(255,255,255,.8); }
.bubble .orig .langtag { margin-top: 1px; }
.bubble .tr-mark { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--translate); margin-bottom: 3px; }
.bubble .foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 3px; font-size: 11px; color: var(--ink-3); }
.msg.me .bubble .foot { color: rgba(255,255,255,.75); }
.bubble .acts { position: absolute; top: -14px; right: 8px; display: none; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--bg-elev); box-shadow: var(--shadow-md); border: 1px solid var(--border); z-index: 2; }
.msg.me .bubble .acts { right: auto; left: 8px; }
.bubble:hover .acts, .bubble:focus-within .acts { display: flex; }
.bubble .acts button { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
.bubble .acts button:hover { background: var(--bg-hover); color: var(--accent); }
.bubble .acts svg { width: 15px; height: 15px; }
.bubble.pending-tr .txt { opacity: .55; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .4; animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; } .typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.jump-bottom { position: absolute; right: 24px; bottom: 96px; z-index: 4; display: none; }
.jump-bottom.show { display: inline-flex; }

/* composer */
.composer { padding: 10px 16px 16px; background: transparent; }
.composer-box { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px 8px 12px; border-radius: 24px; background: var(--bg-elev); border: 1.5px solid var(--border); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.composer-box textarea { flex: 1; border: 0; background: transparent; resize: none; max-height: 160px; min-height: 28px; padding: 6px 4px; line-height: 1.45; font-size: 15.5px; outline: none; }
.composer-box textarea::placeholder { color: var(--ink-3); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--brand-grad); color: #fff; display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 6px 16px rgba(99,102,241,.45); transition: transform .15s var(--ease), opacity .2s; }
.send-btn:hover { transform: scale(1.06); }
.send-btn:disabled { opacity: .4; box-shadow: none; transform: none; cursor: default; }
.composer-hint { display: flex; align-items: center; gap: 8px; padding: 0 12px 8px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.composer-hint .chip { height: 24px; font-size: 11.5px; }
.mic-live { color: var(--danger) !important; background: var(--danger-bg) !important; animation: pulseRed 1.4s infinite; }
@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.45); } 100% { box-shadow: 0 0 0 12px rgba(239,68,68,0); } }
.emoji-pop { position: absolute; bottom: 82px; left: 20px; z-index: 20; width: 330px; max-height: 280px; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop .16s var(--ease); }
.emoji-pop button { font-size: 22px; height: 38px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--bg-hover); }

/* --- info panel --- */
.info { display: none; flex-direction: column; min-height: 0; background: var(--bg-elev); border-left: 1px solid var(--border); overflow-y: auto; }
.app.info-open .info { display: flex; }
.info-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px; }
.info-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 20px 20px; gap: 10px; }
.info-hero h3 { font-size: 20px; letter-spacing: -.01em; }
.info-sec { padding: 4px 16px 16px; }
.info-sec h4 { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); margin: 10px 4px 8px; }
.member { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: var(--r-md); }
.member .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .sub { font-size: 12.5px; color: var(--ink-3); font-weight: 400; }
.code-box { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: var(--r-md); background: var(--bg-sunken); font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: .18em; justify-content: space-between; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .txt { flex: 1; min-width: 0; }
.setting-row .txt b { display: block; font-weight: 600; font-size: 14.5px; }
.setting-row .txt span { font-size: 12.5px; color: var(--ink-3); }

/* ============================================================================
   CALL
   ============================================================================ */
.call { position: fixed; inset: 0; z-index: 300; background: #07080f; color: #fff; display: flex; flex-direction: column; animation: fade .25s; }
.call-top { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 16px 20px; background: linear-gradient(180deg, rgba(0,0,0,.6), transparent); pointer-events: none; }
.call-top > * { pointer-events: auto; }
.call-top .ttl { font-weight: 700; font-size: 16px; }
.call-top .sub { font-size: 13px; color: rgba(255,255,255,.7); }
.call-timer { font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: var(--r-pill); background: rgba(255,255,255,.14); font-size: 13px; font-weight: 600; }
.call-state { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 12px; border-radius: var(--r-pill); background: rgba(255,255,255,.12); }
.call-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.call-state.ok i { background: var(--ok); }
.call-state.bad i { background: var(--danger); }
.grid { flex: 1; display: grid; gap: 10px; padding: 70px 14px 110px; min-height: 0; grid-auto-rows: minmax(0, 1fr); align-content: stretch; }
.grid[data-n="1"] { grid-template-columns: 1fr; }
.grid[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid[data-n="3"], .grid[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid[data-n="5"], .grid[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { position: relative; border-radius: var(--r-lg); overflow: hidden; background: linear-gradient(160deg, #1a1d36, #0d0f1e); min-height: 0; display: grid; place-items: center; box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.local video { transform: scaleX(-1); }
.tile.local.screen video { transform: none; object-fit: contain; }
.tile .noavatar { display: grid; place-items: center; gap: 12px; z-index: 1; }
.tile .nm { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 8px; border-radius: var(--r-pill); background: rgba(0,0,0,.55); backdrop-filter: blur(8px); font-size: 13px; font-weight: 600; }
.tile .nm svg { width: 14px; height: 14px; }
.tile.speaking { box-shadow: 0 0 0 3px var(--ok), 0 0 28px rgba(16,185,129,.4); }
.tile .tbadge { position: absolute; right: 12px; top: 12px; z-index: 2; display: inline-flex; gap: 6px; }
.tile .tbadge .chip { height: 24px; background: rgba(0,0,0,.55); color: #fff; backdrop-filter: blur(8px); font-size: 11.5px; }
.tile .tbadge .chip.tr { color: #67e8f9; }
.tile.connecting::after { content: "Connecting…"; position: absolute; z-index: 3; inset: auto 0 50% 0; text-align: center; font-size: 14px; color: rgba(255,255,255,.7); }
.tile .peer-vol { position: absolute; right: 12px; bottom: 12px; z-index: 2; opacity: 0; transition: opacity .2s; }
.tile:hover .peer-vol { opacity: 1; }
.pip { position: absolute; z-index: 6; right: 18px; bottom: 112px; width: 200px; aspect-ratio: 4/3; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-lg), 0 0 0 2px rgba(255,255,255,.18); background: #111; cursor: grab; touch-action: none; }
.pip video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pip.screen video { transform: none; object-fit: contain; }
.pip .off { position: absolute; inset: 0; display: grid; place-items: center; background: #181b33; }
.call-bar { position: absolute; z-index: 7; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 26px; background: rgba(24,27,52,.78); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,.1); }
.cbtn { position: relative; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; transition: background .15s, transform .12s; }
.cbtn:hover { background: rgba(255,255,255,.22); }
.cbtn:active { transform: scale(.93); }
.cbtn.off { background: #fff; color: #161a2e; }
.cbtn.on { background: var(--brand-grad); color: #fff; box-shadow: 0 0 0 3px rgba(139,92,246,.35); }
.cbtn.hang { background: var(--danger); width: 64px; border-radius: 26px; }
.cbtn.hang:hover { background: #f05252; }
.cbtn .lbl { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: rgba(255,255,255,.7); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s; }
.cbtn:hover .lbl { opacity: 1; }
.cbtn .led { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #22d3ee; box-shadow: 0 0 10px #22d3ee; animation: pulse 1.6s infinite; }
.cbar-sep { width: 1px; height: 30px; background: rgba(255,255,255,.18); margin: 0 4px; }

/* live captions + translation panel */
.captions { position: absolute; z-index: 6; left: 50%; bottom: 112px; transform: translateX(-50%); width: min(720px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.cap { align-self: center; max-width: 100%; padding: 10px 16px; border-radius: 16px; background: rgba(8,10,24,.78); backdrop-filter: blur(12px); font-size: 17px; line-height: 1.35; text-align: center; animation: msgIn .25s var(--ease); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.cap .who { display: block; font-size: 12px; font-weight: 700; color: #67e8f9; margin-bottom: 2px; letter-spacing: .02em; }
.cap .orig { display: block; font-size: 13px; color: rgba(255,255,255,.6); margin-top: 3px; }
.cap.fade { opacity: 0; transition: opacity 1s; }
.tpanel { position: absolute; z-index: 8; right: 18px; top: 74px; width: 340px; max-height: calc(100% - 200px); overflow-y: auto; padding: 18px; border-radius: var(--r-lg); background: rgba(20,23,41,.92); backdrop-filter: blur(20px); box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,.1); animation: pop .2s var(--ease); }
.tpanel h3 { font-size: 16px; margin-bottom: 4px; }
.tpanel p { font-size: 13px; color: rgba(255,255,255,.65); margin-bottom: 14px; }
.tpanel .field > label { color: rgba(255,255,255,.75); }
.tpanel .select, .tpanel .input { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff; height: 42px; }
.tpanel .select option { color: #111; }
.tpanel .setting-row { border-color: rgba(255,255,255,.1); }
.tpanel .setting-row .txt span { color: rgba(255,255,255,.55); }
.peer-tr { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid rgba(255,255,255,.08); }
.peer-tr .st { margin-left: auto; font-size: 12px; color: rgba(255,255,255,.6); }
.peer-tr .st.live { color: #67e8f9; }
.precall { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: radial-gradient(900px 500px at 50% 0, #2a2f66 0%, #07080f 70%); }
.precall .box { width: min(480px, 92vw); text-align: center; }
.precall .preview { position: relative; width: 100%; aspect-ratio: 4/3; border-radius: var(--r-xl); overflow: hidden; background: #111; margin-bottom: 20px; box-shadow: var(--shadow-lg); }
.precall .preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.precall .preview .noav { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(160deg, #1a1d36, #0d0f1e); }
.precall .preview .ctl { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }
.meter { height: 6px; border-radius: 6px; background: rgba(255,255,255,.15); overflow: hidden; margin: 0 24px 18px; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 1180px) {
  .app.info-open { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .app.info-open .info { position: fixed; z-index: 120; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); box-shadow: var(--shadow-lg); animation: slideIn .28s var(--ease); }
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
@media (max-width: 900px) {
  :root { --sidebar-w: 100vw; }
  .app, .app.info-open { grid-template-columns: 1fr; }
  .app .convo { position: fixed; inset: 0; z-index: 50; transform: translateX(100%); transition: transform .3s var(--ease); }
  .app.in-convo .convo { transform: none; }
  .convo-head .back { display: grid; }
  .fab { left: auto; right: 20px; }
  .msg { max-width: 88%; }
  .grid { padding: 64px 8px 120px; }
  .grid[data-n="2"] { grid-template-columns: 1fr; }
  .grid[data-n="3"], .grid[data-n="4"] { grid-template-columns: 1fr 1fr; }
  .pip { width: 120px; right: 12px; bottom: 124px; }
  .tpanel { right: 8px; left: 8px; width: auto; top: 64px; }
  .call-bar { gap: 6px; padding: 8px 10px; bottom: 14px; }
  .cbtn { width: 46px; height: 46px; }
  .cbtn.hang { width: 54px; }
  .emoji-pop { left: 8px; width: calc(100vw - 16px); }
}
@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .brand-sm { display: flex; color: var(--ink); margin-bottom: 28px; }
  .auth-card .brand-sm .brand-mark { background: var(--brand-grad); border: 0; }
  .code-row input { width: 44px; height: 56px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- friends / new chat ---------- */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin: 0 16px 10px; padding: 4px; border-radius: var(--r-md); background: var(--bg-sunken); }
.seg button { position: relative; z-index: 1; height: 34px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-3); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: color .2s; }
.seg button.active { color: var(--ink); }
.seg .thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 9px; background: var(--bg-elev); box-shadow: var(--shadow-xs); transition: transform .3s var(--ease); }
.seg[data-active="friends"] .thumb { transform: translateX(100%); }
.sec-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.friend { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: var(--r-md); text-align: left; transition: background .12s; }
.friend:hover { background: var(--bg-hover); }
.friend .meta { flex: 1; min-width: 0; }
.friend .nm { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend .sub { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.friend .acts { display: flex; gap: 6px; }
.friend .row-btn { opacity: 0; transition: opacity .15s; }
.friend:hover .row-btn, .friend:focus-within .row-btn { opacity: 1; }
@media (hover: none) { .friend .row-btn { opacity: 1; } }
.pick-list { max-height: 320px; overflow-y: auto; margin: 10px -8px 0; padding: 0 8px; }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: var(--r-md); text-align: left; cursor: pointer; }
.pick-row:hover { background: var(--bg-hover); }
.pick-row.on { background: var(--bg-active); }
.pick-row .box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-strong); display: grid; place-items: center; color: transparent; transition: all .15s var(--ease); flex: 0 0 auto; }
.pick-row.on .box { background: var(--brand-grad); border-color: transparent; color: #fff; transform: scale(1.05); }
.pick-row .box svg { width: 14px; height: 14px; stroke-width: 3; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; min-height: 0; }
.chips-row .chip { height: 30px; padding-right: 6px; }
.chips-row .chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.chips-row .chip button:hover { background: rgba(0,0,0,.12); }
.modal .search svg { left: 16px; }
.friend .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- presence ---------- */
.presence { color: var(--ink-3); }
.presence.on { color: var(--ok); font-weight: 600; }
.presence.on::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 5px; vertical-align: 1px; }

/* ---------- clickable avatars + profile viewer ---------- */
.avatar.clickable { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.avatar.clickable:hover { box-shadow: 0 0 0 3px var(--bg-active), 0 0 0 5px var(--accent); }
.pv-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.pv-name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.pv-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.pv-bio { margin: 0 0 14px; color: var(--ink-2); font-size: 14.5px; white-space: pre-wrap; }
.pv-stage { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: var(--r-lg); background: var(--bg-sunken); overflow: hidden; }
.pv-stage img { width: 100%; height: 100%; object-fit: contain; animation: fade .25s; cursor: pointer; }
.pv-stage .pv-none { text-align: center; color: var(--ink-3); display: grid; gap: 10px; justify-items: center; }
.pv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(10,12,24,.55); color: #fff; backdrop-filter: blur(6px); transition: background .15s; }
.pv-nav:hover { background: rgba(10,12,24,.8); }
.pv-nav.prev { left: 10px; } .pv-nav.next { right: 10px; }
.pv-count { position: absolute; right: 10px; bottom: 10px; padding: 3px 10px; border-radius: var(--r-pill); background: rgba(10,12,24,.6); color: #fff; font-size: 12px; font-weight: 600; }
.pv-strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 2px; }
.pv-strip button { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; opacity: .65; border: 2px solid transparent; transition: all .15s; }
.pv-strip button.on { opacity: 1; border-color: var(--accent); }
.pv-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- photo manager (profile + sign-up) ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.photo-grid.drag { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: var(--r-md); }
.ph { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--bg-sunken); border: 2px solid transparent; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.main { border-color: var(--accent); }
.ph .main-tag { position: absolute; left: 6px; top: 6px; padding: 2px 8px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); font-size: 10.5px; font-weight: 800; letter-spacing: .04em; }
.ph .ph-acts { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: 6px; padding: 6px; background: linear-gradient(0deg, rgba(0,0,0,.65), transparent); opacity: 0; transition: opacity .15s; }
.ph:hover .ph-acts, .ph:focus-within .ph-acts { opacity: 1; }
@media (hover: none) { .ph .ph-acts { opacity: 1; } }
.ph .ph-acts button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.92); color: #161a2e; }
.ph .ph-acts button:hover { background: #fff; transform: scale(1.08); }
.ph .ph-acts svg { width: 15px; height: 15px; }
.more-photos { margin: -4px 0 14px; text-align: center; }
.more-grid { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.more-grid img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }

/* ---------- attachments ---------- */
.attach-tray { display: flex; gap: 10px; overflow-x: auto; padding: 4px 12px 10px; }
.attach-tray:empty { display: none; }
.tray-item { position: relative; flex: 0 0 auto; width: 84px; height: 84px; border-radius: 14px; overflow: hidden; background: var(--bg-sunken); border: 1px solid var(--border); }
.tray-item img, .tray-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-item .kind { position: absolute; left: 6px; bottom: 6px; padding: 1px 7px; border-radius: var(--r-pill); background: rgba(10,12,24,.65); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.tray-item .kind svg { width: 11px; height: 11px; }
.tray-item .x { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(10,12,24,.7); color: #fff; }
.tray-item .x svg { width: 12px; height: 12px; }
.tray-item .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.3); }
.tray-item .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.tray-item.err { border-color: var(--danger); }
.tray-item .err-note { position: absolute; inset: 0; display: grid; place-items: center; padding: 6px; text-align: center; font-size: 10.5px; font-weight: 600; color: #fff; background: rgba(160,30,30,.8); }
.drop-hint { position: absolute; inset: 8px; z-index: 30; display: none; place-items: center; border: 3px dashed var(--accent); border-radius: var(--r-xl); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(4px); font-size: 20px; font-weight: 700; color: var(--accent); pointer-events: none; text-align: center; }
.convo.dragging .drop-hint { display: grid; }
.atts { display: flex; flex-direction: column; gap: 6px; margin: 2px -6px 6px; }
.att { position: relative; border-radius: 14px; overflow: hidden; background: var(--bg-sunken); max-width: min(420px, 100%); }
.att.img { display: block; padding: 0; cursor: pointer; line-height: 0; }
.att.img { background: var(--bg-sunken); }
.att.img img { width: auto; height: auto; max-width: 100%; max-height: 420px; object-fit: contain; display: block; margin: 0 auto; transition: filter .2s; }
.att.img:hover img { filter: brightness(1.06); }
.att.vid video { display: block; width: 100%; max-height: 380px; background: #000; }
.att.proc { display: flex; align-items: center; gap: 12px; padding: 18px 16px; min-width: 220px; line-height: 1.3; font-size: 13.5px; color: var(--ink-2); }
.att.proc.failed { color: var(--danger); background: var(--danger-bg); }
.msg.me .att.proc { background: rgba(255,255,255,.16); color: #fff; }
.msg.me .att.proc.failed { background: rgba(255,255,255,.9); color: var(--danger); }
.lightbox { background: rgba(4,5,12,.88); cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; box-shadow: var(--shadow-lg); animation: pop .22s var(--ease); }
.lightbox .lb-x { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255,255,255,.14); }
.lightbox .lb-dl { position: absolute; top: 14px; right: 62px; color: #fff; background: rgba(255,255,255,.14); }

/* left panel: bigger, clearer profile pictures */
.room .avatar, .friend .avatar { width: 54px; height: 54px; font-size: 19px; }
.room .avatar .dot, .friend .avatar .dot { width: 13px; height: 13px; }
.room, .friend { gap: 14px; }
.avatar img { image-rendering: auto; }

/* ---------- expandable dialog ---------- */
.modal-head .head-btns { display: flex; gap: 4px; }
.overlay.full { padding: 0; }
.modal.full { width: 100vw !important; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; border: 0; }
.modal.full .modal-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.modal.full .pv-stage { flex: 1; aspect-ratio: auto; min-height: 0; }
.pv-full { position: absolute; right: 10px; top: 10px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(10,12,24,.55); color: #fff; backdrop-filter: blur(6px); transition: background .15s; z-index: 2; }
.pv-full:hover { background: rgba(10,12,24,.8); }

/* ---------- image viewer ---------- */
.iv { position: fixed; inset: 0; z-index: 800; display: flex; flex-direction: column; background: rgba(4,5,12,.96); color: #fff; animation: fade .2s; user-select: none; -webkit-user-select: none; }
.iv-top { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: linear-gradient(180deg, rgba(0,0,0,.55), transparent); position: absolute; top: 0; left: 0; right: 0; z-index: 3; }
.iv-title { font-weight: 650; font-size: 15px; max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iv-count { font-size: 13px; color: rgba(255,255,255,.7); margin-left: 8px; font-variant-numeric: tabular-nums; }
.iv-sp { flex: 1; }
.iv-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.1); transition: background .15s, transform .12s; }
.iv-btn:hover { background: rgba(255,255,255,.22); }
.iv-btn:active { transform: scale(.93); }
.iv-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: default; }
.iv-stage.zoomed { cursor: grab; }
.iv-stage.dragging { cursor: grabbing; }
.iv-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; max-height: none; will-change: transform; transition: opacity .2s; box-shadow: 0 10px 60px rgba(0,0,0,.6); background: #111; image-rendering: auto; }
.iv-spin, .iv-fail { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none; }
.iv-stage.loading .iv-spin { display: block; border-color: rgba(255,255,255,.25); border-top-color: #fff; }
.iv-stage.failed .iv-fail { display: block; color: rgba(255,255,255,.75); }
.iv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.12); backdrop-filter: blur(6px); z-index: 2; transition: background .15s; }
.iv-nav:hover { background: rgba(255,255,255,.26); }
.iv-nav.prev { left: 14px; } .iv-nav.next { right: 14px; }
.iv-zoom { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 4px 14px; border-radius: var(--r-pill); background: rgba(0,0,0,.65); font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .25s; pointer-events: none; font-variant-numeric: tabular-nums; }
.iv-zoom.show { opacity: 1; }
.iv-strip { display: flex; gap: 8px; justify-content: center; overflow-x: auto; padding: 10px 14px 14px; background: linear-gradient(0deg, rgba(0,0,0,.55), transparent); }
.iv-strip button { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 10px; overflow: hidden; opacity: .6; border: 2px solid transparent; transition: all .15s; }
.iv-strip button.on { opacity: 1; border-color: #fff; }
.iv-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.iv-hint { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); font-size: 12px; color: rgba(255,255,255,.5); pointer-events: none; animation: fade 4s forwards reverse; opacity: 0; }
@media (max-width: 700px) { .iv-title { max-width: 30vw; } .iv-hint { display: none; } .iv-nav { width: 40px; height: 40px; } }

.att.img[style] img { width: 100%; height: 100%; max-height: none; }
