/* ==============================================================================
   Family Hub — Modern Dark Design System
   Compatible with Debian 13, PHP 8.5, and Nginx (No Node.js build required)
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --app-visible-height: 100dvh;
  --user-accent: #4f46e5;
  --user-accent-rgb: 79, 70, 229;
  --bg-primary: #020617;
  --bg-secondary: #0b0f19;
  --bg-surface: rgba(15, 23, 42, 0.7);
  --bg-surface-elevated: rgba(30, 41, 59, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-accent: rgba(var(--user-accent-rgb), 0.35);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -4px rgba(var(--user-accent-rgb), 0.35);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  color-scheme: dark;
}

html, body {
  min-height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Windows & Cross-Platform Dark Scrollbars */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: #020617;
}

::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
  border: 2px solid #020617;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #1e293b #020617;
}

/* Media & SVG Constraints (Prevents image blowouts across all devices) */
img, video, canvas, audio, iframe, embed, object {
  max-width: 100%;
  height: auto;
  display: block;
}

svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color-scheme: dark;
}

/* Layout Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* ── Typography & Headings ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.text-gradient {
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-accent {
  color: var(--user-accent);
}

.text-muted {
  color: var(--text-muted);
}

/* ── Top Navigation Bar ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.125rem;
  font-weight: 800;
  color: #ffffff;
  transition: var(--transition);
}

.brand-link:hover {
  transform: scale(1.02);
}

.brand-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background: rgba(var(--user-accent-rgb), 0.2);
  border: 1px solid rgba(var(--user-accent-rgb), 0.4);
  color: #a5b4fc;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 0.35rem;
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #ffffff;
  background: rgba(var(--user-accent-rgb), 0.2);
  border: 1px solid rgba(var(--user-accent-rgb), 0.3);
  box-shadow: 0 0 15px -3px rgba(var(--user-accent-rgb), 0.25);
}

/* User Menu Dropdown */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 9999px;
  background: var(--user-accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.875rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition);
}

.avatar-btn:hover {
  border-color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Dropdown Menu */
.dropdown {
  position: relative;
}

.dropdown.open {
  z-index: 1001;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 15rem;
  background: #0f172a;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  box-shadow: var(--shadow-card);
  z-index: 1000;
  display: none;
  animation: dropdownFade 0.15s ease-out forwards;
}

.dropdown.open > .dropdown-menu,
.dropdown.open .dropdown-menu,
.dropdown-menu.open {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

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

.dropdown-header {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.35rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.dropdown-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.dropdown-item.danger {
  color: #f87171;
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.35rem 0;
}

/* ── Banners ── */
.impersonation-banner {
  background: rgba(245, 158, 11, 0.2);
  border-bottom: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  font-weight: 600;
}

.impersonation-banner a, .impersonation-banner button {
  background: #f59e0b;
  color: #020617;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.75rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.maintenance-alert-banner {
  background: rgba(239, 68, 68, 0.2);
  border-bottom: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #fee2e2;
  text-align: center;
  font-weight: 600;
}

/* Flash Toasts */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success {
  background: rgba(16, 185, 129, 0.95);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast-error {
  background: rgba(239, 68, 68, 0.95);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

/* ── Cards & Surfaces ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-medium);
}

.card-elevated {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
}

/* Feature Grid Cards */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .feature-grid { grid-template-columns: repeat(4, 1fr); }
}

.feature-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.75rem 1.5rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.6) 100%);
  backdrop-filter: blur(16px);
  transition: var(--transition);
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--user-accent);
  opacity: 0;
  transition: var(--transition);
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

.feature-card:hover::before {
  opacity: 1;
}

.feature-emoji {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.feature-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
}

.feature-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.feature-arrow {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  color: var(--text-dim);
  font-size: 1.25rem;
  transition: var(--transition);
}

.feature-card:hover .feature-arrow {
  color: #ffffff;
  transform: translateX(3px);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.25;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--user-accent);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 15px rgba(var(--user-accent-rgb), 0.35);
}

