/* ========================================================
   PHP Online Photo Gallery - Responsive Stylesheet
   Dark & Light Mode, Mobile Settings Drawer, Slider Lightbox
   ======================================================== */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #222634;
  --bg-card-hover: #2b3142;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-color: #2d3345;
  --input-bg: #141721;
  --header-bg: rgba(26, 29, 39, 0.88);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.55);
  --grid-item-size: 260px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  /* Core Color Tokens */
  --token-canvas: #F5F0E8;
  --token-surface: #FFFCF7;
  --token-glass: #FFFFFF;
  --token-espresso: #49372C;
  --token-mocha: #725642;
  --token-caramel: #B58B62;
  --token-taupe: #D9CCBC;
  --token-muted: #786E64;

  /* Mapped Theme Variables */
  --bg-primary: #F5F0E8;            /* Canvas: Main page background */
  --bg-secondary: #FFFCF7;          /* Surface: Card & content area */
  --bg-card: #FFFCF7;               /* Surface: Card & content area */
  --bg-card-hover: #F5F0E8;         /* Canvas hover state */
  --accent-color: #B58B62;          /* Caramel: Primary action & highlight */
  --accent-hover: #725642;          /* Mocha: Secondary button & active navigation */
  --accent-glow: rgba(181, 139, 98, 0.28);
  --text-main: #49372C;             /* Espresso: Primary text */
  --text-muted: #786E64;            /* Muted: Secondary text */
  --border-color: #D9CCBC;          /* Taupe: Border & divider */
  --input-bg: #FFFCF7;              /* Surface: Input background */
  --header-bg: rgba(255, 255, 255, 0.88); /* Glass: Transparent panel base */
  --shadow-sm: 0 2px 10px rgba(73, 55, 44, 0.07);
  --shadow-lg: 0 16px 36px rgba(73, 55, 44, 0.14);
}

/* Dynamic Theme Token Overrides (Adapts to Light Mode Palette, Presets & Custom User Colors) */
[data-theme="light"] .site-header {
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
}
[data-theme="light"] .brand-badge {
  background: var(--accent-glow);
  color: var(--accent-hover);
  border-color: var(--border-color);
}
[data-theme="light"] .btn-primary {
  background: var(--accent-color);
  color: #FFFFFF;
}
[data-theme="light"] .btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px var(--accent-glow);
}
[data-theme="light"] .btn-outline {
  background: var(--accent-hover);
  color: var(--bg-card);
  border-color: var(--accent-hover);
}
[data-theme="light"] .btn-outline:hover {
  background: var(--text-main);
  border-color: var(--text-main);
  color: var(--bg-card);
}
[data-theme="light"] .category-tab {
  background: var(--bg-card);
  color: var(--text-muted);
  border-color: var(--border-color);
}
[data-theme="light"] .category-tab:hover {
  border-color: var(--accent-color);
  color: var(--text-main);
}
[data-theme="light"] .category-tab.active {
  background: var(--accent-hover);
  color: var(--bg-card);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 10px var(--accent-glow);
}
.marquee-container {
  background: linear-gradient(90deg, var(--text-main), var(--accent-hover), var(--accent-color));
  color: #FFFFFF;
}
[data-theme="dark"] .marquee-container {
  background: linear-gradient(90deg, var(--accent-hover), var(--accent-color));
}
[data-theme="light"] .photo-category-tag {
  background: var(--accent-glow);
  color: var(--accent-hover);
  border: 1px solid var(--border-color);
}
[data-theme="light"] .photo-views {
  background: var(--bg-primary);
  color: var(--accent-hover);
  border: 1px solid var(--border-color);
}
.chat-send-btn {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
  box-shadow: 0 3px 10px var(--accent-glow);
}

/* ========================================================
   Dynamic Theme Studio Modal (User & Admin Customizer)
   ======================================================== */
