@layer base, layout, components, responsive;

@layer base {
  :root {
    color-scheme: light;
    --bg: #faf7f0; --card: #fffefa; --ink: #263f37; --muted: #647169;
    --line: #dfe5da; --soft: #f0eee6; --green: #285e4c; --green-soft: #e2efe5;
    --button-ink: #fffef8; --accent: #8c5938; --focus: #7652ab;
    --scene: #e5f0e2; --scene-two: #f5dfbd; --lilac: #e7dff5;
    --star: #e8b84c; --shadow: #344d3c0c; --nav-shadow: #263f3714;
  }
  :root[data-mode=bedtime] {
    color-scheme: dark;
    --bg: #191d32; --card: #252a43; --ink: #f2effa; --muted: #babbd0;
    --line: #3e435b; --soft: #30364e; --green: #c9b8f1; --green-soft: #393650;
    --button-ink: #242137; --accent: #e6c896; --focus: #e5ca8c;
    --scene: #2b354c; --scene-two: #3c3a56; --lilac: #413c5b;
    --star: #d2bc89; --shadow: #00000012; --nav-shadow: #00000030;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { scroll-padding-bottom: 110px; }
  body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 ui-rounded, 'SF Pro Rounded', 'Avenir Next', Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; }
  h1,h2,h3,p { margin: 0; }
  h1,h2,h3 { line-height: 1.25; }
  button,input,select { font: inherit; }
  button,select,summary { cursor: pointer; }
  button,a,input,select { -webkit-tap-highlight-color: transparent; }
  button { color: inherit; touch-action: manipulation; }
  button:disabled { cursor: default; opacity: .55; }
  button:not(:disabled):active { transform: scale(.97); }
  a { color: inherit; }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
  svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
  .sprite { display: none; }
  .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; }
  .skip-link { position: fixed; top: -80px; left: 20px; z-index: 10; padding: 15px; background: var(--card); }
  .skip-link:focus { top: 10px; }
}

