/* DarkCall - Communication Hub */
/* Design tokens from existing brand: #060608 bg, #00e5ff accent, JetBrains Mono + Space Grotesk */

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

:root {
  --bg: #060608;
  --surface: #0c0c10;
  --surface-2: #111116;
  --surface-3: #18181f;
  --surface-hover: #1e1e28;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(0, 229, 255, 0.15);

  --accent: #00e5ff;
  --accent-soft: rgba(0, 229, 255, 0.1);
  --accent-medium: rgba(0, 229, 255, 0.2);
  --accent-glow: 0 0 20px rgba(0, 229, 255, 0.15);

  --sent-bg: #0a2a3a;
  --sent-border: rgba(0, 229, 255, 0.12);
  --received-bg: var(--surface-2);
  --received-border: var(--border);

  --text: #e4e4ea;
  --text-secondary: #9d9da8;
  --text-muted: #5c5c6a;
  --text-accent: var(--accent);

  --online: #00c853;
  --busy: #ffab00;
  --offline: #5c5c6a;
  --danger: #ff4444;

  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Space Grotesk', sans-serif;

  --sidebar-w: 340px;
  --header-h: 56px;
  --input-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}

.hidden { display: none !important; }

/* ===== AUTH SCREEN ===== */

#auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridShift 30s linear infinite;
}

.auth-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.06) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: breathe 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes gridShift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.auth-card {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 2.5rem;
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  animation: fadeIn 0.6s var(--ease);
}

.auth-logo {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4rem;
}

.auth-tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  margin-bottom: 2.5rem;
}

.auth-divider {
  width: 40px;
  height: 2px;
  background: var(--accent);
  margin: 0 auto 2rem;
  box-shadow: var(--accent-glow);
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#auth-name {
  width: 100%;
  padding: 0.85rem 1.2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s var(--ease);
}

#auth-name:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#auth-name::placeholder {
  color: var(--text-muted);
}

#auth-btn {
  padding: 0.85rem 1.5rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease);
  letter-spacing: 0.02em;
}

#auth-btn:hover:not(:disabled) {
  background: #33ecff;
  box-shadow: var(--accent-glow);
}

#auth-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.auth-token-hint {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== MAIN APP LAYOUT ===== */

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

#user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

#user-id {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-actions {
  display: flex;
  gap: 0.4rem;
}

.sidebar-actions button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}

.sidebar-actions button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-search-wrap {
  position: relative;
  margin-top: 0.5rem;
}

.sidebar-search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#sidebar-search {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  transition: border-color 0.2s var(--ease);
}

#sidebar-search:focus {
  border-color: rgba(0, 229, 255, 0.25);
}

#sidebar-search::placeholder {
  color: var(--text-muted);
}

/* Broadcast button */
.sidebar-broadcast {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

#btn-broadcast {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all 0.15s var(--ease);
}

#btn-broadcast:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.broadcast-icon {
  color: var(--accent);
}

/* Conversation list */
.conv-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-track { background: transparent; }
.conv-list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

.conv-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-align: left;
  transition: background 0.15s var(--ease);
  position: relative;
}

.conv-item:hover {
  background: var(--surface-hover);
}

.conv-item.active {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
}

.conv-item.unread .conv-name {
  color: var(--text);
  font-weight: 600;
}

.conv-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.conv-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.conv-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.conv-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-badge {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.conv-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Connection status */
.conn-status {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--offline);
}

.conn-dot.online { background: var(--online); box-shadow: 0 0 6px var(--online); }
.conn-dot.connecting { background: var(--busy); animation: pulse 1.5s infinite; }
.conn-dot.offline { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== CHAT AREA ===== */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* Chat header */
.chat-header {
  height: var(--header-h);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}

#btn-back {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
}

#btn-back:hover { background: var(--surface-hover); color: var(--text); }

#chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.chat-target-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.chat-target-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-target-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-target-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Empty state */
#chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.empty-logo {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-muted) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 320px;
  line-height: 1.6;
}

.empty-hint {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  opacity: 0.6;
}

/* Chat container (header already separate) */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

.msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  animation: msgIn 0.2s var(--ease);
}

.msg-sent {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-received {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
  margin-left: 12px;
}

.msg-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-sent .msg-bubble {
  background: var(--sent-bg);
  border: 1px solid var(--sent-border);
  border-bottom-right-radius: var(--radius-xs);
}

.msg-received .msg-bubble {
  background: var(--received-bg);
  border: 1px solid var(--received-border);
  border-bottom-left-radius: var(--radius-xs);
}

.msg-text {
  font-size: 0.9rem;
  line-height: 1.5;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 4px;
}

.msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.msg-platform {
  font-size: 0.6rem;
  color: var(--accent);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  background: var(--accent-soft);
  border-radius: 3px;
}

.msg-date-sep {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 1rem 0 0.5rem;
  letter-spacing: 0.04em;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Message input */
.msg-input-area {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  background: var(--surface);
}

#msg-input {
  flex: 1;
  resize: none;
  padding: 0.65rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.4;
  max-height: 160px;
  min-height: 38px;
  transition: border-color 0.2s var(--ease);
}

#msg-input:focus {
  border-color: rgba(0, 229, 255, 0.25);
}

