/* ============================================================
   Reddy Support — customer chat  ·  v32
   WhatsApp-accurate UI, mobile first, light + dark themes
   ============================================================ */

/* ---------- light theme (WhatsApp light) ---------- */
:root {
  --accent: #00a884;
  --accent-deep: #008069;
  --accent-soft: #d9fdd3;
  --green: #25d366;

  --bg-chat: #efeae2;
  --bg-panel: #ffffff;
  --bg-bar: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-sunken: #f0f2f5;

  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-in-text: #111b21;
  --bubble-out-text: #111b21;

  --header-bg: #ffffff;
  --header-text: #111b21;
  --header-icon: #54656f;
  --header-sub: #667781;

  --text: #111b21;
  --text-dim: #667781;
  --text-faint: #8696a0;
  --line: #e9edef;
  --line-soft: rgba(11, 20, 26, 0.08);
  --tick-read: #53bdeb;

  --shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --shadow-md: 0 2px 10px rgba(11, 20, 26, 0.12);
  --shadow-lg: 0 12px 44px rgba(11, 20, 26, 0.24);

  --ripple: rgba(11, 20, 26, 0.06);
  --pattern-opacity: 0.055;
  --pattern-invert: 0;

  --header-h: 58px;
  --radius: 14px;
  --app-h: 100dvh;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

/* ---------- dark theme (WhatsApp dark) ---------- */
html[data-theme="dark"] {
  --accent: #00a884;
  --accent-deep: #00a884;
  --accent-soft: #005c4b;

  --bg-chat: #0b141a;
  --bg-panel: #111b21;
  --bg-bar: #1f2c33;
  --bg-elevated: #233138;
  --bg-sunken: #182229;

  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-in-text: #e9edef;
  --bubble-out-text: #e9edef;

  --header-bg: #1f2c33;
  --header-text: #e9edef;
  --header-icon: #aebac1;
  --header-sub: #8696a0;

  --text: #e9edef;
  --text-dim: #8696a0;
  --text-faint: #667781;
  --line: #222d34;
  --line-soft: rgba(255, 255, 255, 0.08);
  --tick-read: #53bdeb;

  --shadow: 0 1px 0.5px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 44px rgba(0, 0, 0, 0.6);

  --ripple: rgba(255, 255, 255, 0.08);
  --pattern-invert: 1;

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  overscroll-behavior: none;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Inter, Roboto, "Noto Sans", "Noto Color Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-chat);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.app { display: flex; height: var(--app-h); overflow: hidden; }

/* the customer view is a single conversation — no desktop chat list */
.sidebar { display: none !important; }

/* ============================================================
   Conversation shell
   ============================================================ */
.conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-chat);
}

/* ---------------- header ---------------- */
.conv-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  height: calc(var(--header-h) + var(--safe-t));
  padding: 0 4px 0 10px;
  padding-top: var(--safe-t);
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 1px 3px rgba(11, 20, 26, 0.08);
  transition: background .22s ease;
}
html[data-theme="dark"] .conv-header { box-shadow: none; border-bottom: 1px solid var(--line); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-deep); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
/* The photo sits on top of the fallback letter instead of beside it, so it
   fills the whole circle and no background colour peeks out at the edge. */
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  /* contain, not cover: the whole logo stays visible instead of being
     cropped to fill the circle */
  object-fit: contain;
  border-radius: 50%;
}
.avatar:has(img) { background: transparent; }
.avatar-header { width: 42px; height: 42px; margin-right: 8px; }

.conv-heading { flex: 1; min-width: 0; }
.conv-title {
  font-size: 16.5px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-status {
  font-size: 12.5px; color: var(--header-sub); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-status.online { color: var(--accent); }
.conv-status.typing { color: var(--accent); }

.hdr-btn {
  position: relative;
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--header-icon);
  transition: background .16s ease, transform .16s ease;
}
.hdr-btn svg { width: 22px; height: 22px; }
.hdr-btn:active { background: var(--ripple); transform: scale(.94); }
@media (hover: hover) { .hdr-btn:hover { background: var(--ripple); } }

.hdr-badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: #f15c6d; color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--header-bg);
}

