/* ══════════════════════════════════════════════════════════
   HandleMe app components (index.html only). Mobile first;
   ≥1024px with a signed-in user gets a sidebar instead of tabs.
   ══════════════════════════════════════════════════════════ */

html, body { height: 100%; }
body { overscroll-behavior-y: none; }
body.has-layer { overflow: hidden; }

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
}

/* ── App bar (phones, and visitors on desktop) ─────────── */
.app-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 12px;
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; height: 54px; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; color: var(--text); }
.bar-right { display: flex; align-items: center; gap: 6px; }
.online-pill { display: inline-flex; align-items: center; gap: 7px; font-size: .8125rem; color: var(--text2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.online-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--online); }
.conn-off .online-pill i { background: var(--offline); }
.top-banners { flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; padding: 0 0 10px; }
.top-banners:empty { display: none; }

#view-root { overflow-y: auto; overflow-x: hidden; min-height: 0; position: relative; -webkit-overflow-scrolling: touch; background: var(--bg); }
.view { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.view-full { height: 100%; max-width: none; padding: 0; }

/* ── Bottom tabs (phones) ──────────────────────────────── */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.bottom-nav[hidden] { display: none; }
.nav-brand, .nav-foot { display: none; }
.nav-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 56px; font-size: .6875rem; font-weight: 500; color: var(--text3);
  -webkit-tap-highlight-color: transparent;
}
.nav-item .ic { width: 23px; height: 23px; }
.nav-item.on { color: var(--primary); }
.nav-badge {
  position: absolute; top: 5px; left: calc(50% + 5px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .6875rem; font-weight: 600; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--nav-bg);
}

/* Inside a chat on a phone the chat header is the top bar, and there are no tabs. */
@media (max-width: 1023px) {
  body[data-route="chat"] .bottom-nav, body[data-route="voice"] .bottom-nav, body[data-route="conversation"] .bottom-nav { display: none; }
  body[data-route="chat"] .app-bar, body[data-route="voice"] .app-bar, body[data-route="conversation"] .app-bar { border-bottom: 0; }
  body[data-route="chat"] .app-bar > :not(.top-banners), body[data-route="voice"] .app-bar > :not(.top-banners), body[data-route="conversation"] .app-bar > :not(.top-banners) { display: none; }
  body[data-route="chat"] .top-banners, body[data-route="voice"] .top-banners, body[data-route="conversation"] .top-banners { padding-top: 8px; }
}

/* ── Sidebar (desktop, signed in) ──────────────────────── */
@media (min-width: 1024px) {
  .app.has-nav { grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .app.has-nav .bottom-nav {
    grid-column: 1; grid-row: 1 / -1;
    display: flex; flex-direction: column; gap: 2px;
    padding: 14px 12px 16px; background: var(--sidebar-bg);
    border-top: 0; border-right: 1px solid var(--border);
  }
  .app.has-nav .nav-brand { display: flex; align-items: center; gap: 9px; padding: 4px 10px 18px; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; color: var(--text); }
  .app.has-nav .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; height: 38px; padding: 0 10px; border-radius: 8px; font-size: .9375rem; color: var(--text2); }
  .app.has-nav .nav-item .ic { width: 19px; height: 19px; }
  .app.has-nav .nav-item:hover { background: var(--surface3); color: var(--text); }
  .app.has-nav .nav-item.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
  .app.has-nav .nav-item.on .ic { color: var(--primary); }
  .app.has-nav .nav-badge { position: static; margin-left: auto; box-shadow: none; }
  .app.has-nav .nav-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 8px 10px 0; font-size: .8125rem; color: var(--text2); }
  .app.has-nav .app-bar { grid-column: 2; grid-row: 1; padding: 0; border: 0; background: transparent; }
  .app.has-nav .app-bar > :not(.top-banners) { display: none; }
  .app.has-nav .top-banners { padding: 12px 24px 0; }
  .app.has-nav #view-root { grid-column: 2; grid-row: 2; }
  .view { padding: 32px 32px 56px; }
  .h1 { font-size: 1.625rem; }
}

