/* ==========================================================================
   عائلة يحيي صبيح - Yahia Sobeih Family Real-time Chat
   Sophisticated Dark Theme & Responsive Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Variables & Design Tokens (Sophisticated Dark)
   -------------------------------------------------------------------------- */
:root {
  /* Obsidian & Deep Slate Color Palette */
  --bg-primary: #0b0f19;       /* Deep Obsidian Slate - App Canvas */
  --bg-secondary: #131d31;     /* Slate 900 Surface - Containers & Headers */
  --bg-tertiary: #1e293b;      /* Slate 800 - Cards & Input Fields */
  --bg-elevated: #243350;      /* Slightly elevated interactive elements */
  --bg-overlay: rgba(11, 15, 25, 0.88); /* Blur backdrop */

  /* Accents & Brand Gradients */
  --accent-primary: #0284c7;   /* Sky 600 */
  --accent-secondary: #38bdf8; /* Sky 400 */
  --accent-highlight: #60a5fa; /* Blue 400 */
  --accent-gradient: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  --accent-gradient-vibrant: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  --accent-hover: #0369a1;
  --accent-glow: rgba(56, 189, 248, 0.22);
  --accent-glow-subtle: rgba(2, 132, 199, 0.15);

  /* Status & Alerts */
  --color-success: #10b981;    /* Emerald 500 */
  --color-danger: #f43f5e;     /* Rose 500 */
  --color-warning: #f59e0b;    /* Amber 500 */
  --color-info: #38bdf8;

  /* Text & Typography Hierarchy */
  --text-main: #f8fafc;        /* Slate 50 - Crisp White */
  --text-body: #e2e8f0;        /* Slate 200 */
  --text-muted: #94a3b8;       /* Slate 400 */
  --text-dim: #64748b;         /* Slate 500 */
  --text-inverted: #0b0f19;

  /* Borders & Shadows */
  --border-subtle: rgba(51, 65, 85, 0.65); /* Slate 700 / 65% */
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);

  /* Layout dimensions */
  --header-height: 72px;
  --footer-height: 76px;
  --max-content-width: 980px;
}

/* --------------------------------------------------------------------------
   2. Reset & Global Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* --------------------------------------------------------------------------
   3. Main App Layout & Grid
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  background-color: var(--bg-primary);
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

/* --------------------------------------------------------------------------
   4. App Header & Brand Bar
   -------------------------------------------------------------------------- */
.app-header {
  flex-shrink: 0;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 30;
  box-shadow: var(--shadow-sm);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  position: relative;
  box-shadow: 0 2px 10px var(--accent-glow);
  flex-shrink: 0;
}

.online-indicator-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background-color: var(--color-success);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.family-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.3px;
}

.family-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-success);
}
.status-badge .status-dot {
  font-size: 0.5rem;
}
.status-badge.offline {
  color: var(--color-warning);
}

.member-count-badge {
  color: var(--accent-secondary);
  font-weight: 500;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  color: var(--text-main);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.user-profile-badge:hover {
  background-color: var(--bg-elevated);
  border-color: var(--accent-secondary);
}

.user-avatar-pill {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  text-align: right;
  line-height: 1.1;
}
.user-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.user-name-display {
  font-size: 0.82rem;
  font-weight: 700;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent-secondary);
}

.profile-arrow {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background-color: var(--bg-tertiary);
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-elevated);
  transform: translateY(-1px);
}

.install-pwa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}
.install-pwa-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
}

/* Search Bar (Collapsible) */
.search-bar-container {
  padding: 8px 16px 12px;
  background-color: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  animation: slide-down 0.2s ease;
}

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

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  right: 14px;
  color: var(--text-dim);
  pointer-events: none;
}
.search-input-wrapper input {
  width: 100%;
  padding: 10px 42px 10px 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-input-wrapper input:focus {
  border-color: var(--accent-secondary);
}
.search-clear-btn {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}
.search-results-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
  padding-right: 4px;
}

