:root {
  --bg: #e9dfcd;
  --surface: #ffffff;
  --surface-2: #f1ebe0;
  --ink: #1d2433;
  --ink-2: #5b6474;
  --line: #d3c6ae;
  --navy: #122a52;
  --saffron: #e8921a;
  --saffron-soft: #fbe8cc;
  --accent-ink: #ffffff;
  --done: #2f8a57;
  --shadow: 0 1px 3px rgba(60, 40, 10, .14), 0 6px 16px rgba(60, 40, 10, .10);
  --radius: 16px;
  --font: "Inter", "Noto Sans Gurmukhi", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-pa: "Noto Sans Gurmukhi", "Inter", system-ui, sans-serif;
  --bar-h: 84px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080c14; --surface: #1a2438; --surface-2: #222e47; --ink: #edf0f6; --ink-2: #9aa5b8;
    --line: #33415f; --navy: #0a1a36; --saffron: #f4a028; --saffron-soft: #3a2c16; --accent-ink: #1a1206;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #080c14; --surface: #1a2438; --surface-2: #222e47; --ink: #edf0f6; --ink-2: #9aa5b8;
  --line: #33415f; --navy: #0a1a36; --saffron: #f4a028; --saffron-soft: #3a2c16; --accent-ink: #1a1206;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.pa { font-family: var(--font-pa); }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; flex: none; }
.brand-pa { font-family: "Baloo Paaji 2", var(--font-pa); font-weight: 800; font-size: 23px; line-height: 1.15; color: #f4a028; letter-spacing: .01em; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.brand-en { font-size: 12.5px; opacity: .75; letter-spacing: .02em; }
.brand-sub { font-size: 11.5px; opacity: .85; line-height: 1.25; margin-top: 1px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
}
.icon-btn:active { background: rgba(127,127,127,.18); }
.icon-btn svg, .play-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill, .play-btn svg .fill { fill: currentColor; stroke: none; }
.icon-btn svg text { font: 700 6.5px var(--font); fill: currentColor; stroke: none; }
.icon-btn-spacer { width: 44px; flex: none; }

main { max-width: 760px; margin: 0 auto; padding: 16px; outline: none; }

/* Home */
.continue {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--saffron); color: var(--accent-ink); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.continue .c-ico { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; flex: none; }
.continue .c-ico svg { width: 20px; height: 20px; fill: currentColor; }
.continue .c-k { font-size: 12.5px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .05em; }
.continue .c-t { font-family: var(--font-pa); font-weight: 700; font-size: 17px; }
.continue .c-s { font-size: 13.5px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue > div { min-width: 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.seg button { padding: 8px 14px; border-radius: 999px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search {
  flex: 1 1 180px; min-width: 0; height: 46px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 0 18px; font: inherit; font-size: 15px;
}
.search:focus { outline: 2px solid var(--saffron); outline-offset: 1px; }

.group { margin: 22px 0 10px; }
.group h2 { font-family: var(--font-pa); font-size: 17px; margin: 0; font-weight: 700; }
.group .g-en { font-size: 13px; color: var(--ink-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.card {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); min-height: 112px; display: flex; flex-direction: column; gap: 2px;
  position: relative;
}
.card:active { transform: scale(.985); }
.card .t-pa { font-family: var(--font-pa); font-weight: 700; font-size: 20px; line-height: 1.25; }
.card .t-en { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.card .t-meta { margin-top: auto; padding-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.card .t-meta b { color: var(--ink); font-weight: 600; }
.badge {
  position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: var(--saffron-soft); color: var(--ink); padding: 2px 7px; border-radius: 6px;
}
.card .prog { height: 3px; background: var(--surface-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.card .prog i { display: block; height: 100%; background: var(--done); }
.empty { color: var(--ink-2); text-align: center; padding: 40px 0; }
.foot { color: var(--ink-2); font-size: 12.5px; text-align: center; margin: 30px 0 10px; }
.foot a { color: inherit; }

/* Topic */
.t-head h1 { font-family: var(--font-pa); font-size: 28px; margin: 4px 0 0; line-height: 1.2; }
.t-head .t-en { color: var(--ink-2); font-size: 15px; margin-bottom: 14px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.mode {
  text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; min-height: 76px;
}
.mode[aria-pressed="true"] { border-color: var(--saffron); background: var(--saffron-soft); }
.mode:disabled { opacity: .45; cursor: not-allowed; }
.mode .m-pa { font-family: var(--font-pa); font-weight: 700; font-size: 17px; }
.mode .m-en { font-size: 13px; color: var(--ink-2); }
.mode .m-meta { font-size: 13px; margin-top: 4px; font-weight: 600; }
.hint { font-size: 13px; color: var(--ink-2); margin: 6px 2px 14px; }
.play-all {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px;
  background: var(--navy); color: #fff; border-radius: 999px; font-weight: 700; font-size: 17px;
  box-shadow: var(--shadow); margin-bottom: 8px;
}
:root[data-theme="dark"] .play-all { background: var(--saffron); color: var(--accent-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .play-all { background: var(--saffron); color: var(--accent-ink); } }
.play-all svg { width: 22px; height: 22px; fill: currentColor; }
.play-all .pa { font-family: var(--font-pa); }
.secondary { display: block; margin: 0 auto 14px; font-size: 14px; color: var(--ink-2); text-decoration: underline; padding: 8px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.item { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px 14px; min-height: 60px; }
.item .n { width: 30px; flex: none; text-align: center; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.item .it { flex: 1; min-width: 0; font-family: var(--font-pa); font-size: 15.5px; line-height: 1.4; }
.item .d { flex: none; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.item.played .n { color: var(--done); font-weight: 700; }
.item.current { background: var(--saffron-soft); }
.item.current .n { color: var(--saffron); }

/* Player — mini bar */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(0,0,0,.12);
  display: grid; grid-template-columns: 112px 1fr auto; grid-template-areas: "bar bar bar" "video info ctrls";
  align-items: center; column-gap: 12px; padding: 0 8px calc(8px + env(safe-area-inset-bottom)) 8px;
  transition: transform .25s ease;
}
.player.off { transform: translateY(calc(100% + 30px)); pointer-events: none; }
.p-head, .p-seek, .p-extra, .p-note, .big-only { display: none !important; }
.p-progress-mini { grid-area: bar; height: 3px; margin: 0 -8px 8px; background: var(--surface-2); }
.p-progress-mini i { display: block; height: 100%; width: 0; background: var(--saffron); }
.p-video { grid-area: video; width: 112px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: #000; }
.p-video { position: relative; }
.p-video iframe, .p-video > div { width: 100%; height: 100%; display: block; border: 0; }
.p-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.player.audio-mode .p-thumb { display: block; }
.player.expanded.audio-mode .p-thumb { object-fit: contain; background: #000; }
.player.expanded .p-note.au-note, .player.expanded.audio-mode .p-note.yt-note { display: none !important; }
.player.expanded.audio-mode .p-note.au-note { display: block !important; }
.player.audio-mode #pWalk { display: none; }
.badge.pa { font-family: var(--font-pa); letter-spacing: 0; }
.p-info { grid-area: info; min-width: 0; cursor: pointer; }
.p-title { font-family: var(--font-pa); font-weight: 600; font-size: 14.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-sub { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-ctrls { grid-area: ctrls; display: flex; align-items: center; gap: 2px; }
.play-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--saffron); color: var(--accent-ink); }
.play-btn .i-pause { display: none; }
.player.playing .play-btn .i-pause { display: block; }
.player.playing .play-btn .i-play { display: none; }

/* Player — expanded "now playing" sheet */
.player.expanded {
  top: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  border-top: 0; background: var(--bg);
}
.player.expanded .p-head { display: flex !important; align-items: center; margin: calc(6px + env(safe-area-inset-top)) -8px 6px; }
.player.expanded .p-head-title { flex: 1; text-align: center; font-family: var(--font-pa); font-weight: 600; font-size: 15px; color: var(--ink-2); }
.player.expanded .p-progress-mini { display: none; }
.player.expanded .p-video { width: 100%; max-width: 640px; align-self: center; border-radius: 14px; }
.player.expanded .p-info { cursor: default; margin: 18px 0 4px; text-align: center; }
.player.expanded .p-title { font-size: 20px; -webkit-line-clamp: 4; font-weight: 700; }
.player.expanded .p-sub { font-size: 14px; margin-top: 4px; white-space: normal; }
/* caption: topic on its own, more prominent line; mode and position on the line below */
.p-sub .p-topic { font-family: var(--font-pa); font-weight: 700; color: var(--ink); }
.p-sub .p-data::before { content: " · "; }
.player.expanded .p-sub .p-topic { display: block; font-size: 17px; margin-top: 6px; }
.player.expanded .p-sub .p-data { display: block; font-size: 13.5px; margin-top: 2px; }
.player.expanded .p-sub .p-data::before { content: none; }
.player.expanded .p-seek { display: block !important; margin: 10px 0 0; }
.player.expanded .p-seek, .player.expanded .p-info { width: 100%; max-width: 640px; align-self: center; }
.p-seek input { width: 100%; accent-color: var(--saffron); height: 28px; }
.p-times { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.player.expanded .p-ctrls { justify-content: center; gap: 10px; margin: 10px 0 16px; }
.player.expanded .big-only { display: inline-grid !important; }
.player.expanded .play-btn { width: 72px; height: 72px; }
.player.expanded .play-btn svg { width: 32px; height: 32px; }
.player.expanded .icon-btn { width: 52px; height: 52px; }
.player.expanded .icon-btn svg { width: 28px; height: 28px; }
.player.expanded .p-extra { display: flex !important; flex-wrap: wrap; gap: 8px; justify-content: center; }
.player.expanded .p-note { display: block !important; font-size: 12.5px; color: var(--ink-2); text-align: center; max-width: 460px; margin: 18px auto 0; }
.chip { min-height: 42px; padding: 0 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--saffron-soft); border-color: var(--saffron); }
.chip.walk { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Sheet (speed / timer choices) */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 520px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet-card h3 { margin: 0 0 12px; font-size: 16px; font-family: var(--font-pa); }
.sheet-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.sheet-opts button { min-height: 48px; border-radius: 12px; background: var(--surface-2); font-weight: 600; }
.sheet-opts button[aria-pressed="true"] { background: var(--saffron); color: var(--accent-ink); }

/* Walk-mode lock */
.lock { position: fixed; inset: 0; z-index: 50; background: #000; color: #8a8f99; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.lock-inner { text-align: center; padding: 24px; max-width: 420px; }
.lock-logo { font-family: var(--font-pa); font-size: 46px; color: #7a5a22; }
.lock-title { font-family: var(--font-pa); font-size: 18px; color: #b9bec8; margin-top: 16px; }
.lock-sub { font-size: 14px; margin-top: 6px; }
.hold { position: relative; overflow: hidden; margin-top: 48px; min-height: 60px; padding: 0 26px; border-radius: 999px; border: 1px solid #333; color: #b9bec8; font-size: 15px; }
.hold-fill { position: absolute; inset: 0; width: 0; background: #3a2c16; }
.hold.holding .hold-fill { width: 100%; transition: width 1.2s linear; }
.hold-txt { position: relative; font-family: var(--font-pa); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 28px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .player { grid-template-columns: 88px 1fr auto; }
  .p-video { width: 88px; }
  .grid { grid-template-columns: 1fr 1fr; }
}
