{
  "id": 112,
  "slug": "expandable-mini-player-sheet",
  "name": "Expandable Mini-Player to Full-Screen Media Sheet",
  "kind": "ui",
  "family": "Media & Stories",
  "sourceSite": {
    "name": "Pocket Casts",
    "url": "https://pocketcasts.com",
    "verifiedStatus": 200
  },
  "tagline": "Persistent bottom mini-player that expands seamlessly into a full-screen chaptered player with speed, scrub, and sleep timer.",
  "whyUnique": "Lets listeners browse episodes uninterrupted while keeping transport controls one tap away and expanding into deep chapter/speed tools on demand.",
  "theme": "dark",
  "mobileStrength": "native-first",
  "tags": [
    "mini-player",
    "media-sheet",
    "audio-player",
    "chapter-scrub",
    "podcast-ui"
  ],
  "bestFor": [
    "Podcast & audiobook apps",
    "Music streaming players",
    "Course & lecture platforms",
    "Guided meditation apps"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#101218",
      "name": "Studio Obsidian"
    },
    {
      "role": "surface",
      "hex": "#1B1E28",
      "name": "Deck Charcoal"
    },
    {
      "role": "ink",
      "hex": "#F9FAFB",
      "name": "Pure White"
    },
    {
      "role": "accent",
      "hex": "#F43E37",
      "name": "Broadcast Red"
    },
    {
      "role": "muted",
      "hex": "#9CA3AF",
      "name": "Signal Gray"
    }
  ],
  "typography": {
    "display": "Plus Jakarta Sans",
    "body": "Inter",
    "mono": "JetBrains Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=JetBrains+Mono:wght@500;600&family=Plus+Jakarta+Sans:wght@700;800&display=swap",
    "scaleNotes": "Tabular monospace timestamps paired with bold 18-24px episode titles and compact chapter rows."
  },
  "layoutNotes": "Scrollable episode queue with a pinned bottom mini-player bar (including hairline progress strip) that morphs upward into a centered full-height player sheet.",
  "interactionNotes": "Simulated playback clock drives both mini and full scrubbers in sync; includes ±15s skip, 1x/1.2x/1.5x/2x speed cycler, sleep timer pill, and clickable chapter jump list.",
  "mobileNotes": "Large 56px play/pause button and thumb-friendly bottom transport row inside the expanded sheet, with swipe-down or chevron button to collapse.",
  "agentGuardrails": {
    "do": [
      "Keep Play/Pause directly clickable on the mini-player without forcing expansion",
      "Synchronize playback position, episode metadata, and progress bar across mini and full views",
      "Add bottom padding equal to the mini-player height so the last episode row is never obscured"
    ],
    "dont": [
      "Do not interrupt playback state when expanding or collapsing the media sheet",
      "Do not make seek thumbs smaller than 24-44px hit area on touch screens"
    ]
  },
  "demoFile": "demos/expandable-mini-player-sheet.html",
  "thumbDesktop": "thumbs/expandable-mini-player-sheet-desktop.webp",
  "thumbMobile": "thumbs/expandable-mini-player-sheet-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/expandable-mini-player-sheet",
    "markdown": "https://templates.michaelpitts.net/t/expandable-mini-player-sheet.md",
    "api": "https://templates.michaelpitts.net/api/templates/expandable-mini-player-sheet",
    "demo": "https://templates.michaelpitts.net/demos/expandable-mini-player-sheet.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/expandable-mini-player-sheet-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/expandable-mini-player-sheet-mobile.webp"
  },
  "agentPrompt": "Design & build using template #112 \"Expandable Mini-Player to Full-Screen Media Sheet\" (ui / Media & Stories, dark theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/expandable-mini-player-sheet.md\nLive demo: https://templates.michaelpitts.net/demos/expandable-mini-player-sheet.html\nReal-world inspiration: Pocket Casts (https://pocketcasts.com)\n\nCore aesthetic: Lets listeners browse episodes uninterrupted while keeping transport controls one tap away and expanding into deep chapter/speed tools on demand.\nPalette: canvas: #101218 (Studio Obsidian), surface: #1B1E28 (Deck Charcoal), ink: #F9FAFB (Pure White), accent: #F43E37 (Broadcast Red), muted: #9CA3AF (Signal Gray)\nTypography: Display=\"Plus Jakarta Sans\", Body=\"Inter\", Mono=\"JetBrains Mono\"\nLayout: Scrollable episode queue with a pinned bottom mini-player bar (including hairline progress strip) that morphs upward into a centered full-height player sheet.\nInteractions: Simulated playback clock drives both mini and full scrubbers in sync; includes ±15s skip, 1x/1.2x/1.5x/2x speed cycler, sleep timer pill, and clickable chapter jump list.\nMobile: Large 56px play/pause button and thumb-friendly bottom transport row inside the expanded sheet, with swipe-down or chevron button to collapse.\n\nGuardrails:\n- DO: Keep Play/Pause directly clickable on the mini-player without forcing expansion\n- DO: Synchronize playback position, episode metadata, and progress bar across mini and full views\n- DO: Add bottom padding equal to the mini-player height so the last episode row is never obscured\n- DON'T: Do not interrupt playback state when expanding or collapsing the media sheet\n- DON'T: Do not make seek thumbs smaller than 24-44px hit area on touch screens",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>CastDeck — Expandable Mini-Player to Full-Screen Media Sheet</title>\n<style>\n  :root {\n    --canvas: #101218;\n    --surface: #1B1E28;\n    --surface-hi: #252938;\n    --ink: #F9FAFB;\n    --accent: #F43E37;\n    --accent-soft: rgba(244, 62, 55, 0.16);\n    --muted: #9CA3AF;\n    --border: rgba(255, 255, 255, 0.08);\n    --radius: 16px;\n    --font: \"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n  }\n\n  * { box-sizing: border-box; margin: 0; padding: 0; }\n\n  html, body {\n    background: var(--canvas);\n    color: var(--ink);\n    font-family: var(--font);\n    line-height: 1.45;\n    -webkit-font-smoothing: antialiased;\n    overflow-x: clip;\n  }\n\n  .feed-shell {\n    max-width: 820px;\n    margin: 0 auto;\n    padding: 18px 14px 116px;\n  }\n\n  @media (min-width: 768px) {\n    .feed-shell { padding: 28px 24px 128px; }\n  }\n\n  .feed-head {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    margin-bottom: 20px;\n  }\n\n  .brand {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n  }\n\n  .brand-dot {\n    width: 38px;\n    height: 38px;\n    border-radius: 11px;\n    background: var(--accent);\n    display: grid;\n    place-items: center;\n    box-shadow: 0 6px 18px rgba(244, 62, 55, 0.32);\n  }\n\n  .brand h1 { font-size: 1.2rem; font-weight: 750; letter-spacing: -0.02em; }\n  .brand p { font-size: 0.78rem; color: var(--muted); }\n\n  .queue-badge {\n    font-size: 0.76rem;\n    font-weight: 700;\n    color: var(--muted);\n    background: var(--surface);\n    border: 1px solid var(--border);\n    padding: 6px 12px;\n    border-radius: 999px;\n  }\n\n  /* Episode Feed */\n  .ep-list {\n    display: flex;\n    flex-direction: column;\n    gap: 12px;\n  }\n\n  .ep-card {\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: var(--radius);\n    padding: 13px;\n    display: flex;\n    align-items: center;\n    gap: 13px;\n    cursor: pointer;\n    transition: background 0.15s, border-color 0.15s;\n  }\n\n  .ep-card:hover { background: var(--surface-hi); }\n  .ep-card.playing { border-color: var(--accent); }\n\n  .ep-art {\n    width: 64px;\n    height: 64px;\n    border-radius: 12px;\n    overflow: hidden;\n    flex-shrink: 0;\n  }\n\n  .ep-art svg { width: 100%; height: 100%; display: block; }\n\n  .ep-meta { flex: 1; min-width: 0; }\n\n  .ep-show {\n    font-size: 0.74rem;\n    font-weight: 700;\n    color: var(--accent);\n    text-transform: uppercase;\n    letter-spacing: 0.04em;\n  }\n\n  .ep-title {\n    font-size: 0.94rem;\n    font-weight: 700;\n    color: var(--ink);\n    margin: 2px 0 4px;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n\n  .ep-sub {\n    font-size: 0.78rem;\n    color: var(--muted);\n  }\n\n  .ep-play-btn {\n    width: 44px;\n    height: 44px;\n    border-radius: 50%;\n    border: none;\n    background: var(--surface-hi);\n    color: var(--ink);\n    cursor: pointer;\n    display: grid;\n    place-items: center;\n    flex-shrink: 0;\n  }\n\n  .ep-card.playing .ep-play-btn {\n    background: var(--accent);\n    color: #FFFFFF;\n  }\n\n  /* Persistent Bottom Mini-Player */\n  .mini-player {\n    position: fixed;\n    left: 50%;\n    bottom: 12px;\n    transform: translateX(-50%);\n    width: calc(100% - 20px);\n    max-width: 780px;\n    background: #1E2230;\n    border: 1px solid rgba(255, 255, 255, 0.12);\n    border-radius: 16px;\n    overflow: hidden;\n    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);\n    z-index: 30;\n    cursor: pointer;\n    touch-action: none;\n  }\n\n  .mini-progress-track {\n    height: 3px;\n    background: rgba(255, 255, 255, 0.1);\n    width: 100%;\n  }\n\n  .mini-progress-fill {\n    height: 100%;\n    width: 0%;\n    background: var(--accent);\n    transition: width 0.2s linear;\n  }\n\n  .mini-row {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    padding: 9px 10px 9px 12px;\n  }\n\n  .mini-art {\n    width: 46px;\n    height: 46px;\n    border-radius: 10px;\n    overflow: hidden;\n    flex-shrink: 0;\n  }\n\n  .mini-art svg { width: 100%; height: 100%; display: block; }\n\n  .mini-info { flex: 1; min-width: 0; }\n  .mini-info strong {\n    display: block;\n    font-size: 0.88rem;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n  .mini-info span {\n    display: block;\n    font-size: 0.74rem;\n    color: var(--muted);\n  }\n\n  .mini-ctrl {\n    width: 44px;\n    height: 44px;\n    border: none;\n    border-radius: 50%;\n    background: transparent;\n    color: var(--ink);\n    cursor: pointer;\n    display: grid;\n    place-items: center;\n    flex-shrink: 0;\n  }\n\n  .mini-ctrl:hover { background: rgba(255, 255, 255, 0.08); }\n\n  /* Full-Screen Expandable Media Sheet */\n  .player-sheet {\n    position: fixed;\n    inset: 0;\n    background: linear-gradient(180deg, #1E2232 0%, #101218 46%);\n    z-index: 50;\n    display: flex;\n    flex-direction: column;\n    transform: translateY(100%);\n    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);\n    overflow-y: auto;\n  }\n\n  .player-sheet.open { transform: translateY(0); }\n  .player-sheet.dragging { transition: none; }\n\n  .sheet-inner {\n    max-width: 560px;\n    width: 100%;\n    margin: 0 auto;\n    padding: 12px 18px 36px;\n    display: flex;\n    flex-direction: column;\n    gap: 18px;\n  }\n\n  .drag-handle-wrap {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    padding-top: 4px;\n    touch-action: none;\n  }\n\n  .drag-pill {\n    width: 42px;\n    height: 5px;\n    border-radius: 999px;\n    background: rgba(255, 255, 255, 0.24);\n  }\n\n  .sheet-icon-btn {\n    min-width: 44px;\n    min-height: 44px;\n    border: none;\n    border-radius: 12px;\n    background: transparent;\n    color: var(--ink);\n    cursor: pointer;\n    display: grid;\n    place-items: center;\n  }\n\n  .sheet-icon-btn:hover { background: rgba(255, 255, 255, 0.08); }\n\n  .hero-art {\n    width: min(260px, 68vw);\n    aspect-ratio: 1 / 1;\n    margin: 4px auto 0;\n    border-radius: 22px;\n    overflow: hidden;\n    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.55);\n  }\n\n  .hero-art svg { width: 100%; height: 100%; display: block; }\n\n  .hero-titles { text-align: center; }\n  .hero-titles h2 { font-size: 1.22rem; font-weight: 750; margin-bottom: 4px; }\n  .hero-titles p { font-size: 0.85rem; color: var(--muted); }\n\n  /* Interactive Scrubber */\n  .scrubber-block { display: flex; flex-direction: column; gap: 6px; }\n\n  .scrub-input {\n    width: 100%;\n    accent-color: var(--accent);\n    height: 6px;\n    cursor: pointer;\n  }\n\n  .time-row {\n    display: flex;\n    justify-content: space-between;\n    font-size: 0.76rem;\n    color: var(--muted);\n    font-variant-numeric: tabular-nums;\n  }\n\n  /* Transport Controls */\n  .transport {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 8px;\n  }\n\n  .pill-btn {\n    min-height: 44px;\n    min-width: 56px;\n    padding: 0 12px;\n    border-radius: 999px;\n    border: 1px solid var(--border);\n    background: var(--surface);\n    color: var(--ink);\n    font-size: 0.8rem;\n    font-weight: 700;\n    font-family: inherit;\n    cursor: pointer;\n  }\n\n  .pill-btn.active {\n    border-color: var(--accent);\n    color: var(--accent);\n    background: var(--accent-soft);\n  }\n\n  .skip-btn {\n    min-width: 52px;\n    min-height: 52px;\n    border: none;\n    border-radius: 50%;\n    background: transparent;\n    color: var(--ink);\n    font-size: 0.82rem;\n    font-weight: 750;\n    font-family: inherit;\n    cursor: pointer;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n  }\n\n  .skip-btn:hover { background: rgba(255, 255, 255, 0.08); }\n\n  .play-big {\n    width: 66px;\n    height: 66px;\n    border-radius: 50%;\n    border: none;\n    background: var(--accent);\n    color: #FFFFFF;\n    cursor: pointer;\n    display: grid;\n    place-items: center;\n    box-shadow: 0 10px 26px rgba(244, 62, 55, 0.4);\n  }\n\n  /* Chapters List */\n  .chapters-card {\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: var(--radius);\n    padding: 14px;\n  }\n\n  .chapters-head {\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n    font-size: 0.78rem;\n    font-weight: 700;\n    text-transform: uppercase;\n    letter-spacing: 0.05em;\n    color: var(--muted);\n    margin-bottom: 10px;\n  }\n\n  .chapter-row {\n    width: 100%;\n    min-height: 46px;\n    padding: 8px 10px;\n    border: none;\n    border-radius: 10px;\n    background: transparent;\n    color: var(--ink);\n    font-family: inherit;\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 10px;\n    text-align: left;\n  }\n\n  .chapter-row:hover { background: rgba(255, 255, 255, 0.05); }\n  .chapter-row.current { background: var(--accent-soft); color: #FFFFFF; }\n  .chapter-row.current .ch-time { color: var(--accent); }\n\n  .ch-title { font-size: 0.86rem; font-weight: 600; }\n  .ch-time { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }\n</style>\n</head>\n<body>\n<div class=\"feed-shell\">\n  <header class=\"feed-head\">\n    <div class=\"brand\">\n      <div class=\"brand-dot\" aria-hidden=\"true\">\n        <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#FFFFFF\" stroke-width=\"2.2\" stroke-linecap=\"round\"><circle cx=\"12\" cy=\"12\" r=\"2.5\"/><path d=\"M8.5 15.5a5 5 0 0 1 0-7\"/><path d=\"M15.5 8.5a5 5 0 0 1 0 7\"/><path d=\"M5.5 18.5a9.2 9.2 0 0 1 0-13\"/><path d=\"M18.5 5.5a9.2 9.2 0 0 1 0 13\"/></svg>\n      </div>\n      <div>\n        <h1>CastDeck</h1>\n        <p>Tap or drag the mini-player upward for chapters &amp; sleep timer</p>\n      </div>\n    </div>\n    <span class=\"queue-badge\">4 Episodes</span>\n  </header>\n\n  <main id=\"epList\" class=\"ep-list\" aria-label=\"Podcast episodes\"></main>\n</div>\n\n<!-- Persistent Bottom Mini-Player -->\n<aside id=\"miniPlayer\" class=\"mini-player\" role=\"region\" aria-label=\"Mini audio player\">\n  <div class=\"mini-progress-track\"><div id=\"miniFill\" class=\"mini-progress-fill\"></div></div>\n  <div class=\"mini-row\">\n    <div id=\"miniArt\" class=\"mini-art\"></div>\n    <div class=\"mini-info\">\n      <strong id=\"miniTitle\"></strong>\n      <span id=\"miniSub\"></span>\n    </div>\n    <button id=\"miniSkip\" class=\"mini-ctrl\" type=\"button\" aria-label=\"Forward 15 seconds\">+15</button>\n    <button id=\"miniPlay\" class=\"mini-ctrl\" type=\"button\" aria-label=\"Play or pause\"></button>\n  </div>\n</aside>\n\n<!-- Full-Screen Expandable Media Sheet -->\n<section id=\"playerSheet\" class=\"player-sheet\" aria-label=\"Full screen audio player\">\n  <div class=\"sheet-inner\">\n    <div id=\"sheetDragHeader\" class=\"drag-handle-wrap\">\n      <button id=\"collapseSheet\" class=\"sheet-icon-btn\" type=\"button\" aria-label=\"Collapse player\">\n        <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n      </button>\n      <div class=\"drag-pill\" aria-hidden=\"true\"></div>\n      <span id=\"sleepBadge\" style=\"font-size:0.75rem;color:var(--accent);font-weight:700;min-width:44px;text-align:right\"></span>\n    </div>\n\n    <div id=\"heroArt\" class=\"hero-art\"></div>\n\n    <div class=\"hero-titles\">\n      <h2 id=\"sheetTitle\"></h2>\n      <p id=\"sheetShow\"></p>\n    </div>\n\n    <div class=\"scrubber-block\">\n      <input id=\"scrubInput\" class=\"scrub-input\" type=\"range\" min=\"0\" max=\"100\" value=\"0\" aria-label=\"Seek episode timeline\">\n      <div class=\"time-row\">\n        <span id=\"timeElapsed\">0:00</span>\n        <span id=\"chapterNow\" style=\"color:var(--ink);font-weight:600\"></span>\n        <span id=\"timeRemain\">-0:00</span>\n      </div>\n    </div>\n\n    <div class=\"transport\">\n      <button id=\"speedBtn\" class=\"pill-btn\" type=\"button\" aria-label=\"Playback speed\">1.0x</button>\n      <button id=\"back15Btn\" class=\"skip-btn\" type=\"button\" aria-label=\"Back 15 seconds\">-15s</button>\n      <button id=\"sheetPlayBtn\" class=\"play-big\" type=\"button\" aria-label=\"Play or pause\"></button>\n      <button id=\"fwd15Btn\" class=\"skip-btn\" type=\"button\" aria-label=\"Forward 15 seconds\">+15s</button>\n      <button id=\"sleepBtn\" class=\"pill-btn\" type=\"button\" aria-label=\"Sleep timer\">Sleep</button>\n    </div>\n\n    <div class=\"chapters-card\">\n      <div class=\"chapters-head\">\n        <span>Chapters</span>\n        <span id=\"chapterCount\"></span>\n      </div>\n      <div id=\"chapterList\"></div>\n    </div>\n  </div>\n</section>\n\n<script>\n(function () {\n  const EPISODES = [\n    {\n      id: \"ep1\", show: \"Design Details Live\", title: \"Spatial Interfaces & Tactile Motion\", date: \"Today\", duration: 2460,\n      colors: [\"#F43E37\", \"#7C2D12\", \"#FCA5A5\"],\n      chapters: [\n        { t: 0, title: \"Intro & Weekly Tooling Picks\" },\n        { t: 420, title: \"Spring Physics vs. Cubic Beziers\" },\n        { t: 1180, title: \"Thumb Reach Zones on 390px Screens\" },\n        { t: 1890, title: \"Listener Q&A and Wrap-up\" }\n      ]\n    },\n    {\n      id: \"ep2\", show: \"Systems Under Hood\", title: \"Local-First Sync Engines Explained\", date: \"May 16\", duration: 3120,\n      colors: [\"#3B82F6\", \"#1E3A8A\", \"#93C5FD\"],\n      chapters: [\n        { t: 0, title: \"Why Optimistic UI Matters\" },\n        { t: 740, title: \"CRDTs vs. Operational Transforms\" },\n        { t: 1680, title: \"IndexedDB & SQLite in the Browser\" },\n        { t: 2540, title: \"Conflict Resolution Patterns\" }\n      ]\n    },\n    {\n      id: \"ep3\", show: \"Analog Craft\", title: \"Field Recording in Kyoto Rain\", date: \"May 11\", duration: 1980,\n      colors: [\"#10B981\", \"#064E3B\", \"#6EE7B7\"],\n      chapters: [\n        { t: 0, title: \"Packing Ultra-Light Microphones\" },\n        { t: 620, title: \"Dawn Acoustics at Philosopher's Path\" },\n        { t: 1340, title: \"Mixing Ambient Stems for Podcasts\" }\n      ]\n    },\n    {\n      id: \"ep4\", show: \"Founders Notebook\", title: \"Bootstrapping Calm Software Tools\", date: \"May 04\", duration: 2740,\n      colors: [\"#A855F7\", \"#4C1D95\", \"#D8B4FE\"],\n      chapters: [\n        { t: 0, title: \"Pricing for Long-Term Sustainability\" },\n        { t: 880, title: \"Saying No to Feature Bloat\" },\n        { t: 1920, title: \"Customer Support as Product Research\" }\n      ]\n    }\n  ];\n\n  const SPEEDS = [1.0, 1.2, 1.5, 2.0];\n  const SLEEPS = [\n    { label: \"Off\", sec: 0 },\n    { label: \"15m\", sec: 900 },\n    { label: \"30m\", sec: 1800 },\n    { label: \"Ch.\", sec: -1 } // End of chapter\n  ];\n\n  const state = {\n    epIdx: 0,\n    time: 438,\n    playing: true,\n    speedIdx: 0,\n    sleepIdx: 0,\n    sleepRemain: 0,\n    expanded: false\n  };\n\n  const els = {\n    epList: document.getElementById(\"epList\"),\n    miniPlayer: document.getElementById(\"miniPlayer\"),\n    miniFill: document.getElementById(\"miniFill\"),\n    miniArt: document.getElementById(\"miniArt\"),\n    miniTitle: document.getElementById(\"miniTitle\"),\n    miniSub: document.getElementById(\"miniSub\"),\n    miniPlay: document.getElementById(\"miniPlay\"),\n    miniSkip: document.getElementById(\"miniSkip\"),\n    sheet: document.getElementById(\"playerSheet\"),\n    sheetDragHeader: document.getElementById(\"sheetDragHeader\"),\n    collapseSheet: document.getElementById(\"collapseSheet\"),\n    heroArt: document.getElementById(\"heroArt\"),\n    sheetTitle: document.getElementById(\"sheetTitle\"),\n    sheetShow: document.getElementById(\"sheetShow\"),\n    scrubInput: document.getElementById(\"scrubInput\"),\n    timeElapsed: document.getElementById(\"timeElapsed\"),\n    timeRemain: document.getElementById(\"timeRemain\"),\n    chapterNow: document.getElementById(\"chapterNow\"),\n    speedBtn: document.getElementById(\"speedBtn\"),\n    back15Btn: document.getElementById(\"back15Btn\"),\n    sheetPlayBtn: document.getElementById(\"sheetPlayBtn\"),\n    fwd15Btn: document.getElementById(\"fwd15Btn\"),\n    sleepBtn: document.getElementById(\"sleepBtn\"),\n    sleepBadge: document.getElementById(\"sleepBadge\"),\n    chapterCount: document.getElementById(\"chapterCount\"),\n    chapterList: document.getElementById(\"chapterList\")\n  };\n\n  function fmtTime(sec) {\n    const s = Math.max(0, Math.floor(sec));\n    const m = Math.floor(s / 60);\n    const r = s % 60;\n    return `${m}:${r < 10 ? \"0\" : \"\"}${r}`;\n  }\n\n  function coverSvg(colors, idx) {\n    const [c1, c2, c3] = colors;\n    return `<svg viewBox=\"0 0 160 160\">\n      <defs><linearGradient id=\"cg${idx}\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"${c1}\"/><stop offset=\"100%\" stop-color=\"${c2}\"/></linearGradient></defs>\n      <rect width=\"160\" height=\"160\" fill=\"url(#cg${idx})\"/>\n      <circle cx=\"80\" cy=\"80\" r=\"46\" fill=\"none\" stroke=\"${c3}\" stroke-width=\"6\" opacity=\"0.5\"/>\n      <circle cx=\"80\" cy=\"80\" r=\"24\" fill=\"${c3}\" opacity=\"0.88\"/>\n      <circle cx=\"80\" cy=\"80\" r=\"9\" fill=\"${c2}\"/>\n    </svg>`;\n  }\n\n  function playIcon(isPlaying, size) {\n    return isPlaying\n      ? `<svg width=\"${size}\" height=\"${size}\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><rect x=\"6\" y=\"4\" width=\"4.5\" height=\"16\" rx=\"1.2\"/><rect x=\"13.5\" y=\"4\" width=\"4.5\" height=\"16\" rx=\"1.2\"/></svg>`\n      : `<svg width=\"${size}\" height=\"${size}\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><polygon points=\"6 4 20 12 6 20 6 4\"/></svg>`;\n  }\n\n  function currentEpisode() { return EPISODES[state.epIdx]; }\n\n  function activeChapterIndex(ep, t) {\n    let idx = 0;\n    for (let i = 0; i < ep.chapters.length; i++) {\n      if (t >= ep.chapters[i].t) idx = i;\n    }\n    return idx;\n  }\n\n  function renderFeed() {\n    els.epList.innerHTML = EPISODES.map((ep, idx) => {\n      const isCur = idx === state.epIdx;\n      return `\n        <article class=\"ep-card ${isCur ? \"playing\" : \"\"}\" data-ep=\"${idx}\">\n          <div class=\"ep-art\">${coverSvg(ep.colors, \"f\" + idx)}</div>\n          <div class=\"ep-meta\">\n            <div class=\"ep-show\">${ep.show}</div>\n            <div class=\"ep-title\">${ep.title}</div>\n            <div class=\"ep-sub\">${ep.date} &middot; ${fmtTime(ep.duration)} &middot; ${ep.chapters.length} chapters</div>\n          </div>\n          <button class=\"ep-play-btn\" data-play-ep=\"${idx}\" type=\"button\" aria-label=\"Play ${ep.title}\">\n            ${playIcon(isCur && state.playing, 18)}\n          </button>\n        </article>\n      `;\n    }).join(\"\");\n  }\n\n  function renderPlayer() {\n    const ep = currentEpisode();\n    const pct = (state.time / ep.duration) * 100;\n    const chIdx = activeChapterIndex(ep, state.time);\n    const ch = ep.chapters[chIdx];\n\n    els.miniFill.style.width = pct.toFixed(2) + \"%\";\n    els.miniArt.innerHTML = coverSvg(ep.colors, \"m\" + state.epIdx);\n    els.miniTitle.textContent = ep.title;\n    els.miniSub.textContent = `${ep.show} · ${fmtTime(ep.duration - state.time)} left`;\n    els.miniPlay.innerHTML = playIcon(state.playing, 20);\n\n    els.heroArt.innerHTML = coverSvg(ep.colors, \"h\" + state.epIdx);\n    els.sheetTitle.textContent = ep.title;\n    els.sheetShow.textContent = ep.show;\n\n    els.scrubInput.max = ep.duration;\n    els.scrubInput.value = Math.floor(state.time);\n    els.timeElapsed.textContent = fmtTime(state.time);\n    els.timeRemain.textContent = \"-\" + fmtTime(ep.duration - state.time);\n    els.chapterNow.textContent = ch.title;\n\n    els.sheetPlayBtn.innerHTML = playIcon(state.playing, 26);\n    els.speedBtn.textContent = SPEEDS[state.speedIdx].toFixed(1) + \"x\";\n    els.speedBtn.classList.toggle(\"active\", state.speedIdx !== 0);\n\n    const sl = SLEEPS[state.sleepIdx];\n    els.sleepBtn.textContent = sl.sec === 0 ? \"Sleep\" : sl.label;\n    els.sleepBtn.classList.toggle(\"active\", sl.sec !== 0);\n    els.sleepBadge.textContent = sl.sec > 0 ? fmtTime(state.sleepRemain) : (sl.sec === -1 ? \"End ch.\" : \"\");\n\n    els.chapterCount.textContent = `${chIdx + 1} / ${ep.chapters.length}`;\n    els.chapterList.innerHTML = ep.chapters.map((c, i) => `\n      <button class=\"chapter-row ${i === chIdx ? \"current\" : \"\"}\" data-seek=\"${c.t}\" type=\"button\">\n        <span class=\"ch-title\">${i + 1}. ${c.title}</span>\n        <span class=\"ch-time\">${fmtTime(c.t)}</span>\n      </button>\n    `).join(\"\");\n\n    els.sheet.classList.toggle(\"open\", state.expanded);\n  }\n\n  function renderAll() {\n    renderFeed();\n    renderPlayer();\n  }\n\n  // Simulated Live Playback Loop\n  setInterval(() => {\n    if (!state.playing) return;\n    const ep = currentEpisode();\n    const prevCh = activeChapterIndex(ep, state.time);\n    const step = 0.5 * SPEEDS[state.speedIdx];\n    state.time = Math.min(ep.duration, state.time + step);\n    if (state.time >= ep.duration) {\n      state.playing = false;\n    }\n    if (SLEEPS[state.sleepIdx].sec > 0) {\n      state.sleepRemain = Math.max(0, state.sleepRemain - 0.5);\n      if (state.sleepRemain === 0) {\n        state.playing = false;\n        state.sleepIdx = 0;\n      }\n    } else if (SLEEPS[state.sleepIdx].sec === -1) {\n      if (activeChapterIndex(ep, state.time) !== prevCh) {\n        state.playing = false;\n        state.sleepIdx = 0;\n      }\n    }\n    renderPlayer();\n  }, 500);\n\n  // Feed Clicks\n  els.epList.addEventListener(\"click\", (e) => {\n    const card = e.target.closest(\"[data-ep]\");\n    if (!card) return;\n    const idx = Number(card.dataset.ep);\n    if (idx === state.epIdx) {\n      state.playing = !state.playing;\n    } else {\n      state.epIdx = idx;\n      state.time = 0;\n      state.playing = true;\n    }\n    renderAll();\n  });\n\n  // Mini-Player Controls & Tap/Drag Up\n  els.miniPlay.addEventListener(\"click\", (e) => {\n    e.stopPropagation();\n    state.playing = !state.playing;\n    renderAll();\n  });\n\n  els.miniSkip.addEventListener(\"click\", (e) => {\n    e.stopPropagation();\n    state.time = Math.min(currentEpisode().duration, state.time + 15);\n    renderPlayer();\n  });\n\n  let miniDragY = null;\n  els.miniPlayer.addEventListener(\"pointerdown\", (e) => {\n    if (e.target.closest(\"button\")) return;\n    miniDragY = e.clientY;\n  });\n  els.miniPlayer.addEventListener(\"pointerup\", (e) => {\n    if (miniDragY === null) return;\n    const dy = miniDragY - e.clientY;\n    miniDragY = null;\n    if (dy >= -10) {\n      state.expanded = true;\n      renderPlayer();\n    }\n  });\n\n  // Sheet Collapse & Drag Down\n  els.collapseSheet.addEventListener(\"click\", () => {\n    state.expanded = false;\n    renderPlayer();\n  });\n\n  let sheetDrag = null;\n  els.sheetDragHeader.addEventListener(\"pointerdown\", (e) => {\n    if (e.target.closest(\"button\")) return;\n    sheetDrag = { startY: e.clientY, dy: 0 };\n    els.sheet.classList.add(\"dragging\");\n  });\n  window.addEventListener(\"pointermove\", (e) => {\n    if (!sheetDrag) return;\n    sheetDrag.dy = Math.max(0, e.clientY - sheetDrag.startY);\n    els.sheet.style.transform = `translateY(${sheetDrag.dy}px)`;\n  });\n  window.addEventListener(\"pointerup\", () => {\n    if (!sheetDrag) return;\n    const dy = sheetDrag.dy;\n    sheetDrag = null;\n    els.sheet.classList.remove(\"dragging\");\n    els.sheet.style.transform = \"\";\n    if (dy > 90) {\n      state.expanded = false;\n      renderPlayer();\n    }\n  });\n\n  // Full-Screen Transport Controls\n  els.scrubInput.addEventListener(\"input\", (e) => {\n    state.time = Number(e.target.value);\n    renderPlayer();\n  });\n\n  els.sheetPlayBtn.addEventListener(\"click\", () => {\n    state.playing = !state.playing;\n    renderAll();\n  });\n\n  els.back15Btn.addEventListener(\"click\", () => {\n    state.time = Math.max(0, state.time - 15);\n    renderPlayer();\n  });\n\n  els.fwd15Btn.addEventListener(\"click\", () => {\n    state.time = Math.min(currentEpisode().duration, state.time + 15);\n    renderPlayer();\n  });\n\n  els.speedBtn.addEventListener(\"click\", () => {\n    state.speedIdx = (state.speedIdx + 1) % SPEEDS.length;\n    renderPlayer();\n  });\n\n  els.sleepBtn.addEventListener(\"click\", () => {\n    state.sleepIdx = (state.sleepIdx + 1) % SLEEPS.length;\n    state.sleepRemain = Math.max(0, SLEEPS[state.sleepIdx].sec);\n    renderPlayer();\n  });\n\n  els.chapterList.addEventListener(\"click\", (e) => {\n    const row = e.target.closest(\"[data-seek]\");\n    if (!row) return;\n    state.time = Number(row.dataset.seek);\n    state.playing = true;\n    renderAll();\n  });\n\n  document.addEventListener(\"keydown\", (e) => {\n    if (e.key === \"Escape\" && state.expanded) {\n      state.expanded = false;\n      renderPlayer();\n    }\n  });\n\n  renderAll();\n})();\n</script>\n</body>\n</html>\n"
}