/* PWA Prompt Banner */
.pwa-prompt-banner {
  background: linear-gradient(90deg, #1e293b 0%, #0369a1 100%);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  gap: 12px;
}
.pwa-banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}
.pwa-banner-actions {
  display: flex;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   5. Chat Stream & Messages
   -------------------------------------------------------------------------- */
.chat-main {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: 
    radial-gradient(circle at 15% 15%, rgba(2, 132, 199, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(56, 189, 248, 0.04) 0%, transparent 45%),
    var(--bg-primary);
}

.chat-main::-webkit-scrollbar {
  width: 8px;
}
.chat-main::-webkit-scrollbar-track {
  background: rgba(11, 15, 25, 0.5);
}
.chat-main::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.chat-main::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}

/* Floating Chat Navigation Controls (Scroll Up & Down) */
.chat-nav-controls {
  position: absolute;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  left: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(19, 29, 49, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  padding: 6px 5px;
  border-radius: var(--radius-full);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.75), 0 0 16px var(--accent-glow-subtle);
  user-select: none;
  pointer-events: auto;
}

.chat-nav-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-nav-btn:hover {
  background: var(--accent-primary);
  color: #ffffff;
  transform: scale(1.08);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.chat-nav-btn:active {
  transform: scale(0.92);
}

.chat-nav-btn-mini {
  width: 30px;
  height: 30px;
  font-size: 0.8rem;
  background: rgba(30, 41, 59, 0.5);
  border-color: transparent;
  color: var(--text-muted);
}

.chat-nav-btn-mini:hover {
  background: var(--bg-elevated);
  color: var(--accent-secondary);
  transform: scale(1.05);
}

.nav-tooltip {
  position: absolute;
  right: 48px;
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-6px);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
}

.chat-nav-btn:hover .nav-tooltip {
  opacity: 1;
  transform: translateX(0);
}

.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--color-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-primary);
}

/* Welcome Card */
.family-welcome-card {
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(19, 29, 49, 0.8) 100%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  text-align: center;
  margin-bottom: 22px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.family-welcome-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient-vibrant);
}
.welcome-icon-box {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 0 16px var(--accent-glow-subtle);
}
.family-welcome-card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}
.family-welcome-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 16px;
  line-height: 1.5;
}
.quick-family-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.greeting-pill {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  color: var(--text-body);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.greeting-pill:hover {
  background-color: var(--accent-primary);
  border-color: var(--accent-secondary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* Messages Stream */
.messages-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding-bottom: 20px;
}

/* Date Divider */
.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0;
  position: relative;
}
.date-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--border-subtle);
  z-index: 1;
}
.date-divider-pill {
  position: relative;
  z-index: 2;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 4px 16px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: var(--shadow-sm);
}

/* Message Bubble Container */
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 85%;
  position: relative;
  animation: message-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Outgoing (Sent by You) */
.message-row.outgoing {
  align-self: flex-start;
  direction: rtl;
}

/* Incoming (Sent by Others) */
.message-row.incoming {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.sender-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2px;
  overflow: hidden;
  position: relative;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.sender-avatar img,
.user-avatar-pill img,
.member-chip-avatar img,
.delete-avatar-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.message-bubble-box {
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 140px;
  max-width: 100%;
}

.message-bubble {
  padding: 11px 16px 9px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
}

/* Outgoing Bubble Styling */
.message-row.outgoing .message-bubble {
  background: var(--accent-gradient);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* Incoming Bubble Styling */
.message-row.incoming .message-bubble {
  background-color: var(--bg-secondary);
  color: var(--text-body);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

/* Sender Name on Bubble */
.message-sender-name {
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.message-row.outgoing .message-sender-name {
  color: rgba(255, 255, 255, 0.9);
}
.message-row.incoming .message-sender-name {
  color: var(--accent-secondary);
}

/* Text Content */
.message-text {
  font-size: 0.95rem;
  white-space: pre-wrap;
}

/* Message Meta (Time & Status & Delete) */
.message-footer-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.72rem;
  opacity: 0.85;
}

.message-time {
  direction: ltr;
}

.message-status-check {
  font-size: 0.75rem;
}

.msg-delete-btn {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.4;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.75rem;
  transition: opacity 0.2s, color 0.2s;
}
.message-row:hover .msg-delete-btn {
  opacity: 0.8;
}
.msg-delete-btn:hover {
  opacity: 1;
  color: var(--color-danger) !important;
}

/* --------------------------------------------------------------------------
   6. Message Attachments (Images, Videos, Audios, YouTube)
   -------------------------------------------------------------------------- */

/* Images */
.chat-media-image {
  margin: 6px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 100%;
  cursor: pointer;
  position: relative;
  background-color: rgba(0, 0, 0, 0.2);
}
.chat-media-image img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.chat-media-image:hover img {
  transform: scale(1.02);
}

/* Video Player */
.chat-media-video {
  margin: 6px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 100%;
  background: #000;
}
.chat-media-video video {
  width: 100%;
  max-height: 300px;
  display: block;
  outline: none;
}

/* Audio Player */
.chat-media-audio {
  margin: 6px 0;
  width: 100%;
  min-width: 220px;
  max-width: 320px;
}
.chat-media-audio audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md);
  outline: none;
}

/* YouTube Video Embed */
.youtube-embed-wrapper {
  margin: 8px 0;
  width: 100%;
  min-width: 260px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: #000;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.youtube-embed-wrapper .video-aspect {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
}
.youtube-embed-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Link Card */
.chat-link-card {
  margin: 6px 0;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background-color 0.2s;
}
.chat-link-card:hover {
  background-color: rgba(0, 0, 0, 0.4);
}
.chat-link-card i {
  font-size: 1rem;
  color: var(--accent-secondary);
}
.chat-link-card span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
}

