/* ====================================
   CCR CHURCH APP - DESIGN SYSTEM
   Based on Friends Library aesthetic
   ==================================== */

/* Prevent iOS Safari pinch-to-zoom and all swipe/overscroll behavior */
html, body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Also prevent pull-to-refresh */
body {
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
}

:root {
  /* Colors */
  --bg: #f0f0f0;
  --card: #ffffff;
  --card-hover: #fafafa;
  --border: rgba(0,0,0,0.06);
  --text: #1a1a1a;
  --muted: #8a8a8a;
  --accent: #b8860b;
  --accent-light: #d4a84b;
  --accent-glow: rgba(184,134,11,0.10);

  /* Gold Gradients */
  --gold-grad: linear-gradient(135deg, #d4a84b, #b8860b, #8b6914, #d4a84b);
  --gold-border: linear-gradient(135deg, #e8c96a, #b8860b, #7a5a0a, #c9a23a);
  --gold-shine: linear-gradient(135deg, #f5e6b8, #d4a84b, #b8860b, #d4a84b, #f5e6b8);

  /* Semantic Colors */
  --green: #3d8b4f;
  --blue: #4a7ab5;
  --purple: #7a5fad;
  --red: #c0392b;
  --orange: #c77530;
  --teal: #3d8b7a;

  /* Surfaces */
  --surface: #e8e8e8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-neu: 6px 6px 12px rgba(0,0,0,0.06), -4px -4px 10px rgba(255,255,255,0.9);
  --shadow-neu-inset: inset 2px 2px 5px rgba(0,0,0,0.05), inset -2px -2px 5px rgba(255,255,255,0.8);

  /* Glassmorphism */
  --glass-bg: rgba(255,255,255,0.25);
  --glass-border: rgba(255,255,255,0.3);
  --glass-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

/* Dark Theme */
body.dark-theme {
  --bg: #1a1a1a;
  --card: #2a2a2a;
  --card-hover: #333333;
  --border: rgba(255,255,255,0.08);
  --text: #f0f0f0;
  --muted: #8a8a8a;
  --surface: #333333;
  --shadow-neu: 6px 6px 12px rgba(0,0,0,0.4), -4px -4px 10px rgba(255,255,255,0.02);
  --shadow-neu-inset: inset 2px 2px 5px rgba(0,0,0,0.3), inset -2px -2px 5px rgba(255,255,255,0.02);
  --glass-bg: rgba(42,42,42,0.7);
  --glass-border: rgba(255,255,255,0.1);
}

/* ====================================
   BASE STYLES
   ==================================== */

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
  padding-bottom: 40px;
}

/* Page swipe transition */
#app.slide-left {
  animation: slideInFromRight 0.25s ease-out;
}
#app.slide-right {
  animation: slideInFromLeft 0.25s ease-out;
}
@keyframes slideInFromRight {
  from { transform: translateX(30px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideInFromLeft {
  from { transform: translateX(-30px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

/* Page indicator dots */
.page-indicator {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 90;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.page-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: all 0.2s;
}
.page-indicator .dot.active {
  background: var(--gold, #b8860b);
  width: 18px;
  border-radius: 3px;
}

/* ====================================
   TYPOGRAPHY
   ==================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  background: var(--gold-shine);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 8px;
  margin-bottom: 8px;
}

.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* ====================================
   FLOATING ACTION BUTTON NAVIGATION
   ==================================== */

/* (Pull-down navigation removed — deprecated, unused.) */

/* FAB backdrop overlay — dims and blurs background when menu is open */
.fab-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.fab-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#fab-nav {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1000;
  pointer-events: none;
}

/* FAB trigger — gold circle in the lower-right corner. */
/* #fab-nav (the wrapper) is `pointer-events: none` so clicks pass through
   the empty space around the trigger; the trigger needs `auto` to opt back in. */
.fab-trigger {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 20px));
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  top: auto;
  transform: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--gold-grad);
  box-shadow: 0 8px 24px rgba(184,134,11,0.35), 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s, box-shadow 0.2s, background 0.2s;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  z-index: 1001;
  overflow: visible;
}

.fab-trigger:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(184,134,11,0.45), 0 4px 8px rgba(0,0,0,0.18);
}

.fab-trigger:active {
  transform: scale(0.94);
}

.fab-trigger-icon {
  font-size: 24px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-trigger.active .fab-trigger-icon {
  transform: rotate(90deg);
}

.fab-version-badge {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  letter-spacing: 0.4px;
  white-space: nowrap;
  padding: 0;
  cursor: pointer;
}

.fab-version-badge:hover {
  color: var(--accent);
}

.fab-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  display: grid;
  grid-template-columns: repeat(3, 84px);
  gap: 12px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(20, 20, 25, 0.62);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-menu.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.fab-item {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.10);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.fab-item:hover {
  background: rgba(212,168,75,0.25);
}

.fab-item:active {
  transform: scale(0.96);
}

.fab-item.active {
  background: var(--gold-grad);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.fab-item.active .fab-icon,
.fab-item.active .fab-label {
  filter: brightness(1.2);
}

.fab-icon {
  font-size: 28px;
  line-height: 1;
}

.fab-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.9;
}

/* More Menu Overlay */
.more-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.more-menu-overlay.active {
  display: flex;
}

.more-menu-content {
  background: var(--card);
  border-radius: 20px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.more-menu-content h2 {
  font-size: 24px;
  margin-bottom: 20px;
  background: var(--gold-shine);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.more-menu-item {
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.more-menu-item:hover {
  background: var(--accent-glow);
  transform: translateX(4px);
}

.more-menu-icon {
  font-size: 24px;
}

.more-menu-close {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 12px;
  margin-top: 8px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
}

.more-menu-close:hover {
  background: var(--surface);
  color: var(--text);
}

/* ====================================
   PAGE CONTAINER
   ==================================== */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  padding-top: 12px;
}

@supports not (padding-top: env(safe-area-inset-top)) {
  .page {
    padding-top: 16px;
  }
}

.page-header {
  margin-bottom: 0;
}

/* Sticky banner: header + buttons stay at top on scroll */
.page-sticky-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: env(safe-area-inset-top, 16px) 20px 12px 20px;
  margin: -12px -20px 12px -20px;
  border-bottom: 1px solid var(--border);
}

@supports not (padding-top: env(safe-area-inset-top)) {
  .page-sticky-banner {
    padding-top: 16px;
  }
}

/* Prevent horizontal scroll — only on body, NOT html (html overflow breaks sticky in Safari) */
body {
  overflow-x: hidden;
}

/* ====================================
   BUTTONS
   ==================================== */

.btn {
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.btn-primary {
  background: var(--gold-grad);
  color: white;
  box-shadow: 0 4px 15px rgba(184,134,11,0.25);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(184,134,11,0.35);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  border-color: var(--accent-light);
  background: var(--accent-glow);
}

.btn-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: nowrap;
}

.btn-group .btn {
  flex: 1;
  justify-content: center;
  padding: 10px 16px;
  font-size: 13px;
  min-height: 44px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ====================================
   CARDS
   ==================================== */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-neu);
  transition: all 0.3s;
  overflow: hidden;
  max-width: 100%;
}

.card-clickable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card-clickable:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-clickable:active {
  transform: scale(0.98);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.card-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* ====================================
   FORMS
   ==================================== */

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  max-width: 100%;
  padding: 12px 16px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: all 0.3s;
  box-shadow: var(--shadow-neu-inset);
  min-height: 44px;
  box-sizing: border-box;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-neu-inset), 0 0 0 3px rgba(184,134,11,0.08);
}

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

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b8860b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.form-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 6px;
}

.form-success {
  color: var(--green);
  font-size: 12px;
  margin-top: 6px;
}

/* ====================================
   BADGES
   ==================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge-gold {
  background: var(--accent-glow);
  color: var(--accent);
}

.badge-owner-fav {
  background: linear-gradient(135deg, rgba(184,134,11,0.15), rgba(212,169,74,0.15));
  color: #b8860b;
  font-weight: 700;
}

.badge-green {
  background: rgba(61,139,79,0.10);
  color: var(--green);
}

.badge-blue {
  background: rgba(74,122,181,0.10);
  color: var(--blue);
}

.badge-purple {
  background: rgba(122,95,173,0.10);
  color: var(--purple);
}

.badge-red {
  background: rgba(192,57,43,0.10);
  color: var(--red);
}

.badge-orange {
  background: rgba(199,117,48,0.10);
  color: var(--orange);
}

/* ====================================
   TABS
   ==================================== */

.tabs {
  display: inline-flex;
  gap: 0;
  padding: 4px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-neu);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.3s ease;
  white-space: nowrap;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  background: var(--card);
  box-shadow: var(--shadow-md);
  position: relative;
}

.tab.active::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  padding: 2px;
  background: var(--gold-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

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

.search-bar {
  position: relative;
  margin-bottom: 14px;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: all 0.3s;
  box-shadow: var(--shadow-neu-inset);
  min-height: 44px;
}

.search-bar input:focus {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-neu-inset), 0 0 0 3px rgba(184,134,11,0.1);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

/* ====================================
   MODAL
   ==================================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card);
  border: 2px solid var(--accent-light);
  border-radius: 20px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px;
  position: relative;
  box-shadow: var(--shadow-lg);
  box-sizing: border-box;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-right: 40px;
}

/* ====================================
   EMPTY STATE
   ==================================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 13px;
}

/* ====================================
   LOADING
   ==================================== */

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* Gentle pulse for pending "SAR ——" placeholders while data loads */
@keyframes sar-throb {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.sar-pending {
  animation: sar-throb 1.1s ease-in-out infinite;
}

/* ====================================
   UTILITY CLASSES
   ==================================== */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

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

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

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

@media (max-width: 640px) {
  .page {
    padding: 16px 12px;
  }

  .page-title {
    font-size: 20px;
  }

  .btn-group {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  .btn-group .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    font-size: 12px;
    min-height: 40px;
  }

  .modal {
    padding: 20px;
    border-radius: 16px;
    margin: 8px;
  }

  .modal-overlay {
    padding: 16px;
    align-items: center;
    justify-content: center;
  }

  .modal {
    max-height: 80vh;
    border-radius: 16px;
    margin: 0;
    width: 85%;
    max-width: 85%;
  }

  /* Library cards - single column on small phones */
  .library-books-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lib-card-cover {
    width: 52px;
    height: 76px;
    border-radius: 6px;
  }

  .lib-card-title {
    font-size: 13px;
  }

  .lib-card-author {
    font-size: 11px;
  }

  /* Book detail modal on mobile */
  .book-modal-header {
    gap: 14px;
  }

  .book-modal-cover {
    width: 80px;
    height: 120px;
  }

  .book-modal-title {
    font-size: 18px;
  }

  .book-modal-author {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .book-modal-summary {
    font-size: 13px;
    line-height: 1.6;
  }
}

/* Two columns on wider phones */
@media (min-width: 440px) and (max-width: 640px) {
  .library-books-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lib-card-cover {
    width: 48px;
    height: 70px;
  }

  .lib-card-inner {
    gap: 8px;
  }

  .lib-card-title {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .lib-card-author {
    font-size: 10px;
  }

  .lib-card-badges .badge {
    font-size: 8px;
    padding: 1px 5px;
  }
}

@media (hover: none) {
  .card-clickable:hover {
    transform: none;
    box-shadow: var(--shadow-neu);
  }
}

/* ====================================
   THEME TOGGLE
   ==================================== */

.theme-toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: 28px;
  transition: background 0.3s;
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.1), inset -2px -2px 4px rgba(255,255,255,0.5);
}

.theme-toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.theme-toggle input:checked + .theme-toggle-slider {
  background: var(--accent);
}

.theme-toggle input:checked + .theme-toggle-slider:before {
  transform: translateX(24px);
}

.theme-toggle-slider:hover {
  opacity: 0.9;
}

body.dark-theme .theme-toggle-slider:before {
  background: #f0f0f0;
}

/* ====================================
   BIBLE READING TRACKER PAGE
   ==================================== */

.bible-page {
  padding-bottom: 60px;
}

.bible-stats-card {
  padding: 24px;
  margin-bottom: 24px;
}

.bible-overall-progress {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.progress-ring-wrapper {
  flex-shrink: 0;
}

.bible-stats-text {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.genre-progress-section {
  margin-bottom: 32px;
}

.genre-progress-section h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text);
}

.genre-bar-item {
  margin-bottom: 16px;
}

.genre-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.genre-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.genre-percent {
  font-size: 13px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.genre-bar {
  height: 8px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.genre-bar-fill {
  height: 100%;
  background: var(--gold-grad);
  border-radius: 8px;
  transition: width 0.3s ease;
}

.bible-books-grid {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.genre-section {
  margin-bottom: 24px;
}

.genre-heading {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.books-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.book-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-neu);
  cursor: pointer;
  transition: all 0.3s ease;
}

.book-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.book-card.completed {
  border: 2px solid var(--green);
}

.book-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.book-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.book-progress {
  font-size: 13px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.book-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.book-progress-fill {
  height: 100%;
  background: var(--gold-grad);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.chapter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
}

.chapter-btn {
  width: 30px;
  height: 26px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  touch-action: manipulation;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chapter-btn:hover {
  border-color: var(--accent-light);
  background: var(--accent-glow);
}

.chapter-btn.read {
  background: var(--gold-grad);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

/* ====================================
   LIBRARY PAGE
   ==================================== */

.library-page {
  padding-bottom: 60px;
}

.library-search-bar {
  margin-bottom: 16px;
}

.library-search-bar input {
  width: 100%;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  outline: none;
  transition: all 0.3s;
  box-shadow: var(--shadow-neu-inset);
  min-height: 44px;
}

.library-search-bar input:focus {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-neu-inset), 0 0 0 3px rgba(184,134,11,0.1);
}

.library-pills {
  scrollbar-width: none;
}

.library-pills::-webkit-scrollbar {
  display: none;
}

.library-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  color: var(--muted);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.library-pill:hover {
  border-color: var(--accent-light);
  color: var(--accent);
  box-shadow: var(--shadow-md);
}

.library-pill.active {
  font-weight: 700;
  box-shadow: var(--shadow-md);
  transform: scale(1.05);
}

/* When NOT active, override inline styles to neutral */
.library-pill:not(.active) {
  background: var(--card) !important;
  color: var(--muted) !important;
  border-color: var(--border) !important;
}

.library-filters {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-neu);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.filter-row select {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 44px;
}

.filter-row select:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(184,134,11,0.1);
}

.library-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.library-book-card {
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  /* Skip rendering off-screen cards so a long library paints instantly; the
     browser renders them as they scroll into view. contain-intrinsic-size
     reserves each card's height so the scrollbar stays accurate. Degrades
     gracefully (renders normally) where unsupported. */
  content-visibility: auto;
  contain-intrinsic-size: auto 128px;
}

.library-book-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.library-book-card:active {
  transform: scale(0.98);
}

.library-book-card.dimmed {
  opacity: 0.3;
  filter: grayscale(50%);
  transition: opacity 0.2s, filter 0.2s;
}

/* Book card inner layout */
/* Gold left accent bar for owner favorites only */
.library-book-card.lib-fav-card {
  border-left: 4px solid var(--accent, #b8860b);
}

.lib-card-inner {
  display: flex;
  gap: 12px;
}

.lib-card-cover {
  width: 60px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.lib-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lib-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.lib-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.lib-card-author {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-card-badges {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.lib-fav-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: var(--gold-grad);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(184,134,11,0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.lib-stars {
  background: var(--gold-shine);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 11px;
  letter-spacing: 0.5px;
}

/* Legacy compact styles (kept for other pages) */
.book-info-compact {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.book-title-compact {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.book-author-compact {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.book-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: auto;
}

/* ====================================
   BOOK DETAIL MODAL
   ==================================== */

.book-modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.book-modal-cover {
  width: 120px;
  height: 175px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
  background: var(--surface);
}

.book-modal-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-modal-info {
  flex: 1;
  min-width: 0;
}

.book-modal-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  padding-right: 40px;
  line-height: 1.3;
}

.book-modal-author {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.book-modal-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.book-modal-summary {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.book-modal-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-bottom: 20px;
  overflow: hidden;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
}

.book-modal-form {
  padding: 16px;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-sizing: border-box;
  overflow: hidden;
  max-width: 100%;
}

.book-modal-form .form-group {
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.book-modal-form .form-input,
.book-modal-form .btn,
.book-modal-form input,
.book-modal-form button {
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

/* Nuclear: prevent ANY child from overflowing the modal */
.modal * {
  max-width: 100%;
  box-sizing: border-box;
}

.modal input,
.modal button,
.modal select,
.modal textarea {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Ensure form sections stay within modal content area */
.modal .book-modal-section,
.modal .book-modal-form,
.modal .book-modal-summary,
.modal .book-modal-header {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  margin-left: 0;
  margin-right: 0;
}



.book-modal-msg {
  margin-top: 12px;
}

/* ====================================
   CHECKOUT LOG CARDS
   ==================================== */

.checkout-log-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkout-log-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: opacity 0.2s;
  box-shadow: var(--shadow-neu);
  overflow: hidden;
  word-break: break-word;
}

.checkout-log-card.returned {
  opacity: 0.35;
}

.checkout-log-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.checkout-log-reader {
  font-size: 14px;
  font-weight: 700;
}

.checkout-log-book {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.checkout-log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
}

.checkout-log-dates {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
}

.checkout-log-progress {
  flex: 1;
  max-width: 120px;
}

.checkout-log-bar {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: var(--shadow-neu-inset);
}

.checkout-log-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.checkout-log-bar-fill.reading {
  background: var(--gold-grad);
}

.checkout-log-bar-fill.completed {
  background: var(--green);
}

.checkout-log-buttons {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.checkout-log-btn-progress,
.checkout-log-btn-return {
  flex: 1;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s;
}

.checkout-log-btn-progress {
  background: var(--gold-grad);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.checkout-log-btn-return {
  background: var(--green);
  color: white;
}

.checkout-log-edit {
  margin-top: 10px;
  padding: 10px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.checkout-edit-input {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-neu-inset);
}

.checkout-edit-save {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  background: var(--gold-grad);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
  margin-left: 8px;
}

.badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-green {
  background: rgba(61,139,79,0.15);
  color: var(--green);
}

.badge-orange {
  background: rgba(199,117,48,0.15);
  color: var(--orange);
}

.badge-muted {
  background: var(--surface);
  color: var(--muted);
}

.library-tab-content {
  display: none;
}

.library-tab-content.active {
  display: block;
}

/* ====================================
   GIVING PAGE
   ==================================== */

.giving-page {
  padding-bottom: 60px;
}

.giving-tab-content {
  display: none;
}

.giving-tab-content.active {
  display: block;
}

.giving-summary {
  padding: 12px 18px;
  margin-bottom: 16px;
}
.giving-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.giving-summary-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.giving-summary .giving-total {
  font-size: 26px;
}
.giving-summary-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.giving-summary h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.giving-total {
  font-size: 42px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: var(--gold-shine);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.charities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.charity-card {
  padding: 20px;
}

.charity-header {
  margin-bottom: 12px;
}

.charity-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.charity-category {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.charity-description {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 16px;
}

.charity-allocation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.allocation-amount {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.allocation-percent {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.charity-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.charity-progress-fill {
  height: 100%;
  background: var(--gold-grad);
  border-radius: 8px;
  transition: width 0.3s ease;
}

.coming-soon-card {
  padding: 48px 24px;
  text-align: center;
}

.coming-soon-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

/* ====================================
   VOTE PAGE — Approval Voting UI
   ==================================== */

.vote-page {
  padding-bottom: 100px;
}

.vote-tab-content.hidden {
  display: none;
}

/* Name input section */
.vote-name-section {
  margin-bottom: 16px;
}

.vote-name-section .form-label {
  font-size: 14px;
  font-weight: 600;
}

.vote-hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.vote-name-input {
  transition: border-color 0.2s;
}

/* Voter count */
.vote-voter-count {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
  padding: 10px;
}

.vote-voter-count strong {
  color: var(--text);
  font-size: 18px;
  font-family: 'JetBrains Mono', monospace;
}

/* Category cards */
.vote-category-card {
  margin-bottom: 16px;
}

.vote-cat-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.vote-cat-budget {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Option rows */
.vote-opt-row {
  margin-bottom: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.vote-opt-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 3px;
  border-radius: 7px;
  transition: background 0.15s;
}

.vote-opt-row:active .vote-opt-top {
  background: rgba(0,0,0,0.03);
}

body.dark-theme .vote-opt-row:active .vote-opt-top {
  background: rgba(255,255,255,0.04);
}

.vote-opt-row.selected .vote-opt-top {
  background: var(--accent-glow);
}

/* Checkmark */
.vote-checkmark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 11px;
}

.vote-opt-row.selected .vote-checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.vote-opt-row.selected .vote-checkmark::after {
  content: "✓";
  color: white;
  font-weight: 700;
}

/* Option info */
.vote-opt-info {
  flex: 1;
  min-width: 0;
}

.vote-opt-name {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.vote-opt-note {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
}

/* Stats */
.vote-opt-stats {
  text-align: right;
  flex-shrink: 0;
}

.vote-opt-votes {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}

.vote-opt-amount {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
}

.vote-opt-amount.vote-eliminated {
  color: var(--red);
  opacity: 0.7;
}

/* Progress bar */
.vote-bar-bg {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 1px 28px 0 28px;
}

.vote-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  background: var(--accent);
}

.vote-bar-fill.green {
  background: var(--green);
}

.vote-bar-fill.eliminated {
  background: var(--red);
  opacity: 0.4;
}

/* Save option highlight */
.vote-save-opt .vote-opt-name {
  color: var(--orange);
}

/* Tags */
.vote-tag {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  letter-spacing: 0.3px;
}

.vote-tag-elim {
  background: rgba(192,57,43,0.15);
  color: var(--red);
}

.vote-tag-cap {
  background: rgba(61,139,79,0.12);
  color: var(--green);
}

.vote-tag-closed {
  background: rgba(184,134,11,0.15);
  color: var(--gold);
  font-size: 11px;
  padding: 3px 10px;
}

.vote-opt-row.vote-readonly {
  cursor: default;
  pointer-events: none;
}

.vote-past-header {
  margin-bottom: 0;
}

.vote-past-poll {
  margin-bottom: 24px;
}

.vote-past-poll:last-child {
  margin-bottom: 0;
}

/* Submit bar */
.vote-submit-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  background: linear-gradient(transparent, var(--bg) 30%);
  z-index: 10;
}

.vote-submit-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--gold-grad);
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: opacity 0.2s;
  box-shadow: 0 4px 15px rgba(184,134,11,0.25);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.vote-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.vote-submit-btn:not(:disabled):active {
  opacity: 0.85;
}

/* Toast */
.vote-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.vote-toast.show {
  opacity: 1;
}

/* New poll form option rows */
.poll-option-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.poll-option-row .form-input {
  flex: 1;
}

.poll-option-row .poll-remove-opt {
  min-width: 36px;
  padding: 8px;
  font-size: 18px;
  line-height: 1;
}

/* Poll option cards */
.vote-poll-option {
  margin-bottom: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.vote-poll-option.vote-readonly {
  cursor: default;
  pointer-events: none;
}

.vote-poll-option.selected .vote-opt-top {
  background: var(--accent-glow);
}

.vote-poll-option.selected .vote-checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.vote-poll-option.selected .vote-checkmark::after {
  content: "✓";
  color: white;
  font-weight: 700;
}

.vote-poll-option:not(.vote-readonly):active .vote-opt-top {
  background: rgba(0,0,0,0.03);
}

body.dark-theme .vote-poll-option:not(.vote-readonly):active .vote-opt-top {
  background: rgba(255,255,255,0.04);
}

/* Vote option percentage display */
.vote-opt-percentage {
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Threshold indicator */
.vote-threshold-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
  opacity: 0.5;
  z-index: 1;
}

.vote-bar-fill.below-threshold {
  background: var(--red);
  opacity: 0.6;
}

/* Passed tag */
.vote-tag-passed {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(61,139,79,0.15);
  color: var(--green);
  letter-spacing: 0.3px;
}

/* User voted indicator */
.vote-user-voted {
  background: var(--accent-glow);
  color: var(--gold);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
  text-align: center;
}

/* Poll card styling — tighter vertical rhythm so more polls fit on a phone. */
.vote-poll-card {
  position: relative;
  padding: 12px 14px;
}

/* ─── HOME / LANDING PAGE ─── */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 24px 20px;
}

.home-header {
  text-align: center;
  margin-bottom: 32px;
}

.home-greeting {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  background: var(--gold-shine);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

.home-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-neu);
  aspect-ratio: 1;
}

.home-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-light);
}

.home-tile:active {
  /* no scale on tap — avoids page wiggle */
}

.home-tile-icon {
  font-size: 36px;
  line-height: 1;
}

.home-tile-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .home-grid {
    max-width: 320px;
    gap: 10px;
  }

  .home-tile {
    padding: 16px 6px;
    border-radius: 14px;
  }

  .home-tile-icon {
    font-size: 30px;
  }

  .home-tile-label {
    font-size: 11px;
  }

  .home-greeting {
    font-size: 24px;
  }
}

/* ─── SERMON GRID ─── */
.sermon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sermon-card {
  padding: 12px !important;
  margin-bottom: 0 !important;
}

@media (max-width: 380px) {
  .sermon-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── FAB BADGE (notification dot) ─── */
.fab-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: var(--red, #c0392b);
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  animation: badge-pulse 2s ease-in-out infinite;
}

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

/* ====================================
   BIBLE PAGE - COMPACT LAYOUT
   ==================================== */

.bible-stats-compact {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--card);
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.main-progress {
  flex-shrink: 0;
}

.testament-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 80px;
}

.testament-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75em;
}

.testament-label {
  font-weight: 600;
  color: var(--muted);
  min-width: 24px;
}

.testament-numbers {
  font-weight: 700;
  color: var(--text);
}

.quick-stats {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.quick-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 45px;
}

.stat-number {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.6em;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.bible-nav-buttons {
  margin-bottom: 16px;
}

.bible-nav-buttons .btn {
  flex: 1;
  min-width: 0;
}

.genre-stats-panel {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.genre-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.genre-row:last-child {
  margin-bottom: 0;
}

.genre-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.genre-name {
  font-weight: 600;
  font-size: 0.8em;
}

.genre-numbers {
  font-size: 0.75em;
  color: var(--muted);
  font-weight: 500;
}

.genre-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.genre-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .bible-stats-compact {
    gap: 12px;
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }
  
  .testament-stats {
    order: 1;
    flex-direction: row;
    justify-content: space-around;
    min-width: 0;
  }
  
  .quick-stats {
    order: 2;
    justify-content: space-around;
    gap: 8px;
  }
  
  .main-progress {
    order: 0;
    align-self: center;
  }
}

/* Bible lock button and locked state styles */
.bible-lock-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
  margin-left: 8px;
}

.bible-lock-btn:hover {
  background: var(--surface);
}

.book-card.locked {
  opacity: 0.5;
  filter: grayscale(50%);
}

.book-header-right {
  display: flex;
  align-items: center;
}

/* Bible stats panel styles */
.bible-stats-panel {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* Overall progress bar (always visible) */
.bible-overall-progress {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-neu);
}

.bible-overall-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bible-overall-read {
  font-size: 16px;
  color: var(--text);
}

.bible-overall-sep {
  color: var(--muted);
  font-size: 16px;
}

.bible-overall-days {
  font-size: 16px;
  color: var(--muted);
}

.bible-overall-bar {
  position: relative;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: visible;
}

.bible-overall-bar-fill {
  height: 100%;
  background: var(--gold-grad);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bible-overall-bar-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: var(--red, #e74c3c);
  border-radius: 50%;
  z-index: 1;
  transition: left 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.bible-target-input {
  padding: 4px 8px !important;
  font-size: 12px !important;
  min-height: 32px !important;
  border-radius: 8px !important;
  width: auto !important;
  min-width: 120px;
}

/* Three compact rings in a row */
.bible-rings-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.bible-ring-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Chapters per day card */
.bible-cpd-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-neu);
}

.bible-progress-circles {
  display: flex;
  justify-content: space-around;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.bible-progress-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 100px;
}

.bible-genre-stats {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Testament card layout - new Bible structure */
/* Bible section groups (collapsible) */
.bible-section-group {
  border-bottom: 1px solid var(--border);
}

.bible-section-group:last-child {
  border-bottom: none;
}

.bible-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--surface);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.2s;
}

.bible-section-header:active {
  background: var(--border);
}

.bible-section-chevron {
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.2s;
}

.bible-section-body {
  padding: 0 16px;
}

.bible-book-section { 
  padding: 12px 0; 
  border-bottom: 1px solid var(--border); 
}

.bible-book-section:last-child { 
  border-bottom: none; 
}

.bible-book-bar { 
  height: 4px; 
  background: var(--surface); 
  border-radius: 2px; 
  margin: 6px 0 8px; 
  overflow: hidden; 
}

.bible-book-bar-fill { 
  height: 100%; 
  border-radius: 2px; 
  transition: width 0.3s; 
}

.bible-chapter-grid { 
  display: grid; 
  grid-template-columns: repeat(10, 1fr); 
  gap: 4px; 
}

.chapter-btn { 
  width: 100%; 
  aspect-ratio: 1; 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  background: var(--card); 
  color: var(--text); 
  font-size: 12px; 
  font-weight: 600; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  transition: all 0.15s; 
  -webkit-tap-highlight-color: transparent; 
  padding: 0; 
}

.chapter-btn.read { 
  background: var(--gold-grad); 
  color: white; 
  border-color: transparent; 
}

.bible-book-section.locked .chapter-btn { 
  opacity: 0.4; 
  pointer-events: none; 
}

.bible-lock-btn { 
  background: none; 
  border: none; 
  font-size: 14px; 
  cursor: pointer; 
  padding: 2px; 
  opacity: 0.5; 
}

.bible-lock-btn.locked { 
  opacity: 1; 
}

/* ====================================
   CHARITY CARDS (GIVING DASHBOARD STYLE)
   ==================================== */

/* Category filter pills */
.cat-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.cat-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
}

.cat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cat-btn.active {
  color: #fff;
}

.cat-btn.active[data-cat="all"] { background: var(--accent); border-color: var(--accent); }
.cat-btn.active[data-cat="church"] { background: #60a5fa; border-color: #60a5fa; }
.cat-btn.active[data-cat="orphan"] { background: #d4a017; border-color: #d4a017; }
.cat-btn.active[data-cat="persecuted"] { background: #f97316; border-color: #f97316; }
.cat-btn.active[data-cat="word"] { background: #166534; border-color: #166534; }
.cat-btn.active[data-cat="local"] { background: #4ade80; border-color: #4ade80; color: #0f172a; }
.cat-btn.active[data-cat="global"] { background: #1e40af; border-color: #1e40af; }

/* Charity grid — matches dashboard */
.charity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* Charity card — dashboard style */
.giving-charity-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.giving-charity-card.dimmed {
  opacity: 0.3;
  filter: grayscale(80%);
  transform: scale(0.98);
}

/* Removed charities: kept for history (still tappable for the modal) but
   visibly grayed with a struck-through name. */
.giving-charity-card.removed {
  opacity: 0.6;
  filter: grayscale(65%);
}
.giving-charity-card.removed .card-name {
  text-decoration: line-through;
  text-decoration-color: rgba(148,163,184,0.7);
}

.giving-charity-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

/* Category-colored left border + gradient */
.giving-charity-card.cat-church { border-left: 3px solid #60a5fa; background: linear-gradient(135deg, var(--card) 90%, rgba(96,165,250,0.06)); }
.giving-charity-card.cat-orphan { border-left: 3px solid #facc15; background: linear-gradient(135deg, var(--card) 90%, rgba(250,204,21,0.06)); }
.giving-charity-card.cat-persecuted { border-left: 3px solid #f97316; background: linear-gradient(135deg, var(--card) 90%, rgba(249,115,22,0.06)); }
.giving-charity-card.cat-word { border-left: 3px solid #166534; background: linear-gradient(135deg, var(--card) 90%, rgba(22,101,52,0.06)); }
.giving-charity-card.cat-local { border-left: 3px solid #4ade80; background: linear-gradient(135deg, var(--card) 90%, rgba(74,222,128,0.06)); }
.giving-charity-card.cat-global { border-left: 3px solid #1e40af; background: linear-gradient(135deg, var(--card) 90%, rgba(30,64,175,0.06)); }

/* Card image */
.giving-charity-card .card-img {
  width: 100%;
  height: 96px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #eef0f5;
}

.giving-charity-card .card-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Card top row — category tag + badge */
.giving-charity-card .card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

/* Card name */
.giving-charity-card .card-name {
  font-size: 14px;
  font-weight: 600;
}

/* Category tags (pill style) */
.cat-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 6px;
}

.cat-tag-church { background: rgba(96,165,250,0.15); color: #60a5fa; }
.cat-tag-orphan { background: rgba(250,204,21,0.15); color: #d4a017; }
.cat-tag-persecuted { background: rgba(249,115,22,0.15); color: #f97316; }
.cat-tag-word { background: rgba(22,101,52,0.15); color: #22c55e; }
.cat-tag-local { background: rgba(74,222,128,0.15); color: #4ade80; }
.cat-tag-global { background: rgba(30,64,175,0.15); color: #6088e0; }
.cat-tag-onetime { background: rgba(148,163,184,0.18); color: #94a3b8; }

/* Per-fund sections (Charity tab) — subtle neutral card + colored left edge & bar */
.fund-sections { display: flex; flex-direction: column; gap: 10px; }
.fund-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
}
.fund-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 6px;
}
.fund-section-name { font-size: 13px; font-weight: 700; color: var(--text); }
.fund-section-meta { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.fund-section-bal { font-size: 12px; font-weight: 600; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.fund-section-vote {
  background: transparent; border: 1px solid var(--border); color: var(--accent);
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; cursor: pointer;
  transition: border-color 0.15s;
}
.fund-section-vote:hover { border-color: var(--accent); }
.fund-section-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.fund-section-bar-fill { height: 100%; background: var(--muted); border-radius: 2px; }

/* Responsive mini summary cards — reflow to fill the width on wide screens */
.fund-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.mini-card {
  position: relative;
  display: flex; align-items: flex-start; gap: 8px; text-align: left;
  background: var(--card-hover); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; cursor: pointer; transition: border-color 0.15s;
}
.mini-card-score {
  position: absolute; top: 6px; right: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 8.5px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 999px;
}
.mini-card-score.s100 { background: rgba(34,197,94,0.16);  color: #16a34a; }
.mini-card-score.smid { background: rgba(245,158,11,0.18); color: #d97706; }
.mini-card-score.slow { background: rgba(239,68,68,0.16);  color: #dc2626; }
.mini-card-score.snr  { background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.mini-card:hover { border-color: var(--accent); }
.mini-card.removed { opacity: 0.5; }
.mini-card-seeking { border-style: dashed; background: transparent; }
.mini-card-seeking-icon {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--muted); font-size: 18px; font-weight: 700;
}
.mini-card-seeking .mini-card-name { color: var(--muted); padding-right: 0; }
.mini-card-logo {
  width: 34px; height: 34px; object-fit: contain; border-radius: 6px; flex-shrink: 0;
  background: #fff; padding: 2px;
}
.mini-card-logo--none {
  display: flex; align-items: center; justify-content: center; padding: 0;
  background: var(--border); color: var(--muted); font-weight: 700; font-size: 15px;
}
.mini-card-body { min-width: 0; flex: 1; }
.mini-card-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  padding-right: 30px; /* clear the top-right score badge */
}
.mini-card.removed .mini-card-name { text-decoration: line-through; text-decoration-color: rgba(148,163,184,0.6); }
.mini-card-desc {
  font-size: 10px; color: var(--muted); line-height: 1.35; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mini-card-foot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mini-tag {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 8.5px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 5px; border-radius: 4px; white-space: nowrap;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
}
.mini-tag.active  { background: rgba(34,197,94,0.14);  border-color: transparent; color: #16a34a; }
.mini-tag.nom     { background: rgba(236,72,153,0.14); border-color: transparent; color: #ec4899; }
.mini-tag.amount  { background: rgba(212,160,23,0.16); border-color: transparent; color: #b8860b; }

/* Draft poll (editor-only, above the live polls) */
.draft-poll-wrap { border: 1px dashed #f59e0b; border-radius: 12px; padding: 6px; margin-bottom: 12px; }
.draft-poll-banner {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: #d97706; padding: 4px 8px 8px;
}

/* Allocation poll (grouped categories + multi-select ballot) */
.alloc-poll-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vote-status-badge { font-size: 11px; color: var(--muted); white-space: nowrap; }
.alloc-poll-desc { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.alloc-poll-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.alloc-cat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.alloc-cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.alloc-cat-name { font-size: 13px; font-weight: 700; color: var(--text); }
.alloc-cat-budget { font-size: 12px; font-weight: 600; color: var(--accent); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.alloc-opts { display: flex; flex-direction: column; gap: 6px; }
.alloc-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.alloc-opt.votable { cursor: pointer; }
.alloc-opt.votable:hover { border-color: var(--accent); }
.alloc-box { width: 15px; height: 15px; border: 1.5px solid var(--line-hi, var(--border)); border-radius: 4px; flex-shrink: 0; position: relative; }
.alloc-opt.mine { border-color: var(--accent); background: rgba(59,130,246,0.06); }
.alloc-opt.mine .alloc-box { background: var(--accent); border-color: var(--accent); }
.alloc-opt.mine .alloc-box::after { content: '✓'; position: absolute; inset: 0; color: #fff; font-size: 11px; line-height: 15px; text-align: center; }
.alloc-opt-name { flex: 1; font-size: 13px; color: var(--text); }
.alloc-opt-res { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
/* Live-projection: each option stacks its clickable row above a progress bar */
.alloc-opt-wrap { display: flex; flex-direction: column; gap: 4px; }
.alloc-bar-bg { height: 4px; background: var(--border); border-radius: 3px; overflow: hidden; }
.alloc-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.25s ease; }
.alloc-bar-fill.below { background: var(--red); }
.alloc-bar-fill.held { background: var(--gold, #d4a017); }
.alloc-opt-tag { margin-left: 6px; }
.alloc-tag.cap { font-size: 10px; background: rgba(34,197,94,0.15); color: #16a34a; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.alloc-poll-actions { margin-top: 12px; }

/* Editor tools (allocation poll) — collapsed <details> so members never see it */
.alloc-editor { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 8px; }
.alloc-editor > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); list-style: none; padding: 4px 0; }
.alloc-editor > summary::-webkit-details-marker { display: none; }
.alloc-editor[open] > summary { color: var(--accent); }
.alloc-editor-body { margin-top: 8px; display: flex; flex-direction: column; gap: 14px; }
.alloc-editor-sec { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.alloc-editor-h { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.alloc-editor-hint { font-weight: 400; color: var(--muted); font-size: 11px; }
.alloc-date-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.alloc-date-row input { flex: 1; max-width: 220px; }
.alloc-limit-cat { margin-bottom: 10px; }
.alloc-limit-cat-name { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.alloc-limit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; }
.alloc-limit-name { font-size: 12px; color: var(--text); flex: 1; min-width: 0; }
.alloc-limit-input { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.alloc-limit-input input { width: 90px; padding: 4px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); }
.alloc-editor-status { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-tag.onetime { background: rgba(148,163,184,0.18); border-color: transparent; color: #94a3b8; }
.mini-tag.removed { background: rgba(148,163,184,0.18); border-color: transparent; color: #94a3b8; }
/* Charity Navigator score */
.mini-tag.score.s100 { background: rgba(34,197,94,0.14);  border-color: transparent; color: #16a34a; }
.mini-tag.score.smid { background: rgba(245,158,11,0.16); border-color: transparent; color: #d97706; }
.mini-tag.score.slow { background: rgba(239,68,68,0.14);  border-color: transparent; color: #dc2626; }
.mini-tag.score.snr  { background: var(--card); border-color: var(--border); color: var(--muted); }

/* Per-fund accent — subtle: only the left edge + the balance bar are colored */
.fund-section.fs-church     { border-left-color: #60a5fa; }
.fund-section.fs-church     .fund-section-bar-fill { background: #60a5fa; }
.fund-section.fs-orphan     { border-left-color: #d4a017; }
.fund-section.fs-orphan     .fund-section-bar-fill { background: #d4a017; }
.fund-section.fs-persecuted { border-left-color: #f97316; }
.fund-section.fs-persecuted .fund-section-bar-fill { background: #f97316; }
.fund-section.fs-word       { border-left-color: #22c55e; }
.fund-section.fs-word       .fund-section-bar-fill { background: #22c55e; }
.fund-section.fs-local      { border-left-color: #4ade80; }
.fund-section.fs-local      .fund-section-bar-fill { background: #4ade80; }
.fund-section.fs-global     { border-left-color: #6088e0; }
.fund-section.fs-global     .fund-section-bar-fill { background: #6088e0; }

/* Badge (Given/New/Org) */
.card-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-given { background: rgba(96,165,250,0.15); color: #60a5fa; }
.badge-new { background: rgba(236,72,153,0.15); color: #ec4899; }
.badge-org { background: rgba(59,130,246,0.15); color: var(--accent); }
.badge-potential { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge-removed { background: rgba(148,163,184,0.2); color: #94a3b8; }

/* Card description */
.giving-charity-card .card-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

/* Card footer */
.giving-charity-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.giving-charity-card .card-amount {
  font-size: 15px;
  font-weight: 700;
}

.giving-charity-card .card-amount.zero {
  color: var(--muted);
  font-size: 14px;
}

.giving-charity-card .card-freq {
  font-size: 11px;
  color: var(--muted);
}

/* Score circle (top-right corner) */
.giving-charity-card .card-score {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.score-green { background: rgba(22,163,74,0.1); color: var(--green); border: 2px solid var(--green); }
.score-yellow { background: rgba(217,119,6,0.1); color: var(--orange); border: 2px solid var(--orange); }
.score-red { background: rgba(220,38,38,0.1); color: var(--red); border: 2px solid var(--red); }
.score-na { background: rgba(107,113,133,0.08); color: var(--muted); border: 2px solid var(--border); font-size: 9px; }

/* Click hint */
.giving-charity-card .click-hint {
  font-size: 10px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.giving-charity-card:hover .click-hint {
  opacity: 1;
}

/* Charity modal overlay */
.charity-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.charity-modal-overlay.show {
  display: flex;
}

.charity-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}

.charity-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.charity-modal .modal-close:hover {
  color: var(--text);
}

.charity-modal h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.charity-modal .modal-sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
}

.charity-modal .modal-desc {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--text);
}

.charity-modal .modal-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.charity-modal .modal-link:hover {
  text-decoration: underline;
}

.charity-modal .modal-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.charity-modal .modal-stat {
  background: var(--card-hover);
  border-radius: 8px;
  padding: 10px 14px;
  flex: 1;
}

.charity-modal .modal-stat .stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.charity-modal .modal-stat .stat-value {
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.charity-modal .update-box {
  background: var(--card-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
}

.charity-modal .update-box h3 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Legacy support */
.category-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cat-church { background: #60a5fa; }
.cat-orphan { background: #d4a017; }
.cat-persecuted { background: #f97316; }
.cat-word { background: #166534; }
.cat-local { background: #4ade80; color: #0f172a; }
.cat-global { background: #1e40af; }

.status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  color: white;
}

.status-given { background: #3b82f6; }
.status-new { background: #ec4899; }

/* Score circles — legacy */
.score-circle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
}

.score-100 { background: #16a34a; }
.score-75 { background: #d97706; }
.score-warning { background: #dc2626; }

/* Copy card button */
.copy-card-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 26px;
  border: none;
  background: var(--surface, #f5f5f5);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  line-height: 1;
  white-space: nowrap;
}
.copy-card-btn:hover,
.copy-card-btn:active {
  opacity: 1;
}

/* ====================================
   VOLUNTEER GRID TABLE
   ==================================== */

.vol-grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.vol-grid-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 12px;
}

.vol-grid-th {
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--accent);
}

.vol-grid-td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  line-height: 1.4;
}

.vol-grid-date {
  font-weight: 700;
  white-space: nowrap;
  color: var(--accent);
}

.vol-grid-current {
  background: var(--accent-glow);
}

.vol-grid-current .vol-grid-date {
  color: var(--accent);
}

body.dark-theme .vol-grid-th {
  background: var(--accent);
  color: #1a1a1a;
}

/* Pray side button */
.pray-side-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 28px;
  min-width: 28px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface, #f5f5f5);
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  padding: 8px 0;
}
.pray-side-btn:active {
  background: var(--accent);
  color: white;
}
.pray-side-btn.prayed {
  background: var(--accent);
  color: white;
  opacity: 0.6;
  cursor: default;
}

/* Fix form overflow on mobile — clip instead of overflow-x:hidden to preserve sticky */
#app {
  overflow-clip-margin: 0;
  overflow-x: clip;
  width: 100%;
}
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Show/hide password button */
.show-pw-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

/* ====================================
   DOCUMENTS PAGE
   ==================================== */

.doc-category-section {
  margin-bottom: 12px;
}

.doc-category-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  transition: all 0.2s;
  box-shadow: var(--shadow-neu);
  -webkit-tap-highlight-color: transparent;
}

.doc-category-header:hover {
  box-shadow: var(--shadow-lg);
}

.doc-category-header:active {
  transform: scale(0.98);
}

.doc-category-title {
  flex: 1;
  text-align: left;
}

.doc-category-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 10px;
  border-radius: 20px;
}

.doc-category-chevron {
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.3s ease;
}

.doc-category-chevron.expanded {
  transform: rotate(90deg);
}

.doc-category-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 4px;
}

.doc-category-body.expanded {
  max-height: 2000px;
  padding: 8px 4px 4px;
}

.doc-card {
  margin-bottom: 10px;
  padding: 14px 16px;
}

.doc-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-card-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.doc-card-info {
  flex: 1;
  min-width: 0;
}

.doc-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.doc-card-actions {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ── Timer ── */
.timer-unit {
  font-size: clamp(3.5rem, 22vw, 9rem);
  font-weight: bold;
  color: var(--gold, #c9a84c);
  line-height: 1;
  font-family: Georgia, serif;
  min-width: 1.4ch;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.6em 0.3em;
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
}
.timer-unit:active { background: rgba(201,168,76,0.15); }
.timer-colon {
  font-size: clamp(3.5rem, 22vw, 9rem);
  color: var(--gold, #c9a84c);
  opacity: 0.45;
  line-height: 1;
  padding: 0 4px;
}
#timer-overlay { background: var(--bg); }
#timer-overlay-inner { background: var(--bg); }
#timer-content { position: relative; z-index: 1002; }
#timer-burst-canvas { z-index: 1001; }
#timer-done-screen { background: var(--bg); opacity: 0; pointer-events: none; }
#timer-done-screen.fade-in { opacity: 1; transition: opacity 0.7s ease-out; pointer-events: none; }
#timer-keys-hint { color: var(--muted); }

/* Hide FAB and pull-down when timer overlay is open */
body.timer-open .fab-trigger,
body.timer-open .fab-overlay {
  display: none !important;
}

/* Light theme adjustments for timer */
body:not(.dark-theme) .timer-unit:active { background: rgba(184,134,11,0.1); }

/* Voting page loading state — shown while polls and vote counts fetch. */
.vote-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}
.vote-loading::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vote-spin 0.8s linear infinite;
}
@keyframes vote-spin {
  to { transform: rotate(360deg); }
}
