:root {
  --font-ui: 'Plus Jakarta Sans', 'Noto Sans Devanagari', 'Noto Sans Kannada', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', 'Noto Sans Devanagari', 'Noto Sans Kannada', Georgia, serif;

  --card-primary: #5E239D;
  --card-dark: #441775;
  --card-soft: #F5EFFC;
  --card-border: #D4BDEE;
  --card-glow: rgba(94, 35, 157, 0.24);

  --ink-900: #1C1726;
  --ink-700: #4A4358;
  --ink-500: #756D85;
  --surface-0: #FFFCF7;
  --surface-card: #FFFFFF;

  --prism-gradient: linear-gradient(
    90deg,
    #B9382E 0%,
    #D46A0E 18%,
    #D6A118 34%,
    #1D7A41 52%,
    #1565A8 70%,
    #5E239D 85%,
    #A3266B 100%
  );

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #F4EFE7;
  color: var(--ink-900);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* Soft colorful ambient orbs for tablet/outer framing */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  transition: background 450ms ease;
}

.orb-1 {
  width: 320px;
  height: 320px;
  top: -80px;
  left: -70px;
  background: radial-gradient(circle, rgba(185, 56, 46, 0.45), transparent 70%);
}

.orb-2 {
  width: 360px;
  height: 360px;
  bottom: -100px;
  right: -80px;
  background: radial-gradient(circle, rgba(21, 101, 168, 0.42), transparent 70%);
}

.orb-3 {
  width: 280px;
  height: 280px;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--card-glow), transparent 72%);
}

/* Mobile & Tablet Only App Shell */
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #FFFDF9 0%, #FAF5EC 100%);
  overflow: hidden;
}

@media (min-width: 620px) {
  body {
    padding: 18px 20px;
    align-items: center;
  }

  .app-shell {
    max-width: 560px;
    height: min(92dvh, 880px);
    border-radius: 30px;
    border: 1px solid rgba(94, 35, 157, 0.12);
    box-shadow:
      0 24px 60px rgba(28, 23, 38, 0.14),
      0 6px 18px rgba(94, 35, 157, 0.08);
  }
}

.prism-bar {
  height: 6px;
  width: 100%;
  flex-shrink: 0;
  background: var(--prism-gradient);
}

.prism-bar-bottom {
  height: 5px;
}

/* Views */
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.view[hidden] {
  display: none;
}

/* ===========================
   HOME VIEW
=========================== */
.view-home {
  justify-content: space-between;
  gap: 20px;
  padding-top: max(26px, env(safe-area-inset-top));
}

.home-header {
  text-align: center;
  padding: 6px 4px 0;
}

.eyebrow {
  margin: 0 0 10px;
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #7D5508;
  background: linear-gradient(135deg, rgba(214, 161, 24, 0.16), rgba(185, 56, 46, 0.1));
  border: 1px solid rgba(214, 161, 24, 0.28);
}

.brand-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2.15rem, 7vw, 2.85rem);
  font-weight: 700;
  line-height: 1.12;
  background: linear-gradient(135deg, #5E239D 0%, #B9382E 52%, #C2590A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home-subtitle {
  margin: 0 auto;
  max-width: 34ch;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  line-height: 1.5;
  color: var(--ink-700);
}

.language-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto 0;
}

.section-label {
  margin: 0 4px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-500);
}

.language-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lang-card {
  width: 100%;
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1.5px solid transparent;
  background: var(--surface-card);
  text-align: left;
  cursor: pointer;
  color: var(--ink-900);
  box-shadow: 0 10px 26px rgba(28, 23, 38, 0.06);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 180ms ease;
}

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

.lang-card:focus-visible {
  outline: 3px solid var(--card-primary);
  outline-offset: 2px;
}

.lang-card-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: #FFFFFF;
  flex-shrink: 0;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
}

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

.lang-name {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.lang-native {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-700);
  line-height: 1.35;
}

.lang-arrow {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 180ms ease;
}

.lang-card:hover .lang-arrow {
  transform: translateX(3px);
}