/* Reactions Bar */
.bubble-reactions-bar {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.reaction-pill {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px 6px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-main);
  cursor: pointer;
}
.reaction-pill:hover {
  border-color: var(--accent-secondary);
}

/* --------------------------------------------------------------------------
   7. Upload Progress & Attachment Preview Bar
   -------------------------------------------------------------------------- */
.upload-progress-container {
  background-color: var(--bg-secondary);
  padding: 8px 16px;
  border-top: 1px solid var(--border-subtle);
}
.upload-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--accent-secondary);
  margin-bottom: 4px;
}
.progress-bar-track {
  height: 4px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  transition: width 0.2s ease;
}

/* Attachment Preview Bar */
.attachment-preview-bar {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 16px;
  animation: slide-up 0.2s ease;
}

@keyframes slide-up {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.preview-item-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px;
}
.preview-thumbnail {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--accent-secondary);
  font-size: 1.2rem;
}
.preview-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.preview-filename {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-filesize {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.preview-remove-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.preview-remove-btn:hover {
  background-color: var(--color-danger);
  color: #fff;
}

/* --------------------------------------------------------------------------
   8. Emoji Bar & Audio Recording Bar
   -------------------------------------------------------------------------- */
.quick-emoji-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background-color: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-emoji-bar::-webkit-scrollbar {
  display: none;
}
.emoji-chip {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: transform 0.15s ease;
  line-height: 1;
}
.emoji-chip:hover {
  transform: scale(1.3);
}

/* Audio Recording Bar */
.audio-recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  animation: slide-up 0.2s ease;
}
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-danger);
}
.recording-blinking-dot {
  width: 12px;
  height: 12px;
  background-color: var(--color-danger);
  border-radius: 50%;
  animation: record-pulse 1s infinite alternate;
}
@keyframes record-pulse {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}
.recording-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
}
.recording-time {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-danger);
  direction: ltr;
}
.recording-actions {
  display: flex;
  gap: 8px;
}
.btn-rec-cancel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-tertiary);
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-rec-cancel:hover {
  background-color: var(--color-danger);
  color: #fff;
}
.btn-rec-send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   9. Chat Footer & Input Box
   -------------------------------------------------------------------------- */
.chat-footer {
  flex-shrink: 0;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  position: relative;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.message-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
}

.action-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.action-btn:hover {
  color: var(--accent-secondary);
  background-color: var(--bg-elevated);
}

.send-btn {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.send-btn:hover {
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
  color: #fff;
  transform: translateY(-1px);
}

.input-wrapper {
  flex: 1;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  transition: border-color 0.2s;
}
.input-wrapper:focus-within {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 1px var(--accent-secondary);
}

.message-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  direction: rtl;
}
.message-textarea::placeholder {
  color: var(--text-dim);
}

/* Scroll to Bottom Button */
.scroll-bottom-btn {
  position: absolute;
  bottom: calc(85px + env(safe-area-inset-bottom, 0px));
  left: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--accent-secondary);
  color: var(--accent-secondary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  z-index: 25;
  transition: all 0.2s ease;
  animation: bounce 2s infinite;
}
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  60% { transform: translateY(-3px); }
}
.scroll-bottom-btn:hover {
  background-color: var(--accent-primary);
  color: #fff;
}
.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--color-danger);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
}

