:root {
  color-scheme: light dark;
  --bg: #ffffff; --canvas: #eef0f6; --bg2: #f3f4f9; --bg3: #e6e8f1; --ink: #0e1124; --ink2: #666c82; --line: #e6e8f0;
  --accent: #5b5cf0; --accent2: #8b5cf6; --accent-ink: #fff; --accent-soft: rgba(91,92,240,.11); --accent-text: #4a4be0;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --bubble-in: #f1f2f8; --bubble-out-ink: #fff;
  --danger: #d6336c; --ok: #12a150;
  --shadow: 0 24px 60px -12px rgba(20,22,60,.28), 0 2px 8px rgba(20,22,60,.06);
  --shadow-sm: 0 1px 2px rgba(20,22,60,.05), 0 6px 20px -8px rgba(20,22,60,.12);
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font: 16px/1.45 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  letter-spacing: -.011em; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --bg: #14151c; --canvas: #0a0b10; --bg2: #1c1e28; --bg3: #282b38; --ink: #eef0f7; --ink2: #9399ae; --line: #242733;
    --accent: #7f80ff; --accent2: #a78bfa; --accent-ink: #fff; --accent-soft: rgba(127,128,255,.16); --accent-text: #a5a6ff;
    --grad: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bubble-in: #20222d; --danger: #ff6b8b; --ok: #4ade80;
    --shadow: 0 24px 60px -12px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4); --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -8px rgba(0,0,0,.5); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #14151c; --canvas: #0a0b10; --bg2: #1c1e28; --bg3: #282b38; --ink: #eef0f7; --ink2: #9399ae; --line: #242733;
    --accent: #7f80ff; --accent2: #a78bfa; --accent-ink: #fff; --accent-soft: rgba(127,128,255,.16); --accent-text: #a5a6ff;
    --grad: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bubble-in: #20222d; --danger: #ff6b8b; --ok: #4ade80;
    --shadow: 0 24px 60px -12px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4); --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -8px rgba(0,0,0,.5); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; max-width: 100%; overflow-x: hidden; }
body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { background: var(--canvas); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--bg3) transparent; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--ink2); font-size: .875rem; }
.center { text-align: center; }
.error { color: var(--danger); font-size: .875rem; min-height: 1.2em; }
.ic { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.app { height: 100dvh; display: grid; grid-template-columns: minmax(300px, 384px) 1fr; gap: 10px; padding: 10px; }
.list-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); border-radius: 20px; box-shadow: var(--shadow-sm); overflow: hidden; }
.conv-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); border-radius: 20px; box-shadow: var(--shadow-sm); overflow: hidden; }
@media (max-width: 859px) {
  body { background: var(--bg); }
  .app { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0; }
  .list-pane { border-radius: 0; box-shadow: none; }
  .conv-pane { border-radius: 0; box-shadow: none; position: fixed; inset: 0; z-index: 5; transform: translateX(100%); visibility: hidden; transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s .28s; }
  .app.has-open .conv-pane { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2,.8,.2,1); }
}
@media (min-width: 860px) { .back { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.bar { display: flex; align-items: center; gap: 4px; padding: calc(10px + var(--safe-t)) 10px 8px 20px; min-height: calc(60px + var(--safe-t)); }
.bar h1 { font-size: 1.5rem; font-weight: 750; flex: 1; letter-spacing: -.03em; }
.icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--ink2); flex: none; transition: background .15s, color .15s, transform .1s; }
.icon:active:not(:disabled) { transform: scale(.94); }
.icon:hover { background: var(--bg2); color: var(--ink); }
.icon:disabled { opacity: .35; cursor: default; }

