:root {
  color-scheme: light;
  --page: #eef3f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-blue: #edf4ff;
  --text: #17233b;
  --muted: #65738b;
  --line: #dbe3ef;
  --primary: #1769e8;
  --primary-strong: #0957ce;
  --primary-soft: #e9f2ff;
  --success: #0c9b67;
  --success-soft: #e6f8f1;
  --warning: #e58c16;
  --warning-soft: #fff5df;
  --danger: #d84452;
  --danger-soft: #ffedf0;
  --incoming: #ffffff;
  --outgoing: #dff6e9;
  --chat-green: #0b8f6a;
  --chat-green-strong: #087b5c;
  --chat-wall: #efeae2;
  --shadow: 0 18px 50px rgb(34 62 105 / 12%);
  --shadow-soft: 0 8px 24px rgb(34 62 105 / 9%);
  --radius: 22px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c1422;
  --surface: #121d2f;
  --surface-soft: #17243a;
  --surface-blue: #172945;
  --text: #f2f6ff;
  --muted: #a6b4c9;
  --line: #293851;
  --primary: #6ca6ff;
  --primary-strong: #8bb8ff;
  --primary-soft: #18335b;
  --success: #46d39b;
  --success-soft: #123b31;
  --warning: #ffc267;
  --warning-soft: #3d301b;
  --danger: #ff8490;
  --danger-soft: #44232a;
  --incoming: #1a2940;
  --outgoing: #174735;
  --chat-green: #19a57d;
  --chat-green-strong: #15906d;
  --chat-wall: #0b141a;
  --shadow: 0 20px 55px rgb(0 0 0 / 28%);
  --shadow-soft: 0 8px 24px rgb(0 0 0 / 22%);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea { font: inherit; }

button { cursor: pointer; }

.ui-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.welcome {
  min-height: 100dvh;
  padding: max(30px, env(safe-area-inset-top)) 24px max(30px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 95% 4%, rgb(23 105 232 / 17%), transparent 32%),
    radial-gradient(circle at 5% 96%, rgb(16 191 164 / 14%), transparent 30%),
    var(--surface);
  display: flex;
  flex-direction: column;
}

.welcome-top,
.topbar,
.row,
.nav,
.status-line,
.card-heading,
.message-meta,
.composer,
.setting-row { display: flex; align-items: center; }

.welcome-top { justify-content: space-between; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand img { width: 46px; height: 46px; }
.brand strong { display: block; font-size: 18px; letter-spacing: -0.3px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 19px;
}

.install-cta {
  min-width: 112px;
  height: 42px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #1769e8, #09a78f);
  box-shadow: 0 8px 20px rgb(23 105 232 / 28%);
  animation: install-pulse 1.8s ease-in-out infinite;
}
.install-cta strong { font-size: 9px; line-height: 1; letter-spacing: .045em; white-space: nowrap; }
.install-cta-icon { width: 18px; height: 18px; flex: 0 0 18px; stroke-width: 2.2; }
.install-cta:active { transform: scale(.96); }

.welcome-copy { margin: auto 0 32px; }
.welcome-copy .eyebrow,
.section-label {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.welcome-copy h1 {
  max-width: 390px;
  margin: 12px 0 14px;
  font-size: clamp(35px, 10vw, 48px);
  line-height: 1.02;
  letter-spacing: -1.8px;
}
.welcome-copy p {
  max-width: 410px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 16px;
}

.welcome-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-weight: 750; font-size: 13px; }
.field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 15px;
  outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(23 105 232 / 12%); }

.primary-button,
.secondary-button,
.danger-button {
  border: 0;
  border-radius: 15px;
  min-height: 50px;
  padding: 0 18px;
  font-weight: 800;
}
.primary-button { width: 100%; background: var(--primary); color: white; }
.primary-button:hover { background: var(--primary-strong); }
.secondary-button { color: var(--primary); background: var(--primary-soft); }
.danger-button { color: var(--danger); background: var(--danger-soft); }
.button-small { min-height: 38px; padding: 0 13px; font-size: 12px; }
.button-loading { opacity: 0.68; pointer-events: none; }

.privacy-note { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 13px 2px 0; }
.pilot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 11px;
  font-weight: 800;
}