.theme-studio-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100005;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.theme-studio-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}
.theme-studio-dialog {
  background: var(--bg-card, #222634);
  color: var(--text-main, #f3f4f6);
  border: 1px solid var(--border-color, #2d3345);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.theme-studio-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #2d3345);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.theme-studio-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-studio-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-studio-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.theme-preset-btn {
  border: 2px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-preset-btn:hover {
  border-color: var(--accent-color);
  transform: translateY(-2px);
}
.theme-preset-btn.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.theme-swatch-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.theme-swatch-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
}
.theme-preset-label {
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.theme-custom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
}
.theme-color-field {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-color-field input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.theme-color-field-info {
  min-width: 0;
  flex: 1;
}
.theme-color-field-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.theme-color-field-hex {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: monospace;
}
.theme-studio-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-primary);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 1. Header & Navigation */
.site-header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-badge {
  background: var(--accent-glow);
  color: var(--accent-color);
  border: 1px solid rgba(99, 102, 241, 0.35);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--accent-color);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-outline {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}
.btn-outline:hover {
  color: var(--text-main);
  border-color: var(--accent-color);
  background: var(--bg-card-hover);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.theme-toggle-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Mobile Settings Toggle Button (Shown on small screens) */
.mobile-settings-btn {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}
.mobile-settings-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Mobile Settings Drawer / Offcanvas */
.settings-drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 950;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.settings-drawer.open {
  display: flex;
  opacity: 1;
}

.settings-drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 85vw);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.settings-drawer.open .settings-drawer-content {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}
.drawer-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
}
.drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.drawer-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

/* 2. Scrolling Marquee Announcement Bar */
.marquee-container {
  background: linear-gradient(90deg, #4338ca, #6366f1, #3b82f6);
  color: #ffffff;
  padding: 8px 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 500;
  position: relative;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.15);
}

.marquee-content {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 28s linear infinite;
}
.marquee-container:hover .marquee-content {
  animation-play-state: paused;
}

@keyframes marquee {
  0%   { transform: translate(0, 0); }
  100% { transform: translate(-100%, 0); }
}

/* 3. Category Filter Tabs */
.filter-bar {
  max-width: 1440px;
  margin: 18px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar {
  display: none;
}

.category-tab {
  padding: 7px 16px;
  border-radius: 30px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition);
}
.category-tab:hover,
.category-tab.active {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* 4. Gallery Photo Wall (Responsive Grid) */
.gallery-wrapper {
  max-width: 1440px;
  margin: 20px auto 60px;
  padding: 0 20px;
  flex: 1;
  width: 100%;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-item-size, 215px), 220px), 1fr));
  gap: 14px;
}

.photo-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
  contain: layout paint;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  transition: border-color 0.15s ease;
}

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

.photo-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 215px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
  contain: strict;
}

.photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
}

.photo-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  flex: 1 1 auto;
}

/* Caption below the photo: shows up to 2 lines, scrollable if longer */
.photo-caption {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  max-height: calc(1.4em * 2); /* Exact height for two lines */
  overflow-y: auto;            /* Scrollable if more than two lines */
  overflow-x: hidden;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) transparent;
  cursor: text;
}
.photo-caption::-webkit-scrollbar {
  width: 4px;
}
.photo-caption::-webkit-scrollbar-track {
  background: transparent;
}
.photo-caption::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.35);
  border-radius: 4px;
}
.photo-caption:hover::-webkit-scrollbar-thumb {
  background: var(--accent-color);
}

.photo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 2px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.photo-category-tag {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-color);
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-views {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 8px;
  border-radius: 10px;
  color: #f59e0b;
  font-weight: 600;
  margin-left: auto;
}

/* Empty State */
.empty-gallery {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-gallery svg {
  width: 56px;
  height: 56px;
  stroke: var(--text-muted);
  margin-bottom: 16px;
}

/* 5. Slider Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  user-select: none;
}

/* Slider Navigation Buttons on Both Sides */
.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  background: rgba(26, 29, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1010;
  transition: var(--transition);
}
.slider-btn:hover {
  background: var(--accent-color);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-50%) scale(1.08);
}
.slider-btn.prev {
  left: 20px;
}
.slider-btn.next {
  right: 20px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1015;
  transition: var(--transition);
}
.lightbox-close:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.lightbox-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 29, 39, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 22px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.88rem;
  color: #fff;
  z-index: 1010;
  max-width: min(85vw, 680px);
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#lightboxCaption {
  font-weight: 500;
  line-height: 1.4;
  max-height: calc(1.4em * 2);
  overflow-y: auto;
  overflow-x: hidden;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
  word-break: break-word;
  padding: 0 4px;
}
#lightboxCaption::-webkit-scrollbar {
  width: 4px;
}
#lightboxCaption::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 4px;
}

/* 6. Welcome Modal Popup (1s after login) */
.welcome-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}
.welcome-modal.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.welcome-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 32px 28px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: popUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.welcome-card h3 {
  font-size: 1.4rem;
  margin-bottom: 12px;
  color: var(--text-main);
}
.welcome-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

@keyframes popUp {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* 7. Two-Way Visitor Messaging Widget */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
}

.chat-toggle-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px var(--accent-glow);
  position: relative;
  transition: var(--transition);
}
.chat-toggle-btn:hover {
  transform: scale(1.08);
  background: var(--accent-hover);
}

.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-secondary);
}

.chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 340px;
  height: 460px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat-window.open {
  display: flex;
}

.chat-header {
  background: var(--bg-card);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}