.btn-primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 6px 20px rgba(var(--user-accent-rgb), 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-medium);
}

.btn-danger {
  background: var(--danger-bg);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #ef4444;
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.775rem;
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0.4rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.95rem;
  background: #090e1a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 0.875rem;
  line-height: 1.4;
  transition: var(--transition);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--user-accent);
  box-shadow: 0 0 0 3px rgba(var(--user-accent-rgb), 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.25);
  background: #0d1527;
}

.form-input:disabled, .form-select:disabled, .form-textarea:disabled {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.06);
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.8;
}

.form-input::placeholder, .form-textarea::placeholder {
  color: #64748b;
}

/* Custom SVG Dropdown Chevron for selects */
.form-select {
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 1rem;
  cursor: pointer;
}

.form-select option {
  background-color: #0f172a;
  color: #ffffff;
  padding: 0.5rem;
}

/* Compact input variants */
.form-input-sm, .form-select-sm,
.form-input.text-xs, .form-select.text-xs {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.form-textarea {
  resize: vertical;
  min-height: 85px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* Cross-Platform Checkbox */
.form-checkbox {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: #090e1a;
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  margin: 0;
}

.form-checkbox:checked {
  background: var(--user-accent);
  border-color: var(--user-accent);
}

.form-checkbox:checked::before {
  content: "";
  width: 0.5rem;
  height: 0.3rem;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.725rem;
  font-weight: 700;
  border-radius: 9999px;
  line-height: 1;
}

.badge-primary { background: rgba(var(--user-accent-rgb), 0.2); color: #a5b4fc; border: 1px solid rgba(var(--user-accent-rgb), 0.3); }
.badge-success { background: var(--success-bg); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: var(--warning-bg); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: var(--danger-bg); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ── Modals & Overlays ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: #0f172a;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: #ffffff;
}

/* ── Authentic Discord-Style Chat Layout ── */
.chat-wrapper {
  display: flex;
  height: calc(100vh - 6.5rem);
  min-height: 520px;
  background: #313338;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.6);
}

/* Left Sidebar (Channels & DMs) */
.chat-sidebar {
  width: 260px;
  background: #2b2d31;
  border-right: 1px solid rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}

.chat-sidebar-server-header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  background: #2b2d31;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 0.95rem;
  color: #f2f3f5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chat-sidebar-section {
  padding: 1rem 1rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 800;
  color: #949ba4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-channel-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  color: #949ba4;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.12s ease;
  text-decoration: none;
}

.chat-channel-item:hover {
  color: #dbdee1;
  background: rgba(255, 255, 255, 0.05);
}

.chat-channel-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
  font-weight: 700;
}

.chat-channel-item .channel-hash {
  color: #80848e;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.chat-channel-item.active .channel-hash {
  color: #ffffff;
}

/* Sidebar User Footer Bar */
.chat-sidebar-user-footer {
  padding: 0.5rem 0.75rem;
  background: #232428;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(0, 0, 0, 0.2);
}

.chat-sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #313338;
  min-width: 0;
  position: relative;
}

/* Chat Header */
.chat-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  background: #313338;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-header-hash {
  color: #80848e;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.chat-header-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #f2f3f5;
  margin: 0;
}