/* --------------------------------------------------------------------------
   10. Modals & Popups
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scale-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-box.modal-large {
  max-width: 750px;
}

@keyframes scale-up {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.modal-icon.danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--color-danger);
}

.modal-title-box h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}
.modal-title-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Preset Members Selection Grid in User Modal */
.preset-members-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.preset-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--accent-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}
.btn-text-link:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #fff;
}

.member-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  max-height: 175px;
  overflow-y: auto;
  padding: 4px;
  border-radius: var(--radius-md);
  background: rgba(11, 15, 25, 0.4);
  border: 1px solid var(--border-subtle);
}

.member-chip-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.member-chip-card:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-secondary);
  transform: translateY(-1px);
}
.member-chip-card.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.member-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.member-chip-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 12px 0;
}
.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-divider span {
  padding: 0 10px;
}

/* Bulk Family Members Modal Styles */
.bulk-instructions-card {
  background: rgba(19, 29, 49, 0.85);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instruction-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}
.instruction-row i {
  color: var(--accent-secondary);
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.detected-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-main);
}
.detected-badge strong {
  color: var(--accent-secondary);
  font-size: 1.05rem;
  font-weight: 800;
}

.toolbar-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bulk-names-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  direction: rtl;
  resize: vertical;
  min-height: 140px;
  transition: all 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
.bulk-names-textarea:focus {
  border-color: var(--accent-secondary);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.bulk-preview-section {
  margin-top: 14px;
}

.bulk-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 130px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(11, 15, 25, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.bulk-preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  animation: fade-in 0.2s ease;
}

.bulk-preview-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.manual-name-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.manual-name-input-wrapper input {
  font-size: 1.05rem;
  padding: 14px 44px 14px 16px;
  background-color: var(--bg-primary);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.manual-name-input-wrapper input:focus {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.manual-name-input-wrapper i {
  font-size: 1.15rem;
  color: var(--accent-secondary);
}

.input-help-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-top: 4px;
}

.input-help-box i {
  color: var(--accent-secondary);
  font-size: 0.95rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.input-help-box span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon i {
  position: absolute;
  right: 14px;
  color: var(--text-dim);
}
.input-with-icon input {
  width: 100%;
  padding: 10px 42px 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}
.input-with-icon input:focus {
  border-color: var(--accent-secondary);
}

/* Avatar Customizer in User Modal */
.avatar-selection-section {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avatar-customizer-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(11, 15, 25, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  flex-wrap: wrap;
}

.avatar-preview-box {
  position: relative;
  flex-shrink: 0;
}

.user-modal-avatar-preview {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  border: 2px solid var(--accent-secondary);
  box-shadow: 0 0 16px var(--accent-glow-subtle);
  overflow: hidden;
  position: relative;
}

.user-modal-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-status-badge {
  position: absolute;
  bottom: -2px;
  left: -2px;
  color: var(--color-success);
  background: var(--bg-primary);
  border-radius: 50%;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-options-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.avatar-btn-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.avatar-sub-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.btn-text-danger:hover {
  background: rgba(244, 63, 94, 0.1);
  text-decoration: underline;
}

/* Preset Illustrated Avatars Drawer */
.preset-avatars-drawer {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-top: 4px;
}

.preset-avatars-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-icon-mini {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}
.btn-icon-mini:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.preset-avatars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px;
}

.preset-avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  padding: 0;
}
.preset-avatar-btn:hover {
  transform: scale(1.1);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 10px var(--accent-glow);
}
.preset-avatar-btn.selected {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.preset-avatar-btn img,
.preset-avatar-btn svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Live Camera Snapshot Modal */
.modal-camera-box {
  max-width: 480px;
  width: 92%;
}

.modal-camera-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
}

.camera-stream-container {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 320px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  border: 2px solid var(--border-glass);
  box-shadow: var(--shadow-lg), 0 0 24px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

#cameraVideo,
#cameraCapturedImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-guide-ring {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 2px dashed rgba(56, 189, 248, 0.7);
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  animation: pulse-ring 2.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.02); opacity: 1; border-color: var(--accent-secondary); }
  100% { transform: scale(1); opacity: 0.8; }
}

.camera-flash-fx {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
}
.camera-flash-fx.flash-active {
  opacity: 0.9;
}

.camera-controls-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 320px;
  padding: 4px 0;
}