.chat-status {
  font-size: 0.75rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.chat-body {
  flex: 1 1 auto;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-primary);
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.45) rgba(0, 0, 0, 0.04);
}
.chat-body::-webkit-scrollbar {
  width: 6px;
}
.chat-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
}
.chat-body::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.45);
  border-radius: 6px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.75);
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}
.chat-bubble.visitor {
  align-self: flex-end;
  background: var(--accent-color);
  color: #fff;
  border-bottom-right-radius: 2px;
}
.chat-bubble.admin {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 2px;
}
.chat-time {
  font-size: 0.68rem;
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}

.chat-footer {
  padding: 10px 14px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-input-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* Document Upload & Attachment Styles (Visitor Chat) */
.chat-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.chat-attach-btn:hover {
  background: var(--bg-primary);
  color: var(--accent-color);
  transform: scale(1.06);
}

.chat-doc-preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 0.72rem;
  color: var(--text-main);
  max-width: 120px;
  flex-shrink: 0;
}
.chat-doc-preview-badge .doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-doc-preview-badge .doc-remove-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 1px;
}

.chat-attachment-container {
  margin-top: 4px;
  margin-bottom: 4px;
}
.chat-attachment-img-wrap {
  display: block;
  max-width: 200px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.chat-attachment-img {
  width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: cover;
  display: block;
}

.chat-attachment-doc-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: var(--transition);
  max-width: 220px;
}
.chat-bubble.visitor .chat-attachment-doc-card {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
}
.chat-bubble.admin .chat-attachment-doc-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.chat-attachment-doc-card:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.chat-doc-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}
.chat-doc-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.chat-doc-name {
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-doc-meta {
  font-size: 0.66rem;
  opacity: 0.8;
  margin-top: 1px;
}
.chat-doc-dl-icon {
  flex-shrink: 0;
  opacity: 0.85;
}
.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 10px 16px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease;
}
.chat-input:focus {
  border-color: var(--accent-color);
}
.chat-send-btn {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.chat-send-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}
.chat-send-btn:active {
  transform: scale(0.94);
}

/* 8. Password Login Screen */
.login-container {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-lock-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-glow);
  color: var(--accent-color);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.login-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--text-main);
}
.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.form-group {
  margin-bottom: 20px;
  text-align: left;
}
.form-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}
.form-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 18px;
  text-align: left;
}

/* ========================================================
   Mobile Responsiveness & Breakpoints
   ======================================================== */
@media (max-width: 768px) {
  .header-inner {
    padding: 10px 16px;
  }
  .brand-title span:first-of-type {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.05rem;
  }
  .brand-badge {
    display: none;
  }

  /* Hide desktop buttons in header */
  .desktop-only-action {
    display: none !important;
  }

  /* Show mobile settings toggle button */
  .mobile-settings-btn {
    display: inline-flex;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  .photo-overlay {
    padding: 10px;
  }
  .photo-caption {
    font-size: 0.8rem;
  }
  .photo-meta {
    font-size: 0.7rem;
  }

  .slider-btn {
    width: 44px;
    height: 44px;
  }
  .slider-btn.prev {
    left: 10px;
  }
  .slider-btn.next {
    right: 10px;
  }
  .lightbox-info {
    bottom: 14px;
    padding: 6px 14px;
    font-size: 0.78rem;
    gap: 10px;
  }
  .chat-window {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: min(520px, 85dvh) !important;
    max-height: 85dvh !important;
    border-radius: 20px 20px 0 0 !important;
    border: 1px solid var(--border-color) !important;
    border-bottom: none !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45) !important;
    z-index: 1050 !important;
  }
  .chat-header {
    padding: 12px 16px;
    border-radius: 20px 20px 0 0;
  }
  .chat-widget {
    bottom: 18px;
    right: 18px;
  }
  .chat-toggle-btn {
    width: 52px;
    height: 52px;
  }
  .chat-footer {
    padding: 8px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    gap: 6px;
  }
  .chat-input {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
    padding: 9px 14px;
  }
  .chat-bubble {
    max-width: 88%;
    font-size: 0.88rem;
    padding: 8px 12px;
  }
}

/* Mobile: Hide floating toggle button when chat window is open */
@media (max-width: 768px) {
  .chat-widget .chat-window.open ~ .chat-toggle-btn {
    display: none !important;
  }
}


/* ========================================================
   Global 8px Default Border Radius, Granular Target CSS & Sort/Group Toolbar
   ======================================================== */