.chat-header-topic {
  font-size: 0.775rem;
  color: #949ba4;
  margin: 0;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

/* Messages Feed */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Standard Message Row */
.chat-message-row {
  display: flex;
  gap: 0.85rem;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  transition: background 0.1s ease;
  position: relative;
}

.chat-message-row:hover {
  background: #2e3035;
}

/* Consecutive Message Row (no repeated avatar/header) */
.chat-message-row.consecutive {
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
  padding-left: 3.75rem;
}

.chat-message-row.consecutive .consecutive-timestamp {
  position: absolute;
  left: 0.65rem;
  top: 0.25rem;
  font-size: 0.6875rem;
  color: #949ba4;
  opacity: 0;
  transition: opacity 0.1s ease;
  user-select: none;
}

.chat-message-row.consecutive:hover .consecutive-timestamp {
  opacity: 1;
}

/* Avatars */
.chat-message-avatar {
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 9999px;
  background: var(--user-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 0.15rem;
}

.chat-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Message Content */
.chat-message-content {
  flex: 1;
  min-width: 0;
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
}

.chat-sender-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #f2f3f5;
  cursor: pointer;
}

.chat-sender-name:hover {
  text-decoration: underline;
}

.chat-timestamp {
  font-size: 0.725rem;
  color: #949ba4;
  font-weight: 400;
  cursor: default;
}

.chat-message-body {
  font-size: 0.9375rem;
  color: #dbdee1;
  line-height: 1.45;
  word-break: break-word;
}

.chat-message-body a {
  color: #00a8fc;
  text-decoration: underline;
}

.chat-message-body a:hover {
  color: #5865f2;
}

/* Attachment styling */
.chat-attachment-img {
  max-width: 380px;
  max-height: 280px;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: filter 0.15s ease;
  display: block;
}

.chat-attachment-img:hover {
  filter: brightness(1.08);
}

.chat-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: #2b2d31;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  margin-top: 0.4rem;
  color: #00a8fc;
  font-size: 0.85rem;
  text-decoration: none;
}

/* Message Context Actions & Long Press */
.chat-floating-actions {
  display: none !important; /* Replaced by contextual long-press and desktop more-btn to avoid covering info */
}

.chat-msg-more-btn {
  display: none;
  position: absolute;
  top: 4px;
  right: 8px;
  background: #2b2d31;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #b5bac1;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  transition: all 0.15s ease;
}

.chat-msg-more-btn:hover {
  background: #35373c;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

@media (hover: hover) and (pointer: fine) {
  .chat-message-row:hover .chat-msg-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.chat-message-row.message-long-pressed {
  background: rgba(88, 101, 242, 0.18) !important;
  transition: background 0.1s ease;
}

/* Reactions Bar */
.chat-reactions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.775rem;
  background: rgba(43, 45, 49, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #b5bac1;
  cursor: pointer;
  transition: all 0.12s ease;
  font-weight: 600;
}

.reaction-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.reaction-pill.reacted {
  background: rgba(88, 101, 242, 0.2);
  border-color: #5865f2;
  color: #f2f3f5;
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 0 1rem 1rem 1rem;
  background: #313338;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #383a40;
  border: none;
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.chat-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f2f3f5;
  font-size: 0.9375rem;
  font-family: inherit;
  padding: 0.25rem 0.4rem;
}

.chat-input-field::placeholder {
  color: #80848e;
}

.chat-attach-btn {
  background: #4e5058;
  color: #dbdee1;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
}

.chat-attach-btn:hover {
  background: #5865f2;
  color: #ffffff;
}

.chat-send-btn {
  background: #5865f2;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chat-send-btn:hover {
  background: #4752c4;
}

.chat-send-btn:active {
  transform: scale(0.97);
}

/* Mobile & Cross-Platform Responsive Styles */
.chat-channels-toggle-btn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-channels-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-sidebar-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  background: #1e1f22;
}

.chat-sidebar-backdrop {
  display: none;
}

@media (max-width: 768px) {
  /* ── Mobile Chat Viewport & Floating Android Keyboard Engine ── */
  body.chat-active-page,
  body.chat-page {
    height: 100% !important;
    height: 100dvh !important;
    height: var(--app-visible-height, 100dvh) !important;
    max-height: var(--app-visible-height, 100dvh) !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    position: relative !important;
  }

  body.chat-active-page .app-container,
  body.chat-page .app-container {
    height: 100% !important;
    height: 100dvh !important;
    height: var(--app-visible-height, 100dvh) !important;
    max-height: var(--app-visible-height, 100dvh) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  body.chat-active-page .site-header,
  body.chat-page .site-header {
    flex-shrink: 0 !important;
    height: 3.25rem !important;
    min-height: 3.25rem !important;
    transition: all 0.2s ease;
  }

  body.chat-active-page .site-header .header-inner,
  body.chat-page .site-header .header-inner {
    height: 3.25rem !important;
  }

  /* When Android virtual keyboard opens, smoothly hide global header so user has maximum typing & chat viewing area */
  body.chat-active-page.keyboard-open .site-header,
  body.chat-page.keyboard-open .site-header {
    display: none !important;
  }

  body.chat-active-page .main-content,
  body.chat-page .main-content {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.chat-active-page .chat-wrapper,
  body.chat-page .chat-wrapper,
  .chat-wrapper {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100% !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: row !important;
    overflow: hidden !important;
    position: relative !important;
  }

  body.chat-active-page .chat-main,
  body.chat-page .chat-main,
  .chat-main {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
    background: #313338;
  }

  .chat-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84%;
    max-width: 320px;
    z-index: 100;
    background: #2b2d31;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.85);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .chat-sidebar-mobile-header {
    display: flex;
  }

  .chat-sidebar-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 90;
  }

  .chat-sidebar.open ~ .chat-sidebar-backdrop {
    display: block;
  }

  .chat-channels-toggle-btn {
    display: inline-flex;
  }

  .chat-header {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    background: #2b2d31;
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
    z-index: 10;
  }

  .chat-header-topic {
    display: none;
  }

  .chat-messages-container {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 0.5rem;
  }

  .chat-message-row {
    padding: 0.35rem 0.45rem;
    gap: 0.6rem;
  }

  .chat-message-row.consecutive {
    padding-left: 3.1rem;
  }

  .chat-message-avatar {
    width: 2.1rem !important;
    height: 2.1rem !important;
    min-width: 2.1rem !important;
    font-size: 0.8rem;
  }


  /* Floating Bottom Composer Bar right above Android keypad */
  .chat-input-wrapper {
    flex-shrink: 0 !important;
    width: 100% !important;
    background: #2b2d31 !important;
    border-top: 1px solid rgba(0, 0, 0, 0.25) !important;
    padding: 0.4rem 0.5rem !important;
    padding-bottom: max(0.4rem, env(safe-area-inset-bottom, 0.4rem)) !important;
    z-index: 30 !important;
    position: relative !important;
  }

  /* Enforce 16px to prevent unwanted iOS & Android page auto-zoom */
  .chat-input-field {
    font-size: 16px !important;
  }

  .chat-channel-cog-btn {
    opacity: 1 !important;
    padding: 0.35rem 0.6rem;
  }
}

.chat-channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
  transition: background 0.12s ease;
  position: relative;
}