.camera-status-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-camera-footer {
  justify-content: center;
}

.camera-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Button UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-danger {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(1.1);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.btn-outline:hover {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

/* Message Preview & Confirmation in Delete Modal */
.delete-msg-info-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.delete-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 6px;
  font-size: 0.82rem;
}

.delete-sender-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.delete-avatar-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
}

.delete-msg-time {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.message-preview-to-delete {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 110px;
  overflow-y: auto;
  word-break: break-word;
  padding: 2px 0;
}

.delete-safety-box {
  background: rgba(244, 63, 94, 0.08);
  border: 1.5px dashed rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}
.delete-safety-box:hover {
  background: rgba(244, 63, 94, 0.12);
  border-color: var(--color-danger);
}

.delete-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.delete-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-danger);
  cursor: pointer;
  flex-shrink: 0;
}

.delete-checkbox-label .checkbox-text {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}

.warning-alert-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: #fbbf24;
  font-size: 0.8rem;
  line-height: 1.45;
}
.warning-alert-card i {
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}
.warning-alert-card strong {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 2px;
}
.warning-alert-card span {
  color: var(--text-muted);
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
  transform: none !important;
  box-shadow: none !important;
}

/* Lightbox Modal */
.lightbox-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fade-in 0.2s ease;
}
.lightbox-close-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.lightbox-info {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.lightbox-download-link {
  color: var(--accent-secondary);
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Media Gallery */
.gallery-tabs {
  display: flex;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
.gallery-tab {
  flex: 1;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}
.gallery-tab.active {
  color: var(--accent-secondary);
  border-bottom-color: var(--accent-secondary);
  background-color: var(--bg-secondary);
}
.gallery-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  min-height: 250px;
  max-height: 450px;
}
.gallery-item-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
}
.gallery-item-card img, .gallery-item-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 0.9rem;
}

/* Settings Modal */
.settings-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.settings-section h4 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}
.text-accent {
  color: var(--accent-secondary);
}
.form-group {
  margin-bottom: 10px;
}
.form-group input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent-secondary);
}
.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
}
.toggle-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   11. Pinned Announcements, Calendar, Albums, Polls & Audio Waveforms
   -------------------------------------------------------------------------- */

/* Pinned Header Dot & Badge */
.pinned-badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  border: 1.5px solid var(--bg-secondary);
}

.events-count-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--bg-secondary);
}

/* Top Pinned Announcement Banner */
.pinned-announcement-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(217, 119, 6, 0.06) 100%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.28);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(8px);
  animation: slideDownBanner 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 15;
}

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

.pinned-banner-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.pinned-pin-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.pinned-content-wrap {
  flex: 1;
  min-width: 0;
}

.pinned-header-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.pinned-tag {
  background: #f59e0b;
  color: #0b0f19;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.pinned-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fbbf24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-sender {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pinned-text {
  font-size: 0.85rem;
  color: var(--text-body);
  line-height: 1.4;
  word-break: break-word;
}

.pinned-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-pinned-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-pinned-action:hover {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

/* Announcement Presets */
.announcement-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.announcement-preset-chip {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.announcement-preset-chip:hover {
  border-color: var(--accent-secondary);
  background: var(--bg-tertiary);
  color: #fff;
}

.modal-actions-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   Family Events & Calendar Styles
   ========================================================================== */
.events-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.events-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.events-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 14px;
  animation: fadeIn 0.2s ease;
}

.events-selected-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f43f5e;
}

.events-bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-select-check {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.event-select-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.event-check-fake {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-subtle);
  background: var(--bg-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.event-select-check input:checked + .event-check-fake {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  border-color: #f43f5e;
}

.event-select-check input:checked + .event-check-fake::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
}

.event-item-card.selected {
  border-color: rgba(244, 63, 94, 0.7);
  box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.2);
}

.btn-event-pick {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-event-pick:hover {
  border-color: #f43f5e;
  color: #f43f5e;
}

.event-item-card.selected .btn-event-pick {
  background: rgba(244, 63, 94, 0.12);
  border-color: #f43f5e;
  color: #f43f5e;
}

.events-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

.events-empty-state i {
  font-size: 2.4rem;
  opacity: 0.5;
}

.events-empty-state p {
  font-size: 0.88rem;
  max-width: 300px;
  line-height: 1.6;
}

.events-stats-pill {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-body);
}

