/* ============================================================
   UPYUGO Chat — WhatsApp-style UI
   Light + dark theming is driven entirely by the [data-theme]
   attribute on <html>, so every colour below is a variable.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #00a884;
  --green-d:      #008069;
  --green-dd:     #005c4b;
  --green-l:      #25d366;
  --teal-deep:    #111b21;

  --bg-app:       #eae6df;
  --bg-panel:     #ffffff;
  --bg-header:    #f0f2f5;
  --bg-hover:     #f5f6f6;
  --bg-active:    #e9edef;
  --bg-input:     #ffffff;
  --bg-chip:      rgba(0,0,0,.05);

  --bubble-in:    #ffffff;
  --bubble-out:   #d9fdd3;

  --text:         #111b21;
  --text-2:       #3b4a54;
  --muted:        #667781;
  --border:       #e9edef;
  --border-2:     #d1d7db;

  --tick:         #8696a0;
  --tick-read:    #53bdeb;
  --danger:       #ea0038;

  --shadow-sm:    0 1px 2px rgba(11,20,26,.13);
  --shadow-md:    0 4px 16px rgba(11,20,26,.15);
  --shadow-lg:    0 12px 40px rgba(11,20,26,.28);

  --radius:       12px;
  --sidebar-w:    380px;

  --wallpaper:    #efeae2;
  --wallpaper-fg: rgba(17,27,33,.045);

  --ease:         cubic-bezier(.2,.8,.3,1);

  /* Safe-area insets. On desktop browsers env() is unsupported or resolves to
     0px, so the fallback keeps the web layout byte-identical. On Android the
     WebView draws edge-to-edge (targetSdk 35+), so these report the status bar,
     navigation bar and any display cutout. Requires viewport-fit=cover. */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

html[data-theme="dark"] {
  --bg-app:       #0b141a;
  --bg-panel:     #111b21;
  --bg-header:    #202c33;
  --bg-hover:     #202c33;
  --bg-active:    #2a3942;
  --bg-input:     #2a3942;
  --bg-chip:      rgba(255,255,255,.07);

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

  --text:         #e9edef;
  --text-2:       #d1d7db;
  --muted:        #8696a0;
  --border:       #222d34;
  --border-2:     #2a3942;

  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow-md:    0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.6);

  --wallpaper:    #0b141a;
  --wallpaper-fg: rgba(255,255,255,.03);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted  { color: var(--muted); font-size: 13px; }
