/* ==========================================================================
   REFUGIO & PALABRA — APPLE DESIGN SYSTEM (WWDC Fluid Interface Spec)
   Palette: Rose Accents (#e57d90) + iOS Translucent Materials & Typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,400;1,500&display=swap');

:root {
  /* Apple Rose Accent */
  --c1: #e57d90;
  --c2: #f1889b;
  --c3: #f99aaa;
  
  /* Apple / iOS Light Mode Materials */
  --bg: #F2F2F7; /* iOS grouped background */
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-solid: #FFFFFF;
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-input: rgba(142, 142, 147, 0.12); /* Apple systemFill */
  
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --glass-border: rgba(255, 255, 255, 0.6);

  --text: #000000;
  --text-primary: #1C1C1E;
  --text-2: #6C6C70; /* iOS secondary label */
  --text-3: #8E8E93; /* iOS tertiary label */

  /* Apple Subtle Depth */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.1);

  /* Apple Typography Stack */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-serif: "Playfair Display", "New York", Georgia, serif;

  /* Apple Radius Hierarchy */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-full: 9999px;

  /* Apple Spring Physics Easing approximation */
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-tight: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-card: rgba(28, 28, 30, 0.85);
  --bg-card-solid: #1C1C1E;
  --bg-card-hover: rgba(44, 44, 46, 0.9);
  --bg-input: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text: #FFFFFF;
  --text-primary: #FFFFFF;
  --text-2: #A1A1A6;
  --text-3: #636366;
}

[data-theme="sepia"] {
  --bg: #F4ECE4;
  --bg-card: rgba(250, 246, 240, 0.88);
  --bg-card-solid: #FAF6F0;
  --bg-card-hover: rgba(253, 251, 250, 0.95);
  --bg-input: rgba(67, 52, 34, 0.08);
  --border: rgba(67, 52, 34, 0.07);
  --border-strong: rgba(67, 52, 34, 0.14);
  --glass-border: rgba(255, 255, 255, 0.5);
  --text: #2C2014;
  --text-primary: #2C2014;
  --text-2: #7D6B57;
  --text-3: #A99986;
}


[data-font-size="small"]  { font-size: 14px; }
[data-font-size="normal"] { font-size: 16px; }
[data-font-size="large"]  { font-size: 18px; }
[data-font-size="xlarge"] { font-size: 20px; }

*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  -webkit-tap-highlight-color: transparent; 
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

.app-container {
  max-width: 800px; /* Tighter width for cleaner reading */
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 90px;
}

/* ── App Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(var(--bg), 0.85); /* Will use JS/CSS fallback if rgba fails, using fixed hex */
}
/* Fallback for background blur */
@supports (backdrop-filter: blur(20px)) {
  .app-header {
    background: transparent;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
}
@supports not (backdrop-filter: blur(20px)) {
  .app-header { background: var(--bg); }
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s var(--ease);
}
.brand-pill:hover {
  background: var(--bg-card-hover);
  border-color: rgba(229, 125, 144, 0.3);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c1);
  box-shadow: 0 0 8px rgba(229, 125, 144, 0.6);
}

.brand-name {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header-actions {
  display: flex;
  gap: 6px;
}

.header-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.header-btn svg { width: 17px; height: 17px; stroke: currentColor; }
.header-btn:hover { background: var(--bg-input); color: var(--c1); border-color: rgba(229, 125, 144, 0.3); }


/* ── Navigation Bottom Bar (Apple Floating Glass Dock) ── */
.app-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: background 0.3s ease;
}

[data-theme="dark"] .app-nav {
  background: rgba(28, 28, 30, 0.75);
  border-top: 0.5px solid rgba(255, 255, 255, 0.12);
}

[data-theme="sepia"] .app-nav {
  background: rgba(250, 246, 240, 0.82);
  border-top: 0.5px solid rgba(67, 52, 34, 0.1);
}

.nav-inner {
  display: flex;
  justify-content: space-around;
  padding: 6px 12px 10px;
  max-width: 600px;
  margin: 0 auto;
}

.nav-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  transition: color 0.15s ease, transform 0.1s var(--ease);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

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

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.6;
  transition: transform 0.3s var(--spring-bounce), stroke-width 0.2s;
}