:root {
  --ui-radius: 8px;
  --ui-control-h: 36px;
  --radius-sm: var(--ui-radius, 8px);
  --radius-md: var(--ui-radius, 8px);
  --radius-lg: var(--ui-radius, 8px);
  --radius-primary-btn: var(--ui-radius, 8px);
  --radius-secondary-btn: var(--ui-radius, 8px);
  --radius-icon-btn: var(--ui-radius, 8px);
  --radius-inputs: var(--ui-radius, 8px);
  --radius-cards: var(--ui-radius, 8px);
  --height-primary-btn: var(--ui-control-h, 36px);
  --height-secondary-btn: var(--ui-control-h, 36px);
  --height-icon-btn: var(--ui-control-h, 36px);
  --height-inputs: var(--ui-control-h, 36px);
}

/* Gallery Sort & Group Toolbar */
.gallery-sort-group-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-cards, 8px);
  box-shadow: var(--shadow-sm);
}

.sort-control-wrap,
.group-control-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar-select {
  width: auto !important;
  min-width: 195px;
  height: var(--height-inputs, var(--ui-control-h, 36px)) !important;
  min-height: var(--height-inputs, var(--ui-control-h, 36px)) !important;
  padding: 0 12px !important;
  font-size: 0.82rem !important;
  font-weight: 600;
  border-radius: var(--radius-inputs, 8px) !important;
  cursor: pointer;
}

.group-pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.group-pill-btn {
  height: var(--height-secondary-btn, var(--ui-control-h, 36px)) !important;
  min-height: var(--height-secondary-btn, var(--ui-control-h, 36px)) !important;
  padding: 0 12px !important;
  border-radius: var(--radius-secondary-btn, 8px) !important;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.group-pill-btn:hover {
  border-color: var(--accent-color);
  color: var(--text-main);
}

.group-pill-btn.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #ffffff;
  border-radius: var(--radius-primary-btn, 8px) !important;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Grouped Photo Sections (Date / Month / Year) */
.gallery-group-section {
  margin-bottom: 26px;
}

.gallery-group-section:last-child {
  margin-bottom: 0;
}

.gallery-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-color);
  border-radius: var(--radius-cards, 8px);
}

.gallery-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.gallery-group-title svg {
  color: var(--accent-color);
  flex-shrink: 0;
}

.gallery-group-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-color);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: var(--radius-cards, 8px);
}

.photo-date-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 640px) {
  .gallery-sort-group-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .sort-control-wrap,
  .group-control-wrap {
    justify-content: space-between;
    width: 100%;
  }
  .toolbar-select {
    flex: 1;
    min-width: 0;
  }
}

/* Granular Target Group Bindings on User Side */
.photo-card,
.login-card,
.welcome-card,
.drawer-item,
.photo-category-tag,
.brand-badge,
.lightbox-img,
.lightbox-info,
.theme-studio-dialog,
.theme-preset-btn,
.theme-color-field,
.chat-welcome-banner,
.chat-msg-bubble,
.chat-attachment-img-wrap,
.chat-attachment-doc-card,
.attachment-preview-dialog {
  border-radius: var(--radius-cards, var(--ui-radius, 8px)) !important;
}

.form-input {
  border-radius: var(--radius-inputs, var(--ui-radius, 8px)) !important;
}

.btn,
.btn-primary,
.btn-outline,
.theme-toggle-btn,
.category-tab,
.chat-back-btn,
.chat-header-icon-btn,
.chat-attach-btn,
.chat-submit-btn,
.chat-text-input,
.preview-action-btn,
.attachment-preview-close,
.theme-studio-close {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
}

.btn-primary {
  border-radius: var(--radius-primary-btn, var(--ui-radius, 8px)) !important;
  height: var(--height-primary-btn, var(--ui-control-h, 36px)) !important;
  min-height: var(--height-primary-btn, var(--ui-control-h, 36px)) !important;
  max-height: var(--height-primary-btn, var(--ui-control-h, 36px)) !important;
  padding: 0 12px !important;
  font-size: 0.82rem !important;
  gap: 6px !important;
}

.btn-outline,
.category-tab,
.chat-back-btn,
.preview-action-btn {
  border-radius: var(--radius-secondary-btn, var(--ui-radius, 8px)) !important;
  height: var(--height-secondary-btn, var(--ui-control-h, 36px)) !important;
  min-height: var(--height-secondary-btn, var(--ui-control-h, 36px)) !important;
  max-height: var(--height-secondary-btn, var(--ui-control-h, 36px)) !important;
  padding: 0 12px !important;
  font-size: 0.82rem !important;
  gap: 6px !important;
}

.theme-toggle-btn,
.mobile-settings-btn,
.chat-header-icon-btn,
.chat-attach-btn,
.chat-submit-btn,
.attachment-preview-close,
.theme-studio-close {
  border-radius: var(--radius-icon-btn, var(--ui-radius, 8px)) !important;
  height: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
  min-height: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
  max-height: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
  width: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
  min-width: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
  padding: 0 !important;
}