/* ── Type & layout helpers ─────────────────────────────── */
.h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.h2 { font-size: 1.125rem; font-weight: 650; letter-spacing: -.01em; }
.h3 { font-size: 1rem; font-weight: 600; }
.muted { color: var(--text2); }
.faint { color: var(--text3); }
.small { font-size: .8125rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin-bottom: 16px; }
.section-title { font-size: .8125rem; font-weight: 600; color: var(--text2); margin: 28px 0 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .9375rem; line-height: 1.2; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn .ic { flex: none; }
.btn.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: none; font-size: .9375rem; min-height: 40px; padding: 8px 16px; }
.btn.btn-primary:hover { background: var(--primary-hover); }
.btn.btn-secondary { background: var(--secondary); color: #fff; border-color: transparent; box-shadow: none; }
.btn.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text2); }
.btn.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: transparent; box-shadow: none; }
.btn.btn-danger-solid { background: var(--danger); color: #fff; border-color: transparent; box-shadow: none; }
.btn-block { width: 100%; }
.btn-lg, .btn.btn-lg { min-height: 48px; padding: 12px 20px; font-size: 1rem; }
.btn-sm, .btn.btn-sm { min-height: 32px; padding: 5px 12px; font-size: .8125rem; gap: 6px; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; color: var(--text2); flex: none;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn.on { color: var(--primary); }
.icon-btn.danger { color: var(--danger); }

/* ── Chips, badges, pills ──────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 4px 12px; border-radius: 999px; font-size: .8125rem; font-weight: 500;
  background: var(--surface); color: var(--text2); border: 1px solid var(--border2);
}
button.chip:hover { border-color: var(--text3); color: var(--text); }
.chip.on, .chip.match { background: var(--primary-dim); color: var(--primary-text); border-color: transparent; }
.chip-x { font-size: 1rem; line-height: 1; opacity: .7; }
.badge {
  display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary); font-size: .6875rem; font-weight: 700; line-height: 20px; text-align: center;
}
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; background: var(--surface2); color: var(--text2); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--accent); }
.pill.ok { background: var(--primary-dim); color: var(--primary-text); }
.pill.bad { background: var(--danger-dim); color: var(--danger); }

/* ── Cards & lists ─────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; text-align: left; width: 100%;
  border-bottom: 1px solid var(--border); background: transparent; color: inherit;
}
.list-row:last-child { border-bottom: none; }
.list-row, .list-row button { text-align: left; }
button.list-row, a.list-row { transition: background var(--transition); }
button.list-row:hover, a.list-row:hover, .list-row.active { background: var(--surface2); }
.list-row > .ic { color: var(--text2); flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-sub { font-size: .8125rem; color: var(--text2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: .75rem; color: var(--text3); flex: none; }
.row-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* ── Avatars & presence ────────────────────────────────── */
.avatar { position: relative; display: inline-flex; flex: none; border-radius: 50%; }
.avatar img, .avatar svg { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-gen .bg { fill: hsl(var(--h) 48% 90%); }
.avatar-gen .ch { fill: hsl(var(--h) 40% 30%); }
:root[data-theme="dark"] .avatar-gen .bg { fill: hsl(var(--h) 24% 25%); }
:root[data-theme="dark"] .avatar-gen .ch { fill: hsl(var(--h) 55% 82%); }
.presence-dot {
  position: absolute; right: 2%; bottom: 2%;
  width: 28%; height: 28%; min-width: 10px; min-height: 10px; max-width: 16px; max-height: 16px;
  border-radius: 50%; background: var(--offline); border: 2px solid var(--surface);
}
.presence-dot[data-on="1"] { background: var(--online); }
.presence-label { color: var(--text3); }
.presence-label[data-on="1"] { color: var(--success); font-weight: 500; }

/* ── Forms ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .8125rem; font-weight: 600; color: var(--text); }
.field input, .field select, .field textarea { width: 100%; }
.field-hint { font-size: .75rem; color: var(--text3); }
.field-status { font-size: .8125rem; font-weight: 500; }
.field-status.ok { color: var(--success); }
.field-status.bad { color: var(--danger); }
.field-status.warn { color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .875rem; color: var(--text2); line-height: 1.45; }
.check input { width: 18px; height: 18px; min-height: 0; margin-top: 1px; padding: 0; flex: none; accent-color: var(--primary); }
details > summary { list-style: none; cursor: pointer; }
.disclosure { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; font-size: .875rem; font-weight: 600; color: var(--primary-text); }
.disclosure .ic { transition: transform var(--transition); }
details[open] > .disclosure .ic { transform: rotate(90deg); }
.avatar-wait { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface2); }
.avatar-wait .spinner { width: 18px; height: 18px; border-width: 2px; }
details > summary::-webkit-details-marker { display: none; }

.setting-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .grow > div:first-child { font-weight: 600; }
.setting-row .grow > div:last-child { font-size: .8125rem; color: var(--text2); margin-top: 2px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; min-height: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--surface3); transition: background var(--transition); }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--transition); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.seg { display: inline-flex; background: var(--surface2); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { height: 32px; padding: 0 12px; border-radius: 7px; font-size: .8125rem; font-weight: 600; color: var(--text2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .seg button.on { background: var(--surface3); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; padding: 10px 0; margin-bottom: -1px; font-weight: 600; color: var(--text3); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text2); }
.tabs button.on { color: var(--text); border-bottom-color: var(--primary); }

/* ── Layers (sheets, modals, full-screen) ──────────────── */
#overlay-root { position: relative; z-index: 100; }
.layer { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s ease; z-index: 100; }
.layer.in { opacity: 1; }
.layer-wrap-modal { align-items: center; padding: 16px; }
.layer-wrap-full { background: var(--bg); }
.layer-panel { background: var(--surface); color: var(--text); width: 100%; max-height: 92dvh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.layer-sheet { border-radius: 16px 16px 0 0; max-width: 560px; transform: translateY(24px); transition: transform .2s ease; padding-bottom: env(safe-area-inset-bottom); }
.layer.in .layer-sheet { transform: none; }
.layer-modal { border-radius: 16px; max-width: 420px; transform: scale(.97); transition: transform .18s ease; }
.layer.in .layer-modal { transform: none; }
.layer-full { height: 100dvh; max-height: none; max-width: none; border-radius: 0; background: var(--bg); }
.layer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 4px 20px; }
.layer-title { font-size: 1.0625rem; font-weight: 650; letter-spacing: -.01em; }
.layer-body { padding: 8px 20px 20px; overflow-y: auto; min-height: 0; }
.layer-full .layer-body { padding: 0; height: 100%; }
@media (min-width: 720px) {
  .layer { align-items: center; }
  .layer-sheet { border-radius: 16px; max-height: 86dvh; }
}
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 12px; border-radius: 10px; font-weight: 500; text-align: left; }
.menu-item .ic { color: var(--text2); }
.menu-item:hover { background: var(--surface2); }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger); }
.confirm p { color: var(--text2); margin-bottom: 18px; line-height: 1.5; }