.chat-channel-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.chat-channel-row.active {
  background: rgba(255, 255, 255, 0.09);
}

.chat-channel-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  color: #949ba4;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.chat-channel-row:hover .chat-channel-link {
  color: #dbdee1;
}

.chat-channel-row.active .chat-channel-link {
  color: #ffffff;
  font-weight: 700;
}

.chat-channel-row.active .channel-hash {
  color: #ffffff;
}

.chat-channel-cog-btn {
  background: transparent;
  border: none;
  color: #949ba4;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: all 0.15s ease;
}

.chat-channel-row:hover .chat-channel-cog-btn {
  opacity: 1;
}

.chat-channel-cog-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  transform: rotate(25deg);
}



/* ── Camping & Checklist Styling ── */
.camping-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .camping-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.checklist-group {
  margin-bottom: 2rem;
}

.checklist-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: var(--transition);
}

.checklist-item:hover {
  border-color: var(--border-medium);
}

.checklist-item.packed {
  opacity: 0.6;
  background: rgba(15, 23, 42, 0.4);
}

.checklist-item.packed .item-name {
  text-decoration: line-through;
  color: var(--text-dim);
}

.custom-checkbox {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  border: 2px solid var(--border-medium);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.custom-checkbox.checked {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

/* ── Calendar Grid ── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.calendar-day-header {
  background: #0f172a;
  padding: 0.75rem 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calendar-cell {
  background: rgba(15, 23, 42, 0.6);
  min-height: 110px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: background 0.15s ease;
}

.calendar-cell:hover {
  background: rgba(30, 41, 59, 0.4);
}

.calendar-cell.other-month {
  opacity: 0.3;
}

.calendar-cell.today {
  border: 1px solid var(--user-accent);
  background: rgba(var(--user-accent-rgb), 0.1);
}

.calendar-date-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.calendar-cell.today .calendar-date-number {
  color: var(--user-accent);
}

.calendar-event-pill {
  padding: 0.25rem 0.45rem;
  background: rgba(var(--user-accent-rgb), 0.25);
  border-left: 3px solid var(--user-accent);
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

/* ── Print Styles for Checklists ── */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .site-header, .no-print, .btn, .header-actions, .modal-overlay, .toast-container {
    display: none !important;
  }
  .card, .checklist-item, .checklist-group-header {
    background: #ffffff !important;
    border: 1px solid #cccccc !important;
    color: #000000 !important;
    box-shadow: none !important;
  }
  .item-name {
    color: #000000 !important;
  }
}

/* ==============================================================================
   Layout, Sizing & Cross-Platform Utilities (No Node.js / Tailwind build needed)
   ============================================================================== */

/* ── Sizing & Dimensions ── */
.w-3, svg.w-3 { width: 0.75rem !important; height: 0.75rem !important; }
.h-3 { height: 0.75rem !important; }
.w-3\.5, svg.w-3\.5 { width: 0.875rem !important; height: 0.875rem !important; }
.h-3\.5 { height: 0.875rem !important; }
.w-4, svg.w-4 { width: 1rem !important; height: 1rem !important; }
.h-4 { height: 1rem !important; }
.w-5, svg.w-5 { width: 1.25rem !important; height: 1.25rem !important; }
.h-5 { height: 1.25rem !important; }
.w-6, svg.w-6 { width: 1.5rem !important; height: 1.5rem !important; }
.h-6 { height: 1.5rem !important; }
.w-7, svg.w-7 { width: 1.75rem !important; height: 1.75rem !important; }
.h-7 { height: 1.75rem !important; }
.w-8, svg.w-8 { width: 2rem !important; height: 2rem !important; }
.h-8 { height: 2rem !important; }
.w-9 { width: 2.25rem; }
.h-9 { height: 2.25rem; }
.w-10 { width: 2.5rem !important; height: 2.5rem !important; min-width: 2.5rem !important; min-height: 2.5rem !important; flex-shrink: 0 !important; }
.h-10 { height: 2.5rem !important; }
.w-12 { width: 3rem; }
.h-12 { height: 3rem; }
.w-16 { width: 4rem; }
.h-16 { height: 4rem; }
.w-20 { width: 5rem !important; height: 5rem !important; min-width: 5rem !important; min-height: 5rem !important; flex-shrink: 0 !important; }
.h-20 { height: 5rem !important; }
.w-24 { width: 6rem; }
.h-24 { height: 6rem; }
.w-28 { width: 7rem; }
.w-32 { width: 8rem; }
.w-48 { width: 12rem; }
.w-56 { width: 14rem; }
.w-64 { width: 16rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-w-0 { min-width: 0; }
.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }

/* ── Avatar Frames & Containers ── */
.avatar-frame-sm {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.avatar-frame {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.avatar-frame-md {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.avatar-frame-lg {
  width: 5rem;
  height: 5rem;
  border-radius: 1rem;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border: 2px solid rgba(var(--user-accent-rgb), 0.4);
  position: relative;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.avatar-frame-lg img, .avatar-frame-md img, .avatar-frame img, .avatar-frame-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Flexbox Utilities ── */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.self-start { align-self: flex-start; }
.self-auto { align-self: auto; }

.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.space-y-1 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.25rem; }
.space-y-1\.5 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.375rem; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
.space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }
.space-y-8 > :not([hidden]) ~ :not([hidden]) { margin-top: 2rem; }

/* ── Grid Utilities ── */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.grid-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:flex-row { flex-direction: row; }
  .sm\:items-center { align-items: center; }
  .sm\:self-auto { align-self: auto; }
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sm\:grid-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
  .md\:flex-row { flex-direction: row; }
  .md\:items-center { align-items: center; }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md\:w-56 { width: 14rem; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Background & Border Utility Fallbacks ── */
.bg-slate-900 { background-color: #0f172a; }
.bg-slate-900\/40 { background-color: rgba(15, 23, 42, 0.4); }
.bg-slate-900\/60 { background-color: rgba(15, 23, 42, 0.6); }
.bg-slate-900\/80 { background-color: rgba(15, 23, 42, 0.8); }
.bg-slate-900\/90 { background-color: rgba(15, 23, 42, 0.9); }
.bg-slate-800 { background-color: #1e293b; }
.bg-slate-800\/40 { background-color: rgba(30, 41, 59, 0.4); }
.bg-slate-800\/60 { background-color: rgba(30, 41, 59, 0.6); }
.bg-indigo-600 { background-color: #4f46e5; }
.bg-indigo-500\/10 { background-color: rgba(99, 102, 241, 0.1); }
.bg-rose-500\/10 { background-color: rgba(244, 63, 94, 0.1); }
.bg-black\/60 { background-color: rgba(0, 0, 0, 0.6); }

.border-slate-800 { border-color: rgba(255, 255, 255, 0.08); }
.border-slate-700 { border-color: rgba(255, 255, 255, 0.15); }
.border-slate-600 { border-color: rgba(255, 255, 255, 0.25); }
.border-indigo-500\/20 { border-color: rgba(99, 102, 241, 0.2); }
.border-indigo-500\/30 { border-color: rgba(99, 102, 241, 0.3); }
.border-indigo-500\/40 { border-color: rgba(99, 102, 241, 0.4); }
.border-rose-500\/20 { border-color: rgba(244, 63, 94, 0.2); }
.border-amber-500\/50 { border-color: rgba(245, 158, 11, 0.5); }

/* ── Typography & Text Utilities ── */
.text-\[9px\] { font-size: 0.5625rem; line-height: 0.75rem; }
.text-\[10px\] { font-size: 0.625rem; line-height: 0.85rem; }
.text-\[11px\] { font-size: 0.6875rem; line-height: 0.95rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }

.text-white { color: #ffffff; }
.text-slate-200 { color: #e2e8f0; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-indigo-300 { color: #a5b4fc; }
.text-indigo-400 { color: #818cf8; }
.text-emerald-400 { color: #34d399; }
.text-rose-400 { color: #fb7185; }
.text-amber-300 { color: #fcd34d; }
.text-amber-400 { color: #fbbf24; }

/* ── Spacing Utilities ── */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-1\.5 { padding: 0.375rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-3\.5 { padding: 0.875rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-1\.5 { padding-left: 0.375rem; padding-right: 0.375rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pb-2 { padding-bottom: 0.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.ml-auto { margin-left: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-5xl { max-width: 64rem; }

.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }
.rounded-2xl { border-radius: 16px; }
.rounded-full { border-radius: 9999px; }

.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.relative { position: relative; }
.absolute { position: absolute; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4); }
.border { border-width: 1px; border-style: solid; }
.border-2 { border-width: 2px; border-style: solid; }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; }
.border-t { border-top-width: 1px; border-top-style: solid; }
.divide-y > :not([hidden]) ~ :not([hidden]) {
  border-top-width: 1px;
  border-top-style: solid;
  border-color: rgba(255, 255, 255, 0.08);
}
.hidden { display: none !important; }
.capitalize { text-transform: capitalize; }
.uppercase { text-transform: uppercase; }
.tracking-tight { letter-spacing: -0.025em; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }

/* ── Interactive Transitions & Hovers ── */
.transition { transition: var(--transition); }
.group:hover .group-hover\:opacity-100 { opacity: 1 !important; }
.opacity-0 { opacity: 0; }

/* ── Responsive Horizontal Tab Bar (Mobile Friendly) ── */
.tab-bar-scrollable {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.35rem;
  white-space: nowrap;
  border-radius: var(--radius-xl);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  scrollbar-width: none;
}
.tab-bar-scrollable::-webkit-scrollbar {
  display: none;
}

/* ── Mobile Calendar Enhancements ── */
@media (max-width: 640px) {
  .calendar-cell {
    min-height: 62px;
    padding: 0.25rem;
    gap: 0.2rem;
  }
  .calendar-day-header {
    padding: 0.4rem 0.15rem;
    font-size: 0.65rem;
  }
  .calendar-date-number {
    font-size: 0.7rem;
    margin-bottom: 0.1rem;
  }
  .calendar-event-pill {
    font-size: 0.625rem;
    padding: 0.15rem 0.25rem;
    line-height: 1.1;
  }
}

/* ── Table Responsiveness ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-responsive table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

/* ==============================================================================
   Real-Time Live Lists & Mobile Interactive Experience
   ============================================================================== */

/* Live Sync Status Indicator */
.live-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.725rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.live-sync-badge:hover {
  background: rgba(16, 185, 129, 0.22);
}
.live-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: liveSyncPulse 2s infinite ease-in-out;
}
.live-sync-badge.connecting {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}
.live-sync-badge.connecting .live-sync-dot {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: none;
}
@keyframes liveSyncPulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px #34d399; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Remote Update Highlight Animation */
@keyframes itemHighlightRemote {
  0% { background: rgba(99, 102, 241, 0.35); border-color: rgba(99, 102, 241, 0.8); }
  100% { background: var(--bg-surface); border-color: var(--border-subtle); }
}
.item-highlight-remote {
  animation: itemHighlightRemote 1.8s ease-out;
}

/* Real-Time List Item Row */
.list-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.list-item-row:hover {
  border-color: var(--border-medium);
  background: rgba(30, 41, 59, 0.6);
}
.list-item-row.is-done {
  opacity: 0.55;
  background: rgba(15, 23, 42, 0.35);
}
.list-item-row.is-done .item-title {
  text-decoration: line-through;
  color: var(--text-dim);
}

/* Satisfying Touch Checkbox */
.list-checkbox-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  border: 2px solid var(--border-medium);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}
.list-checkbox-btn:active {
  transform: scale(0.88);
}
.list-checkbox-btn.checked {
  background: #10b981;
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}
.list-checkbox-btn.checked svg {
  stroke: #ffffff;
}

/* Mobile Quick Add Floating / Sticky bar */
.quick-add-container {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s ease;
}
.quick-add-container:focus-within {
  border-color: rgba(var(--user-accent-rgb), 0.6);
  box-shadow: 0 0 20px -3px rgba(var(--user-accent-rgb), 0.3);
}

/* Mobile responsive enhancements */
@media (max-width: 640px) {
  .lists-hub-container {
    padding-bottom: 5rem;
  }
  .quick-add-container {
    padding: 0.85rem;
    border-radius: 14px;
  }
  .quick-add-container input,
  .quick-add-container select,
  .quick-add-container textarea {
    font-size: 16px !important; /* Critical: Prevents iOS Safari auto-zooming */
  }
  .list-item-row {
    padding: 0.75rem 0.85rem;
    gap: 0.65rem;
  }
  .list-item-actions {
    gap: 0.15rem;
  }
  /* Mobile Bottom Sheet Transform for Modals */
  .modal-overlay.active {
    align-items: flex-end;
    padding: 0;
  }
  .modal-overlay.active .modal-card {
    width: 100%;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: mobileSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes mobileSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* ── Dedicated Household Notes System ── */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.15rem;
}
@media (max-width: 640px) {
  .notes-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}
.note-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.note-card:hover {
  border-color: var(--border-medium);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}
.note-card.is-pinned {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(30, 27, 75, 0.25);
  box-shadow: 0 0 15px -3px rgba(245, 158, 11, 0.15);
}
.note-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
  margin-bottom: 0.5rem;
  word-break: break-word;
}
.note-body {
  font-size: 0.925rem;
  color: #cbd5e1;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  margin-bottom: 1rem;
}
.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.775rem;
  color: var(--text-dim);
}
.note-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