.grow   { flex: 1; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Buttons & icons
   ============================================================ */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; background: none; border-radius: 50%;
  color: var(--muted); font-size: 19px; font-style: normal;
  cursor: pointer; user-select: none;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.icon-btn:hover  { background: var(--bg-active); color: var(--text-2); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg    { width: 22px; height: 22px; fill: currentColor; }

.btn {
  padding: 10px 22px; border: none; border-radius: 24px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: filter .18s var(--ease), transform .18s var(--ease);
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.green  { background: var(--green-d); color: #fff; }
.btn.red    { background: var(--danger);  color: #fff; }
.btn.ghost  { background: var(--bg-active); color: var(--text-2); }

/* ============================================================
   Avatars
   ============================================================ */
.avatar {
  width: 49px; height: 49px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 18px; color: #fff;
  background: var(--muted); user-select: none;
  position: relative; overflow: hidden;
}
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.xs { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 96px; height: 96px; font-size: 38px; }

.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-wrap .presence {
  position: absolute; right: 1px; bottom: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--green-l);
  border: 2.5px solid var(--bg-panel);
  animation: pop .25s var(--ease);
}

@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ============================================================
   AUTH
   ============================================================ */
.auth {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #005c4b 0%, #00a884 100%);
  padding: calc(20px + var(--sat)) calc(20px + var(--sar)) calc(20px + var(--sab)) calc(20px + var(--sal));
}
.auth::before {
  content: ""; position: fixed; inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,.10), transparent 45%),
              radial-gradient(circle at 80% 70%, rgba(255,255,255,.08), transparent 45%);
  pointer-events: none;
}
.auth-card {
  position: relative;
  background: var(--bg-panel); padding: 40px 34px 32px;
  border-radius: 20px; width: 100%; max-width: 380px; text-align: center;
  box-shadow: var(--shadow-lg);
  animation: rise .45s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.auth-logo {
  width: 66px; height: 66px; margin: 0 auto 16px; border-radius: 20px;
  background: linear-gradient(140deg, var(--green), var(--green-dd));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; box-shadow: 0 8px 22px rgba(0,168,132,.35);
}
.auth h1 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.tag { color: var(--muted); font-size: 13.5px; margin: 6px 0 26px; }

.input-group { position: relative; margin-bottom: 14px; text-align: left; }
.input-group input {
  width: 100%; padding: 14px 16px; font-size: 15px;
  border: 1.5px solid var(--border-2); border-radius: 12px;
  background: var(--bg-input); color: var(--text); outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.input-group input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,168,132,.15);
}
.auth-card .btn.green { width: 100%; padding: 14px; border-radius: 12px; font-size: 15px; margin-top: 4px; }
.auth-card .btn[disabled] { opacity: .65; cursor: progress; }
.switch { margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.switch a { color: var(--green-d); cursor: pointer; font-weight: 600; margin-left: 5px; }
.switch a:hover { text-decoration: underline; }
.err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }
.err.ok { color: var(--green-d); }

/* ---- auth tabs ---- */
.auth-tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 20px;
  background: var(--bg-header); border-radius: 12px;
}
.auth-tab {
  flex: 1; padding: 10px 8px; border: none; border-radius: 9px; cursor: pointer;
  background: none; color: var(--muted); font-size: 14px; font-weight: 600;
  font-family: inherit;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.auth-tab:hover { color: var(--text-2); }
.auth-tab.on { background: var(--bg-panel); color: var(--green-d); box-shadow: var(--shadow-sm); }

.auth-pane { animation: fadeIn .22s var(--ease); text-align: left; }
.pane-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; text-align: center; }
.pane-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; text-align: center; }
.pane-sub span { font-weight: 600; color: var(--text-2); }
.muted-inline { color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.auth-back { cursor: pointer; }

/* ---- phone input with fixed +91 prefix ---- */
.phone-field {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  border: 1.5px solid var(--border-2); border-radius: 12px;
  background: var(--bg-input); padding: 0 14px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.phone-field:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,168,132,.15); }
.phone-field .cc {
  font-size: 15px; font-weight: 600; color: var(--muted);
  padding-right: 8px; border-right: 1px solid var(--border-2); user-select: none;
}
.phone-field input {
  flex: 1; border: none; background: none; outline: none;
  padding: 14px 0; font-size: 15px; color: var(--text); letter-spacing: .5px;
}
.phone-field.compact { margin-bottom: 10px; }
.phone-field.compact input { padding: 10px 0; font-size: 14px; }

/* ---- OTP code input ---- */
.otp-input {
  text-align: center; font-size: 26px !important; font-weight: 600;
  letter-spacing: 12px; text-indent: 12px; font-variant-numeric: tabular-nums;
}
.otp-input.small { font-size: 20px !important; letter-spacing: 8px; text-indent: 8px; padding: 10px; }

.recovered {
  text-align: center; font-size: 22px; font-weight: 600; color: var(--green-d);
  background: var(--bg-header); border-radius: 12px; padding: 14px; margin-bottom: 18px;
  word-break: break-all;
}

/* ---- profile recovery-phone box ---- */
.recovery-box {
  margin-top: 20px; padding: 14px; border-radius: 12px;
  background: var(--bg-header); border: 1px solid var(--border);
}
.btn.small { padding: 8px 16px; font-size: 13px; }
.recovery-msg { font-size: 12.5px; margin-top: 8px; min-height: 16px; color: var(--muted); }
.recovery-msg.err  { color: var(--danger); }
.recovery-msg.done { color: var(--green-d); }