.chat-text-input {
  border-radius: var(--radius-inputs, var(--ui-radius, 8px)) !important;
  height: var(--height-inputs, var(--ui-control-h, 36px)) !important;
  min-height: var(--height-inputs, var(--ui-control-h, 36px)) !important;
  max-height: var(--height-inputs, var(--ui-control-h, 36px)) !important;
  flex: 1 1 auto !important;
  padding: 0 14px !important;
}

/* ========================================================
   Two-Way Voice Message Recorder & In-Bubble Audio Player
   ======================================================== */
.chat-mic-btn {
  transition: all 0.2s ease !important;
}
.chat-mic-btn:hover {
  border-color: var(--primary, var(--accent-color, #B58B62)) !important;
  color: var(--primary, var(--accent-color, #B58B62)) !important;
}
.chat-mic-btn.recording {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25) !important;
  animation: voiceBtnPulse 1.4s infinite;
}

@keyframes voiceBtnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.voice-record-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-cards, 8px);
  width: 100%;
}

.voice-record-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.voice-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse 1s infinite;
  flex-shrink: 0;
}

.voice-rec-timer {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.86rem;
  color: #ef4444;
  min-width: 36px;
}

.voice-wave-bars {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.voice-wave-bars span {
  display: block;
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: #ef4444;
  animation: voiceWaveAnim 0.8s ease-in-out infinite;
}
.voice-wave-bars span:nth-child(2) { animation-delay: 0.15s; }
.voice-wave-bars span:nth-child(3) { animation-delay: 0.3s; }
.voice-wave-bars span:nth-child(4) { animation-delay: 0.45s; }
.voice-wave-bars span:nth-child(5) { animation-delay: 0.6s; }

@keyframes voiceWaveAnim {
  0%, 100% { height: 5px; opacity: 0.6; }
  50% { height: 15px; opacity: 1; }
}

.voice-record-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-voice-player-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-cards, 8px);
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  min-width: 230px;
  max-width: 290px;
}

.chat-voice-player-card.visitor {
  background: rgba(0, 0, 0, 0.08);
}

.chat-voice-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
}

.chat-voice-mic-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-voice-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-voice-size {
  font-size: 0.68rem;
  opacity: 0.8;
  flex-shrink: 0;
}

.chat-voice-audio {
  width: 100%;
  height: 34px;
  border-radius: 6px;
  outline: none;
}

@media (max-width: 480px) {
  .chat-voice-player-card {
    min-width: 195px;
    max-width: 100%;
  }
}

/* ========================================================
   WhatsApp-Style Custom Voice Message Player (.wa-voice-player)
   ======================================================== */
.wa-voice-player {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 4px 2px 2px;
  min-width: 235px;
  max-width: 300px;
  user-select: none;
}

.wa-hidden-audio {
  display: none !important;
}

