/* ============================================================
   UNIFIED CSS – Dark & Light themes fully scoped, zero conflicts
   Every original rule preserved exactly as written
   ============================================================ */

/* ----- Global Reset (once) ----- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ----- Design Tokens (once) ----- */
:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --border: #f0f0f0;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --accent: #1a1a1a;
  --accent-hover: #333333;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --transition: 150ms ease;
}

/* ----- Base body (light theme default) ----- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
}

/* ============================================================
   DARK THEME – scoped under body.dark
   ============================================================ */
body.dark {
  background: linear-gradient(160deg, #0f0f1a 0%, #1a1025 50%, #0f1a2e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 24px;
  padding: 24px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.dark .bg-glow {
  position: fixed;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.3;
  pointer-events: none;
  transition: all 0.8s ease;
}

body.dark .bg-glow.top {
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: #7c3aed;
}

body.dark .bg-glow.bottom {
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: #3b82f6;
}

body.dark .bg-glow.connected {
  opacity: 0.5;
  width: 400px;
  height: 400px;
}

body.dark .avatar-container {
  position: relative;
  z-index: 1;
}

body.dark .avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 55px;
  border: 2px solid rgba(255,255,255,0.1);
  transition: all 0.5s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}

body.dark .avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.5s ease;
}

body.dark .avatar.ring {
  animation: ringPulse 1.5s infinite;
  border-color: rgba(59,130,246,0.5);
}

body.dark .avatar.ring::after {
  border-color: rgba(59,130,246,0.3);
  animation: ringGlow 1.5s infinite;
}

body.dark .avatar.connected {
  background: rgba(34,197,94,0.15);
  border-color: rgba(34,197,94,0.4);
}

body.dark .avatar.connected::after {
  border-color: rgba(34,197,94,0.2);
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes ringGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(59,130,246,0.2); }
  50% { box-shadow: 0 0 60px rgba(59,130,246,0.4); }
}