.events-stats-pill i {
  color: #f59e0b;
}

.add-event-form-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease;
}

.add-event-form-card h4 {
  font-size: 0.95rem;
  color: var(--accent-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.modal-date-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}

.event-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.events-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding-left: 4px;
}

.events-list-container.selecting .event-item-card {
  cursor: pointer;
}

.event-item-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.event-item-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.event-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.event-type-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.event-title-wrap {
  flex: 1;
  min-width: 0;
}

.event-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.event-meta-line {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.event-countdown-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--accent-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.event-countdown-badge.today {
  background: #f43f5e;
  color: #fff;
  border-color: transparent;
  animation: pulse 1.5s infinite;
}

.event-countdown-badge.soon {
  background: #f59e0b;
  color: #0b0f19;
  border-color: transparent;
}

.event-countdown-badge.past {
  background: var(--bg-tertiary);
  color: var(--text-dim);
  border-color: var(--border-subtle);
}

.event-notes {
  font-size: 0.84rem;
  color: var(--text-body);
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--accent-secondary);
  margin: 0;
  line-height: 1.4;
}

.event-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.btn-event-greet {
  background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-event-greet:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.btn-event-delete {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-event-delete:hover {
  color: #fff;
  background: #f43f5e;
  border-color: #f43f5e;
}

.event-delete-confirm-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  animation: fadeIn 0.2s ease;
  width: 100%;
  gap: 8px;
}

.event-delete-confirm-wrap span {
  font-size: 0.82rem;
  font-weight: 700;
  color: #f43f5e;
}

.event-delete-confirm-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-confirm-delete-event {
  background: #f43f5e;
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-confirm-delete-event:hover {
  background: #e11d48;
  transform: translateY(-1px);
}

.btn-cancel-delete-event {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-cancel-delete-event:hover {
  color: var(--text-main);
  background: var(--bg-tertiary);
}

/* Toast Notifications Container */
.toast-notification-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  max-width: 90vw;
}

.toast-notification {
  pointer-events: auto;
  background: #0f172a;
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-notification.success {
  border-color: rgba(34, 197, 94, 0.5);
  background: linear-gradient(135deg, #064e3b 0%, #022c22 100%);
}

.toast-notification.error {
  border-color: rgba(244, 63, 94, 0.5);
  background: linear-gradient(135deg, #881337 0%, #4c0519 100%);
}

.toast-notification.info {
  border-color: rgba(56, 189, 248, 0.5);
  background: linear-gradient(135deg, #0c4a6e 0%, #082f49 100%);
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Family Memory Vault & Albums Styles
   ========================================================================== */
.album-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.album-filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.album-pill {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.2s ease;
}

.album-pill.active, .album-pill:hover {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}

.memory-dropzone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-primary);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.memory-dropzone:hover {
  border-color: var(--accent-secondary);
  background: var(--bg-tertiary);
}

.memory-dropzone i {
  font-size: 2rem;
  color: var(--accent-secondary);
}

.memory-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.memory-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.memory-card:hover img {
  transform: scale(1.06);
}

.memory-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(11, 15, 25, 0.9) 0%, rgba(11, 15, 25, 0.2) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  opacity: 0.9;
  transition: opacity 0.2s ease;
}

.memory-caption-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
  line-height: 1.3;
}

.memory-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Lightbox Navigation Buttons */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(19, 29, 49, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.lightbox-nav-btn:hover {
  background: var(--accent-primary);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
  right: 20px;
}

.lightbox-next {
  left: 20px;
}

/* ==========================================================================
   Custom Interactive Audio Waveform Player
   ========================================================================== */
.custom-audio-waveform-player {
  background: rgba(11, 15, 25, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  max-width: 320px;
  position: relative;
}

.audio-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.audio-play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.5);
}

.audio-waveform-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.audio-waveform-track {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 28px;
  cursor: pointer;
  padding: 2px 0;
}

.audio-bar {
  width: 3px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.4);
  transition: height 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.audio-bar.played {
  background: var(--accent-secondary);
}

.custom-audio-waveform-player.playing .audio-bar.played {
  background: linear-gradient(to top, #0284c7, #38bdf8);
}

.audio-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.audio-speed-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-body);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-speed-btn:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* ==========================================================================
   Family Polls & Voting Styles
   ========================================================================== */
.poll-btn {
  color: #38bdf8 !important;
}

.poll-option-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.poll-option-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--accent-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.poll-opt-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
}

.poll-opt-input:focus {
  border-color: var(--accent-secondary);
}

.poll-card-bubble {
  width: 100%;
  min-width: 270px;
  max-width: 380px;
  padding: 4px 0;
}

.poll-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.poll-icon-box {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.poll-question-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}

.poll-multi-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.poll-options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poll-option-item {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
}

.poll-option-item:hover {
  border-color: var(--accent-secondary);
}

.poll-option-item.selected {
  border-color: var(--accent-secondary);
  background: rgba(2, 132, 199, 0.08);
}

.poll-progress-fill {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(56, 189, 248, 0.18);
  border-radius: var(--radius-md);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.poll-option-item.selected .poll-progress-fill {
  background: rgba(56, 189, 248, 0.28);
}

.poll-option-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.poll-opt-text-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.poll-opt-radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.poll-option-item.selected .poll-opt-radio {
  border-color: var(--accent-secondary);
  background: var(--accent-secondary);
}

.poll-option-item.selected .poll-opt-radio::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.poll-opt-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
}

.poll-opt-stats {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-secondary);
  white-space: nowrap;
}

.poll-voters-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding-right: 24px;
}

.poll-voter-avatar-mini {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 1px solid var(--bg-primary);
  overflow: hidden;
}

.poll-voter-avatar-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poll-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.btn-close-poll {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-close-poll:hover {
  color: var(--color-danger);
}

.poll-closed-badge {
  color: #f43f5e;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   12. Responsive Media Queries
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Slightly larger base font on phones so all rem-based text stays readable */
  html {
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .app-container {
    border-left: none;
    border-right: none;
  }

  .header-main {
    padding: 8px 10px;
    gap: 8px;
    overflow: hidden;
  }

  .brand-info {
    flex: 0 0 auto;
    gap: 8px;
  }

  .brand-avatar {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .brand-titles {
    min-width: 0;
  }

  .family-title {
    font-size: 1rem;
    max-width: 120px;
  }

  .family-subtitle {
    font-size: 0.72rem;
    gap: 6px;
  }

  /* Hide member count on phones to give header actions more room */
  .member-count-badge {
    display: none;
  }

  /* Header action icons scroll horizontally on small screens instead of overflowing */
  .header-actions {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
  }
  .header-actions::-webkit-scrollbar {
    display: none;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
    flex-shrink: 0;
  }

  .user-profile-badge {
    padding: 4px 8px;
    gap: 6px;
    flex-shrink: 0;
  }

  .user-meta {
    display: none; /* Hide label on small screens to conserve header space */
  }

  .user-name-display {
    max-width: 90px;
  }

  /* Footer input bar: comfortable tap targets and bigger input text */
  .message-form {
    gap: 6px;
    padding: 8px 10px;
  }

  .action-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .message-textarea {
    font-size: 1rem; /* >= 16px prevents iOS auto-zoom on focus */
    line-height: 1.5;
  }

  .audio-recording-bar {
    padding: 8px 10px;
  }

  /* Modals: nearly full width on phones */
  .modal-backdrop {
    padding: 10px;
  }

  .modal-box {
    max-width: 100%;
  }

  .modal-body {
    padding: 16px;
  }

  .family-welcome-card {
    padding: 18px 14px;
  }

  .family-welcome-card h2 {
    font-size: 1.15rem;
  }

  .message-row {
    max-width: 95%;
  }

  .quick-members-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .pwa-prompt-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .pwa-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .events-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .events-toolbar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .events-bulk-bar {
    flex-wrap: wrap;
  }

  .lightbox-prev {
    right: 8px;
  }

  .lightbox-next {
    left: 8px;
  }
}

@media (max-width: 380px) {
  .brand-avatar {
    width: 32px;
    height: 32px;
  }

  .family-title {
    font-size: 0.9rem;
    max-width: 90px;
  }

  .family-subtitle {
    font-size: 0.68rem;
  }

  .user-profile-badge {
    padding: 3px 6px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }
}
