:root {
  /* WhatsApp/Telegram Inspired Dark Palette */
  --bg-deep:   #0f172a; /* Slate 900 */
  --bg-main:   #1e293b; /* Slate 800 */
  --bg-card:   #334155; /* Slate 700 */
  --bg-accent: #0ea5e9; /* Sky 500 (Modern Blue) */
  --bg-acc-tr: rgba(14, 165, 233, 0.15);
  
  --tx-main:   #f8fafc; /* Slate 50 */
  --tx-dim:    #94a3b8; /* Slate 400 */
  --tx-trace:  #475569; /* Slate 600 */
  
  --bd-main:   #334155;
  --bd-focus:  #0ea5e9;
  
  --sh-sm:     0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --sh-md:     0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --sh-lg:     0 10px 15px -3px rgba(0, 0, 0, 0.2);
  
  --fn: 'Inter', 'Roboto', system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --tbar-h: calc(3.5rem + var(--sb));
}

/* Base Resets */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-deep);
  color: var(--tx-main);
  font-family: var(--fn);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  position: fixed;
}

/* Utilities */
.hid { display: none !important; }
.gone { display: none !important; }
.glass { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); background: rgba(30, 41, 59, 0.7); }

/* Overlays */
.ov { 
  position: fixed; inset: 0; z-index: 2000; 
  display: none; align-items: center; justify-content: center; 
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 1rem;
}
.ov.show { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Auth Page (Stunning Design) --- */
#sl {
  background: radial-gradient(circle at top right, #1e293b, #0f172a), 
              linear-gradient(135deg, #0ea5e9 0%, #1e1b4b 100%);
  background-blend-mode: overlay;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  overflow-y: auto;
}

.auth-container {
  width: 100%; max-width: 420px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 2rem;
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.auth-header { text-align: center; margin-bottom: 2.5rem; }
.auth-logo { 
  font-size: 3.5rem; font-weight: 900; color: #fff; letter-spacing: -3px; 
  text-shadow: 0 0 20px rgba(14, 165, 233, 0.5);
  margin-bottom: 0.5rem;
}

.auth-tabs {
  display: flex; gap: 0.25rem; background: rgba(15, 23, 42, 0.5); 
  padding: 0.375rem; border-radius: 1rem; margin-bottom: 2rem;
}
.auth-tab {
  flex: 1; padding: 0.75rem; border: none; background: transparent; 
  color: var(--tx-dim); font-weight: 700; cursor: pointer; border-radius: 0.75rem;
  transition: 0.3s;
}
.auth-tab.active { background: var(--bg-accent); color: #fff; box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3); }

/* --- Layout Systems --- */

/* Mobile: Telegram Style */
#app-mobile {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  background: var(--bg-deep);
}

#mob-screens {
  flex: 1;
  position: relative;
  overflow: hidden;
  top: var(--st);
}

.scr {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.1, 0.7, 0.1, 1);
}
.scr.active { opacity: 1; transform: translateX(0); pointer-events: all; }

/* Desktop: WhatsApp Style */
#app-desktop {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: var(--bg-deep);
}

