/* Nós: the whole look. Light and dark are full themes (tokens on :root),
   following the system unless chosen in Settings > Chats. No frameworks. */

:root {
  --bg: #f5f8fd;
  --bg-2: #ffffff;
  --bg-tint: #eaf1fc;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --surface-3: #e7eef9;
  --line: rgba(30, 70, 140, 0.10);
  --line-strong: rgba(30, 70, 140, 0.2);
  --text: #0c1830;
  --muted: #5a6b88;
  --dim: #94a3bd;
  --blue: #2a7bff;
  --blue-2: #1a5ff0;
  --cyan: #12b5e8;
  --violet: #7a5cff;
  --green: #18b26b;
  --amber: #f0a020;
  --red: #ef3b4f;
  --accent: var(--blue);
  --accent-soft: rgba(42, 123, 255, 0.12);
  --accent-ink: #ffffff;
  --bubble-in: #ffffff;
  --bubble-in-text: #0c1830;
  --bubble-out: #2a7bff;
  --bubble-out-2: #4f8dff;
  --bubble-out-text: #ffffff;
  --chat-bg: #eef3fb;
  --glow: 0 8px 24px rgba(42, 123, 255, 0.28);
  --shadow: 0 6px 22px rgba(20, 50, 110, 0.08);
  --shadow-strong: 0 12px 40px rgba(20, 50, 110, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --tab-h: 58px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-scale: 1;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #070c19;
  --bg-2: #0b1224;
  --bg-tint: #0d1730;
  --surface: #0f1830;
  --surface-2: #131e3a;
  --surface-3: #1a2748;
  --line: rgba(120, 170, 255, 0.12);
  --line-strong: rgba(120, 170, 255, 0.24);
  --text: #e8f0ff;
  --muted: #93a6c8;
  --dim: #5f7299;
  --blue: #3d8bff;
  --blue-2: #2a6ff5;
  --cyan: #2ad4ff;
  --violet: #8f76ff;
  --green: #2ad18a;
  --amber: #ffb547;
  --red: #ff5468;
  --accent-soft: rgba(61, 139, 255, 0.16);
  --bubble-in: #16213f;
  --bubble-in-text: #e8f0ff;
  --bubble-out: #2a6ff5;
  --bubble-out-2: #3f86ff;
  --chat-bg: #08101f;
  --glow: 0 0 26px rgba(61, 139, 255, 0.45);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  --shadow-strong: 0 14px 44px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: calc(16px * var(--text-scale)) / 1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
svg { display: block; flex: none; }
img { display: block; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#app { position: fixed; inset: 0; overflow: hidden; }
.boot { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); }
.boot img { border-radius: 22px; box-shadow: var(--glow); }
.boot b { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#layer > * { pointer-events: auto; }

/* ---- screens ---- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  animation: enter 0.22s ease both;
}
.screen.back { animation-name: enter-back; }
.screen.leaving { animation: leave 0.2s ease both; pointer-events: none; }
@keyframes enter { from { transform: translateX(26px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes enter-back { from { transform: translateX(-26px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes leave { to { opacity: 0; } }
.screen.tabroot { animation-name: fade; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.screen.with-tabs .scroll { padding-bottom: calc(var(--tab-h) + var(--sab) + 12px); }
.content { padding: 4px 16px 24px; max-width: 720px; margin: 0 auto; width: 100%; }

/* ---- top bars ---- */
.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--sat) + 8px) 10px 8px;
  min-height: calc(var(--sat) + 56px);
  background: var(--bg);
  position: relative; z-index: 2;
}
.topbar .ttl { flex: 1; min-width: 0; font-weight: 650; font-size: 17px; }
.topbar .ttl small { display: block; font-weight: 500; font-size: 12.5px; color: var(--muted); }
.topbar.big { padding-left: 18px; }
.topbar.big .ttl { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.topbar.chat { border-bottom: 1px solid var(--line); background: var(--bg-2); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text);
  transition: background 0.15s;
}
.iconbtn:active { background: var(--surface-3); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn.accent { color: var(--accent); }
.titlebtn { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; padding: 2px 4px; border-radius: 12px; }
.titlebtn b { display: block; font-size: 16px; font-weight: 650; }
.titlebtn small { display: block; font-size: 12.5px; color: var(--muted); }
.titlebtn small.on { color: var(--green); }

/* ---- tab bar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tab-h) + var(--sab)); padding-bottom: var(--sab);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar.hidden { display: none; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 550; color: var(--dim); position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

/* ---- search, segments, chips ---- */
.search {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; margin: 0 16px 10px;
  background: var(--surface-2); border-radius: 12px; color: var(--dim);
}
.search input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); min-width: 0; }
.search svg { width: 18px; height: 18px; }
.seg { display: flex; gap: 6px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-item {
  padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--muted); background: var(--surface-2); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg-item.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.seg-item .n { font-size: 11px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; line-height: 17px; }
.tabs-line { display: flex; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.tabs-line button { flex: 1; padding: 10px 0; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs-line button.active { color: var(--accent); border-color: var(--accent); }

/* ---- lists ---- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; min-height: 68px; position: relative;
  text-align: left; width: 100%;
}
.item:active { background: var(--surface-2); }
.item + .item::before { content: ""; position: absolute; top: 0; left: 76px; right: 0; height: 1px; background: var(--line); }
.item .body { flex: 1; min-width: 0; }
.item .l1 { display: flex; align-items: baseline; gap: 8px; }
.item .name { flex: 1; min-width: 0; font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.item .time.unread { color: var(--accent); font-weight: 600; }
.item .l2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 14.5px; }
.item .l2 .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .l2 .draft { color: var(--red); }
.item .l2 svg { width: 16px; height: 16px; }
.item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.item .tag { font-size: 12.5px; font-weight: 600; color: var(--green); }
.item .tag.off { color: var(--dim); font-weight: 500; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.badge.muted { background: var(--dim); }
.ticks { color: var(--dim); display: inline-flex; }
.ticks.read { color: var(--accent); }
.ticks svg { width: 17px; height: 17px; }

.section-title { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 18px 16px 8px; }
.empty { text-align: center; color: var(--muted); padding: 56px 32px; }
.empty svg { width: 54px; height: 54px; margin: 0 auto 14px; color: var(--dim); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* ---- avatars ---- */
.av {
  width: 50px; height: 50px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  background: linear-gradient(135deg, var(--c1, #5aa0ff), var(--c2, #2a6ff5));
  position: relative;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av svg { width: 55%; height: 55%; }
.av.s { width: 36px; height: 36px; font-size: 14px; }
.av.xs { width: 28px; height: 28px; font-size: 11px; }
.av.l { width: 84px; height: 84px; font-size: 30px; }
.av.xl { width: 116px; height: 116px; font-size: 40px; }
.av-wrap { position: relative; flex: none; }
.center > .av, .center > .av-wrap, .profile-head > .av, .profile-head > .av-wrap, .form.center .av { margin-left: auto; margin-right: auto; }
.av-wrap .dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }
.av.ring { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }

/* ---- cards and settings rows ---- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.group { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; margin: 0 0 14px; }
.setting {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px;
  width: 100%; text-align: left; position: relative;
}
.setting + .setting::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--line); }
.group.plain .setting + .setting::before { left: 14px; }
button.setting:active, .setting.tap:active { background: var(--surface-2); }
.setting .ic { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); flex: none; }
.setting .ic svg { width: 22px; height: 22px; }
.setting .txt { flex: 1; min-width: 0; }
.setting .txt b { display: block; font-weight: 550; }
.setting .txt span { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
.setting .val { color: var(--muted); font-size: 14.5px; display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.setting .chev { width: 18px; height: 18px; color: var(--dim); }
.setting.danger .txt b, .setting.danger .ic { color: var(--red); }
.setting.accent .txt b, .setting.accent .ic { color: var(--accent); }
.note { font-size: 13px; color: var(--muted); padding: 0 6px 14px; line-height: 1.45; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ---- buttons and fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 22px; border-radius: 14px; font-weight: 650; font-size: 16px;
  background: var(--surface-2); color: var(--text); width: 100%;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--blue-2)); color: #fff; box-shadow: var(--glow); }
.btn-outline { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-danger { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.btn-small { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; width: auto; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1; }
.field {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); outline: 0;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.field { height: auto; min-height: 96px; padding: 12px 14px; resize: none; line-height: 1.45; }
.label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 4px 6px; display: block; }
.fab {
  position: absolute; right: 18px; bottom: calc(var(--tab-h) + var(--sab) + 18px); z-index: 5;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 60%, var(--blue-2)); color: #fff;
  display: grid; place-items: center; box-shadow: var(--glow);
}
.fab svg { width: 28px; height: 28px; }

/* ---- welcome ---- */
.welcome { background: radial-gradient(120% 70% at 50% 18%, var(--bg-tint), var(--bg) 70%); overflow: hidden; }
.welcome .hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--sat) + 30px) 24px 10px; text-align: center; position: relative; }
.welcome .logo { width: min(66vw, 280px); height: min(66vw, 280px); }
.welcome h1 { font-size: 46px; margin: 4px 0 6px; font-weight: 800; letter-spacing: -0.03em; }
.welcome p { color: var(--muted); margin: 0; }
.welcome .actions { padding: 10px 24px calc(var(--sab) + 26px); display: flex; flex-direction: column; gap: 12px; max-width: 460px; width: 100%; margin: 0 auto; position: relative; z-index: 1; }
.waves { position: absolute; left: 0; right: 0; bottom: 0; height: 220px; pointer-events: none; opacity: 0.9; }
.logo .node { animation: pulse 3.2s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
.logo .node:nth-of-type(2) { animation-delay: 0.6s; }
.logo .node:nth-of-type(3) { animation-delay: 1.2s; }
.logo .node:nth-of-type(4) { animation-delay: 1.8s; }
.logo .node:nth-of-type(5) { animation-delay: 2.4s; }
.logo .edge { stroke-dasharray: 6 10; animation: flow 2.4s linear infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: 0.85; } }
@keyframes flow { to { stroke-dashoffset: -32; } }

.form { padding: 8px 20px 24px; max-width: 520px; margin: 0 auto; width: 100%; }
.form h2 { font-size: 28px; margin: 6px 0 6px; letter-spacing: -0.02em; }
.form .sub { color: var(--muted); margin: 0 0 18px; }
.avatar-pick { display: grid; place-items: center; margin: 18px 0 8px; }
.avatar-pick .av { cursor: pointer; }
.avatar-pick .edit { position: absolute; right: 2px; bottom: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 3px solid var(--bg); }
.avatar-pick .edit svg { width: 16px; height: 16px; }
.accents { display: flex; gap: 12px; justify-content: center; margin: 18px 0 6px; flex-wrap: wrap; }
.accents button { width: 34px; height: 34px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4); }
.accents button.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--c); }
.words { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.words div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; font-weight: 600; font-size: 15px; display: flex; gap: 6px; }
.words div i { color: var(--dim); font-style: normal; font-size: 12px; min-width: 16px; padding-top: 2px; }
.words.blur div span { filter: blur(6px); }