/* ── Toasts & banners ──────────────────────────────────── */
#toast-root { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; width: min(92vw, 400px); pointer-events: none; }
@media (min-width: 1024px) { #toast-root { bottom: 24px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 14px; border-radius: 12px; background: var(--toast-bg); color: var(--toast-text); box-shadow: var(--shadow); font-size: .875rem; opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; }
.toast::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; }
.toast-success::before { background: var(--online); }
.toast-error::before { background: var(--danger); }
.toast-warn::before { background: #f79009; }
.toast-msg { flex: 1; }
.toast-action { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.toast-x { color: inherit; opacity: .6; font-size: 1.2rem; line-height: 1; padding: 0 2px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: .8125rem; line-height: 1.45; background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.banner-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--accent); }
.banner-info { background: var(--primary-dim); border-color: transparent; color: var(--primary-text); }
.banner-bad { background: var(--danger-dim); border-color: transparent; color: var(--danger); }

.empty { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty .ic { width: 32px; height: 32px; color: var(--text3); margin-bottom: 12px; }
.empty > p:first-of-type { color: var(--text); font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.empty .btn { margin-top: 4px; }
.skel { background: linear-gradient(90deg, var(--surface2), var(--surface3), var(--surface2)); background-size: 200% 100%; animation: skel 1.2s infinite; border-radius: 8px; }
@keyframes skel { to { background-position: -200% 0; } }
.spinner { display: inline-block; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--surface3); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Home ──────────────────────────────────────────────── */
.hero { padding: 12px 0 4px; }
.hero h1 { font-size: clamp(1.75rem, 5.5vw, 2.5rem); font-weight: 750; line-height: 1.12; letter-spacing: -.03em; }
.hero p { color: var(--text2); margin-top: 10px; max-width: 540px; font-size: 1rem; line-height: 1.55; }
.mode-cards { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 24px 0 14px; }
@media (min-width: 640px) { .mode-cards { grid-template-columns: 1fr 1fr; } }
.mode-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border2); box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.mode-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.mode-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--primary); color: #fff; }
.mode-card.voice .mode-icon { background: var(--primary-dim); color: var(--primary-text); }
.mode-text { flex: 1; min-width: 0; }
.mode-text b { display: block; font-size: 1rem; font-weight: 650; }
.mode-text span { display: block; font-size: .8125rem; color: var(--text2); margin-top: 2px; line-height: 1.4; }
.mode-card > .ic:last-child { color: var(--text3); flex: none; }
.interest-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.trust-row { list-style: none; display: grid; gap: 12px; margin: 22px 0 6px; }
@media (min-width: 640px) { .trust-row { grid-template-columns: repeat(3, 1fr); } }
.trust-row li { display: flex; gap: 10px; align-items: flex-start; font-size: .875rem; color: var(--text2); line-height: 1.45; }
.trust-row li .ic { color: var(--primary); flex: none; margin-top: 1px; }
.trust-row li b { display: block; color: var(--text); font-weight: 600; }
.retention-note { font-size: .8125rem; color: var(--text3); margin-top: 14px; }
.steps { list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; color: var(--text2); line-height: 1.5; counter-increment: step; }
.steps li::before { content: counter(step); display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface2); color: var(--text); font-size: .75rem; font-weight: 700; }
.faq .list-row { display: block; min-height: 0; padding: 0; }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; cursor: pointer; font-weight: 600; }
.faq summary .ic { color: var(--text3); transition: transform var(--transition); flex: none; }
.faq details[open] summary .ic { transform: rotate(90deg); }
.faq details p { padding: 0 16px 16px; color: var(--text2); font-size: .875rem; line-height: 1.55; }
.home .site-footer { margin-top: 28px; border-top: 0; padding: 8px 0; }
.how ol { padding-left: 20px; color: var(--text2); line-height: 1.7; }

