:root {
  --purple: #6d3dbd;
  --purple-dark: #4a268c;
  --purple-soft: #eee6ff;
  --orange: #ff8a36;
  --yellow: #ffd667;
  --mint: #dff7e9;
  --ink: #302842;
  --muted: #716982;
  --surface: #fffdf9;
  --line: #e9e2f3;
  --shadow: 0 12px 32px rgba(67, 39, 109, 0.12);
  --font-scale: 1;
}

* { box-sizing: border-box; }

html {
  background: #f7f3fc;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(255, 214, 103, 0.25), transparent 25rem),
    #f8f5fc;
  font-family: "Noto Sans Gujarati", "Shruti", "Nirmala UI", system-ui, sans-serif;
  font-size: calc(16px * var(--font-scale));
  line-height: 1.55;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

body.large-text { --font-scale: 1.13; }

button, input { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 12px;
  color: white;
  background: var(--purple-dark);
}

.skip-link:focus { top: 12px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 10px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(109, 61, 189, 0.1);
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: linear-gradient(145deg, var(--purple), #9b64df);
  box-shadow: 0 8px 18px rgba(109, 61, 189, 0.25);
  font-size: 1.35rem;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.08rem; line-height: 1.15; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 0.72rem; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-button, .install-button {
  min-width: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
}

.icon-button {
  border: 1px solid var(--line);
  background: white;
  font-weight: 800;
}

.install-button {
  padding: 8px 13px;
  color: white;
  background: var(--purple);
  font-size: 0.78rem;
  font-weight: 800;
}

main { width: min(100%, 840px); margin: 0 auto; }
.view { animation: fade-in 220ms ease-out; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
}

.hero {
  position: relative;
  overflow: hidden;
  margin: 0 12px;
  padding: 30px 22px 25px;
  border-radius: 0 0 30px 30px;
  color: white;
  background: linear-gradient(140deg, var(--purple-dark), var(--purple) 60%, #8f5bd4);
  box-shadow: var(--shadow);
}

.hero h1, .section-heading h1 { margin: 3px 0 6px; font-size: clamp(2rem, 8vw, 3.1rem); line-height: 1.15; }
.hero-copy { max-width: 32rem; margin: 0; color: #eee5ff; }
.eyebrow { margin: 0; font-size: 0.78rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }

.hero-decoration { position: absolute; border-radius: 50%; pointer-events: none; }
.decoration-one { right: -42px; top: -60px; width: 170px; height: 170px; border: 25px solid rgba(255,255,255,0.08); }
.decoration-two { right: 95px; bottom: -55px; width: 100px; height: 100px; background: rgba(255, 214, 103, 0.12); }

.festival-banner {
  position: relative;
  width: fit-content;
  margin-top: 15px;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
  font-size: 0.8rem;
  font-weight: 800;
}

.kind-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 16px 10px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,0.88);
  box-shadow: 0 8px 22px rgba(58, 37, 90, 0.06);
}

.kind-button {
  display: grid;
  justify-items: center;
  gap: 1px;
  min-width: 0;
  min-height: 76px;
  padding: 8px 4px;
  border: 0;
  border-radius: 17px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.kind-button > span { font-size: 1.2rem; }
.kind-button strong { font-size: 0.9rem; }
.kind-button small { overflow: hidden; max-width: 100%; font-size: 0.58rem; white-space: nowrap; text-overflow: ellipsis; }
.kind-button.active { color: white; background: linear-gradient(145deg, var(--purple), #8953cf); box-shadow: 0 7px 16px rgba(109, 61, 189, 0.23); }

.day-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 18px 16px 12px;
}

.day-button, .today-button {
  min-height: 42px;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
}

.day-button { border: 1px solid var(--line); background: white; font-size: 0.8rem; }
.today-button { padding: 0 18px; border: 0; color: var(--purple-dark); background: var(--purple-soft); }
.day-button:disabled { opacity: 0.35; cursor: not-allowed; }

.dhun-list { display: grid; gap: 16px; padding: 8px 16px 20px; }

.dhun-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(58, 37, 90, 0.08);
}

.card-top { display: flex; align-items: flex-start; gap: 13px; padding: 19px 18px 12px; }
.dhun-emoji { display: grid; flex: 0 0 auto; width: 52px; height: 52px; place-items: center; border-radius: 17px; background: var(--purple-soft); font-size: 1.6rem; }
.card-title-wrap { flex: 1; min-width: 0; }
.category-label { color: var(--purple); font-size: 0.72rem; font-weight: 900; }
.dhun-title { margin: 2px 0 0; font-size: 1.32rem; line-height: 1.25; }

.favourite-button {
  display: grid;
  flex: 0 0 auto;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #9a91a7;
  background: white;
  cursor: pointer;
  font-size: 1.25rem;
}

.favourite-button.saved { color: #da4772; background: #fff0f4; border-color: #ffc9d8; }

.lyrics {
  margin: 0 18px;
  padding: 17px;
  border-radius: 18px;
  background: linear-gradient(145deg, #f7f2ff, #fff9eb);
  text-align: center;
  font-size: 1.08rem;
  font-weight: 750;
  line-height: 1.9;
}

.lyrics p { margin: 0; }
.lyrics p.singing {
  margin: 2px -7px;
  padding: 3px 7px;
  border-radius: 8px;
  color: white;
  background: var(--purple);
  box-shadow: 0 4px 12px rgba(109, 61, 189, 0.22);
}

.verse-label {
  display: inline-block;
  margin-bottom: 7px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--purple-dark);
  background: white;
  font-size: 0.68rem;
  font-weight: 900;
}

.verse-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 11px 0;
  color: var(--orange);
  font-size: 0.7rem;
}

.verse-divider::before, .verse-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(109, 61, 189, 0.16);
}

.instruction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 12px 18px; }
.instruction {
  padding: 11px 12px;
  border-radius: 14px;
  background: #f6f4f8;
  font-size: 0.76rem;
}
.instruction strong { display: block; margin-bottom: 2px; color: var(--purple-dark); }

.melody-line { margin: 0 18px 13px; padding: 10px 13px; border-radius: 13px; color: #4e4460; background: var(--mint); font-size: 0.76rem; }
.melody-line strong { color: #237245; }

.music-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 18px 10px;
}

.music-guide > div {
  padding: 10px 11px;
  border-radius: 13px;
  background: #f6f3fa;
  font-size: 0.7rem;
}

.music-guide strong, .music-guide span { display: block; }
.music-guide strong { color: var(--purple-dark); }
.music-guide span { margin-top: 2px; color: var(--muted); }

.sargam-guide {
  margin: 0 18px 12px;
  padding: 12px 13px;
  border-radius: 14px;
  color: #3e3152;
  background: #fff2ca;
  font-size: 0.72rem;
}

.sargam-guide > strong { color: #7e5300; }
.sargam-guide p { display: grid; grid-template-columns: 76px 1fr; gap: 6px; margin: 7px 0 0; }
.sargam-guide p span { color: #8c600d; font-weight: 900; }
.sargam-guide small { display: block; margin-top: 8px; color: #725f38; line-height: 1.45; }

.singing-plan {
  margin: 0 18px 14px;
  padding: 13px;
  border: 1px solid #eadff8;
  border-radius: 16px;
  background: #fff;
  font-size: 0.75rem;
}

.singing-plan > strong { color: var(--purple-dark); }
.singing-plan ol { display: grid; gap: 7px; margin: 9px 0 0; padding-left: 22px; }
.singing-plan li { padding-left: 2px; }
.singing-plan li::marker { color: var(--orange); font-weight: 900; }
.singing-plan li span { display: block; }
.singing-plan li small { color: var(--muted); font-weight: 800; }

.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 18px 18px; }
.play-button, .share-button, .primary-button {
  min-height: 47px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 900;
}
.play-button, .primary-button { border: 0; color: white; background: var(--purple); }
.play-button.playing { background: #d4543f; }
.share-button { border: 1px solid var(--line); background: white; }
.audio-hint { margin: -9px 20px 17px; color: var(--muted); text-align: center; font-size: 0.65rem; }

.teacher-tip {
  display: flex;
  gap: 13px;
  margin: 2px 16px 24px;
  padding: 17px;
  border-radius: 20px;
  background: #fff2ca;
}
.tip-icon { display: grid; flex: 0 0 auto; width: 40px; height: 40px; place-items: center; border-radius: 13px; color: #8f5900; background: var(--yellow); }
.teacher-tip h2 { margin: 0; font-size: 1rem; }
.teacher-tip p { margin: 4px 0 0; color: #705821; font-size: 0.83rem; }

.section-heading { padding: 34px 20px 14px; }
.section-heading .eyebrow { color: var(--purple); }
.section-heading h1 { font-size: clamp(1.9rem, 7vw, 2.8rem); }
.section-heading > p:last-child { margin: 0; color: var(--muted); }

.empty-state { margin: 12px 16px; padding: 42px 22px; border: 2px dashed #dacfee; border-radius: 24px; text-align: center; background: white; }
.empty-state span { display: block; font-size: 2rem; }
.empty-state h2 { margin: 8px 0 4px; }
.empty-state p { margin: 0; color: var(--muted); }

.search-box { display: flex; align-items: center; gap: 10px; margin: 0 16px 13px; padding: 0 15px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.search-box > span:first-child { color: var(--purple); font-size: 1.4rem; }
.search-box input { width: 100%; min-height: 52px; border: 0; outline: 0; color: var(--ink); background: transparent; }

.category-chips, .library-kind-chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 8px; scrollbar-width: none; }
.category-chips::-webkit-scrollbar, .library-kind-chips::-webkit-scrollbar { display: none; }
.library-kind-chips { padding-bottom: 10px; }
.library-kind-chips .chip { border-color: #d8caee; }
.library-kind-chips .chip.active { border-color: var(--purple); }
.chip { flex: 0 0 auto; min-height: 38px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: white; cursor: pointer; font-size: 0.78rem; font-weight: 800; }
.chip.active { color: white; border-color: var(--purple); background: var(--purple); }

.compact .dhun-card .lyrics, .compact .dhun-card .instruction-grid, .compact .dhun-card .melody-line, .compact .dhun-card .singing-plan, .compact .dhun-card .music-guide, .compact .dhun-card .sargam-guide, .compact .dhun-card .audio-hint { display: none; }
.compact .dhun-card.open .lyrics, .compact .dhun-card.open .instruction-grid, .compact .dhun-card.open .melody-line, .compact .dhun-card.open .singing-plan, .compact .dhun-card.open .music-guide, .compact .dhun-card.open .sargam-guide, .compact .dhun-card.open .audio-hint { display: block; }
.compact .dhun-card.open .instruction-grid, .compact .dhun-card.open .music-guide { display: grid; }
.compact .dhun-card.open .instruction-grid { display: grid; }
.compact .dhun-card:not(.open) .card-actions { grid-template-columns: 1fr; }
.compact .dhun-card:not(.open) .play-button { display: none; }

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255,253,249,0.96);
  backdrop-filter: blur(18px);
  box-shadow: 0 -8px 24px rgba(62, 40, 91, 0.08);
}

.nav-item { display: grid; justify-items: center; gap: 1px; min-height: 56px; padding: 5px; border: 0; border-radius: 16px; color: var(--muted); background: transparent; cursor: pointer; font-size: 0.72rem; font-weight: 800; }
.nav-item > span:first-child { font-size: 1.25rem; }
.nav-item.active { color: var(--purple-dark); background: var(--purple-soft); }

.install-dialog { width: min(calc(100% - 32px), 420px); padding: 28px 24px 24px; border: 0; border-radius: 26px; color: var(--ink); text-align: center; box-shadow: 0 24px 70px rgba(36, 22, 59, 0.3); }
.install-dialog::backdrop { background: rgba(31, 22, 45, 0.55); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 10px; right: 12px; width: 42px; height: 42px; border: 0; background: transparent; cursor: pointer; font-size: 1.6rem; }
.dialog-icon { display: grid; width: 68px; height: 68px; margin: 0 auto 14px; place-items: center; border-radius: 22px; color: white; background: var(--purple); font-size: 2rem; }
.install-dialog h2 { margin: 0; }
.install-dialog p { color: var(--muted); }
.primary-button { width: 100%; }

.toast { position: fixed; right: 16px; bottom: 92px; left: 16px; z-index: 80; width: fit-content; max-width: calc(100% - 32px); margin: auto; padding: 11px 16px; border-radius: 14px; color: white; background: #332b3f; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: 180ms ease; font-size: 0.82rem; }
.toast.show { opacity: 1; transform: translateY(0); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }

@media (min-width: 680px) {
  body { display: flex; flex-direction: column; padding-bottom: 24px; }
  .app-header { order: 0; }
  .bottom-nav { order: 1; }
  main { order: 2; }
  .app-header { padding-right: calc((100vw - 820px) / 2); padding-left: calc((100vw - 820px) / 2); }
  .hero { margin-top: 18px; border-radius: 30px; padding: 38px 36px; }
  .kind-switch { width: 560px; margin-right: auto; margin-left: auto; }
  .dhun-list:not(.compact) { grid-template-columns: 1fr 1fr; align-items: start; }
  #favourites-list { grid-template-columns: 1fr 1fr; }
  .bottom-nav { position: sticky; top: 80px; right: auto; bottom: auto; left: auto; width: 430px; margin: 10px auto 0; transform: none; border: 1px solid var(--line); border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