/* a button mid-request */
.btn.loading { opacity: .7; cursor: progress; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: flex; height: 100vh; background: var(--bg-app); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head {
  background: var(--bg-header);
  /* Header background fills the status-bar strip; its content sits below it. */
  padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 8px calc(12px + var(--sal));
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.side-head .me-block { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.side-head .me-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-wrap { padding: 8px 12px; flex-shrink: 0; display: flex; gap: 8px; align-items: center; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--bg-header); border-radius: 10px; padding: 0 12px;
  border: 1px solid transparent; transition: border-color .18s var(--ease);
}
.search-box:focus-within { border-color: var(--green); background: var(--bg-panel); }
.search-box .s-icon { color: var(--muted); font-size: 14px; }
.search-box input {
  flex: 1; border: none; background: none; outline: none;
  padding: 9px 0; font-size: 14.5px; color: var(--text);
}
.search-box input::placeholder { color: var(--muted); }
.search-clear { cursor: pointer; color: var(--muted); font-size: 15px; }

.filters { display: flex; gap: 8px; padding: 0 12px 8px; flex-shrink: 0; }
.chip {
  padding: 5px 13px; border-radius: 16px; font-size: 13px; cursor: pointer;
  background: var(--bg-header); color: var(--muted); border: none;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.chip.on { background: #d9fdd3; color: #015c4b; }
html[data-theme="dark"] .chip.on { background: #103529; color: #7ae3c3; }

.chat-list { list-style: none; overflow-y: auto; flex: 1; min-height: 0; }
.list-label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: 12px 16px 6px; font-weight: 600;
}
.chat-list li {
  display: flex; align-items: center; gap: 13px;
  padding: 9px 14px; cursor: pointer; position: relative;
  border-bottom: 1px solid var(--border);
  transition: background .15s var(--ease);
  animation: fadeIn .3s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.chat-list li:hover  { background: var(--bg-hover); }
.chat-list li.active { background: var(--bg-active); }

.ci-main { flex: 1; min-width: 0; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 8px; }
.ci-top { margin-bottom: 3px; }
.ci-name {
  font-weight: 500; font-size: 16px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.ci-time.unread { color: var(--green); font-weight: 600; }
.ci-sub {
  flex: 1; min-width: 0; font-size: 14px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.ci-sub .tick { font-size: 13px; }
.badge {
  background: var(--green-l); color: #fff; font-size: 11.5px; font-weight: 600;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  animation: pop .25s var(--ease);
}
.pin-icon { font-size: 13px; color: var(--muted); flex-shrink: 0; transform: rotate(35deg); }

/* ---------- Chat panel ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.empty {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; text-align: center;
  padding: 40px; border-bottom: 6px solid var(--green);
  background: var(--bg-header);
}
.empty .art { font-size: 74px; opacity: .35; }
.empty h2 { font-size: 30px; font-weight: 300; color: var(--text-2); letter-spacing: -.5px; }
.empty p  { color: var(--muted); font-size: 14px; max-width: 460px; line-height: 1.6; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  background: var(--bg-header);
  padding: calc(8px + var(--sat)) calc(14px + var(--sar)) 8px calc(14px + var(--sal));
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.chat-head .peer-block { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.back { display: none; font-size: 26px; }
.peer-info { flex: 1; min-width: 0; }
.peer-name { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 12.5px; color: var(--muted); height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status.online { color: var(--green); }

/* ---------- Messages ---------- */
.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 14px 5% 10px; min-height: 0;
  display: flex; flex-direction: column; gap: 2px;
  background-color: var(--wallpaper);
  background-image:
    radial-gradient(var(--wallpaper-fg) 1.1px, transparent 1.1px),
    radial-gradient(var(--wallpaper-fg) 1.1px, transparent 1.1px);
  background-size: 34px 34px;
  background-position: 0 0, 17px 17px;
  scroll-behavior: smooth;
}

.day-sep { align-self: center; margin: 14px 0 10px; }
.day-sep span {
  background: var(--bg-header); color: var(--muted);
  font-size: 12px; font-weight: 500; padding: 5px 13px;
  border-radius: 8px; box-shadow: var(--shadow-sm);
}

.msg {
  position: relative; max-width: min(68%, 520px);
  padding: 6px 9px 8px; border-radius: 8px;
  font-size: 14.6px; line-height: 1.4; word-wrap: break-word;
  box-shadow: var(--shadow-sm); margin-bottom: 2px;
  animation: bubbleIn .26s var(--ease);
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.msg.in  { background: var(--bubble-in);  align-self: flex-start; border-top-left-radius: 0; }
.msg.out { background: var(--bubble-out); align-self: flex-end;  border-top-right-radius: 0; }
/* grouped consecutive messages from the same sender */
.msg.grouped { margin-top: 0; }
.msg.grouped.in  { border-top-left-radius: 8px; }
.msg.grouped.out { border-top-right-radius: 8px; }
.msg.first { margin-top: 8px; }

/* the little bubble tail */
.msg:not(.grouped)::after {
  content: ""; position: absolute; top: 0; width: 9px; height: 13px;
}
.msg.in:not(.grouped)::after {
  left: -9px;
  background: radial-gradient(circle at 0 100%, transparent 9px, var(--bubble-in) 9px);
}
.msg.out:not(.grouped)::after {
  right: -9px;
  background: radial-gradient(circle at 100% 100%, transparent 9px, var(--bubble-out) 9px);
}

.msg .sender { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.msg .body   { white-space: pre-wrap; }
.msg.deleted .body { font-style: italic; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.msg.highlight { animation: flash 1.4s var(--ease); }
@keyframes flash { 0%,100% { background: var(--bubble-in); } 30% { background: #ffeeb0; } }
.msg.out.highlight { animation: flashOut 1.4s var(--ease); }
@keyframes flashOut { 0%,100% { background: var(--bubble-out); } 30% { background: #b9f0a8; } }

.msg .meta {
  float: right; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted);
  margin: 6px -2px -3px 10px; user-select: none;
}
.msg.out .meta { color: rgba(17,27,33,.45); }
html[data-theme="dark"] .msg.out .meta { color: rgba(233,237,239,.55); }
.tick { font-size: 13px; letter-spacing: -2px; color: var(--tick); }
.tick.read { color: var(--tick-read); }
.edited-flag { font-style: italic; font-size: 10.5px; }

/* quoted reply inside a bubble */
.replied {
  display: block; border-left: 4px solid var(--green);
  background: var(--bg-chip); border-radius: 5px;
  padding: 5px 9px; margin-bottom: 5px; font-size: 13px; cursor: pointer;
  overflow: hidden;
}
.replied b { display: block; color: var(--green); font-size: 12.5px; margin-bottom: 1px; }
.replied .rtext { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* media */
.msg img.media {
  max-width: 100%; width: 280px; border-radius: 7px;
  display: block; margin: -2px -3px 4px; cursor: pointer;
  transition: filter .2s var(--ease);
}
.msg img.media:hover { filter: brightness(.93); }
.file-chip {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg-chip); padding: 11px 13px; border-radius: 8px;
  min-width: 210px; text-decoration: none; color: inherit;
  transition: filter .18s var(--ease);
}
.file-chip:hover { filter: brightness(.95); }
.file-chip .fi { font-size: 26px; }
.file-chip .fname { font-weight: 500; font-size: 14px; word-break: break-all; }
.file-chip .fsize { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.msg audio { height: 40px; max-width: 240px; display: block; }

/* reactions */
.reax {
  position: absolute; bottom: -11px; right: 8px;
  display: flex; align-items: center; gap: 2px;
  background: var(--bubble-in); border: 1px solid var(--border);
  border-radius: 12px; padding: 1px 6px; font-size: 13px;
  box-shadow: var(--shadow-sm); cursor: pointer; z-index: 2;
  transition: transform .18s var(--ease);
}
.reax:hover { transform: scale(1.08); }
.reax .rcount { font-size: 11px; color: var(--muted); font-weight: 600; }

/* hover chevron opening the message menu */
.msg-menu-btn {
  position: absolute; top: 1px; right: 2px;
  width: 26px; height: 24px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px; border-radius: 4px;
  opacity: 0; transition: opacity .18s var(--ease);
  background: linear-gradient(to left, var(--bubble-in) 60%, transparent);
}
.msg.out .msg-menu-btn { background: linear-gradient(to left, var(--bubble-out) 60%, transparent); }
.msg:hover .msg-menu-btn, .msg-menu-btn:focus { opacity: 1; }

/* typing indicator */
.typing-row { align-self: flex-start; margin: 4px 0 2px; }
.typing-bubble {
  background: var(--bubble-in); border-radius: 8px; border-top-left-radius: 0;
  padding: 11px 14px; display: flex; gap: 4px; align-items: center;
  box-shadow: var(--shadow-sm);
}
.typing-bubble i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.3s infinite both;
}
.typing-bubble i:nth-child(2) { animation-delay: .18s; }
.typing-bubble i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* scroll-to-bottom */
.scroll-btn {
  position: absolute; right: 22px; bottom: calc(92px + var(--sab)); z-index: 5;
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--bg-panel); color: var(--muted); font-size: 18px;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  transform: translateY(8px);
}
.scroll-btn.show { opacity: 1; pointer-events: auto; transform: none; }
.scroll-btn .badge { position: absolute; top: -5px; right: -3px; }

/* skeleton loaders */
.skeleton-wrap { display: flex; flex-direction: column; gap: 12px; padding: 10px 0; }
.sk {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-chip) 25%, rgba(128,128,128,.16) 50%, var(--bg-chip) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk.bubble { height: 44px; width: 46%; }
.sk.bubble.r { align-self: flex-end; width: 38%; }
.sk-row { display: flex; align-items: center; gap: 13px; padding: 11px 14px; }
.sk.circle { width: 49px; height: 49px; border-radius: 50%; flex-shrink: 0; }
.sk.line { height: 11px; }

/* ---------- Reply / edit bar ---------- */
.reply-bar {
  background: var(--bg-header); padding: 9px 14px;
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  border-top: 1px solid var(--border);
  animation: slideUp .22s var(--ease);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.reply-body {
  flex: 1; min-width: 0; border-left: 4px solid var(--green);
  padding: 2px 10px; border-radius: 4px; background: var(--bg-chip);
}
.reply-body .r-name { font-weight: 600; color: var(--green); font-size: 13px; }
.reply-body .r-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  /* Keeps the composer clear of the gesture bar / navigation bar. */
  padding: 8px calc(14px + var(--sar)) calc(8px + var(--sab)) calc(14px + var(--sal));
  background: var(--bg-header); flex-shrink: 0;
  position: relative;
}
.composer .input-shell {
  flex: 1; display: flex; align-items: flex-end;
  background: var(--bg-input); border-radius: 10px; padding: 0 6px;
  min-height: 42px;
}
#msgInput {
  flex: 1; border: none; background: none; outline: none; resize: none;
  padding: 11px 8px; font-size: 15px; line-height: 1.4; color: var(--text);
  font-family: inherit; max-height: 132px; overflow-y: auto;
}
#msgInput::placeholder { color: var(--muted); }

.send {
  width: 44px; height: 44px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--green-d); color: #fff; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.send:hover  { background: var(--green); }
.send:active { transform: scale(.88); }
.send.pulse  { animation: sendPulse .38s var(--ease); }
@keyframes sendPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18) rotate(12deg); }
  100% { transform: scale(1) rotate(0); }
}

#micBtn.recording { color: var(--danger); animation: recPulse 1.1s infinite; }
@keyframes recPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .6; } }

/* recording bar */
.rec-bar {
  position: absolute; inset: 0; background: var(--bg-header);
  display: flex; align-items: center; gap: 14px; z-index: 6;
  padding: 0 calc(18px + var(--sar)) var(--sab) calc(18px + var(--sal));
  animation: fadeIn .2s var(--ease);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: recPulse 1.1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 500; }
.rec-hint { flex: 1; color: var(--muted); font-size: 13.5px; }

/* attachment menu */
.attach-menu {
  position: absolute; bottom: 62px; left: 14px; z-index: 8;
  background: var(--bg-panel); border-radius: 14px; padding: 9px;
  box-shadow: var(--shadow-md); min-width: 200px;
  animation: menuIn .2s var(--ease); transform-origin: bottom left;
}
@keyframes menuIn { from { opacity: 0; transform: scale(.9) translateY(8px); } to { opacity: 1; transform: none; } }
.attach-item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer; font-size: 14.5px;
  transition: background .15s var(--ease);
}
.attach-item:hover { background: var(--bg-hover); }
.attach-item .ai-icon {
  width: 38px; height: 38px; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* emoji picker */
.emoji-panel {
  position: absolute; bottom: 62px; left: 14px; z-index: 8;
  width: min(348px, calc(100vw - 28px)); height: 300px;
  background: var(--bg-panel); border-radius: 14px;
  box-shadow: var(--shadow-md); display: flex; flex-direction: column;
  overflow: hidden; animation: menuIn .2s var(--ease); transform-origin: bottom left;
}
.emoji-tabs { display: flex; gap: 2px; padding: 8px 8px 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emoji-tab {
  border: none; background: none; cursor: pointer; font-size: 18px;
  padding: 5px 9px; border-radius: 8px; opacity: .55;
  transition: opacity .15s var(--ease), background .15s var(--ease);
}
.emoji-tab:hover { background: var(--bg-hover); }
.emoji-tab.on { opacity: 1; background: var(--bg-active); }
.emoji-grid {
  flex: 1; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.emoji-grid button {
  border: none; background: none; cursor: pointer; font-size: 22px;
  padding: 4px; border-radius: 8px; line-height: 1.2;
  transition: transform .12s var(--ease), background .12s var(--ease);
}
.emoji-grid button:hover { background: var(--bg-hover); transform: scale(1.22); }

/* ---------- Context menu ---------- */
.ctx {
  position: fixed; z-index: 70; min-width: 210px;
  background: var(--bg-panel); border-radius: 12px;
  box-shadow: var(--shadow-md); overflow: hidden;
  animation: menuIn .16s var(--ease);
}
.ctx .reactions {
  display: flex; gap: 2px; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.ctx .reactions span {
  font-size: 24px; cursor: pointer; padding: 3px; border-radius: 50%;
  transition: transform .15s var(--ease);
}
.ctx .reactions span:hover { transform: scale(1.35); }
.ctx-item {
  padding: 11px 17px; cursor: pointer; font-size: 14.5px;
  display: flex; align-items: center; gap: 12px;
  transition: background .15s var(--ease);
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  padding: calc(20px + var(--sat)) calc(20px + var(--sar)) calc(20px + var(--sab)) calc(20px + var(--sal));
  background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s var(--ease);
}
.modal-card {
  background: var(--bg-panel); border-radius: 16px; padding: 26px;
  width: 100%; max-width: 380px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: rise .28s var(--ease);
}
.modal-card.center { text-align: center; }
.modal-title { font-size: 19px; font-weight: 600; margin-bottom: 16px; }
.center .modal-title { margin-top: 14px; margin-bottom: 4px; }
.center-self { margin: 0 auto 8px; }
.lbl { font-size: 12.5px; color: var(--green); display: block; margin: 16px 0 5px; font-weight: 500; }
.field {
  width: 100%; padding: 11px 13px; font-size: 14.5px;
  border: 1.5px solid var(--border-2); border-radius: 10px;
  background: var(--bg-input); color: var(--text); outline: none;
  transition: border-color .18s var(--ease);
}
.field:focus { border-color: var(--green); }
.static-field { padding: 9px 0; font-weight: 500; }
.row { display: flex; align-items: center; margin-top: 22px; }
.row.gap { gap: 10px; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.member-list { max-height: 230px; overflow-y: auto; margin-top: 6px; }
.member-list label {
  display: flex; align-items: center; gap: 12px; padding: 9px 6px;
  cursor: pointer; border-radius: 9px; transition: background .15s var(--ease);
}
.member-list label:hover { background: var(--bg-hover); }
.member-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); }

/* image lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  padding: calc(30px + var(--sat)) calc(30px + var(--sar)) calc(30px + var(--sab)) calc(30px + var(--sal));
  animation: fadeIn .2s var(--ease);
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; animation: rise .3s var(--ease); }
.lightbox .lb-close { position: absolute; top: calc(18px + var(--sat)); right: calc(22px + var(--sar)); color: #fff; font-size: 26px; cursor: pointer; }
.lightbox .lb-download {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  color: #fff; background: rgba(255,255,255,.15); padding: 9px 20px;
  border-radius: 22px; text-decoration: none; font-size: 14px;
}

/* ---------- Calls ---------- */
.call-overlay {
  position: fixed; inset: 0; background: var(--teal-deep); z-index: 85;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.video-grid {
  flex: 1; width: 100%; display: grid; gap: 5px; grid-template-columns: 1fr;
  padding: calc(5px + var(--sat)) calc(5px + var(--sar)) 5px calc(5px + var(--sal));
}
.video-grid.multi { grid-template-columns: 1fr 1fr; }
.video-grid video { width: 100%; height: 100%; object-fit: cover; background: #202c33; border-radius: 10px; }
.video-tile { position: relative; overflow: hidden; border-radius: 10px; }
.video-tile .name {
  position: absolute; bottom: 10px; left: 10px; color: #fff; font-size: 13px;
  background: rgba(0,0,0,.5); padding: 3px 10px; border-radius: 10px;
}
.call-status { position: absolute; top: calc(26px + var(--sat)); color: #fff; font-size: 17px; letter-spacing: .3px; }
.call-controls { display: flex; gap: 18px; padding: 24px 24px calc(24px + var(--sab)); }
.cc {
  width: 58px; height: 58px; border-radius: 50%; border: none; font-size: 22px;
  cursor: pointer; background: #2a3942; color: #fff;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.cc:hover  { background: #3b4a54; }
.cc:active { transform: scale(.9); }
.cc.hang   { background: var(--danger); }

.ring { animation: ring 1.6s infinite; }
@keyframes ring {
  0%,100% { box-shadow: 0 0 0 0 rgba(37,211,102,.5); }
  50%     { box-shadow: 0 0 0 18px rgba(37,211,102,0); }
}

/* toast */
.toast-wrap { position: fixed; bottom: calc(24px + var(--sab)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--teal-deep); color: #fff; padding: 11px 20px;
  border-radius: 24px; font-size: 14px; box-shadow: var(--shadow-md);
  animation: rise .25s var(--ease);
}
html[data-theme="dark"] .toast { background: var(--bg-active); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) { :root { --sidebar-w: 320px; } }

@media (max-width: 768px) {
  .sidebar { width: 100%; border-right: none; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .chat { display: none; }
  .back { display: inline-flex; }
  .messages { padding: 12px 12px 8px; }
  .msg { max-width: 84%; }
  .video-grid.multi { grid-template-columns: 1fr; }
  .empty { border-bottom: none; }
  /* Tighter on mobile, but the safe-area insets must survive this override. */
  .composer { padding: 7px calc(8px + var(--sar)) calc(7px + var(--sab)) calc(8px + var(--sal)); }
  .emoji-panel, .attach-menu { left: calc(8px + var(--sal)); }
  .scroll-btn { right: calc(14px + var(--sar)); bottom: calc(86px + var(--sab)); }
}

@media (max-width: 380px) {
  .chat-head .icon-btn.call-btn { display: none; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .messages { scroll-behavior: auto; }
}

/* ===== PIYUSH PRIVATE CHAT MODE ===== */

/* only simple username/password login */
#authTabs,
#authSwitchText,
#authSwitch,
#forgotLink {
  display: none !important;
}

/* no groups/search/filter/profile clutter */
#newGroupBtn,
.search-wrap,
.filters,
#profileBtn,
#themeBtn {
  display: none !important;
}

/* no calling/menu for MVP */
#voiceBtn,
#videoBtn,
#chatMenuBtn {
  display: none !important;
}

/* cleaner sidebar */
.sidebar {
  min-width: 300px;
}

.side-head {
  justify-content: flex-end;
}

/* Pooja-style empty state */
#emptyState h2 {
  font-size: 22px;
}