/* Language-specific jewel colors */
.lang-english {
  background: linear-gradient(135deg, #FFFFFF 0%, #F5EFFC 100%);
  border-color: #D7C1F0;
}
.lang-english .lang-card-badge {
  background: linear-gradient(135deg, #5E239D, #1565A8);
}
.lang-english .lang-arrow {
  background: rgba(94, 35, 157, 0.1);
  color: #5E239D;
}

.lang-hindi {
  background: linear-gradient(135deg, #FFFFFF 0%, #FEF3EC 100%);
  border-color: #F4C7B8;
}
.lang-hindi .lang-card-badge {
  background: linear-gradient(135deg, #B9382E, #D46A0E);
}
.lang-hindi .lang-arrow {
  background: rgba(185, 56, 46, 0.1);
  color: #B9382E;
}

.lang-kannada {
  background: linear-gradient(135deg, #FFFFFF 0%, #ECF9F4 100%);
  border-color: #B5E3CF;
}
.lang-kannada .lang-card-badge {
  background: linear-gradient(135deg, #1D7A41, #0E7C7B);
}
.lang-kannada .lang-arrow {
  background: rgba(14, 124, 123, 0.1);
  color: #0E7C7B;
}

.home-footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 6px;
}

.home-hint {
  font-size: 0.84rem;
  color: var(--ink-500);
}

.home-praise {
  font-size: 0.86rem;
  font-weight: 700;
  color: #5E239D;
}

.home-credit {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(94, 35, 157, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.home-credit-text {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-700);
}

.home-credit-text strong {
  color: var(--ink-900);
  font-weight: 700;
}

.home-credit-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: rgba(94, 35, 157, 0.08);
  border: 1px solid rgba(94, 35, 157, 0.2);
  color: #5E239D;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  transition: background 180ms ease, transform 150ms ease;
}

.home-credit-link:active {
  transform: scale(0.97);
  background: rgba(94, 35, 157, 0.16);
}

/* ===========================
   DECK VIEW (SLIDING CARDS)
=========================== */
.view-deck {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  gap: 12px;
  overflow: hidden;
}

.deck-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.icon-pill-btn {
  height: 40px;
  padding: 0 14px 0 10px;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(28, 23, 38, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-900);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(28, 23, 38, 0.05);
}

.icon-pill-btn:active {
  transform: scale(0.96);
}

.lang-switcher {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: rgba(28, 23, 38, 0.06);
  gap: 2px;
}

.switch-pill {
  height: 34px;
  padding: 0 11px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-700);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.switch-pill.is-active {
  background: var(--card-primary);
  color: #FFFFFF;
  box-shadow: 0 3px 10px var(--card-glow);
}

/* Progress section */
.deck-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.deck-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.deck-lang-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--card-primary);
  transition: color 260ms ease;
}

.progress-pill-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--card-border);
  background: var(--card-soft);
  color: var(--card-dark);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 240ms ease, border-color 240ms ease, color 240ms ease;
}

.progress-pill-btn:active {
  transform: scale(0.96);
}

.progress-track {
  height: 7px;
  width: 100%;
  border-radius: var(--radius-pill);
  background: rgba(28, 23, 38, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 5%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--card-primary), var(--card-dark));
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1), background 280ms ease;
}

/* Card Stage */
.card-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  position: relative;
  touch-action: pan-y;
  user-select: none;
}

.card-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.worship-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card-soft);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow:
    0 16px 36px var(--card-glow),
    0 4px 12px rgba(28, 23, 38, 0.06);
  transform: translate3d(var(--drag-x, 0px), 0, 0);
  will-change: transform, opacity;
  transition:
    background-color 260ms ease,
    border-color 260ms ease,
    box-shadow 260ms ease;
}

.worship-card.is-dragging {
  transition: none;
}