/* theme toggle — sun / moon swap */
#themeBtn .icon-moon { display: none; }
html[data-theme="dark"] #themeBtn .icon-sun { display: none; }
html[data-theme="dark"] #themeBtn .icon-moon { display: block; }
#themeBtn.spin svg { animation: theme-spin .45s ease; }
@keyframes theme-spin { from { transform: rotate(-70deg) scale(.7); } to { transform: rotate(0) scale(1); } }

/* install (add to home screen) button */
#installBtn { color: var(--accent); }
#installBtn::after {
  content: "";
  position: absolute; inset: 5px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: install-pulse 2.8s ease-out infinite;
  pointer-events: none;
}
@keyframes install-pulse {
  0% { transform: scale(.72); opacity: .5; }
  70%, 100% { transform: scale(1.3); opacity: 0; }
}

.whatsapp-header-btn svg { width: 24px; height: 24px; }

/* ---------------- overflow menu ---------------- */
.menu {
  position: absolute;
  top: calc(var(--header-h) + var(--safe-t) - 6px);
  right: 8px;
  min-width: 232px;
  background: var(--bg-elevated);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 7px 0;
  opacity: 0;
  transform: scale(.9) translateY(-6px);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 60;
}
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 20px;
  text-align: left; font-size: 14.5px; color: var(--text);
}
.menu-item .mi-emoji { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.menu-item:active { background: var(--ripple); }
@media (hover: hover) { .menu-item:hover { background: var(--ripple); } }
.menu-item.danger { color: #f15c6d; }

/* ---------------- connection + search bars ---------------- */
.conn-bar {
  flex-shrink: 0;
  padding: 7px 14px;
  background: #fff3cd; color: #8a6116;
  font-size: 12.5px; text-align: center; font-weight: 500;
  border-bottom: 1px solid var(--line);
}
html[data-theme="dark"] .conn-bar { background: #2a2114; color: #f0c078; border-bottom-color: var(--line); }

.message-search {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--line);
}
.message-search svg { width: 18px; height: 18px; color: var(--text-dim); flex-shrink: 0; }
.message-search input {
  flex: 1; min-width: 0;
  border: none; background: transparent; outline: none;
  font-size: 14.5px;
}
.message-search input::placeholder { color: var(--text-faint); }
.message-search button {
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 20px; line-height: 1; color: var(--text-dim);
  display: grid; place-items: center;
}

/* ---------------- name strip ---------------- */
.name-strip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--line);
}
.name-strip-icon { font-size: 17px; }
.name-strip-label { font-size: 13.5px; color: var(--text-dim); flex-shrink: 0; }
.name-strip input {
  flex: 1; min-width: 0;
  padding: 11px 15px;
  border-radius: 22px; border: 1px solid var(--line);
  background: var(--bg-panel);
  font-size: 15px; outline: none;
  transition: border-color .16s ease;
}
.name-strip input:focus { border-color: var(--accent); }
.name-strip button#inlineNameSave {
  padding: 11px 18px; border-radius: 22px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 600;
  flex-shrink: 0;
}
.name-strip button#inlineNameSave:active { transform: scale(.96); }
.name-strip-current { font-size: 14px; font-weight: 600; }
.name-strip-edit { font-size: 15px; color: var(--text-dim); padding: 4px 8px; }

@media (max-width: 520px) {
  .name-strip-label { display: none; }
  .name-strip input { font-size: 15.5px; }
}

/* ============================================================
   Message list
   ============================================================ */
.conv-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 5% 10px;
  position: relative;
  background-color: var(--bg-chat);
}
.conv-body::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url("whatsapp-bg.svg");
  background-repeat: repeat;
  background-size: 366px auto;
  opacity: var(--pattern-opacity);
  filter: invert(var(--pattern-invert));
  pointer-events: none;
  z-index: 0;
}
.conv-body > * { position: relative; z-index: 1; }

.conv-body::-webkit-scrollbar { width: 6px; }
.conv-body::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 3px; }