.nav-item.active { 
  color: var(--c1); 
  font-weight: 700; 
}

.nav-item.active svg { 
  stroke-width: 2.2; 
  transform: scale(1.12); 
}

/* ── Main Views ── */
.app-view {
  display: none;
  animation: viewTransition 0.35s var(--ease);
  padding: 18px 20px 32px;
  flex-grow: 1;
}
.app-view.active { display: block; }
@keyframes viewTransition { 
  from { opacity: 0; transform: translateY(8px); } 
  to { opacity: 1; transform: translateY(0); } 
}

/* ── Global Elements ── */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm svg { width: 16px; height: 16px; }
.icon-lg svg { width: 24px; height: 24px; }

/* ── Buttons (Apple Style with Instant Press Feedback) ── */
.pill-btn {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 0.5px solid var(--border);
  color: var(--text-primary);
  padding: 7px 15px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s var(--ease), background 0.15s, border-color 0.15s;
  font-family: var(--font);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.pill-btn:hover { 
  background: var(--bg-card-hover);
  border-color: rgba(229, 125, 144, 0.35); 
}
.pill-btn:active {
  transform: scale(0.96);
}
.pill-btn svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; }


.primary-btn {
  background: var(--c1);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s var(--ease);
  font-family: var(--font);
  box-shadow: 0 4px 14px rgba(229,125,144, 0.3);
}
.primary-btn:hover { background: var(--c2); transform: translateY(-1px); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn svg { width: 18px; height: 18px; stroke: #fff; }

/* ── Verse of the Day (VOTD) Luxury Apple Card ── */
.votd-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid rgba(229, 125, 144, 0.2);
  border-radius: var(--r-xl);
  padding: 24px 26px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(229, 125, 144, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.votd-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c1) 0%, #f99aaa 50%, var(--c1) 100%);
}

.votd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}

.votd-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--c1);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sparkle-icon {
  font-size: 0.85rem;
  color: var(--c1);
}

.votd-actions {
  display: flex;
  gap: 6px;
}

.pill-btn.mini {
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 600;
}

.votd-text {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  line-height: 1.62;
  color: var(--text);
  margin-bottom: 16px;
  font-style: italic;
  letter-spacing: -0.01em;
}

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

.votd-ref {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--c1);
  letter-spacing: -0.01em;
}

/* ── Modals & Bottom Sheets (iOS Native Style) ── */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity 0.25s var(--ease);
}
.modal.active { pointer-events: auto; opacity: 1; }
.modal-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-sheet,
.modal-content {
  position: relative; width: 100%; max-width: 620px;
  background: var(--bg-card);
  border-radius: 26px 26px 0 0;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.15, 0.9, 0.25, 1);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);
  padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 20px);
}
.modal.active .modal-sheet,
.modal.active .modal-content { transform: translateY(0); }

/* iOS Pull Drag Indicator */
.modal-sheet::before,
.modal-content::before {
  content: '';
  position: sticky;
  top: 8px; left: 50%;
  display: block;
  margin: 8px auto 4px;
  width: 38px; height: 5px;
  background: var(--border-strong);
  border-radius: 4px;
  z-index: 20;
}

.modal-header {
  position: sticky; top: 0;
  background: var(--bg-card);
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px 14px;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.modal-close-btn {
  background: var(--bg-input); border: none; width: 32px; height: 32px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); font-size: 0.95rem; font-weight: 600;
  transition: all 0.2s;
}
.modal-close-btn:hover { background: var(--border-strong); color: var(--text); }