/* Slide transitions */
.worship-card.slide-out-left {
  animation: slideOutLeft 200ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.worship-card.slide-in-right {
  animation: slideInRight 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.worship-card.slide-out-right {
  animation: slideOutRight 200ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.worship-card.slide-in-left {
  animation: slideInLeft 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideOutLeft {
  from { transform: translate3d(var(--drag-x, 0px), 0, 0); opacity: 1; }
  to   { transform: translate3d(-44%, 0, 0); opacity: 0; }
}

@keyframes slideInRight {
  from { transform: translate3d(44%, 0, 0); opacity: 0; }
  to   { transform: translate3d(0, 0, 0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translate3d(var(--drag-x, 0px), 0, 0); opacity: 1; }
  to   { transform: translate3d(44%, 0, 0); opacity: 0; }
}

@keyframes slideInLeft {
  from { transform: translate3d(-44%, 0, 0); opacity: 0; }
  to   { transform: translate3d(0, 0, 0); opacity: 1; }
}

/* Card Header Banner */
.card-banner {
  background: linear-gradient(135deg, var(--card-primary) 0%, var(--card-dark) 100%);
  color: #FFFFFF;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.card-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.card-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--card-primary);
  font-size: 1rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
}

.card-ref {
  font-size: clamp(1rem, 3.6vw, 1.15rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.card-action-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.card-action-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.28);
}

/* Card Body */
.card-content {
  flex: 1;
  min-height: 0;
  padding: clamp(20px, 4.5vw, 30px) clamp(18px, 5vw, 28px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(16px, 3.5vw, 22px);
  overflow-y: auto;
}

.card-verse {
  margin: 0;
  font-size: clamp(1.1rem, 3.8vw, 1.32rem);
  line-height: 1.55;
  font-style: italic;
  font-weight: 500;
  color: var(--ink-700);
}

.card-divider {
  width: 56px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--card-primary), transparent);
}

.card-worship-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-worship-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--card-primary);
}

.card-worship-text {
  margin: 0;
  font-size: clamp(1.22rem, 4.2vw, 1.48rem);
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink-900);
}

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--card-dark);
  flex-shrink: 0;
}

/* Bottom Navigation Controls */
.deck-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-top: 2px;
}

.nav-btn {
  height: 54px;
  border-radius: var(--radius-lg);
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 150ms ease, opacity 180ms ease, box-shadow 200ms ease, background 240ms ease;
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.nav-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.nav-prev {
  flex: 0.9;
  background: #FFFFFF;
  color: var(--ink-900);
  border: 1.5px solid rgba(28, 23, 38, 0.14);
  box-shadow: 0 6px 14px rgba(28, 23, 38, 0.05);
}

.nav-restart {
  width: 54px;
  flex: 0 0 54px;
  background: var(--card-soft);
  color: var(--card-dark);
  border: 1.5px solid var(--card-border);
}

.nav-restart[hidden] {
  display: none;
}

.nav-next {
  flex: 1.6;
  background: linear-gradient(135deg, var(--card-primary) 0%, var(--card-dark) 100%);
  color: #FFFFFF;
  box-shadow: 0 12px 24px var(--card-glow);
}

/* ===========================
   ALL 20 CARDS DIALOG
=========================== */
.index-dialog {
  width: min(100%, 540px);
  max-width: 100%;
  margin: auto auto 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-900);
}

@media (min-width: 620px) {
  .index-dialog {
    margin: auto;
  }
}

.index-dialog::backdrop {
  background: rgba(24, 18, 36, 0.48);
  backdrop-filter: blur(5px);
}

.dialog-sheet {
  background: #FFFDF9;
  border-radius: 26px 26px 0 0;
  padding: 18px 18px max(22px, env(safe-area-inset-bottom));
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.2);
}

@media (min-width: 620px) {
  .dialog-sheet {
    border-radius: 26px;
    padding: 22px;
  }
}

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

.dialog-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--ink-900);
}

.dialog-close-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(28, 23, 38, 0.12);
  background: #FFFFFF;
  color: var(--ink-900);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.index-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--item-border);
  background: var(--item-soft);
  color: var(--ink-900);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.index-item.is-current {
  box-shadow: 0 0 0 2px var(--item-primary);
}

.index-item-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--item-primary);
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.index-item-ref {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toast notification */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 74px));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: #1C1726;
  color: #FFFFFF;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  z-index: 30;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .worship-card.slide-out-left,
  .worship-card.slide-in-right,
  .worship-card.slide-out-right,
  .worship-card.slide-in-left {
    animation: none;
  }

  .progress-fill,
  .lang-card,
  .nav-btn {
    transition: none;
  }
}
