*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--st-font); color: var(--st-text); background: #dfe6ea; }
button, input { font: inherit; border: none; background: none; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app { min-height: 100%; display: grid; place-items: center; padding: 12px; }
.shell {
  position: relative;
  width: min(420px, 100%);
  height: min(860px, 100dvh);
  background: var(--st-bg-muted);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
}
@media (max-width: 480px) {
  .app { padding: 0; }
  .shell { width: 100%; height: 100dvh; border-radius: 0; box-shadow: none; }
}

.glass {
  backdrop-filter: blur(var(--st-blur));
  -webkit-backdrop-filter: blur(var(--st-blur));
  background: var(--st-glass);
}

.screen { flex: 1; overflow: auto; padding-bottom: calc(var(--st-nav-height) + 12px); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px;
  background: rgba(255,255,255,.55);
}
.text-btn { color: var(--st-brand); font-size: var(--st-fs-md); padding: 8px 12px; }
.link-btn { color: var(--st-brand); font-size: var(--st-fs-md); }

/* Chat */
.screen-chat { display: flex; flex-direction: column; padding-bottom: 0; background:
  linear-gradient(180deg, #b7d4b0, #cfe0d4);
  background-size: cover;
}
.chat-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; min-height: var(--st-header-height);
}
.peer-pill {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--st-radius-pill);
  text-align: left;
}
.peer-meta { display: flex; flex-direction: column; min-width: 0; }
.peer-name { font-weight: 600; font-size: var(--st-fs-md); line-height: 1.1; }
.peer-status { font-size: var(--st-fs-xs); color: var(--st-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  border-radius: 50%; background: #dde3ea; display: grid; place-items: center;
  font-weight: 700; flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; margin: 0 auto 8px; background: var(--st-brand); color: #fff; }
.brand-x { background: #111; color: #fff; }
.avatar-btn { font-size: 14px; background: #111; color: #fff; }

.chat-thread {
  flex: 1; overflow: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.date-pill {
  align-self: center; font-size: var(--st-fs-xs);
  padding: 4px 10px; border-radius: var(--st-radius-pill);
  background: rgba(255,255,255,.55); color: #444;
}
.msg { max-width: 78%; display: flex; flex-direction: column; gap: 2px; }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; }
.bubble {
  background: var(--st-bubble-out); padding: 8px 12px;
  border-radius: var(--st-bubble-radius); font-size: var(--st-fs-md);
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.msg-in .bubble { background: var(--st-bubble-in); }
.msg-meta { align-self: flex-end; display: flex; gap: 4px; font-size: 11px; color: #6b7c6a; }
.checks.read { color: var(--st-success-check); }
.sticker-card {
  min-width: 140px; min-height: 140px; border-radius: 18px;
  background: rgba(255,255,255,.7); display: grid; place-items: center;
  font-size: 48px; padding: 12px;
}

.composer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--st-separator);
}
.composer-field {
  flex: 1; display: flex; align-items: center;
  background: #fff; border-radius: var(--st-radius-pill);
  padding: 8px 12px; gap: 6px;
}
.composer-field input { flex: 1; outline: none; min-width: 0; }
.composer-field input::placeholder { color: var(--st-text-secondary); }

/* Settings */
.settings-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
}
.profile-hero { text-align: center; padding: 8px 16px 20px; }
.profile-hero h1 { margin: 0; font-size: var(--st-fs-title); font-weight: 700; }
.profile-sub { margin: 4px 0 0; color: var(--st-text-secondary); font-size: var(--st-fs-sm); }
.card-list {
  margin: 0 12px 12px; background: #fff; border-radius: var(--st-radius-lg); overflow: hidden;
}
.row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; text-align: left; font-size: var(--st-fs-md);
  border-bottom: 1px solid var(--st-separator);
}
.row:last-child { border-bottom: none; }
.row-icon {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; color: #fff;
}
.row-icon.blue { background: var(--st-brand); }
.row-icon.red { background: #ff3b30; }
.row-icon.green { background: #34c759; }
.row-icon.red-dot { background: #d32f2f; border-radius: 50%; font-weight: 700; }
.chev { margin-left: auto; color: var(--st-text-secondary); font-size: 20px; }

/* Calls */
.page-header { padding: 12px; display: flex; justify-content: center; }
.page-header.padded { justify-content: flex-start; }
.page-header h1 { margin: 0; font-size: 28px; }
.segmented {
  display: flex; background: rgba(120,120,128,.12); border-radius: var(--st-radius-pill); padding: 2px;
}
.seg { padding: 6px 18px; border-radius: var(--st-radius-pill); font-size: var(--st-fs-sm); color: #333; }
.seg.active { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.empty-state { text-align: center; padding: 64px 24px; color: var(--st-text-secondary); }
.empty-art { font-size: 72px; margin-bottom: 16px; }
.empty-state p { margin: 0 0 16px; line-height: 1.4; }

/* Chats list */
.chat-row {
  width: 100%; display: flex; gap: 12px; align-items: center;
  padding: 12px 16px; background: #fff; text-align: left;
  border-bottom: 1px solid var(--st-separator);
}
.chat-row .avatar { width: 52px; height: 52px; }
.chat-row-body { flex: 1; min-width: 0; }
.chat-row-top { display: flex; justify-content: space-between; }
.chat-row-top time { color: var(--st-text-secondary); font-size: var(--st-fs-xs); }
.chat-row-preview { color: var(--st-text-secondary); font-size: var(--st-fs-sm); }

/* Tab bar */
.tabbar {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  height: var(--st-nav-height); border-radius: var(--st-radius-pill);
  display: flex; align-items: center; justify-content: space-around;
  box-shadow: var(--st-shadow-nav); padding: 0 4px; z-index: 10;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: #666; padding: 6px 0;
}
.tab span { font-size: 20px; line-height: 1; }
.tab.active { color: var(--st-brand); }
.tab.active span:not(.tab-avatar) { background: var(--st-brand-soft); border-radius: 50%; padding: 4px 8px; }
.tab-avatar {
  width: 22px; height: 22px; border-radius: 50%; background: var(--st-brand); color: #fff;
  font-size: 9px; font-weight: 700; display: grid; place-items: center; position: relative;
}
.tab-avatar::after {
  content: "!"; position: absolute; top: -4px; right: -6px;
  width: 14px; height: 14px; border-radius: 50%; background: #ff3b30; color: #fff;
  font-size: 9px; display: grid; place-items: center;
}
.search-fab {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
  background: #fff; box-shadow: var(--st-shadow-nav); margin-left: 4px;
}

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.18);
  display: grid; place-items: end center;
  padding: 24px;
}
.reactions {
  display: flex; gap: 4px; padding: 8px 10px; border-radius: var(--st-radius-pill);
  margin-bottom: 10px; box-shadow: var(--st-shadow-menu);
}
.reactions button { font-size: 22px; padding: 2px; }
.context-menu, .sheet, .modal {
  width: min(360px, 100%); border-radius: var(--st-radius-lg);
  background: var(--st-glass-dark); box-shadow: var(--st-shadow-menu);
  overflow: hidden; margin-bottom: 40px;
}
.context-menu button, .sheet button {
  width: 100%; text-align: left; padding: 14px 16px;
  border-bottom: 1px solid var(--st-separator); font-size: var(--st-fs-md);
}
.context-menu button:last-child, .sheet button:last-child { border-bottom: none; }
.context-menu hr { margin: 0; border: none; border-top: 1px solid var(--st-separator); }
.danger { color: var(--st-danger) !important; }
.modal { padding: 20px; text-align: center; margin: auto; }
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 16px; color: var(--st-text-secondary); font-size: var(--st-fs-sm); }
.primary-btn {
  display: inline-block; background: var(--st-brand); color: #fff;
  padding: 12px 20px; border-radius: var(--st-radius-pill); text-decoration: none;
  font-weight: 600; margin-bottom: 8px;
}

#msg-menu { place-items: center; align-content: center; }
#msg-menu .reactions { justify-self: center; }
#msg-menu .context-menu { justify-self: center; margin-bottom: 0; }


/* Calls history + overlay (Grok Bot 3) */
.call-history {
  padding: 8px 12px calc(var(--st-nav-height) + 24px);
  overflow: auto;
  flex: 1;
}
.call-row {
  width: 100%; display: flex; gap: 12px; align-items: center;
  padding: 12px 8px; text-align: left; border-radius: var(--st-radius-md);
}
.call-row:active { background: var(--st-bg-muted); }
.call-row-body { flex: 1; min-width: 0; }
.call-row-top { display: flex; justify-content: space-between; gap: 8px; }
.call-row-top time { color: var(--st-text-secondary); font-size: var(--st-fs-xs); }
.call-row-preview { color: var(--st-text-secondary); font-size: var(--st-fs-sm); }
.call-row-top strong.missed { color: var(--st-danger); }

.call-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: linear-gradient(180deg, #1a2a3a 0%, #0b1218 100%);
  color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 48px 24px 40px;
}
.call-overlay[hidden] { display: none !important; }
.call-overlay .call-remote {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; opacity: 0; pointer-events: none;
}
.call-overlay.video-mode .call-remote { opacity: 1; }
.call-overlay .call-local {
  position: absolute; right: 16px; top: 64px; width: 112px; height: 160px;
  border-radius: 12px; object-fit: cover; background: #222;
  border: 2px solid rgba(255,255,255,.35); display: none;
}
.call-overlay.video-mode .call-local { display: block; }
.call-meta { position: relative; z-index: 1; text-align: center; margin-top: 40px; }
.call-meta h2 { margin: 16px 0 6px; font-size: 28px; font-weight: 600; }
.call-meta p { margin: 0; color: rgba(255,255,255,.72); font-size: var(--st-fs-md); }
.call-actions {
  position: relative; z-index: 1; display: flex; gap: 28px;
  align-items: center; margin-bottom: 24px;
}
.call-action {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.16); font-size: 26px;
  display: grid; place-items: center;
}
.call-action.active { background: #fff; color: #111; }
.call-action.hangup { background: #ff3b30; width: 72px; height: 72px; }

/* Auth */
.screen-auth { padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--st-bg-muted); }
.auth-wrap { max-width: 360px; margin: 0 auto; }
.auth-brand { text-align: center; margin-bottom: 16px; }
.auth-brand h1 { margin: 8px 0 0; font-size: 26px; }
.auth-tabs { display: flex; gap: 4px; background: rgba(120,120,128,.12); border-radius: var(--st-radius-pill); padding: 3px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; padding: 8px; border-radius: var(--st-radius-pill); font-size: var(--st-fs-sm); }
.auth-tabs button.active { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.auth-form { display: flex; flex-direction: column; gap: 12px; background: #fff; padding: 16px; border-radius: var(--st-radius-lg); }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--st-fs-sm); color: #444; }
.auth-form input, .auth-form textarea {
  border: 1px solid var(--st-separator); border-radius: 12px; padding: 10px 12px; font-size: var(--st-fs-md);
}
.auth-error { color: var(--st-danger); font-size: var(--st-fs-sm); margin: 0 0 8px; }
.verify-hint { margin: 0; font-size: var(--st-fs-sm); color: var(--st-text-secondary); }
.recovery-box { margin-top: 16px; background: #fff3cd; padding: 14px; border-radius: var(--st-radius-lg); }
.recovery-box code { display: block; word-break: break-all; margin: 8px 0; font-size: 13px; }
.danger-row { color: var(--st-danger) !important; justify-content: center; }
.screen-devices .page-header { justify-content: flex-start; gap: 8px; align-items: center; }
.screen-devices .page-header h1 { font-size: 20px; }

/* —— Desktop web (电脑网页版) —— */
@media (min-width: 900px) {
  .app {
    padding: 0;
    background: #0e1621;
    place-items: stretch;
  }
  .shell {
    width: 100%;
    max-width: none;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    display: grid;
    grid-template-columns: 92px 360px 1fr;
    grid-template-rows: 1fr;
    background: #17212b;
  }
  .shell > .tabbar {
    position: relative;
    left: auto; right: auto; bottom: auto;
    grid-column: 1;
    grid-row: 1;
    width: 92px;
    height: 100%;
    margin: 0;
    border-radius: 0;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    padding: 16px 8px;
    background: #0e1621;
    box-shadow: none;
  }
  .shell > .tabbar .tab {
    flex: 0;
    width: 100%;
    padding: 12px 4px;
    font-size: 11px;
    color: #8b9bab;
  }
  .shell > .tabbar .tab.active { color: #fff; }
  .shell > .tabbar .tab.active span:not(.tab-avatar) {
    background: transparent;
    padding: 0;
  }
  .shell > .tabbar .search-fab {
    margin: auto 0 8px;
    background: #242f3d;
    color: #fff;
    box-shadow: none;
  }
  .shell > .screen {
    grid-column: 2;
    grid-row: 1;
    padding-bottom: 12px;
    background: #17212b;
    color: #f5f5f5;
    border-right: 1px solid rgba(255,255,255,.06);
  }
  .shell > .screen .card-list { background: #242f3d; }
  .shell > .screen .row { border-bottom-color: rgba(255,255,255,.06); color: #f5f5f5; }
  .shell > .screen .profile-hero h1,
  .shell > .screen .page-header h1 { color: #fff; }
  .shell > .screen .profile-sub { color: #8b9bab; }
  .shell > .screen-settings .settings-top .text-btn { color: var(--st-brand); }

  /* Active detail pane (chat / auth full width when shown alone) */
  .shell.desktop-detail > .screen.is-detail {
    grid-column: 3;
    background: linear-gradient(180deg, #0e1a14, #15261c);
    border-right: none;
  }
  .shell:not(.desktop-detail) > .screen-chat,
  .shell:not(.desktop-detail) > .screen-auth {
    display: none !important;
  }
  .shell.desktop-detail > .screen-chat:not([hidden]),
  .shell.desktop-detail > .screen-auth:not([hidden]) {
    display: flex !important;
  }
  .shell.desktop-detail > .screen-chats-list:not([hidden]),
  .shell.desktop-detail > .screen-contacts:not([hidden]),
  .shell.desktop-detail > .screen-calls:not([hidden]),
  .shell.desktop-detail > .screen-settings:not([hidden]),
  .shell.desktop-detail > .screen-devices:not([hidden]) {
    grid-column: 2;
  }

  .placeholder-detail {
    grid-column: 3;
    display: grid;
    place-items: center;
    color: #8b9bab;
    background: #0e1621;
    font-size: 15px;
  }
  .shell.desktop-detail .placeholder-detail { display: none; }

  .composer { background: rgba(23, 33, 43, 0.92); border-top-color: rgba(255,255,255,.06); }
  .composer-field { background: #242f3d; color: #fff; }
  .composer-field input { color: #fff; }
  .chat-header { background: rgba(23, 33, 43, 0.85); }
  .peer-name { color: #fff; }
  .bubble { box-shadow: none; }
}

@media (min-width: 900px) and (max-width: 1100px) {
  .shell { grid-template-columns: 72px 300px 1fr; }
}

.call-incoming-actions {
  position: relative; z-index: 1; display: flex; gap: 40px;
  align-items: center; margin-bottom: 24px;
}
.call-incoming-actions[hidden], .call-actions[hidden] { display: none !important; }
.call-action.accept { background: #34c759; width: 72px; height: 72px; }

/* —— Premium polish —— */
:root {
  --st-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --st-elev: 0 8px 28px rgba(15, 23, 42, 0.08);
  --st-elev-strong: 0 16px 40px rgba(15, 23, 42, 0.14);
}

.shell {
  transition: box-shadow 0.35s var(--st-ease);
}
.card-list.elev, .card-list {
  box-shadow: var(--st-elev);
}
.row {
  transition: background 0.18s var(--st-ease), transform 0.18s var(--st-ease);
}
.row:active { transform: scale(0.985); }
.row:hover { background: rgba(51, 144, 236, 0.06); }

.primary-btn {
  transition: transform 0.18s var(--st-ease), box-shadow 0.18s var(--st-ease), filter 0.18s;
  box-shadow: 0 8px 20px rgba(51, 144, 236, 0.35);
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: scale(0.98); }

.st-avatar-glow {
  box-shadow: 0 0 0 4px rgba(51, 144, 236, 0.15), 0 12px 28px rgba(51, 144, 236, 0.35);
}

.auth-wrap .auth-brand .avatar {
  box-shadow: 0 12px 32px rgba(51, 144, 236, 0.4);
}
.auth-form {
  box-shadow: var(--st-elev-strong);
  border: 1px solid rgba(255,255,255,0.7);
}
.auth-tabs {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}

.screen-lead {
  margin: 0 16px 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--st-text-secondary);
}
.search-wrap { padding: 0 12px 12px; }
.search-wrap input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--st-separator);
  background: #fff;
  font-size: 15px;
  box-shadow: var(--st-elev);
  outline: none;
  transition: box-shadow 0.2s var(--st-ease), border-color 0.2s;
}
.search-wrap input:focus {
  border-color: rgba(51, 144, 236, 0.55);
  box-shadow: 0 0 0 4px rgba(51, 144, 236, 0.15);
}

.chats-header {
  justify-content: space-between !important;
  align-items: center;
  width: 100%;
  padding-right: 8px;
}
.settings-title {
  font-size: 20px;
  font-weight: 700;
  padding: 8px 4px;
}
.settings-hint {
  text-align: center;
  color: var(--st-text-secondary);
  font-size: 12px;
  margin: 20px 16px;
  line-height: 1.4;
}

.empty-card {
  margin: 24px 16px;
  padding: 28px 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff, #f7fafc);
  box-shadow: var(--st-elev);
  text-align: center;
}
.empty-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.empty-card p {
  margin: 0 0 16px;
  color: var(--st-text-secondary);
  font-size: 14px;
  line-height: 1.45;
}
.empty-card .primary-btn { width: 100%; border: none; cursor: pointer; }

.chat-row {
  transition: background 0.15s var(--st-ease);
}
.chat-row:hover { background: rgba(51, 144, 236, 0.06); }
.msg .bubble {
  transition: transform 0.15s var(--st-ease);
  animation: st-pop 0.28s var(--st-ease);
}
@keyframes st-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.tabbar {
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid rgba(255,255,255,0.55);
}

@media (min-width: 900px) {
  .shell > .screen .card-list.elev,
  .shell > .screen .card-list {
    box-shadow: none;
    background: #242f3d;
  }
  .search-wrap input {
    background: #242f3d;
    color: #fff;
    border-color: rgba(255,255,255,0.08);
  }
  .empty-card {
    background: linear-gradient(180deg, #1c2733, #17212b);
    color: #fff;
  }
  .empty-card p { color: #8b9bab; }
  .screen-lead { color: #8b9bab; }
  .settings-hint { color: #8b9bab; }
}


/* Calls polish */
.empty-title { margin: 0 0 8px; font-size: 20px; font-weight: 650; color: var(--st-text); }
.call-empty-art {
  width: 88px; height: 88px; margin: 0 auto 16px; border-radius: 28px;
  display: grid; place-items: center; font-size: 36px;
  background: linear-gradient(145deg, #e8f3ff, #f4f7fb);
  box-shadow: 0 10px 30px rgba(42,171,238,.18);
}
#calls-empty .primary-btn { border: none; cursor: pointer; min-width: 200px; }
.dial-modal { text-align: left; }
.dial-field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; font-size: var(--st-fs-sm); color: var(--st-text-secondary); }
.dial-field input {
  border: 1px solid var(--st-separator); border-radius: 12px; padding: 12px 14px;
  background: #fff; color: var(--st-text); font-size: var(--st-fs-md);
}
.dial-error { color: var(--st-danger); font-size: var(--st-fs-sm); margin: 0 0 10px; }
.call-overlay {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(42,171,238,.38), transparent 60%),
    linear-gradient(180deg, #152033 0%, #0b1018 100%);
}
.call-action-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; color: rgba(255,255,255,.8); font-size: 12px; }
.call-meta .avatar { box-shadow: 0 12px 40px rgba(0,0,0,.35); }

.help-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--st-elev, 0 8px 28px rgba(15,23,42,.08));
  text-align: left;
}
.help-card h3 { margin: 0 0 4px; font-size: 15px; text-align: center; }
.help-domain {
  text-align: center;
  font-size: 12px;
  color: var(--st-brand);
  margin: 0 0 12px;
  word-break: break-all;
}
.help-section { margin-bottom: 12px; font-size: 13px; color: #333; }
.help-section strong { display: block; margin-bottom: 4px; }
.help-section ol { margin: 0; padding-left: 1.2em; line-height: 1.45; }
.help-dl { display: block; text-align: center; text-decoration: none; margin-top: 8px; }
a.row { text-decoration: none; color: inherit; }

/* —— Telegram-like visual pass (usable shell) —— */
.shell {
  background: #fff;
}
.screen-chats-list,
.screen-contacts,
.screen-settings,
.screen-devices,
.screen-calls {
  background: #fff;
}
.screen-chats-list .page-header h1,
.screen-contacts .page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.chat-row {
  background: #fff;
  padding: 10px 16px;
  gap: 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.chat-row .avatar {
  width: 54px;
  height: 54px;
  font-size: 20px;
  background: linear-gradient(135deg, #5ac8fa, #3390ec);
}
.chat-row-top strong {
  font-size: 16px;
  font-weight: 600;
}
.chat-row-preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.screen-chat {
  background-color: #8eab7c;
  background-image:
    radial-gradient(rgba(255,255,255,0.18) 1px, transparent 1px),
    linear-gradient(180deg, #9bb88a 0%, #7f9f6d 100%);
  background-size: 18px 18px, 100% 100%;
}
.chat-header {
  background: rgba(238, 242, 245, 0.92);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.peer-pill {
  background: rgba(255,255,255,0.55);
}
.peer-name { font-size: 16px; }
.msg-out .bubble {
  background: #effdde;
  border-bottom-right-radius: 6px;
}
.msg-in .bubble {
  background: #fff;
  border-bottom-left-radius: 6px;
}
.bubble {
  padding: 8px 12px 6px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  max-width: 100%;
  word-break: break-word;
}
.composer {
  background: rgba(238, 242, 245, 0.96);
  gap: 6px;
}
.composer-field {
  border: 1px solid rgba(0,0,0,0.06);
  min-height: 40px;
}
#btn-send {
  background: var(--st-brand);
  color: #fff;
  font-size: 16px;
  width: 40px;
  height: 40px;
}
#btn-send:disabled { opacity: 0.5; }

.tabbar {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(0,0,0,0.06);
}
.tab.active { color: var(--st-brand); font-weight: 600; }

.auth-wrap {
  padding-bottom: 24px;
}
.screen-auth {
  background: linear-gradient(180deg, #e8f2fc 0%, #f1f2f4 40%, #f1f2f4 100%);
  overflow: auto;
}

.card-list {
  border: 1px solid rgba(0,0,0,0.04);
}

.empty-card {
  border: 1px solid rgba(51,144,236,0.12);
}

/* Make chat fill above tabbar on mobile */
@media (max-width: 899px) {
  .screen-chat {
    padding-bottom: 0;
    height: 100%;
    max-height: calc(100% - var(--st-nav-height) - 24px);
  }
  .shell > .screen-chat:not([hidden]) {
    position: absolute;
    inset: 0 0 calc(var(--st-nav-height) + 20px) 0;
    z-index: 8;
    padding-bottom: 0;
  }
  .shell > .screen-chat .composer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .shell > .screen-chat ~ .tabbar {
    /* chat mode: keep tabbar but chat sits above */
  }
}

/* —— High-end product motion / polish —— */
.screen {
  animation: st-fade 0.22s var(--st-ease, ease);
}
@keyframes st-fade {
  from { opacity: 0.6; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.primary-btn, .icon-btn, .tab, .chat-row, .row {
  -webkit-tap-highlight-color: transparent;
}
.composer-field, .auth-form input, .auth-form textarea, .search-wrap input {
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-form input:focus, .auth-form textarea:focus {
  outline: none;
  border-color: rgba(51,144,236,0.55);
  box-shadow: 0 0 0 4px rgba(51,144,236,0.15);
}
button:disabled, .primary-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.2);
}
.shell {
  -webkit-font-smoothing: antialiased;
}

.st-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 120; max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px; border-radius: 14px;
  background: rgba(20,24,30,.92); color: #fff;
  font-size: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.28);
  backdrop-filter: blur(12px);
}
.st-toast[hidden] { display: none !important; }
#btn-dial-start:disabled { opacity: .65; cursor: wait; }
.call-overlay .avatar-xl {
  background: linear-gradient(145deg, #5ac8fa, #2AABEE);
  border: 3px solid rgba(255,255,255,.2);
}

.call-cta-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.call-cta-row .primary-btn.ghost {
  background: transparent; color: var(--st-brand);
  border: 1.5px solid var(--st-brand);
}
.dial-media { display: flex; gap: 8px; margin: 0 0 14px; }
.dial-media .seg {
  flex: 1; padding: 10px; border-radius: 12px;
  background: var(--st-bg-muted); font-weight: 600;
}
.dial-media .seg.active { background: var(--st-brand); color: #fff; }

/* telegram-tt PhoneCallButton alignment */
.call-action {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.14) !important; color: #fff;
  font-size: 18px; font-weight: 700;
  box-shadow: none;
}
.call-action:hover { background: rgba(255,255,255,.22) !important; }
.call-action.active { background: #fff !important; color: #3c3c43 !important; }
.call-action.hangup { background: #ff3b30 !important; width: 72px; height: 72px; }
.call-action.accept { background: #34c759 !important; width: 72px; height: 72px; }
.call-action-wrap span {
  margin-top: 4px; font-size: 12px; color: #fff;
  text-transform: lowercase; letter-spacing: 0.02em;
}
.call-overlay .call-meta h2 {
  text-shadow: 0 2px 16px rgba(0,0,0,.45);
}