.screen { min-height: 100dvh; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.topbar {
  height: calc(72px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  justify-content: space-between;
  background: rgb(255 255 255 / 88%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
html[data-theme="dark"] .topbar { background: rgb(18 29 47 / 88%); }
.topbar .brand img { width: 38px; height: 38px; }
.topbar .brand strong { font-size: 15px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }

.content { padding: 20px 16px 18px; }
.hello h1 { margin: 4px 0 6px; font-size: 27px; letter-spacing: -0.8px; }
.hello p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 17px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}
.card-heading { justify-content: space-between; gap: 12px; }
.card h2 { margin: 0; font-size: 16px; letter-spacing: -0.2px; }
.card p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.plan-card {
  color: white;
  background: linear-gradient(135deg, #1769e8, #1257c0 58%, #0c9b8c);
  border: 0;
  overflow: hidden;
  position: relative;
}
.plan-card::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgb(255 255 255 / 10%);
  right: -42px;
  top: -60px;
}
.plan-card p { color: rgb(255 255 255 / 75%); }
.plan-name { margin: 22px 0 4px; font-size: 25px; font-weight: 850; }
.plan-date { display: flex; justify-content: space-between; align-items: end; margin-top: 18px; }
.plan-date strong { font-size: 18px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgb(255 255 255 / 17%);
  font-size: 11px;
  font-weight: 800;
}
.status-chip { color: var(--success); background: var(--success-soft); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.quick-action {
  min-height: 105px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
}
.quick-action .quick-icon { display: block; font-size: 22px; margin-bottom: 14px; }
.quick-action strong { display: block; font-size: 13px; }
.quick-action span { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }

.chat-screen { display: flex; flex-direction: column; height: var(--app-viewport-height, 100dvh); min-height: 0; padding-bottom: 0; background: var(--chat-wall); }
.chat-topbar {
  min-height: calc(62px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  background: rgb(255 255 255 / 96%);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 12;
}
html[data-theme="dark"] .chat-topbar { background: #202c33; }
.chat-header-button {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
}
.chat-header-button .ui-icon { width: 21px; height: 21px; }
.chat-searchbar { gap: 5px; padding-right: 13px; }
.chat-searchbar input {
  min-width: 0;
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 20px;
  outline: none;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 13px;
}
.search-count { min-width: 18px; color: var(--muted); font-size: 10px; text-align: center; }
.chat-header-button:hover { background: var(--surface-soft); }
.chat-avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; }
.chat-identity {
  min-width: 0;
  flex: 1;
  padding: 4px 3px;
  text-align: left;
  border: 0;
  color: var(--text);
  background: transparent;
}
.chat-identity strong,
.chat-identity span { display: block; }
.chat-identity strong { font-size: 15px; line-height: 1.25; }
.chat-identity span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.chat-identity .online-dot { width: 6px; height: 6px; margin-right: 3px; }
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 13px 9px 10px;
  background:
    radial-gradient(circle at 8px 8px, rgb(70 88 84 / 7%) 1.5px, transparent 1.7px) 0 0 / 26px 26px,
    radial-gradient(circle at 21px 20px, rgb(70 88 84 / 5%) 1px, transparent 1.2px) 0 0 / 32px 32px,
    var(--chat-wall);
}
.day-marker {
  width: max-content;
  margin: 0 auto 13px;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
  font-size: 10px;
  font-weight: 750;
}
.message { display: flex; margin-bottom: 4px; }
.message.outgoing { justify-content: flex-end; }
.bubble {
  max-width: 87%;
  min-width: 82px;
  padding: 7px 8px 5px;
  border-radius: 9px;
  background: var(--incoming);
  border: 0;
  box-shadow: 0 1px 2px rgb(0 0 0 / 11%);
  position: relative;
}
.outgoing .bubble { background: var(--outgoing); border-top-right-radius: 2px; }
.incoming .bubble { border-top-left-radius: 2px; }
.bubble p { margin: 0; padding-right: 5px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.38; }
.message-meta { justify-content: flex-end; gap: 3px; min-height: 12px; margin: 2px 0 -1px 10px; color: var(--muted); font-size: 9px; }
.delivery { font-size: 10px; letter-spacing: -3px; padding-right: 3px; }
.delivery.read { color: #2b9bd6; }
.reply-button {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  opacity: 0;
  transition: opacity 120ms ease;
}
.bubble:hover .reply-button,
.bubble:focus-within .reply-button { opacity: 1; }
.quoted-message {
  display: grid;
  gap: 2px;
  min-width: 150px;
  margin: -2px 0 6px;
  padding: 6px 8px;
  border-left: 3px solid var(--chat-green);
  border-radius: 5px;
  background: rgb(0 0 0 / 5%);
  font-size: 11px;
}
.quoted-message strong { color: var(--chat-green); }
.quoted-message span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.message-image,
.message-video { display: block; width: min(260px, 68vw); max-height: 320px; margin-bottom: 5px; border-radius: 7px; object-fit: cover; }
.message-audio { width: min(275px, 72vw); height: 42px; }
.message-image-button { display: block; margin: 0; padding: 0; border: 0; border-radius: 7px; color: inherit; background: transparent; }
.message-media-frame { position: relative; width: min(260px, 68vw); }
.message-media-frame .message-video { width: 100%; }
.message-media-frame.audio-frame { width: min(310px, 76vw); padding-right: 31px; }
.message-media-frame.audio-frame .message-audio { width: 100%; }
.media-expand {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: white;
  background: rgb(17 31 47 / 72%);
  font-size: 14px;
  line-height: 1;
}
.audio-frame .media-expand { top: 7px; right: 0; color: var(--muted); background: rgb(0 0 0 / 7%); }
.file-download { color: inherit; text-decoration: none; }
.file-card { min-width: 225px; display: grid; grid-template-columns: 38px 1fr; gap: 8px; align-items: center; padding: 8px; border-radius: 7px; background: rgb(0 0 0 / 5%); }
.media-retry { border: 0; color: inherit; text-align: left; }
.file-card > span { font-size: 25px; }
.file-card strong,
.file-card small { display: block; }
.file-card strong { max-width: 200px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.file-card small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.audio-card { min-width: 235px; display: flex; align-items: center; gap: 8px; }
.play-dot { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--chat-green); font-size: 12px; }
.audio-line { flex: 1; height: 3px; border-radius: 3px; background: var(--muted); opacity: 0.5; }
.audio-card small { color: var(--muted); font-size: 9px; }
.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background: rgb(3 9 18 / 88%);
  backdrop-filter: blur(8px);
}
.media-viewer-card { width: min(100%, 900px); max-height: 100%; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: #111b29; box-shadow: 0 24px 70px rgb(0 0 0 / 45%); }
.media-viewer-card header { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 7px 9px 7px 14px; color: white; background: #162335; }
.media-viewer-card header strong { min-width: 0; flex: 1; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.media-viewer-card header button { width: 34px; height: 34px; border: 0; border-radius: 50%; color: white; background: rgb(255 255 255 / 10%); font-size: 25px; line-height: 1; }
.media-viewer-content { min-height: 180px; max-height: calc(100dvh - 100px); display: grid; place-items: center; overflow: auto; background: #07101c; }
.media-viewer-content img,
.media-viewer-content video { display: block; max-width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; }
.media-viewer-content audio { width: min(520px, calc(100vw - 54px)); margin: 42px 18px; }
.typing { color: var(--muted); font-size: 12px; margin: 6px 5px; min-height: 17px; }
.composer-wrap {
  flex: 0 0 auto;
  padding: 6px 7px calc(7px + env(safe-area-inset-bottom));
  border-top: 0;
  background: var(--chat-wall);
  position: relative;
  z-index: 11;
}
.composer { gap: 6px; align-items: flex-end; }
.quick-replies {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 51px 6px;
}
.quick-replies button {
  min-width: 0;
  height: 31px;
  padding: 0 8px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--chat-green) 46%, var(--line));
  border-radius: 10px;
  color: var(--chat-green-strong);
  background: color-mix(in srgb, var(--surface) 88%, var(--chat-green) 12%);
  box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-replies button:active { transform: scale(0.97); }
.composer textarea {
  resize: none;
  flex: 1;
  height: 42px;
  min-height: 42px;
  max-height: 104px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 5px 8px;
  outline: none;
  line-height: 1.35;
}
.message-field {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  overflow: hidden;
}
.composer-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 21px;
}
.plus-button {
  flex-basis: 46px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: white;
  background: var(--chat-green);
  transition: transform 160ms ease, background 160ms ease;
}
.plus-button .ui-icon { width: 25px; height: 25px; stroke-width: 1.8; }
.plus-button.active { transform: rotate(45deg); background: var(--chat-green-strong); }
.emoji-button .ui-icon { width: 23px; height: 23px; stroke-width: 1.7; }
.send-button {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--chat-green);
  color: white;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.send-button .send-icon { display: none; }
.send-button .mic-icon { display: block; }
.send-button .ui-icon { width: 24px; height: 24px; stroke-width: 2; }
.send-button.has-message .send-icon,
.composer:has(textarea:not(:placeholder-shown)) .send-button .send-icon { display: block; transform: translateX(1px); }
.send-button.has-message .mic-icon,
.composer:has(textarea:not(:placeholder-shown)) .send-button .mic-icon { display: none; }
.composer-panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(64px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 14px 40px rgb(0 0 0 / 18%);
  animation: panel-in 150ms ease-out;
}
.attachment-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 14px 8px 10px; }
.attachment-panel button { min-width: 0; padding: 5px 2px; border: 0; color: var(--muted); background: transparent; font-size: 9px; }
.attachment-icon { width: 45px; height: 45px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 50%; color: white; font-size: 19px; }
.attachment-icon.violet { background: #7b56d8; }
.attachment-icon.pink { background: #e14f8b; }
.attachment-icon.blue { background: #3c86e8; }
.attachment-icon.cyan { background: #21a8bf; }
.emoji-panel { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 12px; }
.emoji-panel button { min-width: 0; height: 34px; padding: 0; border: 0; background: transparent; font-size: 22px; }
.composer-preview { display: flex; align-items: center; gap: 9px; margin: 0 3px 6px 50px; padding: 8px 10px; border-radius: 10px; background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 9%); }
.composer-preview > div { min-width: 0; flex: 1; }
.composer-preview strong,
.composer-preview span,
.composer-preview small { display: block; }
.composer-preview strong { color: var(--chat-green); font-size: 11px; }
.composer-preview span,
.composer-preview small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.composer-preview > button { width: 28px; height: 28px; border: 0; color: var(--muted); background: transparent; font-size: 22px; }
.attachment-preview > span { font-size: 23px; }
.recording-bar { min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 0 4px 0 9px; border-radius: 25px; background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 10%); }
.recording-bar button { border: 0; color: var(--muted); background: transparent; font-size: 18px; }
.recording-dot { width: 9px; height: 9px; border-radius: 50%; background: #e2404d; animation: recording-pulse 1s infinite; }
.recording-bar strong { font-size: 12px; }
.recording-hint { flex: 1; color: var(--muted); font-size: 11px; }
.recording-bar .recording-send { width: 42px; height: 42px; border-radius: 50%; color: white; background: var(--chat-green); }
.recording-bar .ui-icon { width: 20px; height: 20px; margin: auto; }

@keyframes panel-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes recording-pulse { 50% { opacity: 0.35; } }

.alert-item { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; }
.alert-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); }
.alert-item strong { font-size: 13px; }
.alert-item p { margin: 4px 0; }
.alert-item time { color: var(--muted); font-size: 10px; }

.setting-row { justify-content: space-between; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border: 0; }
.setting-row strong { display: block; font-size: 13px; }
.setting-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.security-seal { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 20px; background: var(--success-soft); font-size: 28px; margin-bottom: 14px; }
.logout-guidance { margin: 15px 0 2px; text-align: center; }
.logout-link {
  padding: 4px 7px;
  border: 0;
  color: var(--danger);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.logout-guidance small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.35;
}

.nav {
  position: fixed;
  z-index: 20;
  bottom: 0;
  width: min(100%, 520px);
  height: calc(72px + env(safe-area-inset-bottom));
  padding: 7px 10px env(safe-area-inset-bottom);
  justify-content: space-around;
  background: rgb(255 255 255 / 94%);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
html[data-theme="dark"] .nav { background: rgb(18 29 47 / 94%); }
.nav-button {
  position: relative;
  flex: 1;
  height: 58px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 16px;
  font-size: 10px;
  font-weight: 750;
}
.nav-button .nav-icon { display: block; font-size: 20px; margin-bottom: 4px; }
.nav-button.active { color: var(--primary); background: var(--primary-soft); }
.chat-nav-button .nav-icon {
  width: 30px;
  height: 30px;
  margin: -5px auto 2px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #1769e8, #08aa91);
  box-shadow: 0 5px 13px rgb(23 105 232 / 28%);
  animation: chat-invite-pulse 1.65s ease-in-out infinite;
}
.chat-nav-button.active .nav-icon { animation: none; box-shadow: 0 3px 9px rgb(23 105 232 / 20%); }
.nav-chat-icon { width: 18px; height: 18px; stroke-width: 2; }
.chat-attention-dot {
  position: absolute;
  top: 5px;
  left: calc(50% + 10px);
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: #20c77a;
  animation: chat-dot-blink 1.1s steps(2, end) infinite;
}
.unread-pill { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: white; font-size: 9px; margin-left: 2px; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { font-size: 34px; margin-bottom: 9px; }
.toast-region { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 50; width: min(calc(100% - 28px), 480px); pointer-events: none; }
.toast { margin-top: 8px; padding: 13px 15px; border-radius: 15px; background: #17233b; color: white; box-shadow: var(--shadow); font-size: 12px; animation: toast-in 180ms ease-out; }
.hidden { display: none !important; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes install-pulse {
  0%, 100% { box-shadow: 0 8px 20px rgb(23 105 232 / 25%); transform: scale(1); }
  50% { box-shadow: 0 9px 26px rgb(8 170 145 / 42%); transform: scale(1.035); }
}
@keyframes chat-invite-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.11); }
}
@keyframes chat-dot-blink { 50% { opacity: .25; transform: scale(.75); } }

@media (max-width: 520px) {
  html,
  body,
  .app-shell { height: var(--app-viewport-height, 100dvh); min-height: 0; }
  body { overflow: hidden; }
  .chat-screen { height: var(--app-viewport-height, 100dvh); min-height: 0; }
  body.keyboard-active .chat-topbar { flex: 0 0 54px; min-height: 54px; padding-top: 0; }
  body.keyboard-active .chat-scroll { min-height: 0; }
  body.keyboard-active .quick-replies { display: none; }
  body.keyboard-active .composer-wrap { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

@media (min-width: 521px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100dvh - 48px); border-radius: 30px; }
  .welcome, .screen, .chat-screen { min-height: calc(100dvh - 48px); height: calc(100dvh - 48px); }
  .nav { bottom: 24px; border-radius: 0 0 30px 30px; }
}

@media (max-width: 360px) {
  .content { padding-inline: 12px; }
  .quick-grid { gap: 8px; }
  .brand span { display: none; }
  .chat-header-button { flex-basis: 36px; width: 36px; }
  .emoji-panel { grid-template-columns: repeat(6, 1fr); }
  .quick-replies { gap: 5px; margin-inline: 49px; }
  .quick-replies button { padding-inline: 4px; font-size: 9px; }
  .topbar.install-ready { padding-inline: 10px; }
  .topbar.install-ready .brand { gap: 7px; }
  .topbar.install-ready .brand strong { max-width: 78px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .topbar.install-ready .brand span { display: none; }
  .topbar.install-ready .top-actions { gap: 5px; }
  .install-cta { min-width: 101px; padding-inline: 8px; }
  .install-cta strong { font-size: 8px; }
}

@media (hover: none) {
  .reply-button { opacity: 0.72; }
}

@media (prefers-reduced-motion: reduce) {
  .install-cta,
  .chat-nav-button .nav-icon,
  .chat-attention-dot { animation: none; }
}