@layer layout {
  .site-header { max-width: 1040px; margin: auto; padding: calc(20px + env(safe-area-inset-top)) 32px 12px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
  main { max-width: 960px; min-height: calc(100svh - 84px); margin: auto; padding: 20px 32px calc(112px + env(safe-area-inset-bottom)); }
  .library-book { display: grid; grid-template-columns: 310px minmax(0,1fr); gap: 20px 36px; align-items: start; }
  .book-visual { grid-column: 1; grid-row: 1 / span 3; }
  .book-intro,.player-card,.download-card,.connection { grid-column: 2; }
  .book-intro h1 { font-size: 27px; font-weight: 800; letter-spacing: -.7px; }
  .book-intro { padding-top: 7px; }
  .app-status { color: var(--muted); font-size: 14px; margin: 14px 0; }
  .app-status[data-ready=true] { display: none; }
}

@layer components {
  .setup-panel { max-width: 640px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 26px; }
  .setup-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
  .setup-heading h1 { font-size: 25px; letter-spacing: -.6px; }
  .setup-heading p { font-size: 14px; color: var(--muted); margin-top: 7px; }
  .setup-app-icon { display: grid; place-items: center; flex-shrink: 0; width: 56px; height: 56px; border-radius: 19px; background: var(--green-soft); color: var(--green); }
  .setup-steps { list-style: none; padding: 0; margin: 0; }
  .setup-steps li { display: flex; gap: 14px; padding: 21px 0; border-top: 1px solid var(--line); }
  .step-number { display: grid; place-items: center; width: 33px; height: 33px; flex-shrink: 0; border-radius: 12px; background: var(--lilac); font-weight: 800; }
  .setup-steps li>div { flex: 1; min-width: 0; }
  .setup-steps h2 { font-size: 18px; }
  .setup-steps p { font-size: 14px; color: var(--muted); margin-top: 7px; }
  .setup-steps button { margin-top: 14px; }
  #setup-note { margin: 10px 0 18px; }
  #setup-listen { width: 100%; }
  .invite-qr { width: min(280px,100%); margin: 20px auto; padding: 8px; border-radius: 18px; background: #fff; }
  .invite-qr svg { display: block; width: 100%; height: auto; stroke: none; }
  #share-expiry { color: var(--muted); line-height: 1.5; margin: 12px 0 18px; }
  .share-actions { display: flex; flex-wrap: wrap; gap: 10px; }
  .share-actions button { flex: 1; }
  .manual-copy { display: block; margin-top: 18px; font-size: 14px; }
  .manual-copy input { display: block; width: 100%; margin-top: 8px; padding: 12px; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font-size: 16px; }
  .install-steps { list-style: none; padding: 0; margin: 0; }
  .install-steps li { display: flex; align-items: center; gap: 16px; padding: 19px 0; border-top: 1px solid var(--line); }
  .install-steps li>div:last-child { flex: 1; min-width: 0; }
  .install-steps h3 { font-size: 17px; }
  .install-steps p { color: var(--muted); font-size: 14px; margin-top: 6px; }
  .install-picture { display: grid; place-items: center; width: 66px; height: 76px; flex-shrink: 0; border-radius: 20px; background: var(--green-soft); color: var(--green); }
  .install-picture svg { width: 44px; height: 44px; stroke-width: 2; }
  .brand { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; letter-spacing: -.9px; text-decoration: none; }
  .brand-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 16px; background: var(--green-soft); color: var(--green); transform: rotate(-6deg); }
  .brand-icon svg { width: 25px; height: 25px; }
  .settings-button { display: grid; place-items: center; min-width: 48px; min-height: 48px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); }
  .settings-button:hover { background: var(--green-soft); }
  .eyebrow { color: var(--muted); font-size: 10px; letter-spacing: 1.4px; font-weight: 700; }
  .header-actions { display: flex; gap: 8px; flex-shrink: 0; }
  .mode-toggle { display: flex; justify-content: center; align-items: center; width: 48px; height: 48px; padding: 10px; background: var(--lilac); color: var(--ink); border: 0; border-radius: 22px; font-size: 13px; font-weight: 700; white-space: nowrap; }
  .mode-toggle svg { width: 18px; height: 18px; }
  .book-facts { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-top: 8px; }

  .book-visual { position: relative; display: grid; place-items: center; min-height: 382px; border-radius: 34px; background: radial-gradient(ellipse at 20% 10%, var(--scene-two), transparent 65%), var(--scene); isolation: isolate; overflow: hidden; }
  .scene-orbit { position: absolute; width: 285px; height: 285px; border: 1px dashed var(--green); opacity: .18; border-radius: 50%; transform: rotate(-20deg) scaleY(.8); }
  .scene-star { position: absolute; color: var(--star); fill: var(--star); stroke-width: .5; }
  .star-one { top: 35px; left: 28px; width: 29px; height: 29px; transform: rotate(-12deg); }
  .star-two { top: 76px; right: 25px; width: 22px; height: 22px; transform: rotate(16deg); }
  .star-three { bottom: 58px; left: 30px; width: 17px; height: 17px; }
  .scene-spark { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--green); opacity: .4; }
  .spark-one { top: 95px; left: 22px; }
  .spark-two { bottom: 48px; right: 28px; width: 6px; height: 6px; }
  .book-cover { position: relative; width: 194px; aspect-ratio: 3 / 4; border-radius: 4px 12px 12px 4px; background: #20463d; transform: rotate(-7deg); overflow: hidden; box-shadow: 5px 7px 0 -2px #bcc4a7, 14px 19px 20px -10px #243e3c50; }
  .book-cover>img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .book-spine { position: absolute; inset: 0 auto 0 0; width: 8px; background: linear-gradient(90deg,#0b292b60,transparent); }
  .cover-type { position: absolute; top: 8%; left: 9%; right: 8%; color: #f5e7b9; text-align: center; }
  .cover-type p { font-size: 4px; font-weight: 650; letter-spacing: .9px; }
  .cover-type h2 { font: normal 29px/1.04 Georgia,serif; margin: 18px 0 8px; letter-spacing: -1px; }
  .cover-type em { color: #e9ba74; }
  .cover-type span { display: block; font: italic 7px/1.5 Georgia,serif; opacity: .8; }
  [data-mode=bedtime] .book-cover { filter: brightness(.85) saturate(.85); }

  .player-card { background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 22px 24px 18px; box-shadow: 0 8px 28px var(--shadow); }
  .player-topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  #place-label { color: var(--muted); font-size: 13px; font-weight: 600; }
  #chapter-count { color: var(--green); background: var(--green-soft); border-radius: 12px; padding: 5px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
  .player-card h3 { font-size: 23px; letter-spacing: -.5px; font-weight: 750; margin: 14px 0 0; overflow-wrap: anywhere; }
  .transport { display: flex; justify-content: center; align-items: center; gap: 26px; margin: 18px 0 14px; }
  .play { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 106px; height: 106px; flex-shrink: 0; border: 0; border-radius: 36px; background: var(--green); color: var(--button-ink); font-size: 15px; font-weight: 750; box-shadow: 0 5px 0 color-mix(in srgb, var(--green), #000 17%); transition: transform .15s; }
  .play svg { width: 34px; height: 34px; fill: currentColor; stroke-width: 1; }
  .play:active { box-shadow: 0 2px 0 color-mix(in srgb, var(--green), #000 17%); }
  .skip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 62px; min-height: 76px; padding: 7px; border: 0; border-radius: 22px; background: var(--soft); font-size: 12px; font-weight: 650; }
  .skip svg { width: 27px; height: 27px; }
  .skip:hover { background: var(--green-soft); }
  .seek { --progress: 0%; display: block; width: 100%; height: 44px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; touch-action: pan-y; }
  .seek::-webkit-slider-runnable-track { height: 7px; border-radius: 10px; background: linear-gradient(to right,var(--green) var(--progress),var(--line) var(--progress)); }
  .seek::-moz-range-track { height: 7px; border-radius: 10px; background: linear-gradient(to right,var(--green) var(--progress),var(--line) var(--progress)); }
  .seek::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 21px; height: 21px; margin-top: -7px; border-radius: 50%; border: 3px solid var(--card); background: var(--green); box-shadow: 0 0 0 1px var(--green); }
  .seek::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--card); background: var(--green); box-shadow: 0 0 0 1px var(--green); }
  .time-row { display: flex; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); margin-top: -4px; }
  .notice { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--muted); }
  #player-message { color: var(--accent); }
  #sleep-status { display: flex; align-items: center; gap: 5px; padding: 10px 12px; background: var(--lilac); color: var(--ink); border-radius: 13px; font-size: 13px; }

  .download-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 22px; padding: 15px; background: var(--card); }
  .download-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 15px; color: var(--green); background: var(--green-soft); flex-shrink: 0; }
  .download-copy { flex: 1; min-width: 0; }
  .download-copy h3 { font-size: 15px; font-weight: 750; }
  .download-copy p { color: var(--muted); font-size: 13px; margin-top: 4px; }
  .download-copy .download-detail { font-size: 12px; }
  .download-card[data-ready=true] { background: var(--green-soft); border-color: transparent; }
  .download-card[data-ready=true] .download-icon { background: var(--card); }
  .download-card[data-ready=true] #download-detail { display: none; }
  .download-meter { height: 7px; border-radius: 8px; background: var(--line); overflow: hidden; margin-top: 10px; }
  .download-meter span { display: block; width: 0; height: 100%; background: var(--green); }
  .secondary { min-height: 48px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); padding: 11px 15px; font-size: 14px; font-weight: 650; }
  .secondary:hover { border-color: var(--green); }
  .primary { min-height: 50px; display: flex; align-items: center; justify-content: center; gap: 9px; background: var(--green); color: var(--button-ink); border: 0; border-radius: 16px; padding: 13px 20px; font-weight: 700; }
  .quiet-button { border: 0; background: var(--soft); border-radius: 16px; padding: 11px 15px; min-height: 48px; font-size: 14px; font-weight: 650; }
  .quiet-button:hover { background: var(--green-soft); }
  .connection { font-size: 13px; color: var(--muted); }
  .connection:empty { display: none; }
  .edition-update { margin-top: 20px; }
  .edition-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
  .update-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); padding: 16px; margin-top: 20px; font-size: 14px; }

  .listening-nav { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 5; display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; width: min(420px,calc(100% - 32px)); padding: 7px; background: var(--card); border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 5px 30px var(--nav-shadow); }
  .nav-button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 59px; padding: 7px; border: 0; border-radius: 20px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
  .nav-button svg { width: 25px; height: 25px; }
  .nav-button.is-selected { background: var(--green-soft); color: var(--green); }
  [data-mode=bedtime] #sleep-open:not(.is-selected) { color: var(--accent); }
  #sleep-open[data-active=true] { background: var(--lilac); color: var(--ink); }
  .nav-status { position: absolute; top: -7px; right: 0; border: 2px solid var(--card); background: var(--green); color: var(--button-ink); border-radius: 10px; padding: 1px 6px; font-size: 10px; }

  .unlock-card { max-width: 560px; padding: 26px; border: 1px solid var(--line); border-radius: 26px; background: var(--card); margin: 8px auto 24px; }
  .unlock-card h2 { font-size: 28px; margin: 8px 0 12px; }
  .unlock-card>p:not(.eyebrow) { color: var(--muted); font-size: 15px; }
  .unlock-card form { margin-top: 24px; }
  .unlock-card label { display: block; font-size: 14px; margin-bottom: 8px; }
  .unlock-card input { display: block; width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); padding: 12px; font-size: 16px; }
  .unlock-card .primary { width: 100%; margin-top: 12px; }

  dialog { position: fixed; inset: 0; margin: auto; width: min(540px,calc(100% - 32px)); max-width: none; height: fit-content; max-height: 85vh; max-height: 85dvh; overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: 28px; background: var(--card); color: var(--ink); box-shadow: 0 15px 80px #0004; overscroll-behavior: contain; }
  dialog::backdrop { background: #111b306b; backdrop-filter: blur(3px); }
  .dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
  .dialog-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--soft); color: var(--ink); font-size: 28px; line-height: 1; }
  .dialog-header h2 { font-size: 25px; letter-spacing: -.6px; margin-top: 6px; }
  .dialog-header .eyebrow { font-size: 10px; letter-spacing: .7px; margin-bottom: 8px; }
  .dialog-note { color: var(--muted); font-size: 15px; margin: 16px 0 20px; }
  .sheet-title { display: flex; align-items: center; gap: 10px; }
  .sheet-title h2 { margin: 0; }
  .sheet-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 16px; background: var(--lilac); }
  .chapter-list { list-style: none; padding: 0; margin: 16px 0 0; }
  .chapter-list li + li { margin-top: 8px; }
  .chapter-list button { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 78px; border: 1px solid var(--line); border-radius: 18px; background: transparent; padding: 13px; text-align: left; }
  .chapter-list button:hover,.chapter-list [aria-current=true] { background: var(--green-soft); border-color: var(--green); }
  .chapter-number { display: grid; place-items: center; background: var(--soft); color: var(--ink); width: 36px; height: 40px; border-radius: 12px; font-size: 17px; font-weight: 800; flex-shrink: 0; }
  .chapter-list [aria-current=true] .chapter-number { background: var(--green); color: var(--button-ink); }
  .chapter-title { flex: 1; font-size: 15px; font-weight: 650; line-height: 1.4; }
  .chapter-duration { color: var(--muted); font-size: 12px; white-space: nowrap; }
  .chapter-list svg { width: 15px; height: 15px; fill: var(--green); stroke: var(--green); }
  .timer-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .timer-choices button { min-height: 82px; text-align: center; padding: 15px; border: 1px solid var(--line); border-radius: 20px; background: transparent; font-size: 17px; font-weight: 700; }
  .timer-choices button:last-child { grid-column: 1 / -1; min-height: 56px; }
  .timer-choices [aria-pressed=true] { background: var(--lilac); border-color: var(--green); }
  .settings-section { padding: 24px 0; border-bottom: 1px solid var(--line); }
  .settings-section:last-child { border: 0; padding-bottom: 0; }
  .settings-section h3,.settings-label { display: block; font-size: 16px; font-weight: 750; margin-bottom: 9px; }
  .settings-section p { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
  .mode-switch { display: flex; gap: 6px; padding: 4px; border-radius: 18px; background: var(--soft); }
  .mode-switch button { display: flex; align-items: center; justify-content: center; gap: 5px; flex: 1; min-height: 48px; padding: 9px; background: none; border: 0; border-radius: 14px; font-size: 13px; font-weight: 650; }
  .mode-switch svg { width: 17px; height: 17px; }
  .mode-switch [aria-pressed=true] { background: var(--card); box-shadow: 0 2px 5px var(--shadow); }
  select { background: var(--bg); color: var(--ink); padding: 12px; min-height: 50px; border: 1px solid var(--line); border-radius: 14px; font-size: 16px; width: 100%; }
  .settings-actions,.confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; }
  .fine-print { font-size: 12px !important; }
  .danger { color: #b34636; }
  [data-mode=bedtime] .danger { color: #ffb2a5; }
  details { margin-top: 8px; }
  summary { padding: 12px 0; min-height: 48px; font-size: 14px; color: var(--ink); }
  details ol { padding-left: 23px; }
  details li { margin: 10px 0; color: var(--muted); font-size: 14px; }
}

@layer responsive {
  @media (max-width: 800px) {
    .site-header { max-width: 620px; padding: calc(14px + env(safe-area-inset-top)) 24px 6px; }
    main { max-width: 620px; padding-inline: 24px; }
    .library-book { grid-template-columns: minmax(0,1fr); gap: 16px; }
    .book-visual,.book-intro,.player-card,.download-card,.connection { grid-column: 1; grid-row: auto; }
    .book-visual { min-height: 220px; border-radius: 28px; }
    .book-cover { width: 130px; border-radius: 4px 8px 8px 4px; }
    .cover-type p { font-size: 3px; letter-spacing: .55px; }
    .cover-type h2 { font-size: 20px; margin: 12px 0 6px; letter-spacing: -.7px; }
    .cover-type span { font-size: 5px; }
    .scene-orbit { width: 290px; height: 205px; }
    .star-one { left: 15%; top: 30px; }
    .star-two { right: 16%; top: 50px; }
    .star-three { left: 20%; bottom: 30px; }
    .spark-one { left: 10%; top: 100px; }
    .spark-two { right: 20%; bottom: 40px; }
    .book-intro { text-align: center; padding-top: 0; }
    .book-intro h1 { font-size: 25px; }
    .book-facts { justify-content: center; margin-top: 5px; font-size: 13px; }
  }
  @media (max-width: 480px) {
    .setup-panel { padding: 20px; border-radius: 25px; }
    .setup-heading { gap: 11px; }
    .setup-heading h1 { font-size: 22px; }
    .setup-app-icon { width: 46px; height: 50px; border-radius: 16px; }
    .setup-steps li { gap: 11px; }
    .install-picture { width: 58px; height: 70px; }
    .install-steps li { gap: 13px; }
    .site-header { padding-inline: 20px; }
    .brand { font-size: 22px; gap: 8px; letter-spacing: -.8px; }
    .brand-icon { width: 38px; height: 40px; border-radius: 14px; }
    .brand-icon svg { width: 23px; height: 23px; }
    main { padding-inline: 20px; }
    .mode-toggle svg { width: 17px; height: 17px; }
    .book-visual { min-height: 156px; border-radius: 25px; }
    .book-cover { width: 96px; border-radius: 3px 7px 7px 3px; }
    .book-spine { width: 4px; }
    .cover-type p { font-size: 2px; letter-spacing: .5px; }
    .cover-type h2 { font-size: 14px; margin: 10px 0 4px; letter-spacing: -.5px; }
    .cover-type span { font-size: 3.5px; }
    .scene-orbit { width: 240px; height: 150px; }
    .star-one { width: 24px; height: 24px; left: 14%; top: 23px; }
    .star-two { width: 19px; height: 19px; right: 16%; top: 25px; }
    .star-three { left: 22%; bottom: 20px; }
    .spark-one { top: 85px; left: 12%; width: 6px; height: 6px; }
    .spark-two { right: 13%; bottom: 28px; }
    .library-book { gap: 13px; }
    .book-intro h1 { font-size: 22px; letter-spacing: -.6px; }
    .book-facts { font-size: 12px; }
    .player-card { border-radius: 25px; padding: 17px 19px 16px; }
    .player-card h3 { font-size: 21px; margin-top: 12px; }
    #place-label { font-size: 12px; }
    #chapter-count { font-size: 11px; padding: 5px 9px; }
    .transport { gap: 25px; margin: 17px 0 12px; }
    .play { width: 96px; height: 96px; border-radius: 33px; font-size: 14px; }
    .play svg { width: 32px; height: 32px; }
    .skip { width: 56px; min-height: 69px; font-size: 11px; gap: 4px; border-radius: 20px; }
    .skip svg { width: 25px; height: 25px; }
    .download-card { padding: 13px; gap: 10px; flex-wrap: wrap; border-radius: 20px; }
    .download-copy { min-width: 175px; }
    .download-card[data-ready=true] { flex-wrap: nowrap; }
    .download-card[data-ready=true] .download-copy { min-width: 0; }
    .download-card>.secondary { margin-left: 52px; }
    .download-copy h3 { font-size: 14px; }
    .download-copy p { font-size: 12px; }
    .download-icon { width: 38px; height: 38px; border-radius: 13px; }
    .download-icon svg { width: 22px; height: 22px; }
    .listening-nav { bottom: calc(10px + env(safe-area-inset-bottom)); }
    dialog { padding: 21px; border-radius: 26px; }
    .dialog-header h2 { font-size: 24px; }
    .dialog-note { font-size: 14px; }
    .chapter-list button { gap: 10px; padding: 12px 10px; }
    .chapter-title { font-size: 14px; }
    .chapter-number { width: 32px; height: 38px; font-size: 16px; }
    .chapter-duration { font-size: 11px; }
    .chapter-list svg { width: 13px; height: 13px; }
  }
  @media (max-width: 355px) {
    .site-header, main { padding-inline: 15px; }
    .brand { font-size: 20px; }
    .brand-icon { display: none; }
    .transport { gap: 17px; }
    .book-intro h1 { font-size: 20px; }
    .chapter-duration { display: none; }
  }
  @media (max-width: 480px) and (max-height: 700px) {
    .library-book { grid-template-columns: 66px minmax(0,1fr); column-gap: 14px; }
    .book-visual { grid-column: 1; grid-row: 1; min-height: 90px; border-radius: 17px; }
    .book-cover { width: 51px; border-radius: 2px 4px 4px 2px; }
    .cover-type h2 { font-size: 8px; margin: 5px 0; letter-spacing: -.3px; }
    .scene-orbit,.scene-star,.scene-spark { display: none; }
    .book-intro { grid-column: 2; grid-row: 1; align-self: center; text-align: left; }
    .book-intro h1 { font-size: 21px; }
    .book-facts { justify-content: flex-start; font-size: 11px; gap: 7px; }
    .player-card,.download-card,.connection { grid-column: 1 / -1; }
  }
  @media (prefers-reduced-motion: reduce) {
    *,*::before,*::after { transition: none !important; scroll-behavior: auto !important; }
  }
  @media (display-mode: standalone) { #install-note { display: none; } }
}