.desk-sidebar {
  width: 25rem;
  background: var(--bg-main);
  border-right: 1px solid var(--bd-main);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.desk-main {
  flex: 1;
  position: relative;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.desk-pane {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.desk-pane.active { display: flex; }

/* Responsive Switching */
@media (max-width: 899px) {
  #app-desktop { display: none !important; }
  #app-mobile { display: flex; }
}
@media (min-width: 900px) {
  #app-mobile { display: none !important; }
  #app-desktop { display: flex; }
}

/* --- Components --- */

/* App Bars */
.appbar {
  height: 3.5rem;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  background: var(--bg-main);
  border-bottom: 1px solid var(--bd-main);
}
.appbar-title { font-size: 1.125rem; font-weight: 600; flex: 1; }

/* Sidebar Header (WhatsApp Style) */
.sb-header {
  height: 4rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  flex-shrink: 0;
}

/* Sidebar List Item */
.sb-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
}
.sb-item:hover { background: rgba(255,255,255,0.02); }
.sb-item.active { background: var(--bg-acc-tr); }

/* Navigation (Bottom - Mobile) */
#mob-tbar {
  height: var(--tbar-h);
  background: var(--bg-main);
  border-top: 1px solid var(--bd-main);
  display: flex;
  justify-content: space-around;
  padding-bottom: var(--sb);
  z-index: 100;
}
.tbtn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  border: none;
  background: transparent;
  color: var(--tx-dim);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  transition: all 0.2s;
}
.tbtn .material-icons { font-size: 1.5rem; }
.tbtn.active { color: var(--bg-accent); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: 0.15s;
  gap: 0.5rem;
}
.btn-blk { background: var(--bg-accent); color: #fff; }
.btn-blk:hover { background: #0c8ec4; }
.btn-outline { background: transparent; border: 1.5px solid var(--bd-main); color: var(--tx-main); }
.btn-outline:hover { background: var(--bd-main); }

.inp {
  background: var(--bg-card);
  border: 1.5px solid transparent;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  color: #fff;
  outline: none;
  width: 100%;
  transition: 0.2s;
}
.inp:focus { border-color: var(--bd-focus); }

/* Avatars */
.av { border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex-shrink: 0; background-size: cover; position: relative; }
.av.xs { width: 1.5rem; height: 1.5rem; font-size: 0.7rem; }
.av.s  { width: 2.25rem; height: 2.25rem; font-size: 0.9rem; }
.av.m  { width: 3rem; height: 3rem; font-size: 1.1rem; }
.av.l  { width: 5rem; height: 5rem; font-size: 2rem; }
.odot { position: absolute; bottom: 0; right: 0; width: 0.75rem; height: 0.75rem; background: #22c55e; border: 2px solid var(--bg-deep); border-radius: 50%; }

/* --- Floating Call (Desktop) --- */
#desk-call-window {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 22rem;
  background: var(--bg-main);
  border-radius: 1.5rem;
  border: 1px solid var(--bd-main);
  box-shadow: var(--sh-lg);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
}
@keyframes popIn { from { transform: scale(0.9) translateY(-10px); opacity: 0; } }
#desk-call-window.active { display: flex; }

.dcw-hdr { padding: 1rem; display: flex; align-items: center; gap: 1rem; background: rgba(0,0,0,0.1); }
.dcw-body { padding: 2rem 1rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.dcw-ctrls { display: flex; justify-content: space-evenly; padding: 1rem; background: rgba(0,0,0,0.15); gap: 0.5rem; }

/* Desktop Floating Video */
.dcw-vwrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; }
.dcw-vremote { width: 100%; height: 100%; object-fit: cover; }
.dcw-vlocal { position: absolute; bottom: 0.5rem; right: 0.5rem; width: 5rem; height: 3rem; border-radius: 0.5rem; border: 1px solid rgba(255,255,255,0.2); overflow: hidden; background: #000; }

/* Call Screen Full (Mobile) */
#scaller, #scallee, #svid { z-index: 900; background: var(--bg-deep); }

/* --- Chat & Messaging --- */
.chat-wrap { flex: 1; display: flex; flex-direction: column; background: var(--bg-deep); }
.msg-area { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.bbl { max-width: 80%; padding: 0.75rem 1rem; font-size: 0.9375rem; line-height: 1.4; border-radius: 1rem; }
.bbl.in { background: var(--bg-main); align-self: flex-start; border-bottom-left-radius: 0.25rem; }
.bbl.out { background: rgba(14, 165, 233, 0.3); align-self: flex-end; border-bottom-right-radius: 0.25rem; border: 1px solid var(--bg-accent); }

/* --- Keypad & Dialer --- */
.kgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 2rem; max-width: 20rem; margin: 0 auto; }
.key { width: 4.5rem; height: 4.5rem; border-radius: 50%; border: none; background: var(--bg-main); color: var(--tx-main); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.5rem; }
.key:active { background: var(--bg-card); }
.kd { font-weight: 500; }
.kl { font-size: 0.6rem; opacity: 0.5; text-transform: uppercase; }

/* Registration Success View */
.prof-container { max-width: 25rem; margin: 2rem auto; width: 90%; display: flex; flex-direction: column; gap: 1.5rem; }
.prof-hero { background: var(--bg-main); border-radius: 1.5rem; padding: 2.5rem 1.5rem; border: 1px solid var(--bd-main); display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; }

/* Cards & Lists */
.card { background: var(--bg-main); border-radius: 1rem; overflow: hidden; border: 1px solid var(--bd-main); }
.item-row { display: flex; align-items: center; gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--bd-main); cursor: pointer; }
.item-row:last-child { border-bottom: none; }
.item-info { flex: 1; }
.item-title { font-weight: 600; font-size: 0.95rem; }
.item-sub { color: var(--tx-dim); font-size: 0.8rem; margin-top: 0.125rem; }

/* Toasts */
#toast { position: fixed; bottom: 6rem; left: 50%; transform: translateX(-50%); background: var(--bg-card); color: #fff; padding: 0.75rem 1.5rem; border-radius: 2rem; box-shadow: var(--sh-lg); font-size: 0.875rem; opacity: 0; transition: 0.3s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-10px); }

/* Banner */
#conn-banner { height: 0; overflow: hidden; transition: 0.3s; background: #ea580c; color: #fff; font-size: 0.75rem; display: flex; align-items: center; justify-content: center; border-bottom-left-radius: 0.75rem; border-bottom-right-radius: 0.75rem; }
#conn-banner.show { height: 2rem; }
#conn-banner.online { background: #16a34a; }

/* Loading */
/* --- Chat Conversational Elements --- */
.conv-hdr { height: 4.5rem; display: flex; align-items: center; padding: 0 1rem; border-bottom: 1px solid var(--bd-main); gap: 0.5rem; z-index: 10; }
.conv-info { line-height: 1.2; }
.conv-name { font-weight: 700; font-size: 1rem; color: #fff; }
.conv-stat { font-size: 0.75rem; color: var(--tx-dim); font-weight: 500; }
.conv-stat.on { color: #22c55e; }

.chat-inp-wrap { padding: 0.75rem 1rem; background: var(--bg-main); display: flex; align-items: flex-end; gap: 0.5rem; border-top: 1px solid var(--bd-main); z-index: 10; position: relative; }
.chat-inp { flex: 1; background: var(--bg-card); border: 1.5px solid transparent; border-radius: 1.25rem; padding: 0.625rem 1rem; color: #fff; font-family: inherit; font-size: 0.9375rem; outline: none; resize: none; max-height: 120px; transition: 0.2s; min-height: 42px; }
.chat-inp:focus { border-color: var(--bg-accent); }

.c-btn { width: 42px; height: 42px; border-radius: 50%; border: none; background: transparent; color: var(--tx-dim); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; flex-shrink: 0; }
.c-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.c-send { background: var(--bg-accent); color: #fff; }
.c-send:hover { background: #0ea5e9; transform: scale(1.05); }
.c-send:disabled { background: var(--tx-trace); opacity: 0.5; transform: none; }

/* Typing Indicator Bubble */
.typing-bbl { align-self: flex-start; background: var(--bg-main); padding: 0.75rem 1rem; border-radius: 1rem; border-bottom-left-radius: 0.25rem; display: none; align-items: center; gap: 4px; box-shadow: var(--sh-md); }
.typing-bbl.show { display: flex; animation: fadeIn 0.2s ease; }
.td { width: 6px; height: 6px; border-radius: 50%; background: var(--tx-dim); animation: bounce 1.4s infinite ease-in-out both; }
.td:nth-child(1) { animation-delay: -0.32s; }
.td:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Multimedia Content */
.bbl.img { padding: 4px; background: var(--bg-card); }
.bbl.img img { width: 100%; border-radius: 0.75rem; display: block; max-width: 280px; }
.bbl-time { font-size: 0.65rem; opacity: 0.5; margin-top: 0.25rem; text-align: right; font-weight: 500; text-transform: uppercase; }

/* Voice Notes */
.bbl.voice { display: flex; align-items: center; gap: 0.75rem; min-width: 180px; padding: 0.625rem 0.875rem; }
.vplay { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--bg-accent); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.vbars { flex: 1; display: flex; align-items: center; gap: 2px; height: 24px; }
.vbar { width: 2.5px; background: var(--tx-trace); border-radius: 1px; }
.bbl.out .vbar { background: rgba(255,255,255,0.4); }
.vdur { font-size: 0.7rem; color: var(--tx-dim); font-variant-numeric: tabular-nums; }

/* Recording UI */
.rec-ind { position: absolute; inset: 0; background: var(--bg-main); display: none; align-items: center; padding: 0 1rem; gap: 0.75rem; border-top: 1px solid var(--bd-main); }
.rec-ind.show { display: flex; animation: slideInUp 0.15s ease; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.1); } 100% { opacity: 1; transform: scale(1); } }
.btn-cancel { border: none; background: transparent; color: #ef4444; font-weight: 700; font-size: 0.75rem; cursor: pointer; padding: 0.5rem; }

/* Desktop Specifics */
#app-desktop .msg-area { padding: 2rem 3rem; background: var(--bg-deep); background-image: radial-gradient(var(--bg-main) 1px, transparent 0); background-size: 40px 40px; }
#app-desktop .bbl { max-width: 65%; }

.date-div { text-align: center; margin: 1.5rem 0; font-size: 0.7rem; font-weight: 700; color: var(--tx-dim); text-transform: uppercase; letter-spacing: 1px; position: relative; }
.date-div::before { content: ''; position: absolute; left: 0; top: 50%; width: 35%; height: 1px; background: var(--tx-trace); opacity: 0.3; }
.date-div::after { content: ''; position: absolute; right: 0; top: 50%; width: 35%; height: 1px; background: var(--tx-trace); opacity: 0.3; }
