:root {
  --gold-1: #E8B31A;
  --gold-2: #D99E00;
  --gold-3: #B38200;
  --cream: #FFF9E6;
  --cream-2: #FFF3CC;
  --card-bg: #F7F7F5;
  --ink: #1C1C1E;
  --ink-soft: #636366;
  --line: #E8E4D8;
  --white: #FFFFFF;
  --radius: 14px;
  --nav-h: 64px;
  --header-h: 108px;
  --page-x: 18px;
  --stack-gap: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Match Glide Appearance → Font Family: System Font */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans Telugu", "Noto Sans", sans-serif;
  background: var(--white);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--white);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
  overflow: visible;
}

/* ---------- Header ---------- */
.topbar {
  --topbar-h: 56px;
  background: var(--gold-2);
  color: var(--white);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: visible;
}
/* Home: taller gold bar; logo sits on the bottom edge (Glide style) */
.topbar.is-home {
  --topbar-h: 96px;
  margin-bottom: 44px;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--white);
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 22;
}
.topbar.is-home .icon-btn {
  /* keep menu in the upper gold area, not over the logo */
  top: 28px;
  transform: none;
}
.icon-btn svg { width: 24px; height: 24px; }
#menuBtn { left: 8px; }
#backBtn { left: 8px; }
.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.topbar-center > * { pointer-events: auto; }
.topbar-logo {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, -50%);
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
  z-index: 21;
}
.topbar-title {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 0 48px;
  line-height: var(--topbar-h);
}
.topbar-title[hidden],
.topbar-logo[hidden] { display: none !important; }

.home-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  margin: 16px var(--page-x) 12px;
  color: var(--ink);
}

.home-video {
  margin: var(--stack-gap) var(--page-x) calc(var(--stack-gap) + 8px);
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  aspect-ratio: 16 / 9;
}
.home-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}

.boot-error {
  margin: 12px var(--page-x);
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #fde8e8;
  color: #8a1f1f;
  font-size: 0.9rem;
}

.row-sub {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 400;
  margin-top: 2px;
}


.request-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.request-form input,
.request-form textarea {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
}
.request-form button {
  background: var(--gold-2);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
}
.form-status {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* ---------- Content ---------- */
.screen {
  flex: 1;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  display: none;
}
.screen.active { display: block; }

.container {
  padding: 22px var(--page-x) 12px;
}

.info-card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 var(--page-x) var(--stack-gap);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ink);
}
.info-card--prayer {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
}
.info-card-om {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}

.section-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 10px; line-height: 1.35; }
.section-sub { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.55; margin: 0 0 18px; }

.hairline { border: none; border-top: 1px solid var(--line); margin: 10px 0 16px; }

/* ---------- Grid of cards (list pages) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 4px var(--page-x) 12px !important;
  margin: 0;
}
.tile-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  border: none;
  text-align: center;
  font-family: inherit;
  min-height: 156px;
}
.tile-card img {
  width: 88px; height: 88px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--white);
  flex-shrink: 0;
}
.tile-card .tile-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
  width: 100%;
}

/* ---------- Detail page ---------- */
.video-wrap {
  margin: 12px var(--page-x) var(--stack-gap);
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  aspect-ratio: 16/9;
}
.video-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.video-placeholder {
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}

.step-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 var(--page-x) var(--stack-gap);
  padding: 20px;
  background: var(--white);
}
.step-block h3 { margin: 0 0 10px; font-size: 1.02rem; }
.step-block .shloka { color: var(--ink); font-size: 0.94rem; line-height: 1.65; margin: 0 0 12px; white-space: pre-line; }
.step-block .meaning { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.65; margin: 0; font-style: italic; }

/* ---------- Namavali detail ---------- */
.namavali-box {
  border: 1px solid #9AC7D6;
  border-radius: 10px;
  margin: 0 var(--page-x) calc(var(--stack-gap) + 8px);
  padding: 18px;
  font-size: 0.95rem;
  line-height: 1.9;
  white-space: pre-line;
  color: var(--ink);
  background: #f7fbfd;
}

#textTitle { padding: 18px var(--page-x) 0 !important; margin: 0 0 10px; }
#textSub { padding: 0 var(--page-x) !important; margin: 0 0 14px; }
#textAudioWrap { padding: 0 var(--page-x) 14px !important; }
#textExtra { padding-bottom: 12px; }
#textExtra .step-block { margin-top: 0; }
#visheshaluDetailList { padding: 0 0 8px; }
#visheshaluDetailList .step-block,
#visheshaluDetailList .namavali-box { margin-bottom: var(--stack-gap); }

/* ---------- Deity visheshalu list ---------- */
.row-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px var(--page-x) 12px !important;
  margin: 0;
}
.row-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: none;
  border-left: none; border-right: none; border-top: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  min-height: 68px;
}
.row-item:last-child { border-bottom: none; }
.row-item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.row-item .row-text { flex: 1; font-size: 0.98rem; font-weight: 600; line-height: 1.4; }
.row-item .chevron { color: var(--ink-soft); flex-shrink: 0; }

.markdown-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.85rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
.markdown-body th { background: var(--cream-2); }

.link-row {
  display: flex; align-items: center; gap: 10px;
  margin: 0 var(--page-x);
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--gold-3); text-decoration: none; font-size: 0.92rem;
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px var(--page-x); color: var(--ink-soft); }
.empty-state .emoji { font-size: 2.4rem; margin-bottom: 10px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}
.nav-btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--gold-2); }

/* ---------- Sidebar drawer ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 30; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 78%; max-width: 320px;
  background: var(--white);
  z-index: 31;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid var(--line);
}
.drawer-header img { width: 30px; height: 30px; border-radius: 50%; }
.drawer-header .title { flex: 1; font-weight: 700; font-size: 1.05rem; }
.drawer-header button { border: none; background: none; font-size: 1.3rem; cursor: pointer; color: var(--ink-soft); }
.drawer-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  cursor: pointer;
  font-size: 0.98rem;
  color: var(--ink);
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit;
}
.drawer-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-2); flex-shrink: 0; }
.drawer-item.disabled { color: #B7AFA3; }
.drawer-footer {
  padding: 14px 18px; border-top: 1px solid var(--line);
  font-size: 0.75rem; color: var(--ink-soft); text-align: center;
}

/* Install banner */
.install-banner {
  margin: 8px 0 var(--stack-gap);
  padding: 18px;
  border-radius: var(--radius);
  background: var(--cream-2);
  display: flex;
  align-items: center;
  gap: 14px;
}
.install-status {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.45;
}
.soon-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.install-banner button {
  background: var(--gold-2); color: var(--white); border: none;
  padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 0.85rem;
  cursor: pointer; flex-shrink: 0;
}

@media (min-width: 481px) {
  body { background: #EDEDED; }
  #app {
    margin: 16px auto;
    border-radius: 20px;
    min-height: 90dvh;
    overflow: visible;
  }
}