.search { padding: 2px 14px 10px; position: relative; }
.search::before { content: ""; position: absolute; left: 28px; top: 14px; border: 1.8px solid var(--ink2); border-radius: 50%; box-sizing: border-box; width: 13px; height: 13px; pointer-events: none; }
.search::after { content: ""; position: absolute; left: 39px; top: 25px; width: 6px; height: 1.8px; background: var(--ink2); border-radius: 2px; transform: rotate(45deg); transform-origin: left center; pointer-events: none; }
.search input { width: 100%; height: 42px; border: 1px solid transparent; border-radius: var(--r); background: var(--bg2); padding: 0 14px 0 40px; transition: background .15s, border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; outline: 0; }
.search input:focus { background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::placeholder { color: var(--ink2); }

.chips { display: flex; gap: 6px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 13px; border-radius: 16px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink2); font-size: .8125rem; font-weight: 550; transition: background .15s, color .15s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip:hover { background: var(--bg2); }
.chip.on { background: var(--accent-soft); color: var(--accent-text); box-shadow: none; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip .tag { width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 2px; transform: rotate(45deg); }
.banner { background: #fff3bf; color: #5c4400; font-size: .8125rem; padding: 7px 16px; text-align: center; margin: 0 14px 8px; border-radius: 10px; }

/* ---------- chat list ---------- */
.list { list-style: none; margin: 0; padding: 0 8px calc(12px + var(--safe-b)); overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.row { display: flex; align-items: center; border-radius: 16px; position: relative; transition: background .12s; }
.row:hover { background: var(--bg2); }
.row.open { background: var(--accent-soft); }
.row.dragging { background: var(--bg3); box-shadow: var(--shadow); z-index: 2; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 13px; padding: 10px 12px; text-align: left; border-radius: 16px; }
.row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-top, .row-bot { display: flex; align-items: center; gap: 6px; min-width: 0; }
.title { font-weight: 600; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.unread .title { font-weight: 700; }
.row-top time { margin-left: auto; font-size: .75rem; color: var(--ink2); flex: none; padding-left: 6px; }
.row.unread time { color: var(--accent-text); font-weight: 600; }
.row-top .ic { width: 14px; height: 14px; color: var(--ink2); }
.row-top .fav { fill: #f5b400; stroke: #f5b400; }
.preview { flex: 1; min-width: 0; color: var(--ink2); font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.unread .preview { color: var(--ink); }
.preview em { color: var(--accent-text); font-style: normal; }
.pill { flex: none; font-size: .6875rem; font-weight: 550; padding: 2px 8px; border-radius: 8px; background: var(--bg3); color: var(--ink2); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--grad); color: var(--accent-ink); font-size: .6875rem; font-weight: 700; display: grid; place-items: center; }
.count.quiet { background: var(--bg3); color: var(--ink2); }
.row-more { opacity: 0; width: 36px; height: 36px; margin-right: 4px; }
.row:hover .row-more, .row-more:focus-visible { opacity: 1; }
@media (hover: none) { .row-more { display: none; } }
.grip { width: 32px; height: 44px; display: grid; place-items: center; color: var(--ink2); cursor: grab; touch-action: none; flex: none; margin-left: 2px; }
.empty { text-align: center; padding: 56px 24px; display: grid; gap: 10px; justify-items: center; color: var(--ink2); }
.empty h2 { color: var(--ink); font-size: 1.125rem; }

.avatar { position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center; background: linear-gradient(140deg, hsl(var(--h) 72% 62%), hsl(calc(var(--h) + 35) 62% 46%)) center/cover; color: #fff; font-weight: 650; font-size: .9375rem; letter-spacing: .01em; }
.avatar.sm { width: 40px; height: 40px; font-size: .8125rem; }
.avatar.has-img .ini { visibility: hidden; }
.net { position: absolute; right: -3px; bottom: -3px; width: 19px; height: 19px; border-radius: 50%; background: var(--c); color: #fff; font-size: .625rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2.5px var(--bg); }
.row:hover .net { box-shadow: 0 0 0 2.5px var(--bg2); }
.avatar.sm .net { width: 16px; height: 16px; font-size: .5625rem; }
.net.big { position: static; width: 32px; height: 32px; font-size: .9375rem; box-shadow: none; }

/* ---------- conversation ---------- */
.conv-bar { background: var(--bg); border-bottom: 1px solid var(--line); padding-left: 6px; gap: 10px; }
@media (min-width: 860px) { .conv-bar { padding-left: 20px; } }
.who { flex: 1; min-width: 0; display: grid; }
.who strong, .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who strong { font-weight: 650; letter-spacing: -.015em; }
.who span { font-size: .8125rem; color: var(--ink2); }
.messages { flex: 1; overflow-y: auto; padding: 16px 18px 8px; background: radial-gradient(120% 60% at 100% 0%, var(--accent-soft), transparent 60%); display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.messages > :first-child { margin-top: auto; }
.day, .earlier { align-self: center; margin: 10px 0 6px; font-size: .75rem; color: var(--ink2); }
.day span { background: var(--bg2); padding: 4px 12px; border-radius: 12px; font-weight: 550; }
.msg { max-width: min(76%, 560px); padding: 8px 13px 6px; border-radius: 20px; background: var(--bubble-in); align-self: flex-start; position: relative; overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: var(--grad); color: var(--bubble-out-ink); border-bottom-right-radius: 6px; box-shadow: 0 6px 16px -8px var(--accent); }
.msg.in { border-bottom-left-radius: 6px; }
.msg.notice { background: transparent; border: 1px dashed var(--line); color: var(--ink2); font-size: .875rem; }
.msg.pending { opacity: .65; }
.msg.failed { outline: 2px solid var(--danger); }
.msg .from { font-size: .8125rem; font-weight: 600; color: hsl(var(--h) 55% 45%); margin-bottom: 1px; }
:root[data-theme="dark"] .msg .from { color: hsl(var(--h) 60% 70%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg .from { color: hsl(var(--h) 60% 70%); } }
.msg .text { white-space: pre-wrap; }
.msg .meta { font-size: .6875rem; opacity: .7; text-align: right; margin-top: 1px; display: flex; justify-content: flex-end; align-items: center; gap: 3px; }
.msg .meta .tick { width: 13px; height: 13px; stroke-width: 2.4; }
.retry { text-decoration: underline; font-size: inherit; }
.quote { border-left: 3px solid currentColor; padding: 2px 8px; margin: 2px 0 4px; font-size: .8125rem; opacity: .85; border-radius: 4px; background: rgba(127,127,127,.15); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.photo { display: block; max-width: 100%; border-radius: 12px; background: rgba(127,127,127,.25) center/cover; margin: 2px 0 4px; }
.photo.broken::after { content: "Photo unavailable"; font-size: .8125rem; opacity: .7; }
.file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; margin: 2px 0 4px; border-radius: 12px; background: rgba(127,127,127,.18); font-size: .875rem; text-decoration: none; text-align: left; }
.msg audio, .msg video { display: block; max-width: 100%; border-radius: 12px; margin: 2px 0 4px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.reaction { padding: 2px 8px; border-radius: 12px; background: rgba(127,127,127,.22); font-size: .8125rem; min-height: 26px; }
.reaction.mine { box-shadow: inset 0 0 0 1.5px currentColor; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 2px 22px; background: var(--bg); font-size: .8125rem; color: var(--ink2); }
.reply-bar span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 12px calc(12px + var(--safe-b)); background: var(--bg); }
.composer .icon { width: 46px; height: 46px; border-radius: 50%; }
.reply-bar:not([hidden]) + .composer { border-top: 0; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 1px solid transparent; border-radius: 23px; background: var(--bg2); padding: 11px 18px; max-height: 160px; line-height: 1.35; outline: 0; transition: background .15s, border-color .15s, box-shadow .15s; }
.composer textarea:focus { background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.send { background: var(--grad); color: var(--accent-ink); box-shadow: 0 6px 16px -6px var(--accent); }
.send:hover { background: var(--grad); color: var(--accent-ink); filter: brightness(1.08); }
.send:disabled { background: var(--bg2); color: var(--ink2); opacity: 1; box-shadow: none; }
.placeholder { margin: auto; text-align: center; color: var(--ink2); display: grid; gap: 8px; justify-items: center; padding: 24px; }
.placeholder h2 { color: var(--ink); font-size: 1.375rem; letter-spacing: -.025em; }
.logo { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; width: 60px; height: 60px; padding: 13px; margin-bottom: 10px; border-radius: 19px; background: var(--bg); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.logo i { aspect-ratio: 1; border-radius: 50%; background: var(--c); }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: var(--r); background: var(--bg2); font-weight: 600; letter-spacing: -.01em; transition: background .15s, filter .15s, transform .1s, box-shadow .15s; }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--grad); color: var(--accent-ink); box-shadow: 0 8px 20px -8px var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--grad); }
.btn.ghost { background: transparent; color: var(--ink2); font-weight: 500; font-size: .875rem; min-height: 40px; }
.btn.ghost:hover { background: var(--bg2); color: var(--ink); }
.btn.google { background: #fff; color: #1f1f1f; box-shadow: inset 0 0 0 1px #dadce0, 0 1px 2px rgba(0,0,0,.05); min-height: 50px; font-weight: 550; }
.btn.google:hover { background: #f8faff; box-shadow: inset 0 0 0 1px #c6c9d0, 0 4px 14px -6px rgba(0,0,0,.2); }
:root[data-theme="dark"] .btn.google { background: #131314; color: #e3e3e3; box-shadow: inset 0 0 0 1px #8e918f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.google { background: #131314; color: #e3e3e3; box-shadow: inset 0 0 0 1px #8e918f; } }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .8125rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: grid; gap: 5px; font-size: .875rem; font-weight: 600; }
label small, .menu-item small { font-weight: 400; color: var(--ink2); font-size: .8125rem; }
input:not([type=checkbox]):not([type=radio]):not([type=search]):not([type=file]), select, .sheet textarea {
  min-height: 48px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); width: 100%; font-weight: 400; outline: 0; transition: border-color .15s, box-shadow .15s; }
input:not([type=checkbox]):not([type=radio]):not([type=search]):not([type=file]):focus, select:focus, .sheet textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.inline { display: flex; gap: 8px; margin-top: 12px; }
.inline input { flex: 1; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 400; font-size: 1rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.kv > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.kv strong { overflow: hidden; text-overflow: ellipsis; }
small.ok { color: var(--ok); } small.warn { color: var(--danger); }

/* ---------- sheet ---------- */
.sheet { border: 0; padding: 0; background: var(--bg); color: var(--ink); width: min(440px, 100vw); max-width: 100vw; max-height: min(86dvh, 720px); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop, .lightbox::backdrop { background: rgba(10,11,20,.45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@media (min-width: 600px) { .sheet[open] { animation: pop .18s cubic-bezier(.2,.8,.2,1); } @keyframes pop { from { transform: scale(.97); opacity: 0; } } }
.sheet header { display: flex; align-items: center; padding: 16px 10px 6px 22px; }
.sheet header h2 { flex: 1; font-size: 1.1875rem; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { padding: 6px 22px calc(22px + var(--safe-b)); overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; overscroll-behavior: contain; }
.sheet-body > *, .stack > *, .sheet form { min-width: 0; max-width: 100%; }
.sheet section { display: grid; gap: 8px; padding: 8px 0 14px; border-bottom: 1px solid var(--line); }
.sheet section:last-of-type { border-bottom: 0; }
.sheet h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; color: var(--ink2); }
.sheet h3.center { font-size: 1.125rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
@media (max-width: 599px) {
  .sheet { width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; animation: rise .24s cubic-bezier(.2,.8,.2,1); }
  @keyframes rise { from { transform: translateY(40px); opacity: 0; } }
}
.menu-item { display: flex; align-items: center; width: calc(100% + 16px); margin: 0 -8px; min-height: 48px; padding: 8px 12px; border-radius: 12px; text-align: left; }
.menu-item:hover { background: var(--bg2); }
.menu-item.danger { color: var(--danger); }
.menu-item.two { display: grid; gap: 2px; border: 1px solid var(--line); width: 100%; margin: 0; padding: 12px 14px; }
.contacts { max-height: min(42dvh, 340px); overflow-y: auto; overflow-x: hidden; grid-template-columns: minmax(0, 1fr); min-width: 0; border: 1px solid var(--line); border-radius: var(--r); padding: 4px; display: grid; gap: 1px; align-content: start; }
.contacts > .muted { padding: 10px 12px; }
.contacts > .loading { display: flex; gap: 10px; align-items: flex-start; }
.spin { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--bg3); border-top-color: var(--accent); animation: spin .8s linear infinite !important; }
@keyframes spin { to { transform: rotate(360deg); } }
.contacts .menu-item { width: 100%; min-width: 0; margin: 0; gap: 12px; min-height: 52px; padding: 6px 10px; }
.contacts.busy .menu-item:not(.picked) { opacity: .45; pointer-events: none; }
.contacts .picked { background: var(--accent-soft); }
.contact-text { display: grid; min-width: 0; }
.contact-text strong, .contact-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-text strong { font-weight: 600; }
.quick { display: flex; justify-content: space-between; padding: 4px 0 8px; }
.quick button { width: 46px; height: 46px; font-size: 1.5rem; border-radius: 50%; }
.quick button:hover { background: var(--bg2); }
.acct-head { display: flex; align-items: center; gap: 10px; }
.qr { width: min(260px, 70vw); margin: 4px auto; padding: 12px; background: #fff; border-radius: 16px; }
.qr svg { display: block; width: 100%; height: auto; }
.code { font: 700 1.75rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-align: center; padding: 16px; background: var(--bg2); border-radius: 14px; user-select: all; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: .9375rem; }
.done { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 8px auto 0; }
.done .ic { width: 34px; height: 34px; stroke-width: 2.4; }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { font-size: .875rem; font-weight: 600; padding: 0; margin-bottom: 6px; }
.seg { min-width: 0; }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px; background: var(--bg2); font-weight: 600; cursor: pointer; }
.seg input:checked + span { background: var(--c, var(--accent)); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; height: 100dvh; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; background:
  radial-gradient(42% 46% at 12% 14%, rgba(31,168,85,.20), transparent 70%),
  radial-gradient(40% 44% at 88% 10%, rgba(42,171,238,.22), transparent 70%),
  radial-gradient(46% 50% at 86% 90%, rgba(225,48,108,.18), transparent 70%),
  radial-gradient(44% 48% at 10% 88%, rgba(91,92,240,.24), transparent 70%),
  var(--canvas); }
.card { width: min(400px, 100%); background: var(--bg); border-radius: 28px; padding: 36px 28px 20px; display: grid; gap: 14px; box-shadow: var(--shadow); animation: rise-in .4s cubic-bezier(.2,.8,.2,1); }
@keyframes rise-in { from { transform: translateY(12px); opacity: 0; } }
.card h1 { font-size: 2rem; font-weight: 780; letter-spacing: -.04em; line-height: 1.1; }
.card > .muted { font-size: .9375rem; margin-bottom: 6px; }
.card .error:empty { display: none; }
.card .error { background: color-mix(in srgb, var(--danger) 10%, transparent); padding: 10px 14px; border-radius: 12px; }
.card details summary { cursor: pointer; color: var(--ink2); font-size: .875rem; min-height: 36px; display: flex; align-items: center; gap: 6px; list-style: none; border-radius: 8px; }
.card details summary::-webkit-details-marker { display: none; }
.card details summary::after { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.card details[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.card details summary:hover { color: var(--ink); }
.card #pw > summary { justify-content: center; }
.card #pw > form { margin-top: 8px; }
.card details label { margin-top: 8px; }
.login:not(.has-sso) #pw > summary { display: none; }
.login:not(.has-sso) #pw > form { margin-top: 0; }
.card #try-demo { margin-top: 2px; }

.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100dvh; }
.lightbox img { display: block; max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.lightbox .icon { position: fixed; top: calc(12px + var(--safe-t)); right: 12px; background: rgba(0,0,0,.55); color: #fff; }
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 22px; font-size: .875rem; font-weight: 500; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- native feel: nothing selects like text, everything presses like a control ---------- */
.row, .msg, .bar, .chips, .btn, .menu-item, .sheet header, .day, .earlier, .tray, .empty, .placeholder, .kv, .check, .seg, .toast, .banner, .reply-bar {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.msg a { -webkit-touch-callout: default; }
input, textarea { -webkit-user-select: text; user-select: text; }
.msg { cursor: default; transition: transform .12s, filter .12s; }
.msg:active { transform: scale(.985); filter: brightness(.97); }
.row-main:active { transform: scale(.985); }
.row-main { transition: transform .12s; }
.chip:active, .menu-item:active, .reaction:active { transform: scale(.96); }
.chip, .menu-item, .reaction { transition: transform .1s, background .15s, color .15s; }
.reaction { cursor: pointer; }
.who { cursor: pointer; border-radius: 10px; }
.conv-bar { -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); background: color-mix(in srgb, var(--bg) 82%, transparent); }
/* Hover colours only where there is a real pointer: on a phone they would stick after a tap. */
@media (hover: none) {
  .row:hover { background: none; } .row.open { background: var(--accent-soft); }
  .row:hover .net { box-shadow: 0 0 0 2.5px var(--bg); }
  .row:active { background: var(--bg2); } .icon:active, .menu-item:active { background: var(--bg2); }
}
@media (max-width: 599px) {
  .sheet header { position: relative; padding-top: 22px; }
  .sheet header::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--bg3); }
  .menu-item { min-height: 52px; font-size: 1.0313rem; }
}
.who-row { justify-content: flex-start; }
.bar h1 small { font-size: .75rem; font-weight: 550; letter-spacing: 0; color: var(--ink2); margin-left: 6px; vertical-align: middle; }

/* ---------- "something is updating" ---------- */
.sync { height: 2px; margin: -2px 14px 0; overflow: hidden; border-radius: 2px; background: var(--accent-soft); flex: none; }
.sync i { display: block; width: 40%; height: 100%; border-radius: 2px; background: var(--grad); animation: slide 1.1s ease-in-out infinite !important; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.earlier { display: flex; align-items: center; gap: 8px; }
.earlier .spin { margin: 0; }
.skeleton .avatar { background: var(--bg3); }
.skeleton .row-text i { display: block; height: 11px; border-radius: 6px; background: var(--bg3); width: 46%; } .skeleton .row-text i + i { width: 78%; margin-top: 7px; background: var(--bg2); }
.skeleton { animation: breathe 1.3s ease-in-out infinite !important; pointer-events: none; }
@keyframes breathe { 50% { opacity: .45; } }

/* ---------- pull to refresh ---------- */
.list-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.list { will-change: transform; }
.ptr { position: absolute; top: -40px; left: 50%; width: 34px; height: 34px; margin-left: -17px; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); display: grid; place-items: center; opacity: 0; z-index: 3; pointer-events: none; }
.ptr i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--bg3); border-top-color: var(--ink2); transition: border-color .15s; }
.ptr.ready i { border-top-color: var(--accent); border-right-color: var(--accent); }
.ptr.go i { border-top-color: var(--accent); border-right-color: var(--bg3); animation: spin .7s linear infinite !important; }

/* ---------- attachments: the tray before sending, progress while uploading ---------- */
.tray { display: flex; gap: 8px; padding: 10px 14px 2px; overflow-x: auto; background: var(--bg); scrollbar-width: none; }
.tray::-webkit-scrollbar { display: none; }
.att { position: relative; flex: none; width: 64px; height: 64px; border-radius: 14px; background: var(--bg2) center/cover; box-shadow: inset 0 0 0 1px var(--line); animation: pop-in .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } }
.att.doc { width: 132px; display: flex; align-items: center; gap: 6px; padding: 0 22px 0 10px; color: var(--ink2); }
.att.doc small { font-size: .75rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.att-x { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
.att-x .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.conv-pane.dropping::after { content: "Drop to attach"; position: absolute; inset: 10px; z-index: 6; border-radius: 16px; border: 2px dashed var(--accent); background: color-mix(in srgb, var(--bg) 86%, transparent); display: grid; place-items: center; font-weight: 650; color: var(--accent-text); pointer-events: none; }
@media (min-width: 860px) { .conv-pane { position: relative; } }
.photo { position: relative; overflow: hidden; }
.photo.uploading { filter: saturate(.85); }
.photo .up { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .32); }
.photo .up::before { content: ""; width: 52px; height: 52px; border-radius: 50%; background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, .28) 0); -webkit-mask: radial-gradient(circle, transparent 19px, #000 20px); mask: radial-gradient(circle, transparent 19px, #000 20px); transition: --p .2s; }
.photo .up b { position: absolute; color: #fff; font-size: .6875rem; font-weight: 700; }
.msg.pending:has(.photo.uploading) { opacity: 1; }
.up-file { display: flex; flex-wrap: wrap; }
.up-file span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upbar { flex-basis: 100%; height: 4px; border-radius: 2px; background: rgba(127, 127, 127, .3); overflow: hidden; }
.upbar i { display: block; height: 100%; border-radius: 2px; background: currentColor; transition: width .2s; }

/* iPhones zoom the whole page into any field whose text is smaller than 16px, which leaves the app wider than the screen. */
input, textarea, select { font-size: 16px !important; }

/* ---------- each messenger's own icon instead of a letter ---------- */
.n-wa { background: #25d366 url(icons/net-wa.svg) center/cover !important; }
.n-tg { background: #fff url(icons/net-tg.svg) center/cover !important; }
.n-fb { background: #0099ff url(icons/net-fb.svg) center/cover !important; }
.n-ig { background: #e1306c url(icons/net-ig.svg) center/cover !important; }
.net { width: 20px; height: 20px; }
.avatar.sm .net { width: 17px; height: 17px; }
.chip .dot[class*="n-"] { width: 16px; height: 16px; margin-left: -3px; }
.seg span { gap: 7px; } .seg .dot { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85); }

/* ---------- Settings: the one control for the whole app, set apart from the list's own tools ---------- */
#btn-settings { margin-left: 8px; background: var(--accent-soft); color: var(--accent-text); border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); }
#btn-settings .ic { width: 20px; height: 20px; stroke-width: 1.6; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
#btn-settings:hover { background: var(--accent); color: #fff; }
#btn-settings:hover .ic, #btn-settings:active .ic { transform: rotate(60deg); }

/* ---------- tabs can be picked up and moved ---------- */
.chips { touch-action: pan-x; }
.chip.lifting { position: relative; z-index: 3; background: var(--bg); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1.5px var(--accent); transition: box-shadow .15s; cursor: grabbing; }
.chips.sorting .chip:not(.lifting) { opacity: .7; }
.chips.sorting { cursor: grabbing; }