/* ---- chat ---- */
.chat-screen { background: var(--chat-bg); }
.msgs { flex: 1; overflow-y: auto; padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.day { align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 4px 12px; margin: 10px 0 6px; box-shadow: var(--shadow); }
.sys { align-self: center; font-size: 12.5px; color: var(--muted); text-align: center; max-width: 82%; margin: 6px 0; background: color-mix(in srgb, var(--surface) 70%, transparent); padding: 5px 12px; border-radius: 12px; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 86%; position: relative; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg .av { margin-bottom: 2px; }
.msg.cont .av { visibility: hidden; }
.bubble {
  background: var(--bubble-in); color: var(--bubble-in-text);
  padding: 7px 10px 6px; border-radius: 18px 18px 18px 6px;
  box-shadow: 0 1px 2px rgba(10, 30, 70, 0.08); min-width: 64px; position: relative;
  overflow-wrap: anywhere; user-select: text; -webkit-user-select: text;
}
.msg.cont .bubble { border-radius: 18px 18px 18px 6px; }
.msg.out .bubble { background: linear-gradient(160deg, var(--bubble-out-2), var(--bubble-out)); color: var(--bubble-out-text); border-radius: 18px 18px 6px 18px; }
.bubble .who { font-size: 12.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bubble .text { white-space: pre-wrap; font-size: 15.5px; line-height: 1.38; }
.bubble .text a { color: inherit; text-decoration: underline; }
.bubble .meta { float: right; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; opacity: 0.7; margin: 6px 0 -2px 10px; }
.msg.out .bubble .meta { opacity: 0.85; }
.bubble .meta svg { width: 15px; height: 15px; }
.bubble .meta .read { color: #bfe4ff; opacity: 1; }
.msg.in .bubble .meta .read { color: var(--accent); }
.bubble.deleted .text { font-style: italic; opacity: 0.7; }
.bubble .quote { border-left: 3px solid currentColor; padding: 4px 8px; margin: 0 0 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.06); font-size: 13.5px; opacity: 0.85; }
.msg.out .bubble .quote { background: rgba(255, 255, 255, 0.16); }
.bubble .quote b { display: block; font-size: 12.5px; }
.bubble .fw { font-size: 12px; opacity: 0.7; font-style: italic; margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.bubble .fw svg { width: 13px; height: 13px; }
.bubble .media { margin: -3px -6px 5px; border-radius: 14px; overflow: hidden; position: relative; background: rgba(0, 0, 0, 0.08); width: min(270px, 64vw); max-height: 360px; }
.bubble .media img, .bubble .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.bubble .media .dl { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, 0.2); }
.bubble .media .dl span { background: rgba(0, 0, 0, 0.55); border-radius: 999px; padding: 6px 12px; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bubble .media .dl svg { width: 18px; height: 18px; }
.bubble.media-only { padding: 4px; }
.bubble.media-only .media { margin: 0; }
.bubble.media-only .meta { position: absolute; right: 10px; bottom: 8px; color: #fff; opacity: 1; background: rgba(0, 0, 0, 0.4); border-radius: 999px; padding: 1px 7px; margin: 0; }
.file { display: flex; align-items: center; gap: 10px; padding: 4px 2px 6px; min-width: 210px; }
.file .fi { width: 42px; height: 42px; border-radius: 10px; background: color-mix(in srgb, currentColor 14%, transparent); display: grid; place-items: center; }
.file .fi svg { width: 22px; height: 22px; }
.file b { display: block; font-size: 14.5px; }
.file small { opacity: 0.7; font-size: 12px; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0 4px; }
.voice .play { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, currentColor 16%, transparent); }
.msg.in .voice .play { background: var(--accent); color: #fff; }
.voice .play svg { width: 18px; height: 18px; }
.voice .wave { flex: 1; height: 26px; display: flex; align-items: center; gap: 2px; }
.voice .wave i { flex: 1; background: currentColor; opacity: 0.35; border-radius: 2px; min-height: 3px; }
.voice .wave i.on { opacity: 1; }
.voice small { font-size: 12px; opacity: 0.8; min-width: 32px; }
.reactions { display: flex; gap: 3px; margin-top: -6px; position: relative; z-index: 1; }
.msg.out + .reactions, .reactions.out { align-self: flex-end; margin-right: 10px; }
.reactions.in { margin-left: 44px; }
.reactions span { background: var(--surface); border-radius: 999px; padding: 1px 7px; font-size: 13px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.typing { align-self: flex-start; background: var(--bubble-in); border-radius: 18px; padding: 10px 14px; display: flex; gap: 4px; margin: 4px 0 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px calc(var(--sab) + 8px);
  background: var(--bg-2); border-top: 1px solid var(--line);
}
.composer .box { flex: 1; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 22px; min-height: 42px; padding: 0 4px 0 14px; }
.composer textarea { flex: 1; border: 0; outline: 0; background: none; resize: none; padding: 10px 0; min-height: 42px; max-height: 140px; line-height: 1.35; min-width: 0; }
.composer .iconbtn { width: 42px; height: 42px; border-radius: 50%; color: var(--muted); }
.composer .send { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #fff; box-shadow: var(--glow); }
.composer .rec { background: var(--red); color: #fff; }
.replybar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-2); border-top: 1px solid var(--line); font-size: 13.5px; }
.replybar .q { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 8px; }
.replybar .q b { display: block; color: var(--accent); font-size: 12.5px; }
.recording { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--red); font-weight: 600; padding: 0 8px; }
.recording .dotr { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
.chat-banner { margin: 8px 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted); display: flex; gap: 10px; align-items: flex-start; }
.chat-banner svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 1px; }

/* ---- media grid ---- */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 0 3px; }
.grid3 .cell { aspect-ratio: 1; background: var(--surface-3); overflow: hidden; position: relative; border-radius: 4px; }
.grid3 .cell img { width: 100%; height: 100%; object-fit: cover; }
.grid3 .cell .tagv { position: absolute; right: 5px; bottom: 5px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, 0.5); border-radius: 6px; padding: 1px 5px; }
.month { font-size: 13px; font-weight: 650; color: var(--muted); padding: 16px 12px 8px; }

/* ---- calls ---- */
.call {
  position: fixed; inset: 0; z-index: 40;
  background: radial-gradient(90% 60% at 50% 22%, color-mix(in srgb, var(--accent) 22%, var(--bg)), var(--bg) 75%);
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sat) + 40px) 24px calc(var(--sab) + 34px);
}
.call .who { text-align: center; margin-top: 30px; }
.call .who h2 { margin: 18px 0 4px; font-size: 28px; }
.call .who p { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.call .halo { position: relative; display: grid; place-items: center; }
.call .halo::before, .call .halo::after { content: ""; position: absolute; inset: -18px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); animation: halo 2.4s ease-out infinite; }
.call .halo::after { animation-delay: 1.2s; }
@keyframes halo { from { transform: scale(0.9); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.call video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: -1; }
.call video.local { position: absolute; right: 16px; top: calc(var(--sat) + 16px); width: 110px; height: 160px; object-fit: cover; border-radius: 16px; background: #000; box-shadow: var(--shadow-strong); }
.call.video-on .halo { display: none; }
.call.video-on .who { margin-top: 0; align-self: flex-start; text-align: left; }
.call.video-on .who h2, .call.video-on .who p { color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.call.video-on .cbtn { color: #fff; }
.call .controls { margin-top: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 30px; justify-items: center; }
.call .cbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.call .cbtn i { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); }
.call .cbtn.on i { background: var(--text); color: var(--bg); }
.call .cbtn svg { width: 26px; height: 26px; }
.call .end i { background: var(--red); color: #fff; width: 70px; height: 70px; }
.call .accept i { background: var(--green); color: #fff; width: 70px; height: 70px; }
.call .bottom { display: flex; gap: 60px; margin-top: 30px; }

/* ---- discover / card ---- */
.dcard { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 14px; width: 100%; text-align: left; }
.dcard .di { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.dcard .di svg { width: 28px; height: 28px; }
.dcard b { display: block; font-size: 16.5px; }
.dcard span { font-size: 13.5px; color: var(--muted); }
.qrbox { background: #fff; border-radius: 22px; padding: 18px; width: min(78vw, 300px); margin: 10px auto; box-shadow: var(--shadow-strong); }
.qrbox svg { width: 100%; height: auto; }
.linkbox { font-family: var(--mono); font-size: 11.5px; word-break: break-all; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; color: var(--muted); user-select: all; -webkit-user-select: all; }
.scanner { position: relative; width: 100%; max-width: 420px; aspect-ratio: 1; margin: 10px auto; border-radius: 24px; overflow: hidden; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 14%; border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 24px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); }
.profile-head { text-align: center; padding: 10px 16px 18px; }
.profile-head h2 { margin: 12px 0 2px; font-size: 24px; }
.profile-head p { margin: 0; color: var(--muted); }
.profile-head .acts { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }
.profile-head .acts button { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px; padding: 10px 0; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--accent); font-weight: 600; }
.profile-head .acts svg { width: 22px; height: 22px; }
.verified { color: var(--accent); display: inline-flex; vertical-align: -3px; }
.verified svg { width: 18px; height: 18px; }
.safety { font-family: var(--mono); font-size: 17px; letter-spacing: 0.06em; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 4px; text-align: center; padding: 14px; }
.storage-ring { display: grid; place-items: center; margin: 12px 0 18px; position: relative; }
.storage-ring svg { width: 190px; height: 190px; transform: rotate(-90deg); }
.storage-ring .lbl { position: absolute; text-align: center; }
.storage-ring .lbl b { display: block; font-size: 30px; font-weight: 800; }
.storage-ring .lbl span { font-size: 13px; color: var(--muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.pill.warn { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.pill.bad { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.banner { margin: 0 16px 10px; padding: 12px 14px; border-radius: 16px; background: var(--accent-soft); color: var(--text); display: flex; align-items: center; gap: 12px; text-align: left; width: calc(100% - 32px); }
.banner svg { width: 22px; height: 22px; color: var(--accent); }
.banner b { display: block; font-size: 14.5px; }
.banner span { font-size: 13px; color: var(--muted); }
.banner.warn { background: color-mix(in srgb, var(--amber) 14%, transparent); }
.banner.warn svg { color: var(--amber); }

/* ---- sheets, toasts, menus ---- */
.backdrop { position: fixed; inset: 0; background: rgba(5, 12, 30, 0.42); animation: fade 0.18s both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-strong);
  padding: 8px 18px calc(var(--sab) + 18px); animation: up 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  max-width: 640px; margin: 0 auto;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 38px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet h3 { margin: 4px 0 8px; font-size: 19px; }
.sheet p { color: var(--muted); margin: 0 0 12px; line-height: 1.45; }
.opt { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; text-align: left; }
.opt:last-child { border-bottom: 0; }
.opt .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.opt .ic svg { width: 21px; height: 21px; }
.opt .txt { flex: 1; min-width: 0; }
.opt .txt span { display: block; font-size: 13px; color: var(--muted); }
.opt .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.opt.on .check { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 45%, transparent 50%); }
.opt.danger { color: var(--red); }
.opt.danger .ic { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.quick { display: flex; justify-content: space-between; gap: 4px; padding: 6px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.quick button { font-size: 28px; width: 46px; height: 46px; border-radius: 50%; }
.quick button:active, .quick button.on { background: var(--surface-3); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--sab) + 24px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-strong); max-width: calc(100% - 32px); animation: fade 0.2s both;
}
.toast.bad { background: var(--red); color: #fff; }
.notif {
  position: fixed; left: 10px; right: 10px; top: calc(var(--sat) + 8px); max-width: 520px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-strong);
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; animation: down 0.25s both; text-align: left; width: calc(100% - 20px);
}
.notif b { display: block; font-size: 14.5px; }
.notif span { font-size: 13.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes down { from { transform: translateY(-120%); } to { transform: none; } }
.viewer { position: fixed; inset: 0; background: #000; z-index: 45; display: flex; flex-direction: column; }
.viewer .vbar { display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 8px) 10px 8px; color: #fff; }
.viewer .vbar .iconbtn { color: #fff; }
.viewer .vbody { flex: 1; display: grid; place-items: center; overflow: hidden; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .cap { color: #fff; padding: 10px 16px calc(var(--sab) + 16px); text-align: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.checkbox { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; flex: none; }
.checkbox.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.checkbox svg { width: 14px; height: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 6px 4px 4px; font-size: 13.5px; font-weight: 600; }

@media (min-width: 900px) {
  .sheet { border-radius: 22px; bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
