/* ===== Shri N.V. Vaidyanathan — Thiruppugazh teachings: mobile-first styles ===== */

:root {
  --bg: #eef6f5;
  --card: #ffffff;
  --ink: #10272c;
  --muted: #5a7377;
  --accent: #0e6b73;
  --accent-dark: #084a52;
  --gold: #c9a227;
  --border: #cfe3e1;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 14px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Tamil", "Latha", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.header {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  box-shadow: var(--shadow);
}
.header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.header .sub { margin: 2px 0 0; font-size: 13px; opacity: .9; }

/* ---- Sticky search + ranges ---- */
.stickytop {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.searchbar { padding: 12px 16px 8px; }
.searchbar input {
  width: 100%;
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 18px;
  font-size: 16px; /* 16px+ prevents iOS zoom-on-focus */
  background: #fff;
  color: var(--ink);
  outline: none;
}
.searchbar input:focus { border-color: var(--gold); }
.search-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 8px;
  margin-top: 6px;
}
.count { font-size: 12px; color: var(--muted); }
.filter-chip {
  border: 1px solid var(--gold);
  background: #f8fdfc;
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.filter-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.rangebar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.range-chip {
  flex: 0 0 auto;
  border: 1px solid var(--gold);
  background: #f8fdfc;
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---- Song list ---- */
.list {
  list-style: none;
  margin: 0;
  padding: 8px 12px calc(32px + env(safe-area-inset-bottom));
  flex: 1;
}
.song-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.song {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.song:active { transform: scale(.99); }
.song .num {
  flex: 0 0 auto;
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.song .title { flex: 1; font-size: 18px; font-weight: 600; word-break: break-word; }
.song .badge { flex: 0 0 auto; font-size: 16px; }
.song .chev { color: var(--gold); font-size: 20px; flex: 0 0 auto; }

.empty, .loading { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 15px; }

/* ---- Song detail ---- */
.detail { padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); flex: 1; }
.back {
  display: inline-flex;
  align-items: center;
  height: var(--tap);
  color: var(--accent);
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
}
.songcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.bignum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  padding: 0 10px;
}
.bigtitle { font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.oldno { font-size: 13px; color: var(--muted); }

.section-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-dark);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gold);
}
.recordings { margin-bottom: 18px; }
.rec-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.rec-label { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.audio-el { width: 100%; display: block; }
.videowrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
.videowrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.norec {
  background: var(--card);
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* ---- Footer / back-to-top ---- */
.footer { padding: 16px; text-align: center; font-size: 12px; color: var(--muted); }
.to-top {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: pointer;
  z-index: 20;
}

/* ---- Lyrics (page image) ---- */
.lyrics {
  background: linear-gradient(180deg, #e9f6f4, #f8fdfc);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.lyrics[hidden] { display: none; }
.lyrics-title {
  margin: 0 0 12px;
  padding-bottom: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-dark);
  text-align: center;
  border-bottom: 2px solid var(--gold);
}
.lyrics-imagewrap {
  border-radius: 10px;
  background: #f8fdfc;
  padding: 10px;
  box-shadow: inset 0 0 0 1px var(--gold);
}
.lyrics-image { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff; }

/* ---- Favourites and recently viewed ---- */
.fav-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--gold);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 12px;
}
.fav-btn.on { color: var(--accent); }
.fav-btn:active { transform: scale(.92); }

.shelf { padding: 10px 14px 2px; }
.shelf-title { margin: 0 2px 8px; font-size: 13px; font-weight: 700; color: var(--accent-dark); }
.chips { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.chip-num {
  flex: 0 0 auto;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.chip-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-actions { display: flex; justify-content: center; margin-top: 14px; }
.fav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: #f8fdfc;
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.fav-toggle .fav-ico { font-size: 20px; color: var(--gold); }
.fav-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fav-toggle.on .fav-ico { color: #fff; }