/* ── Verse Action Sheet ── */
.verse-action-content { padding: 18px 20px; }
.verse-preview-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  padding: 14px 16px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  border-left: 3px solid var(--c1);
}
.color-pills-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.color-pills-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.color-pill {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.color-pill:hover, .color-pill:active { transform: scale(1.15); }
.pill-gold   { background: #fed7aa; }
.pill-green  { background: #bbf7d0; }
.pill-sky    { background: #bae6fd; }
.pill-pink   { background: #fbcfe8; }
.pill-purple { background: #e9d5ff; }
.pill-none   { background: var(--bg-input); color: var(--text-2); font-size: 0.75rem; display: flex; align-items: center; justify-content: center; font-weight: 700; }

.verse-action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.verse-grid-action-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.18s;
}
.verse-grid-action-btn:hover { background: var(--bg-card); border-color: var(--c1); color: var(--c1); }
.verse-grid-action-btn .icon svg { width: 20px; height: 20px; stroke: currentColor; }

.verse-note-box {
  background: var(--bg);
  padding: 14px;
  border-radius: var(--r-md);
}
.verse-note-textarea {
  width: 100%;
  min-height: 80px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 0.92rem;
  color: var(--text);
  outline: none;
  resize: vertical;
  margin: 8px 0 10px;
}
.verse-note-textarea:focus { border-color: var(--c1); }

/* ── Bible Search Modal Sheet ── */
.bible-search-sheet { max-height: 90vh; }
.search-modal-header-input {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.search-modal-header-input input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  padding: 10px 14px;
  border-radius: var(--r-full);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  outline: none;
}
.search-testament-select {
  background: var(--bg-input);
  border: none;
  padding: 8px 12px;
  border-radius: var(--r-full);
  font-size: 0.85rem;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.bible-search-results-list {
  padding: 14px 20px;
  max-height: 60vh;
  overflow-y: auto;
}
.search-results-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.bible-search-result-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.18s;
}
.bible-search-result-item:hover { border-color: var(--c1); transform: translateX(2px); }
.search-result-ref { font-weight: 700; font-size: 0.85rem; color: var(--c1); margin-bottom: 4px; }
.search-result-text { font-family: var(--font-serif); font-size: 0.95rem; color: var(--text); line-height: 1.5; }
.search-result-text mark { background: rgba(229,125,144, 0.25); color: var(--text); padding: 1px 3px; border-radius: 3px; }

/* ── Floating TTS Bar ── */
.floating-tts-bar {
  position: fixed;
  bottom: 84px;
  left: 20px;
  right: 20px;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--r-full);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 120;
  transform: translateY(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.15, 0.9, 0.25, 1);
}
.floating-tts-bar.active {
  transform: translateY(0);
  opacity: 1;
}
.tts-snippet-text {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}
.tts-stop-btn {
  background: var(--c1);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* ── Toast ── */
.app-toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #1C1C1E; color: #FFFFFF;
  padding: 10px 20px; border-radius: var(--r-full);
  font-size: 0.86rem; font-weight: 600; font-family: var(--font);
  opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 9999;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  white-space: nowrap;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ── Empty States ── */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-3); }
.empty-state .icon { color: var(--text-3); margin-bottom: 12px; }
.empty-state .icon svg { width: 44px; height: 44px; stroke-width: 1.2; }
.empty-state h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.88rem; line-height: 1.5; max-width: 280px; margin: 0 auto; color: var(--text-2); }

/* ── Mobile Responsive Optimizations (<600px) ── */
@media (max-width: 600px) {
  .header-inner { padding: 12px 16px; }
  .brand-text h1 { font-size: 0.98rem; }
  .brand-subtitle { font-size: 0.74rem; }
  .app-view { padding: 14px 14px 28px; }
  .votd-card { padding: 16px; margin-bottom: 20px; border-radius: var(--r-md); }
  .votd-text { font-size: 1.02rem; line-height: 1.55; }
  .pill-btn { padding: 6px 12px; font-size: 0.78rem; }
  .modal-sheet, .modal-content { max-height: 92vh; border-radius: 20px 20px 0 0; }
  .verse-action-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .nav-item { font-size: 0.65rem; padding: 6px 4px; }
  .nav-item svg { width: 22px; height: 22px; }
}

/* ── Settings View (iOS Grouped Style) ── */
.settings-list {
  max-width: 580px;
  margin: 0 auto;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-label strong {
  font-size: 0.92rem;
  color: var(--text);
}

.settings-label span {
  font-size: 0.76rem;
  color: var(--text-2);
}

.settings-card select.bible-select {
  width: auto;
  min-width: 150px;
  max-width: 190px;
}