body.dark .name {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.3px;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dark .status {
  font-size: 15px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all 0.3s ease;
}

body.dark .status.connected {
  color: #22c55e;
}

body.dark .status.error {
  color: #ef4444;
}

body.dark .timer {
  font-size: 42px;
  font-weight: 700;
  color: #22c55e;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'JetBrains Mono', 'Courier New', monospace;
  letter-spacing: 2px;
  min-height: 52px;
}

body.dark .buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

body.dark button {
  padding: 14px 28px;
  border-radius: 50px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark button:active {
  transform: scale(0.95);
}

body.dark button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

body.dark .btn-answer {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  font-size: 18px;
  padding: 18px 44px;
  box-shadow: 0 8px 32px rgba(34,197,94,0.3);
}

body.dark .btn-answer:hover:not(:disabled) {
  box-shadow: 0 12px 40px rgba(34,197,94,0.45);
  transform: translateY(-2px);
}

body.dark .btn-end {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 8px 32px rgba(239,68,68,0.3);
}

body.dark .btn-end:hover:not(:disabled) {
  box-shadow: 0 12px 40px rgba(239,68,68,0.45);
  transform: translateY(-2px);
}

body.dark .btn-control {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}

body.dark .btn-control:hover:not(:disabled) {
  background: rgba(255,255,255,0.14);
}

body.dark .btn-control.active {
  background: rgba(239,68,68,0.3);
  border-color: rgba(239,68,68,0.5);
}

/* Dark theme responsive */
@media (max-width: 480px) {
  body.dark .avatar {
    width: 110px;
    height: 110px;
    font-size: 45px;
  }
  body.dark .name {
    font-size: 22px;
  }
  body.dark .timer {
    font-size: 34px;
  }
  body.dark button {
    padding: 12px 22px;
    font-size: 14px;
  }
  body.dark .btn-answer {
    font-size: 16px;
    padding: 16px 36px;
  }
}

/* ============================================================
   LIGHT THEME – Login Screen
   ============================================================ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 24px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.login-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 28px;
}

.btn-google {
  width: 100%;
  padding: 12px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  touch-action: manipulation;
  font-family: inherit;
}

.btn-google:hover {
  background: var(--surface);
  border-color: #e0e0e0;
}

.btn-google:active {
  transform: scale(0.98);
}

.btn-google:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-footer {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 20px;
}

/* ============================================================
   LIGHT THEME – Dashboard Layout
   ============================================================ */
.dashboard {
  display: none;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  background: var(--bg);
}

.dashboard.active {
  display: flex;
}

.dashboard .header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.dashboard .header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.dashboard .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.dashboard .header-info {
  flex: 1;
  min-width: 0;
}

.dashboard .header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.dashboard .header-status {
  font-size: 12px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.dashboard .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.dashboard .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dashboard .count-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.dashboard .btn-logout {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  touch-action: manipulation;
  font-size: 16px;
}

.dashboard .btn-logout:hover {
  background: #fef2f2;
  color: var(--danger);
}

.dashboard .btn-logout:active {
  transform: scale(0.95);
}

.dashboard .main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.dashboard .sidebar {
  width: 320px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.dashboard .sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dashboard .user-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dashboard .user-list::-webkit-scrollbar {
  width: 3px;
}

.dashboard .user-list::-webkit-scrollbar-track {
  background: transparent;
}

.dashboard .user-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.dashboard .user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
  touch-action: manipulation;
}

.dashboard .user-item:hover {
  background: var(--surface);
}

.dashboard .user-item.active {
  background: #f5f5f5;
}

.dashboard .user-item:active {
  transform: scale(0.99);
}

.dashboard .u-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.dashboard .u-info {
  flex: 1;
  min-width: 0;
}

.dashboard .u-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard .u-email {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.dashboard .u-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* Unread badge */
.dashboard .u-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  display: none;
}
.dashboard .u-badge.show {
  display: block;
}

/* Typing indicator in chat */
.dashboard .typing-indicator {
  font-size: 11px;
  color: var(--success);
  padding: 4px 12px;
  display: none;
}
.dashboard .typing-indicator.show {
  display: block;
}

/* Message timestamp */
.dashboard .msg-time {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
}

.dashboard .empty-users {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  height: 100%;
}

.dashboard .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.dashboard .empty-users p {
  font-size: 13px;
  line-height: 1.5;
}

.dashboard .chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
}

.dashboard .no-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.dashboard .chat-header {
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dashboard .ch-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.dashboard .ch-info {
  flex: 1;
  min-width: 0;
}

.dashboard .ch-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.dashboard .ch-email {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.dashboard .messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

.dashboard .messages-area::-webkit-scrollbar {
  width: 3px;
}

.dashboard .messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.dashboard .messages-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.dashboard .msg {
  max-width: 75%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard .msg.in {
  align-self: flex-start;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  color: var(--text);
  border: 1px solid var(--border);
}

.dashboard .msg.out {
  align-self: flex-end;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  color: #fff;
  margin-left: auto;
}

.dashboard .chat-input-row {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.dashboard .input-field {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  outline: none;
  background: var(--surface);
  transition: var(--transition);
  font-family: inherit;
  min-width: 0;
}

.dashboard .input-field:focus {
  border-color: #d0d0d0;
  background: var(--bg);
}

.dashboard .input-field::placeholder {
  color: var(--text-tertiary);
}

.dashboard .btn-send {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}

.dashboard .btn-send:hover {
  background: var(--accent-hover);
}

.dashboard .btn-send:active {
  transform: scale(0.95);
}

.dashboard .btn-call {
  width: 40px;
  height: 40px;
  border: none;
  background: #ecfdf5;
  color: var(--success);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}

.dashboard .btn-call:hover {
  background: #d1fae5;
}

.dashboard .btn-call:active {
  transform: scale(0.95);
}

.dashboard .back-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  touch-action: manipulation;
  font-size: 18px;
  flex-shrink: 0;
}

.dashboard .back-btn:hover {
  background: var(--surface);
}

/* Dashboard mobile */
@media (max-width: 768px) {
  .dashboard .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background: var(--bg);
    transition: transform 200ms ease;
  }

  .dashboard .sidebar.hidden {
    transform: translateX(-100%);
  }

  .dashboard .chat-panel {
    width: 100%;
  }

  .dashboard .back-btn {
    display: flex;
  }

  .dashboard .header {
    padding: 10px 12px;
  }

  .dashboard .messages-area {
    padding: 12px;
  }

  .dashboard .msg {
    max-width: 85%;
    font-size: 13px;
  }

  .dashboard .chat-input-row {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .dashboard .input-field {
    padding: 8px 14px;
    font-size: 13px;
  }

  .dashboard .btn-send,
  .dashboard .btn-call {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
}

/* ============================================================
   LIGHT THEME – Chat Screen Layout
   ============================================================ */
.chat-screen {
  display: none;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  background: var(--bg);
}

.chat-screen.active {
  display: flex;
}

.chat-screen .chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.chat-screen .header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.chat-screen .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-screen .header-info {
  flex: 1;
  min-width: 0;
}

.chat-screen .header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chat-screen .header-status {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.chat-screen .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}

.chat-screen .status-dot.online {
  background: var(--success);
}

.chat-screen .status-dot.offline {
  background: var(--warning);
}

.chat-screen .header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.chat-screen .btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  color: var(--text-secondary);
  touch-action: manipulation;
}

.chat-screen .btn-icon:hover {
  background: var(--surface);
  color: var(--text);
}

.chat-screen .btn-icon:active {
  transform: scale(0.95);
}

.chat-screen .btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-screen .btn-icon.primary {
  color: var(--success);
}

.chat-screen .btn-icon.primary:hover {
  background: #ecfdf5;
}

.chat-screen .offline-banner {
  display: none;
  padding: 8px 16px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid #fef3c7;
  flex-shrink: 0;
  font-weight: 500;
}

.chat-screen .offline-banner.show {
  display: block;
}

.chat-screen .messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

.chat-screen .messages-area::-webkit-scrollbar {
  width: 3px;
}

.chat-screen .messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-screen .messages-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-screen .msg {
  max-width: 75%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: fadeIn 200ms ease;
}

.chat-screen .msg.in {
  align-self: flex-start;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  color: var(--text);
  border: 1px solid var(--border);
}

.chat-screen .msg.out {
  align-self: flex-end;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  color: #fff;
  margin-left: auto;
}

.chat-screen .msg-time {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.5;
}

.chat-screen .typing {
  display: none;
  align-self: flex-start;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-tertiary);
}

.chat-screen .typing.active {
  display: block;
}

.chat-screen .typing-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 2px;
}

.chat-screen .typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: bounce 1.2s infinite;
}

.chat-screen .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-screen .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.chat-screen .input-area {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-screen .input-field {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  outline: none;
  background: var(--surface);
  transition: var(--transition);
  font-family: inherit;
  min-width: 0;
}

.chat-screen .input-field:focus {
  border-color: #d0d0d0;
  background: var(--bg);
}

.chat-screen .input-field::placeholder {
  color: var(--text-tertiary);
}

.chat-screen .btn-send {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  flex-shrink: 0;
  touch-action: manipulation;
}

.chat-screen .btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.chat-screen .btn-send:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-screen .btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Chat screen mobile */
@media (max-width: 480px) {
  .chat-screen .chat-header {
    padding: 10px 12px;
  }

  .chat-screen .messages-area {
    padding: 12px;
  }

  .chat-screen .msg {
    max-width: 85%;
    font-size: 13px;
  }

  .chat-screen .input-area {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .chat-screen .input-field {
    padding: 8px 14px;
    font-size: 13px;
  }

  .chat-screen .btn-send {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
}

/* ============================================================
   SHARED COMPONENT – Call Popup (used by all layouts)
   ============================================================ */
.call-popup {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  animation: slideDown 250ms ease;
  max-width: 400px;
  margin: 0 auto;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.call-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: #ecfdf5;
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.call-info {
  flex: 1;
  min-width: 0;
}

.call-title {
  font-size: 14px;
  font-weight: 600;
}

.call-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-call-action {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  touch-action: manipulation;
  flex-shrink: 0;
}

.btn-call-action.accept {
  background: var(--success);
  color: #fff;
  margin-right: 6px;
}

.btn-call-action.accept:hover {
  background: #059669;
}

.btn-call-action.decline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
}

.btn-call-action.decline:hover {
  background: #fef2f2;
  border-color: #fecaca;
}

/* Call popup mobile */
@media (max-width: 480px) {
  .call-popup {
    left: 12px;
    right: 12px;
    padding: 14px;
  }
}

/* Shared mobile small-screen msg override */
@media (max-width: 360px) {
  .dashboard .msg,
  .chat-screen .msg {
    max-width: 90%;
  }
}

.dashboard .u-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  display: none;
}
.dashboard .u-badge.show { display: block; }
.dashboard .msg-time { font-size: 10px; opacity: 0.5; margin-top: 4px; }