/* ── Waiting ───────────────────────────────────────────── */
.waiting { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 70%; text-align: center; padding: 32px 16px; }
.waiting .h2 { margin-top: 10px; }
.radar { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.radar::before { content: ''; position: absolute; inset: 24px; border-radius: 50%; background: var(--primary-dim); }
.radar span { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--primary); opacity: 0; animation: radar 2.4s ease-out infinite; }
.radar span:nth-child(2) { animation-delay: .8s; }
.radar span:nth-child(3) { animation-delay: 1.6s; }
.radar .ic { position: relative; width: 26px; height: 26px; color: var(--primary); }
@keyframes radar { 0% { transform: scale(.45); opacity: .7; } 100% { transform: scale(1.1); opacity: 0; } }

/* ── Chat (random + direct) ────────────────────────────── */
.chat { display: flex; flex-direction: column; height: 100%; max-width: 880px; margin: 0 auto; background: var(--bg); }
@media (min-width: 1024px) { .chat { border-left: 1px solid var(--border); border-right: 1px solid var(--border); } }
.chat-head { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-head .row-main { padding: 2px 0; }
.chat-head .row-title { font-size: .9375rem; }
.chat-head .row-sub { font-size: .75rem; }
.chat-video { position: relative; background: var(--video-bg); flex: none; height: 38dvh; display: none; }
.chat-video.on { display: block; }
.chat-video video { width: 100%; height: 100%; object-fit: cover; }
.chat-video .local { position: absolute; right: 10px; bottom: 10px; width: 28%; max-width: 150px; aspect-ratio: 3 / 4; height: auto; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .3); object-fit: cover; transform: scaleX(-1); }
.chat-video .blur { filter: blur(28px); }
.video-reveal { position: absolute; inset: 0; margin: auto; height: fit-content; width: fit-content; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.msg { max-width: min(78%, 560px); padding: 8px 12px; border-radius: 18px; font-size: .9375rem; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; position: relative; }
.msg.them { align-self: flex-start; background: var(--bubble-peer); color: var(--bubble-peer-text); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--bubble-self); color: var(--bubble-self-text); border-bottom-right-radius: 6px; }
.msg.them + .msg.me, .msg.me + .msg.them { margin-top: 6px; }
.msg.sys { align-self: center; background: transparent; color: var(--text3); font-size: .75rem; text-align: center; max-width: 92%; padding: 6px 8px; }
.msg.sys.shared { color: var(--primary-text); font-weight: 600; }
.msg.media { padding: 3px; background: transparent; }
.msg.media img, .msg.media video { border-radius: 15px; max-height: 320px; max-width: 100%; }
.msg.gif img { border-radius: 15px; max-height: 220px; }
.msg-meta { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-size: .6875rem; opacity: .65; margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg-meta .ic { width: 14px; height: 14px; }
.msg.deleted { font-style: italic; opacity: .7; }
.msg .masked-note { display: block; font-size: .6875rem; opacity: .7; margin-top: 3px; }
.reply-quote { display: block; font-size: .8125rem; padding: 4px 8px; margin-bottom: 4px; border-left: 3px solid currentColor; opacity: .8; border-radius: 4px; background: rgba(0, 0, 0, .06); }
.msg.me .reply-quote { background: rgba(255, 255, 255, .14); }
.reactions { position: absolute; bottom: -11px; right: 8px; background: var(--surface); border-radius: 10px; padding: 0 5px; font-size: .75rem; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.msg.has-reaction { margin-bottom: 12px; }
.typing { padding: 0 16px 4px; font-size: .75rem; color: var(--text3); height: 20px; }
.typing[hidden] { display: block !important; visibility: hidden; }
.media-blur { position: relative; display: block; border-radius: 15px; overflow: hidden; background: var(--surface2); min-width: 160px; min-height: 120px; }
.media-blur img, .media-blur video { filter: blur(28px); transform: scale(1.1); }
.media-blur .reveal { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #fff; font-weight: 600; font-size: .8125rem; background: rgba(0, 0, 0, .3); }
.media-hidden { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 15px; background: var(--surface2); color: var(--text2); font-size: .8125rem; }
.voice-msg { display: flex; align-items: center; gap: 8px; min-width: 200px; }
.voice-msg audio { height: 36px; max-width: 240px; }
.progress { height: 4px; border-radius: 2px; background: var(--surface3); overflow: hidden; margin-top: 4px; }
.progress i { display: block; height: 100%; background: var(--primary); transition: width .1s; }

.composer { border-top: 1px solid var(--border); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); }
.composer:has(~ .chat-bar) { padding-bottom: 6px; }
.composer-row { display: flex; align-items: flex-end; gap: 2px; }
.composer textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 140px; border-radius: 20px; padding: 9px 14px; line-height: 1.35;
  background: var(--surface2); border: 1px solid transparent;
}
.composer textarea:focus { background: var(--surface); border-color: var(--border2); box-shadow: none; }
.composer textarea:disabled { opacity: .7; }
.composer .send { width: 40px; height: 40px; margin-left: 4px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: background var(--transition); }
.composer .send:hover:not(:disabled) { background: var(--primary-hover); }
.composer .send:disabled { background: var(--surface3); color: var(--text3); cursor: default; }
.composer-reply { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; font-size: .8125rem; color: var(--text2); }
.recording { display: flex; align-items: center; gap: 10px; flex: 1; min-height: 40px; padding: 0 10px; color: var(--danger); font-weight: 600; }
.recording i { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.chat-bar { display: flex; gap: 8px; padding: 2px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); }
.chat-bar .btn { flex: 1; min-height: 44px; }
.end-card { margin: 12px auto; width: min(100%, 420px); text-align: center; }
.end-card .row { justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.panel-picker { max-height: 340px; overflow-y: auto; }
.gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.gif-grid button { border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: var(--surface2); }
.gif-grid img { width: 100%; height: 100%; object-fit: cover; }
emoji-picker { width: 100%; --background: var(--surface); --border-color: var(--border); --input-border-color: var(--border2); --input-font-color: var(--text); --category-font-color: var(--text2); --button-hover-background: var(--surface2); --indicator-color: var(--primary); }

/* Messages on desktop: conversation list beside the open chat. */
.split { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }
.split-list { overflow-y: auto; border-right: 1px solid var(--border); background: var(--surface); }
.split-list .view { padding: 20px 12px 24px; max-width: none; }
.split-list .page-head { padding: 0 8px; }
.split-list .tabs { margin: 0 8px 8px; }
.split-list .list { border: 0; border-radius: 0; background: transparent; gap: 2px; }
.split-list .list-row { border: 0; border-radius: 10px; padding: 8px 10px; }
.split-main { min-width: 0; height: 100%; }
.split-main .chat { max-width: none; border: 0; }
.split-empty { display: grid; place-items: center; text-align: center; color: var(--text3); padding: 24px; }
.split-empty .ic { width: 36px; height: 36px; margin: 0 auto 10px; }

/* ── Calls (random voice + direct) ─────────────────────── */
.call-screen { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 100%; min-height: 100%; padding: calc(28px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); background: var(--bg2); text-align: center; }
.call-screen.video { background: #000; color: #fff; }
.call-screen .remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.call-screen .local-video { position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px; width: 28%; max-width: 160px; aspect-ratio: 3/4; border-radius: 12px; object-fit: cover; transform: scaleX(-1); border: 2px solid rgba(255, 255, 255, .3); z-index: 2; }
.call-peer { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 24px; z-index: 1; }
.call-peer .name { font-size: 1.375rem; font-weight: 700; letter-spacing: -.01em; }
.call-status { color: var(--text2); font-variant-numeric: tabular-nums; }
.call-screen.video .call-status { color: rgba(255, 255, 255, .8); }
.call-controls { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; z-index: 1; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); color: var(--text); border: 1px solid var(--border); flex-direction: column; font-size: .625rem; gap: 2px; box-shadow: var(--shadow-sm); }
.call-screen.video .call-btn { background: rgba(255, 255, 255, .16); color: #fff; border-color: transparent; backdrop-filter: blur(8px); }
.call-btn.off { background: var(--text); color: var(--bg); border-color: transparent; }
.call-btn.end { background: var(--danger); color: #fff; border-color: transparent; }
.call-btn.accept { background: var(--success); color: #fff; border-color: transparent; }
.call-btn.next { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.incoming { text-align: center; }
.incoming .row { justify-content: center; gap: 28px; margin-top: 18px; }
.mini-call { position: fixed; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 90; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-radius: 999px; background: var(--success); color: #fff; font-weight: 600; box-shadow: var(--shadow); }
.mini-call[hidden] { display: none; }

/* ── People, profile ───────────────────────────────────── */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 0; }
.toolbar .btn { min-height: 44px; min-width: 44px; padding: 0 12px; }
.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding-top: 4px; }
.profile-head .name { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 380px; margin: 14px auto 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.profile-stats div { text-align: center; }
.profile-stats b { display: inline-flex; align-items: center; gap: 4px; font-size: 1.0625rem; font-weight: 700; }
.profile-stats b .ic { color: #f79009; }
.profile-stats span { display: block; font-size: .75rem; color: var(--text2); margin-top: 1px; }
.profile-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 16px; }
.avatar-edit { position: relative; border-radius: 50%; }
.avatar-edit .cam { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); color: var(--text); border: 1px solid var(--border2); box-shadow: var(--shadow-sm); }
.avatar-edit .pending { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); }
.callout { display: flex; gap: 14px; align-items: flex-start; }
.callout > .ic { flex: none; width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--primary-dim); color: var(--primary-text); }
.callout p { color: var(--text2); font-size: .875rem; line-height: 1.5; margin: 4px 0 12px; }

/* ── Leaderboard ───────────────────────────────────────── */
.lb-rank { width: 28px; text-align: center; font-weight: 700; color: var(--text3); flex: none; font-variant-numeric: tabular-nums; }
.lb-rank.top { color: #dc6803; }
.lb-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Games ─────────────────────────────────────────────── */
.ttt { display: grid; grid-template-columns: repeat(3, 72px); gap: 6px; justify-content: center; margin: 12px 0; }
.ttt button { width: 72px; height: 72px; border-radius: 12px; background: var(--surface2); font-size: 2rem; font-weight: 700; }
.ttt button.x { color: var(--primary); }
.ttt button.o { color: var(--secondary); }
.rps { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
.rps button { font-size: 2.2rem; width: 76px; height: 76px; border-radius: 16px; background: var(--surface2); }
.rps button.on { outline: 2px solid var(--primary); }
.hang-word { font-size: 1.6rem; letter-spacing: .3em; font-weight: 700; text-align: center; margin: 12px 0; font-family: ui-monospace, monospace; }
.keys { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.keys button { padding: 8px 0; border-radius: 6px; background: var(--surface2); font-weight: 600; }
.keys button:disabled { opacity: .3; }
.game-status { text-align: center; font-weight: 600; margin: 6px 0; }

/* ── Consent, ads, install ─────────────────────────────── */
.consent { position: fixed; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 95; max-width: 560px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); font-size: .875rem; color: var(--text2); }
.consent .row { margin-top: 12px; justify-content: flex-end; flex-wrap: wrap; }
.ad-slot { margin: 14px 0; min-height: 100px; border-radius: var(--radius-sm); overflow: hidden; }
.ad-slot:empty { display: none; }
.ad-label { font-size: .625rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); margin: 0 0 4px; }

/* ── Moderation cards ──────────────────────────────────── */
.mod-card { text-align: center; }
.mod-card .ic { width: 40px; height: 40px; color: var(--danger); margin: 0 auto 8px; }
.mod-card h3 { font-size: 1.125rem; margin-bottom: 6px; }
.mod-card p { color: var(--text2); line-height: 1.5; margin-bottom: 16px; }

/* ── SEO hero (static HTML before the app boots) ───────── */
.seo { max-width: 720px; margin: 0 auto; padding: 24px 16px 40px; color: var(--text2); line-height: 1.65; }
.seo h2 { color: var(--text); font-size: 1.125rem; margin: 24px 0 8px; }
.seo ul, .seo ol { padding-left: 20px; }

@media (max-width: 380px) {
  .grid2 { grid-template-columns: 1fr; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); row-gap: 12px; }
}

.list-row > .ic.danger-ic { color: var(--danger); }