/* ---------------- day divider ---------------- */
.day-divider {
  margin: 14px auto;
  width: fit-content;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--bg-bar);
  color: var(--text-dim);
  font-size: 12.2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .3px;
  box-shadow: var(--shadow);
  text-align: center;
}
html[data-theme="dark"] .day-divider { background: #182229; color: #8696a0; }

/* ---------------- bubbles ---------------- */
.msg {
  position: relative;
  max-width: min(78%, 560px);
  width: fit-content;
  margin: 2px 0;
  padding: 6px 9px 8px;
  border-radius: 8px;
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  box-shadow: var(--shadow);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: bubble-in .18s cubic-bezier(.2, .8, .3, 1);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.msg.agent { margin-right: auto; }
.msg.visitor {
  margin-left: auto;
  background: var(--bubble-out);
  color: var(--bubble-out-text);
}

/* first bubble of a run gets the WhatsApp tail */
.msg.agent.tail { border-top-left-radius: 0; margin-top: 10px; }
.msg.visitor.tail { border-top-right-radius: 0; margin-top: 10px; }
.msg.tail::before {
  content: "";
  position: absolute;
  top: 0;
  width: 9px; height: 13px;
}
.msg.agent.tail::before {
  left: -8px;
  background: var(--bubble-in);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}
.msg.visitor.tail::before {
  right: -8px;
  background: var(--bubble-out);
  clip-path: polygon(0 0, 0 100%, 100% 0);
}

.msg.pending { opacity: .72; }

.msg-text { font-size: 15px; line-height: 1.42; white-space: pre-wrap; padding-right: 54px; }
.msg-text a { color: #027eb5; text-decoration: underline; }
html[data-theme="dark"] .msg-text a { color: #53bdeb; }

/* emoji-only messages render large, like WhatsApp */
.msg.emoji-only { background: transparent !important; box-shadow: none; padding: 2px 6px 6px; }
.msg.emoji-only::before { display: none; }
.msg.emoji-only .msg-text { font-size: 40px; line-height: 1.15; padding-right: 48px; }

.msg-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 3px;
  height: 15px;
  margin-top: -15px;
  margin-left: 8px;
  float: right;
  font-size: 11px;
  color: var(--text-faint);
  user-select: none;
}
.msg.visitor .msg-meta { color: rgba(17, 27, 33, .5); }
html[data-theme="dark"] .msg.visitor .msg-meta { color: rgba(233, 237, 239, .6); }
.msg-meta .ticks { width: 15px; height: 11px; flex-shrink: 0; }
.msg-meta .ticks.read { color: var(--tick-read); }

.msg-attachment { display: block; margin: -2px -3px 4px; border-radius: 7px; overflow: hidden; }
.msg-attachment img,
.msg-attachment video {
  display: block; width: 100%; max-width: 340px; max-height: 400px;
  object-fit: cover; border-radius: 7px; background: var(--bg-sunken);
}
.msg-attachment audio { display: block; width: min(260px, 62vw); margin: 4px 0 2px; }

.msg-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(11, 20, 26, .05);
  text-decoration: none; color: inherit;
}
html[data-theme="dark"] .msg-file { background: rgba(255, 255, 255, .06); }
.msg-file-icon svg { width: 26px; height: 26px; color: var(--text-dim); }
.msg-file-name { font-size: 14px; font-weight: 500; word-break: break-word; }
.msg-file-size { font-size: 11.5px; color: var(--text-dim); }

/* caption-less photos, files and voice notes: the timestamp sits below,
   never on top of the media */
.msg.no-text .msg-meta { float: none; margin: 2px 0 0; height: auto; }

.msg.search-match { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

/* system line (call ended, etc.) */
.msg.system {
  max-width: min(86%, 460px);
  margin: 10px auto;
  padding: 7px 13px;
  border-radius: 8px;
  background: var(--bg-bar);
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .msg.system { background: #182229; }
.msg.system::before { display: none; }
.msg.system .msg-text { padding-right: 0; }

/* ---------------- typing indicator ---------------- */
.typing-bubble {
  width: fit-content;
  margin: 8px 0 4px;
  padding: 11px 14px;
  border-radius: 8px 8px 8px 0;
  background: var(--bubble-in);
  box-shadow: var(--shadow);
  display: flex; gap: 4px; align-items: center;
}
.typing-bubble i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  animation: typing-dot 1.25s infinite ease-in-out;
}
.typing-bubble i:nth-child(2) { animation-delay: .18s; }
.typing-bubble i:nth-child(3) { animation-delay: .36s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ---------------- empty state ---------------- */
.empty-state {
  margin: 11vh auto 0;
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  max-width: 340px;
}
.empty-badge {
  width: 76px; height: 76px; margin: 0 auto 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-bar);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.empty-badge svg { width: 36px; height: 36px; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.empty-sub { font-size: 14px; margin: 0; line-height: 1.5; }

/* ---------------- jump to latest ---------------- */
.scroll-down {
  position: absolute;
  right: 14px;
  bottom: 128px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-dim);
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
  z-index: 20;
  animation: bubble-in .2s ease;
}
.scroll-down svg { width: 20px; height: 20px; }
.sd-badge {
  position: absolute; top: -5px; right: -3px;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 19px; text-align: center;
}

.upload-progress {
  flex-shrink: 0;
  padding: 9px 14px;
  background: var(--bg-bar);
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   Quick actions
   ============================================================ */
.quick-actions {
  flex-shrink: 0;
  display: flex;
  gap: 7px;
  padding: 9px 10px 3px;
  overflow-x: auto;
  scrollbar-width: none;
  background: transparent;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-actions.qa-hidden { display: none; }
.qa-chip {
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow);
  transition: transform .14s ease, background .14s ease;
}
.qa-chip:active { transform: scale(.95); }
.qa-chip.qa-primary { background: var(--accent); border-color: transparent; color: #fff; }
.qa-emoji { font-size: 15px; }

/* ============================================================
   Composer
   ============================================================ */
.composer {
  flex-shrink: 0;
  padding: 6px 8px calc(8px + var(--safe-b));
  background: var(--bg-bar);
  transition: background .22s ease;
}

.composer-row { display: flex; align-items: flex-end; gap: 6px; }

.composer-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: var(--bg-panel);
  border-radius: 24px;
  padding: 3px 6px;
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  transition: background .16s ease, transform .14s ease;
}
.icon-btn svg { width: 23px; height: 23px; }
.icon-btn:active { background: var(--ripple); transform: scale(.92); }
@media (hover: hover) { .icon-btn:hover { background: var(--ripple); } }
.icon-btn.active { color: var(--accent); }

#msgInput {
  flex: 1;
  min-width: 0;
  max-height: 132px;
  padding: 9px 4px;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 15.5px;
  line-height: 1.35;
  color: var(--text);
}
#msgInput::placeholder { color: var(--text-faint); }

.round-btn {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .14s ease, background .16s ease;
}
.round-btn svg { width: 22px; height: 22px; }
.round-btn:active { transform: scale(.92); }
#sendBtn { animation: pop-in .16s ease; }
@keyframes pop-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- recording bar ---------------- */
.recording {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px 4px;
}
.rec-cancel { width: 38px; height: 38px; display: grid; place-items: center; color: #f15c6d; }
.rec-cancel svg { width: 21px; height: 21px; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #f15c6d; animation: rec-blink 1.1s infinite; }
@keyframes rec-blink { 50% { opacity: .25; } }
.rec-time { font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-hint { flex: 1; font-size: 12.5px; color: var(--text-dim); }

/* ============================================================
   Emoji picker
   ============================================================ */
.emoji-tray {
  background: var(--bg-panel);
  border-radius: 14px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: sheet-up .18s ease;
}
@keyframes sheet-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 6px 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab {
  flex: 1 0 auto;
  min-width: 44px;
  padding: 7px 0 8px;
  font-size: 19px;
  border-bottom: 2.5px solid transparent;
  opacity: .5;
  transition: opacity .14s ease;
}
.emoji-tab.active { opacity: 1; border-bottom-color: var(--accent); }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px;
  padding: 8px;
  max-height: 210px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.emoji-grid button {
  height: 40px;
  font-size: 24px;
  line-height: 1;
  border-radius: 8px;
  transition: background .12s ease, transform .12s ease;
}
.emoji-grid button:active { background: var(--ripple); transform: scale(1.18); }
.emoji-empty { padding: 22px 12px; text-align: center; font-size: 13px; color: var(--text-dim); grid-column: 1 / -1; }

/* ============================================================
   Bottom sheets
   ============================================================ */
.scrim {
  position: fixed; inset: 0;
  background: rgba(11, 20, 26, .55);
  z-index: 70;
  animation: fade-in .16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(26px + var(--safe-b));
  transform: translateY(105%);
  transition: transform .26s cubic-bezier(.2, .8, .25, 1);
  box-shadow: var(--shadow-lg);
}
.sheet.open { transform: none; }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 18px; }
.sheet-title { font-size: 15.5px; font-weight: 600; margin: 0 0 10px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; }
.sheet-tile { display: grid; justify-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.tile-icon {
  width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  transition: transform .14s ease;
}
.sheet-tile:active .tile-icon { transform: scale(.9); }
.tile-icon svg { width: 24px; height: 24px; }
.ti-media { background: linear-gradient(145deg, #a45cff, #7a3ff2); }
.ti-camera { background: linear-gradient(145deg, #ff5c8a, #e0245e); }
.ti-doc { background: linear-gradient(145deg, #5b8def, #3663d6); }
.ti-audio { background: linear-gradient(145deg, #ff9a3c, #f2760b); }

/* iOS install help sheet */
.install-help { font-size: 14px; color: var(--text-dim); line-height: 1.6; }
.install-help ol { margin: 10px 0 0; padding-left: 20px; }
.install-help li { margin-bottom: 8px; }
.install-help b { color: var(--text); }
.install-done {
  margin-top: 18px; width: 100%;
  padding: 13px; border-radius: 24px;
  background: var(--accent); color: #fff; font-weight: 600;
}

/* ============================================================
   Notification centre
   ============================================================ */
.panel {
  position: fixed; inset: 0;
  z-index: 90;
  background: var(--bg-panel);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.2, .8, .25, 1);
}
.panel.open { transform: none; }
.panel-header {
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--header-h) + var(--safe-t));
  padding: 0 8px 0 4px;
  padding-top: var(--safe-t);
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid var(--line);
}
.panel-header .hdr-btn { color: var(--header-icon); }
.panel-title { flex: 1; font-size: 17px; font-weight: 600; }
.panel-link { color: var(--accent); font-size: 14px; font-weight: 600; padding: 8px; }

.push-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunken);
}
.push-row-text { flex: 1; }
.push-row-title { font-size: 15px; font-weight: 600; }
.push-row-sub { font-size: 12.8px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }

.switch {
  width: 46px; height: 26px; flex-shrink: 0;
  border-radius: 13px;
  background: #c9d1d6;
  position: relative;
  transition: background .2s ease;
}
html[data-theme="dark"] .switch { background: #3b4a54; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch .knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s cubic-bezier(.2, .8, .25, 1);
}
.switch[aria-checked="true"] .knob { transform: translateX(20px); }

.notif-list { flex: 1; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.notif-item.unread { background: var(--bg-sunken); }
.notif-av {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-deep); color: #fff;
  display: grid; place-items: center; font-weight: 600; flex-shrink: 0;
}
.notif-body { flex: 1; min-width: 0; }
.notif-top { display: flex; justify-content: space-between; gap: 8px; }
.notif-title { font-size: 14.5px; font-weight: 600; }
.notif-time { font-size: 11.5px; color: var(--text-dim); flex-shrink: 0; }
.notif-text {
  font-size: 13.5px; color: var(--text-dim); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.notif-empty { padding: 60px 30px; text-align: center; color: var(--text-dim); }
.notif-empty svg { width: 46px; height: 46px; margin-bottom: 14px; opacity: .5; }
.notif-empty p { font-size: 14px; line-height: 1.6; margin: 0; }

/* ============================================================
   Call screen
   ============================================================ */
.call-overlay {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid;
  background: linear-gradient(170deg, #0f2b26 0%, #0b141a 55%, #071016 100%);
  animation: fade-in .2s ease;
}
.call-card {
  display: flex; flex-direction: column;
  height: 100%;
  padding: calc(14px + var(--safe-t)) 20px calc(28px + var(--safe-b));
  color: #e9edef;
}
.call-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.call-top-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 22px; color: rgba(233, 237, 239, .85);
}
.call-secure { font-size: 12px; color: rgba(233, 237, 239, .65); letter-spacing: .2px; }

.call-center {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  text-align: center;
}
.call-avatar {
  width: 132px; height: 132px; border-radius: 50%;
  overflow: hidden; margin-bottom: 20px;
  box-shadow: 0 0 0 4px rgba(0, 168, 132, .28), 0 18px 44px rgba(0, 0, 0, .5);
}
.call-avatar img { width: 100%; height: 100%; object-fit: contain; background: #0e1b21; }
.call-overlay.ringing .call-avatar { animation: call-breathe 2s ease-in-out infinite; }
@keyframes call-breathe {
  0%, 100% { box-shadow: 0 0 0 4px rgba(0, 168, 132, .28), 0 18px 44px rgba(0, 0, 0, .5); }
  50% { box-shadow: 0 0 0 16px rgba(0, 168, 132, .07), 0 18px 44px rgba(0, 0, 0, .5); }
}
.call-title { font-size: 25px; font-weight: 600; letter-spacing: -.01em; }
.call-state { font-size: 15px; color: rgba(233, 237, 239, .75); }
.call-number { font-size: 14px; color: rgba(233, 237, 239, .55); font-variant-numeric: tabular-nums; }

.call-actions {
  display: flex; align-items: center; justify-content: center; gap: 22px;
  padding: 22px 0 10px;
}
.call-action-circle {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  transition: transform .14s ease, background .16s ease;
}
.call-action-circle svg { width: 26px; height: 26px; }
.call-action-circle:active { transform: scale(.92); }
.call-action-circle.end { background: #ea4335; }
.call-action-circle.accept { background: #21b573; animation: call-accept-pulse 1.4s ease-in-out infinite; }
@keyframes call-accept-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(33, 181, 115, .5); }
  70% { box-shadow: 0 0 0 16px rgba(33, 181, 115, 0); }
}
.call-action-circle.off { background: #fff; color: #111b21; }
.call-foot { text-align: center; font-size: 12px; color: rgba(233, 237, 239, .5); }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 120;
  max-width: min(86vw, 400px);
  padding: 11px 18px;
  border-radius: 22px;
  background: rgba(17, 27, 33, .94);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translateX(-50%); } }

/* ============================================================
   Desktop refinement
   ============================================================ */
@media (min-width: 900px) {
  /* Full width on laptops and desktops — the chat fills the browser window
     edge to edge rather than sitting in a narrow column. */
  .app { width: 100%; max-width: none; margin: 0; }
  .conv-body { padding: 16px 6% 12px; }
  .msg { max-width: min(66%, 620px); }
  .composer { padding: 8px 14px 14px; }
  .composer-row { max-width: 1400px; margin: 0 auto; }
  .quick-actions { padding-left: 14px; padding-right: 14px; }
  .panel { left: auto; width: 400px; border-left: 1px solid var(--line); }
  .call-card { max-width: 460px; margin: 0 auto; }
}

/* ============================================================
   Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ============================================================
   Header crowding — phones keep the essentials, the rest moves
   into the ⋮ menu so the support name never gets squeezed out
   ============================================================ */
@media (max-width: 560px) {
  #searchBtn { display: none; }
  .conv-header { padding-left: 8px; }
  .avatar-header { margin-right: 6px; }
}
@media (min-width: 561px) {
  #miSearch { display: none; }
}