/* Circular Play / Pause Button */
.wa-play-btn {
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  border-radius: 50% !important;
  border: none !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  flex-shrink: 0;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.wa-play-btn:hover:not(:disabled) {
  transform: scale(1.06);
}

.wa-play-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.wa-play-btn .wa-icon-play {
  margin-left: 2px;
}

/* Outgoing Bubble Theme (Admin on Admin Side / Visitor on User Side) */
.chat-bubble.admin .wa-play-btn,
.chat-msg-bubble.visitor .wa-play-btn {
  background: rgba(255, 255, 255, 0.24) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.chat-bubble.admin .wa-play-btn:hover,
.chat-msg-bubble.visitor .wa-play-btn:hover {
  background: rgba(255, 255, 255, 0.34) !important;
}

/* Incoming Bubble Theme (Visitor on Admin Side / Admin on User Side) */
.chat-bubble.visitor .wa-play-btn,
.chat-msg-bubble.admin .wa-play-btn {
  background: var(--primary, var(--accent-color, #B58B62)) !important;
  color: #ffffff !important;
  box-shadow: 0 3px 10px var(--primary-glow, var(--accent-glow, rgba(181, 139, 98, 0.28)));
}

/* Right Main Column: Waveform + Bottom Meta Row */
.wa-voice-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Interactive Waveform Track */
.wa-waveform-track {
  position: relative;
  height: 26px;
  display: flex;
  align-items: center;
  width: 100%;
  cursor: pointer;
}

.wa-waveform-bars {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2.5px;
  width: 100%;
  height: 22px;
  pointer-events: none;
}

.wa-wave-bar {
  flex: 1;
  min-width: 2.5px;
  max-width: 4px;
  border-radius: 3px;
  transition: background-color 0.12s ease, opacity 0.12s ease;
}

/* Waveform Colors for Outgoing Bubble */
.chat-bubble.admin .wa-wave-bar,
.chat-msg-bubble.visitor .wa-wave-bar {
  background: rgba(255, 255, 255, 0.38);
}
.chat-bubble.admin .wa-wave-bar.played,
.chat-msg-bubble.visitor .wa-wave-bar.played {
  background: #ffffff;
}

/* Waveform Colors for Incoming Bubble */
.chat-bubble.visitor .wa-wave-bar,
.chat-msg-bubble.admin .wa-wave-bar {
  background: var(--admin-border, var(--border-color, rgba(120, 110, 100, 0.35)));
}
.chat-bubble.visitor .wa-wave-bar.played,
.chat-msg-bubble.admin .wa-wave-bar.played {
  background: var(--primary, var(--accent-color, #B58B62));
}

/* Invisible Range Input Overlay for Smooth Scrubbing + Playhead Thumb */
.wa-seek-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}

/* Bottom Meta Row (Duration + 1x/1.5x/2x Speed Pill + Mic Badge) */
.wa-voice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.7rem;
  line-height: 1;
}

.wa-voice-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  opacity: 0.88;
  letter-spacing: -0.01em;
}

.wa-voice-right-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wa-speed-btn {
  border: none;
  border-radius: 10px !important;
  padding: 2px 7px !important;
  height: 18px !important;
  min-height: 18px !important;
  font-size: 0.66rem !important;
  font-weight: 700 !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.wa-speed-btn:hover {
  transform: scale(1.05);
}

.chat-bubble.admin .wa-speed-btn,
.chat-msg-bubble.visitor .wa-speed-btn {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.chat-bubble.visitor .wa-speed-btn,
.chat-msg-bubble.admin .wa-speed-btn {
  background: var(--primary-glow, var(--accent-glow, rgba(181, 139, 98, 0.2)));
  color: var(--primary, var(--accent-color, #B58B62));
}

.wa-mic-badge {
  display: inline-flex;
  align-items: center;
  opacity: 0.85;
}

@media (max-width: 480px) {
  .wa-voice-player {
    min-width: 205px;
    max-width: 100%;
  }
}

/* Desktop vs Mobile Header Buttons on User Side:
   - Desktop (> 768px): Show icon + label on header buttons, hide mobile gear button
   - Mobile (<= 768px): Strip text labels from all header buttons (.header-btn-label) and make them sleek square icon-only buttons */
@media (min-width: 769px) {
  .mobile-settings-btn {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .header-actions {
    gap: 6px !important;
  }
  .header-action-btn .header-btn-label {
    display: none !important;
  }
  .header-action-btn,
  .mobile-settings-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    min-width: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    height: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    min-height: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    max-height: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    padding: 0 !important;
    border-radius: var(--radius-icon-btn, var(--ui-radius, 8px)) !important;
  }
  .dedicated-chat-app .chat-back-btn .back-text-full,
  .dedicated-chat-app .chat-back-btn .back-text-short {
    display: none !important;
  }
  .dedicated-chat-app .chat-back-btn {
    width: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    min-width: var(--height-icon-btn, var(--ui-control-h, 36px)) !important;
    padding: 0 !important;
  }
}

/* ========================================================
   User Top-Corner Admin Reply Toast Deck (Compact, Max 2 Visible, Overlap on 3+)
   ======================================================== */
.user-top-toast-deck {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100010;
  width: min(272px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}

.user-top-reply-toast {
  position: relative;
  width: 100%;
  background: var(--bg-card, #FFFCF7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-main, #49372C);
  border: 1px solid var(--border-color, #D9CCBC);
  border-left: 3.5px solid var(--accent-color, #B58B62);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.1);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), margin 0.2s ease;
}

.user-top-reply-toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.user-top-reply-toast + .user-top-reply-toast {
  margin-top: 5px;
  z-index: 1;
}

.user-top-reply-toast.toast-overlap-out {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 0 !important;
  transform: translateY(5px) scale(0.93) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.user-top-reply-avatar {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 7px;
  background: var(--accent-glow, rgba(181, 139, 98, 0.18));
  color: var(--accent-color, #B58B62);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-top-reply-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-top-reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--accent-color, #B58B62);
}

.user-top-reply-time {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-muted, #786E64);
}

.user-top-reply-text {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main, #49372C);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================================
   WhatsApp Messenger Bubble & Canvas Styling (User Side)
   ======================================================== */
.dedicated-chat-app .chat-messages-canvas {
  background-color: var(--bg-primary) !important;
  background-image: radial-gradient(rgba(120, 110, 100, 0.11) 1px, transparent 1px) !important;
  background-size: 18px 18px !important;
  gap: 8px !important;
  padding: 14px 18px !important;
}

.wa-date-divider {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px 0;
}

.wa-date-divider span {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.dedicated-chat-app .chat-msg-bubble {
  padding: 7px 11px 5px 12px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14) !important;
  position: relative;
  max-width: min(78%, 520px) !important;
}

/* Outgoing Bubble (Right Side - Visitor) */
.dedicated-chat-app .chat-msg-bubble.visitor {
  border-radius: 12px 2px 12px 12px !important;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-hover)) !important;
  color: #ffffff !important;
  margin-right: 4px;
}

.dedicated-chat-app .chat-msg-bubble.visitor::before {
  content: "";
  position: absolute;
  top: 0;
  right: -6px;
  width: 0;
  height: 0;
  border-top: 8px solid var(--accent-hover);
  border-right: 6px solid transparent;
}

/* Incoming Bubble (Left Side - Admin) */
.dedicated-chat-app .chat-msg-bubble.admin {
  border-radius: 2px 12px 12px 12px !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  margin-left: 4px;
}

.dedicated-chat-app .chat-msg-bubble.admin::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 8px solid var(--bg-card);
  border-left: 6px solid transparent;
}

.dedicated-chat-app .chat-msg-text {
  font-size: 0.92rem !important;
  line-height: 1.42 !important;
}

.dedicated-chat-app .chat-msg-time {
  font-size: 0.66rem !important;
  opacity: 0.85 !important;
  margin-top: 2px !important;
  gap: 3px !important;
}

.wa-read-ticks {
  color: #7dd3fc;
  flex-shrink: 0;
}

/* ========================================================
   AES-256 Encrypted Video Vault Card & Lightbox Player Styles
   ======================================================== */
.photo-img-wrap {
  position: relative;
}

.video-card-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.photo-card.is-video-card:hover .video-card-play-badge {
  transform: translate(-50%, -50%) scale(1.1);
  background: var(--accent-color, #B58B62);
}

.photo-video-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-glow, rgba(181, 139, 98, 0.2));
  color: var(--accent-color, #B58B62);
}

.lightbox-video {
  max-width: 90vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.85);
  background: #000000;
  outline: none;
}

.lightbox-video-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 48px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.vault-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent-color, #B58B62);
  border-radius: 50%;
  animation: vaultSpin 0.75s linear infinite;
}

@keyframes vaultSpin {
  to { transform: rotate(360deg); }
}

/* ========================================================
   User-Side Interactive Category Tag & Lightbox Category Button
   ======================================================== */
button.photo-category-tag.edit-photo-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

button.photo-category-tag.edit-photo-cat-btn:hover {
  background: var(--accent-color, #B58B62);
  color: #ffffff;
  border-color: var(--accent-color, #B58B62);
  transform: translateY(-1px);
}

.lightbox-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 4px 11px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.lightbox-cat-btn:hover {
  background: var(--accent-color, #B58B62);
  border-color: var(--accent-color, #B58B62);
}

.lightbox-video-loader { display: none !important; }

/* =========================================================================
   Full-App Emergency White Lock Screen (User Side: Gallery + Chat + Login)
   ========================================================================= */
#emergencyWhiteLockScreen {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
  z-index: 2147483647 !important;
  display: none;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  outline: none !important;
  cursor: default !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
  pointer-events: all !important;
}

html.emergency-white-locked,
body.emergency-white-locked {
  background: #ffffff !important;
  background-color: #ffffff !important;
  overflow: hidden !important;
}

html.emergency-white-locked body > *:not(#emergencyWhiteLockScreen):not(script):not(style),
body.emergency-white-locked > *:not(#emergencyWhiteLockScreen):not(script):not(style) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html.emergency-white-locked #emergencyWhiteLockScreen,
body.emergency-white-locked #emergencyWhiteLockScreen {
  display: block !important;
}

/* Gallery Header Emergency Button & Mobile Chat Refresh Hide */
.gallery-emergency-btn {
  background: rgba(239, 68, 68, 0.14) !important;
  border: 1px solid rgba(239, 68, 68, 0.45) !important;
  color: #ef4444 !important;
  font-weight: 700 !important;
}
.gallery-emergency-btn:hover {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}

@media (max-width: 768px) {
  #chatRefreshBtn {
    display: none !important;
  }
}

/* =========================================================================
   WhatsApp-Style Quoted Message Reply (Mark Message, Reply Banner & Quoted Bubble)
   ========================================================================= */
.chat-msg-row,
.chat-message-row {
  position: relative;
  align-items: center;
  gap: 6px;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.25s ease;
  touch-action: pan-y;
}

/* Action button beside message bubble to mark/reply */
.wa-msg-reply-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color, var(--admin-border, rgba(148, 163, 184, 0.28)));
  background: var(--bg-card, var(--admin-card, #1e293b));
  color: var(--text-muted, #94a3b8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0.72;
  transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .wa-msg-reply-btn {
    opacity: 0;
    transform: scale(0.88);
  }
  .chat-msg-row:hover .wa-msg-reply-btn,
  .chat-message-row:hover .wa-msg-reply-btn,
  .chat-msg-row.is-marked-for-reply .wa-msg-reply-btn,
  .chat-message-row.is-marked-for-reply .wa-msg-reply-btn {
    opacity: 1;
    transform: scale(1);
  }
}

.wa-msg-reply-btn:hover,
.wa-msg-reply-btn:active {
  opacity: 1 !important;
  transform: scale(1.08) !important;
  background: var(--accent-color, var(--primary, #6366f1)) !important;
  border-color: var(--accent-color, var(--primary, #6366f1)) !important;
  color: #ffffff !important;
}

/* Order so reply button sits on the inner side of the bubble */
.chat-msg-row.visitor-row .wa-msg-reply-btn,
.chat-message-row.admin-row .wa-msg-reply-btn {
  order: -1;
}
.chat-msg-row.admin-row .wa-msg-reply-btn,
.chat-message-row.visitor-row .wa-msg-reply-btn {
  order: 2;
}

/* Marked message highlight when selected for reply */
.chat-msg-row.is-marked-for-reply .chat-msg-bubble,
.chat-message-row.is-marked-for-reply .chat-bubble {
  outline: 2px solid var(--accent-color, var(--primary, #6366f1));
  outline-offset: 2px;
}

/* Pulse highlight when user clicks a quoted reply to jump to original message */
@keyframes waQuoteJumpPulse {
  0%   { transform: scale(1); filter: brightness(1); }
  25%  { transform: scale(1.025); filter: brightness(1.22); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.45); }
  60%  { transform: scale(1.01); filter: brightness(1.12); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25); }
  100% { transform: scale(1); filter: brightness(1); }
}

.wa-msg-highlight-pulse .chat-msg-bubble,
.wa-msg-highlight-pulse .chat-bubble {
  animation: waQuoteJumpPulse 1.4s ease-out;
}

/* Quoted Message Box inside Bubble */
.wa-quoted-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  border-left: 3.5px solid #38bdf8;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, transform 0.12s ease;
  max-width: 100%;
  overflow: hidden;
  text-align: left;
}

.wa-quoted-msg:hover {
  filter: brightness(1.06);
}
.wa-quoted-msg:active {
  transform: scale(0.985);
}

/* Outgoing bubble quoted style */
.chat-msg-bubble.visitor .wa-quoted-msg,
.chat-bubble.admin .wa-quoted-msg {
  background: rgba(0, 0, 0, 0.2);
  border-left-color: #ffffff;
  color: #ffffff;
}
.chat-msg-bubble.visitor .wa-quoted-msg.quoted-other,
.chat-bubble.admin .wa-quoted-msg.quoted-other {
  border-left-color: #7dd3fc;
}

/* Incoming bubble quoted style */
.chat-msg-bubble.admin .wa-quoted-msg,
.chat-bubble.visitor .wa-quoted-msg {
  background: rgba(120, 110, 100, 0.13);
  border-left-color: var(--accent-color, var(--primary, #6366f1));
  color: var(--text-main, #f3f4f6);
}
.chat-msg-bubble.admin .wa-quoted-msg.quoted-other,
.chat-bubble.visitor .wa-quoted-msg.quoted-other {
  border-left-color: #10b981;
}

.wa-quoted-sender {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-msg-bubble.visitor .wa-quoted-msg .wa-quoted-sender,
.chat-bubble.admin .wa-quoted-msg .wa-quoted-sender {
  color: #e0f2fe;
}
.chat-msg-bubble.admin .wa-quoted-msg .wa-quoted-sender,
.chat-bubble.visitor .wa-quoted-msg .wa-quoted-sender {
  color: var(--accent-color, var(--primary, #6366f1));
}

.wa-quoted-text {
  font-size: 0.79rem;
  line-height: 1.32;
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* Active Reply Preview Banner Above Chat Input Bar */
.wa-reply-preview-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px;
  background: var(--bg-primary, var(--admin-bg, rgba(15, 23, 42, 0.65)));
  border: 1px solid var(--border-color, var(--admin-border, #2d3345));
  border-left: 4px solid var(--accent-color, var(--primary, #6366f1));
  border-radius: 12px;
  width: 100%;
  animation: popIn 0.16s ease-out;
}

.wa-reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-reply-preview-sender {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-color, var(--primary, #6366f1));
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-reply-preview-text {
  font-size: 0.81rem;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-reply-cancel-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color, var(--admin-border, rgba(148, 163, 184, 0.25)));
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted, #94a3b8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.wa-reply-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #ef4444;
}

