:root {
  --saffron: #FF9933;
  --deep: #E8650A;
  --accent: #C2410C;
  --bg: #FFF8EC;
  --card: #FFFFFF;
  --text: #3B1F0E;
  --muted: #8A6A55;
  --line: #F1DFC8;
  --track: #F6E3CB;
  --shadow: 0 2px 12px rgba(122, 46, 14, .10);
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #170E08;
    --card: #24170F;
    --text: #F7E7D6;
    --muted: #BFA48F;
    --line: #3A2619;
    --track: #3A2619;
    --accent: #FFA552;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Telugu", "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
body.has-player { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg { fill: currentColor; }

/* ---------- Header ---------- */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: calc(56px + env(safe-area-inset-top)) 12px 14px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 236, 179, .55) 0, rgba(255, 236, 179, 0) 45%),
    linear-gradient(165deg, #FFC46B 0%, #FF9933 45%, #E8650A 100%);
  color: #fff;
  overflow: hidden;
  min-height: 180px;
}
.hero-text { text-align: center; flex: 1 1 auto; min-width: 0; padding-bottom: 6px; }
.hero h1 {
  margin: 2px 0 0;
  font-size: clamp(1.6rem, 6vw, 2.3rem);
  letter-spacing: .5px;
  text-shadow: 0 2px 8px rgba(90, 30, 4, .35);
}
.tagline { margin: 0; font-size: .78rem; opacity: .95; letter-spacing: .3px; color: #5A1E04; font-weight: 600; }
.subtitle { margin: 0; font-size: 1rem; opacity: .95; }
.byline { margin: 6px auto 0; max-width: 34ch; text-wrap: balance; font-size: .9rem; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(90, 30, 4, .35); }
.hero-actions { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 8px; display: flex; gap: 6px; align-items: center; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border: 0; border-radius: 50%;
  background: transparent;
  position: relative;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.hero .icon-btn { color: #fff; background: rgba(90, 30, 4, .18); }
.btn-ghost {
  border: 1.5px solid rgba(255, 255, 255, .85); color: #fff;
  background: rgba(90, 30, 4, .18);
  padding: 7px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600;
}

/* ---------- Banners ---------- */
.banner {
  margin: 10px auto 0; max-width: 760px;
  padding: 10px 12px; border-radius: 10px;
  background: #FFE7C2; color: #6B2A07; font-size: .9rem;
}
@media (prefers-color-scheme: dark) { .banner { background: #3A2412; color: #FFD9AE; } }
.tip { display: flex; gap: 8px; align-items: flex-start; }
.tip span { flex: 1; }
.inline-ico { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- Main ---------- */
main { max-width: 760px; margin: 0 auto; padding: 12px 12px 24px; }

.continue {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  margin: 4px 0 14px; padding: 14px;
  border: 0; border-radius: var(--radius);
  background: linear-gradient(135deg, #FFB347, #E8650A);
  color: #fff; box-shadow: var(--shadow);
}
.c-play { flex: 0 0 52px; height: 52px; border-radius: 50%; background: rgba(255, 255, 255, .25); display: grid; place-items: center; }
.c-play svg { width: 30px; height: 30px; }
.c-text { display: flex; flex-direction: column; min-width: 0; }
.c-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; opacity: .9; }
.c-title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-meta { font-size: .85rem; opacity: .95; }

.toolbar { display: flex; gap: 8px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 0; }
.toolbar input, .toolbar select {
  font: inherit; color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 9px 12px; min-width: 0;
}
.toolbar input { flex: 1; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--saffron); outline-offset: 0; }
.count { margin: 2px 2px 8px; color: var(--muted); font-size: .85rem; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: stretch;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1.5px solid transparent;
}
.row.current { border-color: var(--saffron); }
.row-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  border: 0; background: none; text-align: left;
  padding: 12px 4px 12px 12px;
}
.num {
  flex: 0 0 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--track); color: var(--accent);
  font-weight: 700; font-size: .85rem;
}
.row.done .num { background: #2E7D32; color: #fff; }
.row.done .num svg { width: 20px; height: 20px; }
.row.current .num { background: var(--deep); color: #fff; }
.info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.meta { font-size: .8rem; color: var(--muted); }
.bar { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--saffron), var(--deep)); }
.row:not(.started) .bar { display: none; }

.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq b { width: 3px; background: #fff; border-radius: 1px; animation: eq 1s ease-in-out infinite; }
.eq b:nth-child(2) { animation-delay: -.3s; }
.eq b:nth-child(3) { animation-delay: -.6s; }
.paused .eq b { animation-play-state: paused; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

.empty { text-align: center; color: var(--muted); padding: 24px 0; }

/* ---------- Player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card);
  border-top: 3px solid var(--saffron);
  box-shadow: 0 -4px 20px rgba(90, 30, 4, .18);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.player > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.p-title { font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-seek { display: flex; align-items: center; gap: 8px; margin: 6px auto 4px; }
.time { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; }
.time:last-child { text-align: right; }
#p-range {
  --pct: 0%;
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; margin: 10px 0;
  background: linear-gradient(90deg, var(--deep) var(--pct), var(--track) var(--pct));
}
#p-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--deep); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
#p-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--deep); border: 3px solid #fff; }
.p-ctrls { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.play-btn {
  width: 62px; height: 62px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, #FFB347, #E8650A); color: #fff;
  display: grid; place-items: center; box-shadow: 0 3px 10px rgba(232, 101, 10, .45);
}
.play-btn svg { width: 34px; height: 34px; }
.skip svg { width: 34px; height: 34px; }
.icon-btn.skip { width: 48px; height: 48px; }
.skip span { position: absolute; font-size: .6rem; font-weight: 800; top: 55%; left: 50%; transform: translate(-50%, -50%); }
.player .icon-btn { color: var(--text); }
.chip {
  min-width: 52px; height: 34px; padding: 0 8px;
  border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--bg); font-size: .85rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
}
.chip svg { width: 16px; height: 16px; }
.chip.on { background: var(--deep); border-color: var(--deep); color: #fff; }

/* ---------- Dialogs ---------- */
dialog { border: 0; color: var(--text); background: var(--card); padding: 0; }
dialog::backdrop { background: rgba(30, 10, 0, .5); }
.sheet { width: min(560px, 100vw); max-height: 88vh; border-radius: 18px; padding: 0 16px 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); padding: 12px 0 4px; }
.sheet h2 { margin: 0; font-size: 1.2rem; }
.sheet section { border-top: 1px solid var(--line); padding: 10px 0; }
.sheet h3 { margin: 6px 0; font-size: 1rem; color: var(--accent); }
.hint { margin: 4px 0 8px; color: var(--muted); font-size: .88rem; }
textarea {
  width: 100%; font: .85rem ui-monospace, Consolas, monospace; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; resize: vertical;
}
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row-btns.end { justify-content: flex-end; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700;
  background: var(--deep); color: #fff;
}
.btn-ghost-dark { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.btn-danger { background: #B3261E; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 20px; height: 20px; accent-color: var(--deep); }
.confirm { width: min(380px, 92vw); border-radius: 16px; padding: 18px; }
.confirm p { margin: 0 0 8px; }

.toast {
  position: fixed; left: 50%; transform: translate(-50%, 20px);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: #3B1F0E; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
  max-width: 90vw; text-align: center;
}
body.has-player .toast { bottom: calc(200px + env(safe-area-inset-bottom)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .chip { min-width: 44px; padding: 0 6px; }
  .icon-btn { width: 38px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) { .eq b { animation: none; height: 10px; } }