#msg-input::placeholder {
  color: var(--text-muted);
}

#btn-send {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}

#btn-send:hover {
  background: #33ecff;
  box-shadow: var(--accent-glow);
}

/* ===== MODALS (shared) ===== */

#directory-panel, .modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s var(--ease);
}

.modal-card {
  width: 520px;
  max-width: 95vw;
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-weight: 600;
  font-size: 1rem;
}

.modal-header button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}

.modal-header button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-search-wrap {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-search-wrap input {
  width: 100%;
  padding: 0.55rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
}

.modal-search-wrap input:focus {
  border-color: rgba(0, 229, 255, 0.25);
}

.modal-search-wrap input::placeholder {
  color: var(--text-muted);
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.modal-field input {
  padding: 0.65rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease);
}

.modal-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--surface-2);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  word-break: break-all;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.btn-primary {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s var(--ease);
}

.btn-primary:hover {
  background: #33ecff;
  box-shadow: var(--accent-glow);
}

.btn-danger {
  padding: 0.6rem 1rem;
  background: var(--surface-2);
  color: var(--danger);
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 68, 68, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s var(--ease);
  margin-right: auto;
}

.btn-danger:hover {
  background: rgba(255, 68, 68, 0.1);
  border-color: var(--danger);
}

/* Directory-specific */

.dir-filters {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.dir-filters {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.dir-count {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dir-type-btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 100px;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
  font-family: var(--font-mono);
}

.dir-type-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.dir-type-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}

#dir-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.dir-agent {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  text-align: left;
  transition: background 0.15s var(--ease);
}

.dir-agent:hover {
  background: var(--surface-hover);
}

.dir-agent-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.dir-agent.online .dir-agent-avatar {
  border: 2px solid var(--online);
}

.dir-agent-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dir-agent-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-agent-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dir-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--offline);
}

.dir-status-dot.online { background: var(--online); }
.dir-status-dot.busy { background: var(--busy); }
.dir-status-dot.offline { background: var(--offline); }

.dir-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  :root {
    --sidebar-w: 100vw;
  }

  #app {
    flex-direction: column;
    position: relative;
  }

  .sidebar {
    position: absolute;
    inset: 0;
    z-index: 10;
    width: 100%;
    min-width: 100%;
    transition: transform 0.25s var(--ease);
  }

  .chat-area {
    position: absolute;
    inset: 0;
    z-index: 5;
    transform: translateX(100%);
    transition: transform 0.25s var(--ease);
  }

  #app.mobile-chat .sidebar {
    transform: translateX(-100%);
  }

  #app.mobile-chat .chat-area {
    transform: translateX(0);
  }

  #btn-back {
    display: flex;
  }

  .msg {
    max-width: 85%;
  }

  .dir-card {
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }
}

@media (max-width: 480px) {
  .auth-card {
    margin: 1rem;
    padding: 2rem 1.5rem;
  }
}

/* ===== TYPING INDICATOR ===== */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  margin-top: 0.25rem;
  align-self: flex-start;
  background: var(--received-bg);
  border: 1px solid var(--received-border);
  border-radius: var(--radius);
  border-bottom-left-radius: var(--radius-xs);
  max-width: fit-content;
  animation: msgIn 0.2s var(--ease);
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingPulse 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 60%, 100% { transform: scale(0.7); opacity: 0.4; }
  30% { transform: scale(1); opacity: 1; }
}

.typing-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== READ RECEIPTS ===== */

.msg-receipt {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  margin-left: 2px;
}

.msg-receipt.read {
  color: var(--accent);
}

/* ===== SEARCH HIGHLIGHTING ===== */

mark {
  background: rgba(0, 229, 255, 0.3);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* ===== CHAT SEARCH BAR ===== */

#chat-search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

#chat-search-input {
  flex: 1;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
}

#chat-search-input:focus {
  border-color: rgba(0, 229, 255, 0.25);
}

#chat-search-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 70px;
  text-align: right;
}

#btn-chat-search-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}

#btn-chat-search-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

#btn-chat-search {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}

#btn-chat-search:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ===== FILE ATTACHMENTS ===== */

#btn-attach {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}

#btn-attach:hover {
  background: var(--surface-hover);
  color: var(--accent);
  border-color: var(--border-accent);
}

#attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.attach-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-width: 240px;
}

.attach-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-xs);
}

.attach-file {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
}

.attach-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 140px;
}

.attach-remove {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}

.attach-remove:hover {
  background: var(--danger);
  color: white;
}

.msg-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 0.4rem;
  display: block;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface-3);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

/* User text block */
.sidebar-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===== PREFERS REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
