/* ══════════════════════════════════════════════════════════════════════════
   DREAM MACHINE PLAYER — the animated book reader
   Themed on the Poppy the Dragon books: teal scales, pink ear-and-wing accents, peach belly
   cream paper, and Poppy's knitted rainbow scarf (pink / blue / yellow / orange).
   Scripts: js/dm-cast.js (characters), js/dm-stage.js (scenes), js/dream-machine.js (player).
   ══════════════════════════════════════════════════════════════════════════ */
.dm-reader {
    --pp-teal: #5aae98;
    --pp-teal-deep: #12403b;
    --pp-teal-night: #08201e;
    --pp-pink: #f4899a;
    --pp-coral: #f07aa0;
    --pp-peach: #f7c8a0;
    --pp-cream: #fff8ec;
    --pp-ink: #2b3a4a;
    --scarf-pink: #f06c9b;
    --scarf-blue: #4fb3e8;
    --scarf-yellow: #f7c948;
    --scarf-orange: #f39a4b;
    --scarf-stripes: repeating-linear-gradient(90deg,
        var(--scarf-pink) 0 26px, var(--scarf-blue) 26px 52px,
        var(--scarf-yellow) 52px 78px, var(--scarf-orange) 78px 104px);
    --knit: repeating-linear-gradient(60deg, rgba(255,255,255,.24) 0 2px, transparent 2px 5px),
        repeating-linear-gradient(-60deg, rgba(0,0,0,.09) 0 2px, transparent 2px 5px);

    position: fixed; inset: 0; z-index: 3000; display: flex; flex-direction: column;
    background:
        radial-gradient(ellipse 60% 40% at 12% 100%, rgba(244, 137, 154, .16), transparent 70%),
        radial-gradient(ellipse 50% 40% at 92% 8%, rgba(176, 124, 224, .16), transparent 70%),
        radial-gradient(ellipse at 50% 0%, #1f5c55 0%, var(--pp-teal-deep) 55%, var(--pp-teal-night) 100%);
    color: var(--pp-cream);
    animation: dmFade .35s ease both;
}
.dm-reader[hidden] { display: none; }
body.dm-no-scroll { overflow: hidden; }
@keyframes dmFade { from { opacity: 0; } to { opacity: 1; } }

/* Poppy's scales, very faintly, behind everything */
.dm-reader-scales {
    position: absolute; inset: 0; pointer-events: none; opacity: .8;
    background-image:
        radial-gradient(circle at 50% 0, transparent 12px, rgba(130, 205, 182, .07) 13px, transparent 15px),
        radial-gradient(circle at 0 100%, transparent 12px, rgba(130, 205, 182, .07) 13px, transparent 15px),
        radial-gradient(circle at 100% 100%, transparent 12px, rgba(130, 205, 182, .07) 13px, transparent 15px);
    background-size: 30px 18px;
    mask-image: radial-gradient(ellipse at 50% 40%, transparent 30%, #000 85%);
}

/* ── Header ── */
.dm-reader-header {
    position: relative; display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 12px 28px; background: rgba(4, 22, 20, .35); border-bottom: 1px solid rgba(130, 205, 182, .16);
}
.dm-reader-titles { min-width: 0; }
.dm-reader-title { font-family: var(--font-playful); font-size: 1.35rem; color: var(--pp-cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-reader-meta { color: #f9b9c4; font-size: .85rem; }
.dm-reader-controls { display: flex; gap: 10px; flex-shrink: 0; }
.dm-control {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 46px; height: 46px; padding: 0 12px; border-radius: 30px; cursor: pointer;
    background: rgba(130, 205, 182, .1); border: 1px solid rgba(130, 205, 182, .3); color: var(--pp-cream);
    font-family: var(--font-playful); font-weight: 600; font-size: 1rem; transition: var(--transition-smooth);
}
.dm-control-wide { padding: 0 18px; }
.dm-control:hover { background: rgba(244, 137, 154, .3); border-color: var(--pp-pink); }
.dm-control.active { background: var(--pp-coral); border-color: var(--pp-coral); color: #3d0d20; }
.dm-control[hidden] { display: none; }
.dm-control:focus-visible, .dm-pbtn:focus-visible, .dm-knot:focus-visible,
.dm-big-play:focus-visible, .dm-big-read:focus-visible { outline: 3px solid var(--scarf-yellow); outline-offset: 3px; }

/* ── The book ── */
.dm-reader-body {
    position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 22px 24px 14px;
}
.dm-book {
    position: relative; display: flex;
    width: min(1060px, 100%, calc((100vh - 250px) * 1.84));
    width: min(1060px, 100%, calc((100dvh - 250px) * 1.84));
    aspect-ratio: 1.84;
    border-radius: 18px; perspective: 2400px;
    box-shadow: 0 34px 70px rgba(0, 0, 0, .5), 0 0 0 8px #2f6f62, 0 0 0 10px #1c4d45, 0 0 46px 12px rgba(90, 174, 152, .25);
}
/* The spine's shadow */
.dm-book::after {
    content: ''; position: absolute; top: 0; bottom: 0; left: calc(50% - 22px); width: 44px; pointer-events: none; z-index: 5;
    background: linear-gradient(90deg, transparent, rgba(60, 40, 70, .2) 42%, rgba(60, 40, 70, .32) 50%, rgba(60, 40, 70, .2) 58%, transparent);
}
.dm-page {
    position: relative; flex: 0 0 50%; min-width: 0; overflow: hidden; background: var(--pp-cream); color: var(--pp-ink);
    background-image:
        radial-gradient(circle at 92% 6%, rgba(244, 137, 154, .14), transparent 34%),
        radial-gradient(circle at 6% 96%, rgba(90, 174, 152, .14), transparent 36%);
}
.dm-page-picture { border-radius: 18px 0 0 18px; }
.dm-words { border-radius: 0 18px 18px 0; display: flex; flex-direction: column; padding: 46px 54px 22px; }

.dm-plate { position: absolute; inset: 14px; }
.dm-plate > *, .dm-ghost-left > *, .dm-leaf-picture > * { position: absolute; inset: 0; border-radius: 14px; overflow: hidden; }
.dm-ghost-left > *, .dm-leaf-picture > * { inset: 14px; }
.dm-plate-cover .dm-stage { display: none; }

/* Cover art on its own plate */
.dm-cover-art {
    display: flex; align-items: center; justify-content: center; padding: 22px;
    background: radial-gradient(circle at 50% 30%, #2a7a6c, #0e3632 80%);
}
.dm-cover-art picture { height: 100%; display: flex; justify-content: center; align-items: center; }
.dm-cover-art img {
    max-height: 100%; width: auto; max-width: 100%; object-fit: contain; border-radius: 10px;
    box-shadow: 0 16px 34px rgba(0, 0, 0, .5), 0 0 30px rgba(247, 201, 72, .35);
    animation: dmCover 1s cubic-bezier(.25, 1, .5, 1) both;
}
@keyframes dmCover { from { transform: rotateY(-35deg) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* The scarf bookmark hanging over the words page */
.dm-ribbon {
    position: absolute; top: 0; right: 44px; width: 26px; height: 92px; z-index: 2;
    background: var(--knit), linear-gradient(180deg, var(--scarf-pink) 0 25%, var(--scarf-blue) 25% 50%, var(--scarf-yellow) 50% 75%, var(--scarf-orange) 75%);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .18));
}

/* ── Words ── */
.dm-words-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 22px; overflow-x: hidden; overflow-y: auto; }
.dm-page-text { font-family: var(--font-playful); font-weight: 500; font-size: clamp(1.1rem, 1.75vw, 1.55rem); line-height: 1.62; color: var(--pp-ink); }
.dm-page-text em { font-style: italic; color: #c2405f; }
.dm-word { display: inline-block; border-radius: 6px; animation: dmWord .45s ease both; animation-delay: calc(var(--i, 0) * 40ms + 200ms); transition: color .2s, background-color .2s, box-shadow .2s; }
@keyframes dmWord { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
/* Karaoke: once the words are being read, unread ones soften and the current word glows */
.dm-karaoke .dm-word { color: #8d99a6; }
.dm-karaoke .dm-word.is-read { color: var(--pp-ink); }
.dm-karaoke em .dm-word.is-read { color: #c2405f; }
.dm-karaoke .dm-word.is-now { color: #5b1532; background: rgba(247, 201, 72, .6); box-shadow: 0 0 0 3px rgba(247, 201, 72, .6); }
.dm-page-number { align-self: center; padding-top: 10px; font-family: var(--font-playful); font-size: .85rem; color: #8aa59e; }
.dm-page-extra:empty { display: none; }
.dm-page-extra { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.dm-cta-note { font-size: .8rem; color: #7b7396; }
.dm-words-cta { background: linear-gradient(170deg, #fff7d6, #fde7f0); }

/* Title page */
.dm-words-cover .dm-words-inner { align-items: center; text-align: center; }
.dm-words-cover .dm-page-text { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dm-cover-kicker {
    font-size: .85rem; font-weight: 600; padding: 4px 14px; border-radius: 20px;
    background: rgba(90, 174, 152, .16); color: #2f6f62;
}
.dm-cover-title { font-weight: 700; font-size: clamp(1.6rem, 2.8vw, 2.4rem); line-height: 1.15; color: #1f5c55; }
.dm-cover-by { font-size: 1rem; color: #b5527a; }
.dm-words-cover .dm-page-extra { align-items: center; }
.dm-big-play, .dm-big-read {
    display: inline-flex; align-items: center; gap: 10px; cursor: pointer; border-radius: 40px;
    font-family: var(--font-playful); font-weight: 700; transition: var(--transition-smooth);
}
.dm-big-play {
    padding: 14px 30px 14px 22px; border: 0; font-size: 1.2rem; color: #fff;
    background: linear-gradient(135deg, var(--pp-coral), #e0567f);
    box-shadow: 0 8px 20px rgba(224, 86, 127, .4), inset 0 -3px 0 rgba(0, 0, 0, .12);
    animation: dmBeckon 2.4s ease-in-out 1s infinite;
}
.dm-big-play:hover { transform: translateY(-2px) scale(1.03); }
.dm-big-read { padding: 10px 22px; font-size: 1rem; background: transparent; color: #2f6f62; border: 2px solid rgba(47, 111, 98, .35); }
.dm-big-read:hover { background: rgba(90, 174, 152, .14); }
@keyframes dmBeckon { 0%, 100% { box-shadow: 0 8px 20px rgba(224, 86, 127, .4), 0 0 0 0 rgba(240, 122, 160, .5); } 50% { box-shadow: 0 8px 20px rgba(224, 86, 127, .4), 0 0 0 12px rgba(240, 122, 160, 0); } }

/* ── Page flip ── */
.dm-ghost, .dm-leaf { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 6; }
.dm-ghost[hidden], .dm-leaf[hidden] { display: none; }
.dm-ghost { background: var(--pp-cream); }
.dm-ghost-left { left: 0; border-radius: 18px 0 0 18px; }
.dm-ghost-right { left: 50%; border-radius: 0 18px 18px 0; }
.dm-ghost-right > .dm-words, .dm-leaf-front > .dm-words { position: absolute; inset: 0; border-radius: inherit; }
.dm-ghost .dm-word, .dm-leaf .dm-word { animation: none; }
.dm-leaf { z-index: 7; transform-style: preserve-3d; pointer-events: none; }
.dm-leaf-next { left: 50%; transform-origin: left center; }
.dm-leaf-prev { left: 0; transform-origin: right center; }
.dm-leaf-face { position: absolute; inset: 0; backface-visibility: hidden; background: var(--pp-cream); overflow: hidden; }
.dm-leaf-next .dm-leaf-face.dm-leaf-front { border-radius: 0 18px 18px 0; }
.dm-leaf-prev .dm-leaf-face.dm-leaf-front { border-radius: 18px 0 0 18px; }
.dm-leaf-back { transform: rotateY(180deg); }
.dm-leaf-next .dm-leaf-back { border-radius: 18px 0 0 18px; }
.dm-leaf-prev .dm-leaf-back { border-radius: 0 18px 18px 0; }
.dm-leaf-face::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.dm-leaf-next.is-turning { animation: dmLeafNext .76s cubic-bezier(.45, .05, .35, 1) both; }
.dm-leaf-prev.is-turning { animation: dmLeafPrev .76s cubic-bezier(.45, .05, .35, 1) both; }
.is-turning .dm-leaf-face::after { animation: dmLeafShade .76s ease both; }
.dm-leaf-next .dm-leaf-front::after { background: linear-gradient(90deg, rgba(40, 30, 60, .35), transparent 60%); }
.dm-leaf-prev .dm-leaf-front::after { background: linear-gradient(270deg, rgba(40, 30, 60, .35), transparent 60%); }
.dm-leaf-back::after { background: linear-gradient(90deg, transparent 40%, rgba(40, 30, 60, .25)); }
@keyframes dmLeafNext { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
@keyframes dmLeafPrev { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
@keyframes dmLeafShade { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }

/* Narrow screens slide the page in instead */
.dm-turn-next { animation: dmSlideNext .45s cubic-bezier(.25, 1, .5, 1) both; }
.dm-turn-prev { animation: dmSlidePrev .45s cubic-bezier(.25, 1, .5, 1) both; }
.dm-open-anim { animation: dmOpen .6s cubic-bezier(.25, 1, .5, 1) both; }
@keyframes dmSlideNext { from { transform: translateX(40px) rotate(1deg); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes dmSlidePrev { from { transform: translateX(-40px) rotate(-1deg); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes dmOpen { from { transform: scale(.88) translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Paused */
.dm-is-frozen .dm-page-picture::after {
    content: '⏸ Paused'; position: absolute; top: 26px; left: 26px; z-index: 4; padding: 5px 14px; border-radius: 20px;
    background: rgba(8, 32, 30, .72); color: var(--pp-cream); font-family: var(--font-playful); font-weight: 600; font-size: .9rem;
}

/* ── Player bar ── */
.dm-player {
    display: flex; align-items: center; gap: 22px; margin-top: 26px;
    width: min(1060px, 100%, calc((100vh - 250px) * 1.84));
    width: min(1060px, 100%, calc((100dvh - 250px) * 1.84));
}
.dm-player-buttons { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dm-pbtn {
    display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%;
    border: 0; cursor: pointer; background: var(--pp-cream); color: #1f5c55; transition: var(--transition-smooth);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1);
}
.dm-pbtn:hover:not(:disabled) { transform: translateY(-2px); background: #fff; }
.dm-pbtn:disabled { opacity: .35; cursor: not-allowed; }
.dm-pbtn-play { width: 62px; height: 62px; color: #fff; background: linear-gradient(135deg, var(--pp-coral), #e0567f); box-shadow: 0 6px 18px rgba(224, 86, 127, .45), inset 0 -3px 0 rgba(0, 0, 0, .14); }
.dm-pbtn-play svg { width: 28px; height: 28px; }
.dm-pbtn-play:hover:not(:disabled) { background: linear-gradient(135deg, #f58db0, #e86890); }
.dm-pbtn-play.is-playing { animation: dmPlayPulse 2s ease-in-out infinite; }
@keyframes dmPlayPulse { 0%, 100% { box-shadow: 0 6px 18px rgba(224, 86, 127, .45), 0 0 0 0 rgba(240, 122, 160, .55); } 50% { box-shadow: 0 6px 18px rgba(224, 86, 127, .45), 0 0 0 10px rgba(240, 122, 160, 0); } }

/* Poppy's scarf is the progress bar; each knot is a page */
.dm-scarf { position: relative; flex: 1; height: 26px; display: flex; align-items: center; }
.dm-scarf-track {
    position: relative; width: 100%; height: 16px; border-radius: 8px; overflow: hidden;
    background: var(--knit), var(--scarf-stripes); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25);
}
.dm-scarf-track::before { content: ''; position: absolute; inset: 0; background: rgba(8, 32, 30, .62); }
.dm-scarf-fill {
    position: absolute; top: 0; bottom: 0; left: 0; width: 0; z-index: 1; border-radius: 8px;
    background: var(--knit), var(--scarf-stripes); transition: width .5s cubic-bezier(.25, 1, .5, 1);
}
.dm-knots { position: absolute; inset: 0; }
.dm-knot {
    position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; padding: 0; border-radius: 50%; cursor: pointer;
    background: #0e3632; border: 3px solid rgba(255, 248, 236, .55); transition: transform .2s, background-color .2s, border-color .2s;
}
.dm-knot:first-child { margin-left: 0; }
.dm-knot:last-child { margin-left: -22px; }
.dm-knot:hover { transform: scale(1.2); }
.dm-knot.is-done { background: var(--pp-cream); border-color: var(--pp-cream); }
.dm-knot.is-here { background: var(--scarf-yellow); border-color: #fff; transform: scale(1.25); box-shadow: 0 0 0 4px rgba(247, 201, 72, .35); }
.dm-progress-label { flex-shrink: 0; min-width: 13ch; text-align: right; color: rgba(255, 248, 236, .82); font-family: var(--font-playful); font-size: .95rem; }
.dm-hint { margin-top: 12px; color: rgba(255, 248, 236, .45); font-size: .8rem; text-align: center; }

/* Poppy keeps you company in the corner */
.dm-mascot { flex-shrink: 0; width: 76px; margin: -30px -6px -12px 0; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.dm-mascot svg { display: block; width: 100%; height: auto; }

/* ══ Stage ══════════════════════════════════════════════════════════════ */
.dm-stage { position: absolute; inset: 0; overflow: hidden; container-type: size; background: #1b1f4a; isolation: isolate; }
.dm-stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 20; box-shadow: inset 0 0 40px rgba(20, 10, 40, .35); border-radius: inherit; }
.dm-bg { position: absolute; inset: 0; }
.dm-bg-none { background: transparent; }
.dm-bg-night { background: radial-gradient(circle at 78% 18%, rgba(253, 243, 196, .25), transparent 24%), linear-gradient(180deg, #0f1a4a 0%, #2b2470 55%, #4a3684 100%); }
.dm-bg-sky { background: radial-gradient(circle at 50% 10%, rgba(255, 246, 201, .22), transparent 40%), linear-gradient(180deg, #0a0f38 0%, #1f1c63 55%, #3a3a8f 100%); }
.dm-bg-dusk { background: radial-gradient(circle at 30% 70%, rgba(255, 196, 150, .4), transparent 40%), linear-gradient(180deg, #3b2e74 0%, #a65f9c 55%, #f4a58a 100%); }
.dm-bg-day { background: radial-gradient(circle at 80% 15%, rgba(255, 244, 190, .9), transparent 18%), linear-gradient(180deg, #9fdcf5 0%, #d9f3ef 65%, #fff3d6 100%); }
.dm-bg-river { background: linear-gradient(180deg, #2a3b7a 0%, #7a63ae 50%, #e9a5b2 100%); }
.dm-bg-canopy { background: radial-gradient(circle at 50% 40%, #2f8070 0%, #17504a 50%, #0b302c 100%); }
.dm-bg-den { background: radial-gradient(circle at 30% 30%, rgba(255, 200, 140, .35), transparent 45%), linear-gradient(180deg, #4a3560 0%, #6b4a5e 100%); }
.dm-hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 34%; }
.dm-waves { position: absolute; left: 0; right: 0; bottom: 4%; height: 14%; }
.dm-waves span { position: absolute; left: -10%; width: 120%; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .45); animation: dmWave 3.4s ease-in-out infinite; }
.dm-waves span:nth-child(1) { top: 10%; } .dm-waves span:nth-child(2) { top: 38%; animation-delay: -.9s; }
.dm-waves span:nth-child(3) { top: 64%; animation-delay: -1.8s; } .dm-waves span:nth-child(4) { top: 90%; animation-delay: -2.6s; }
@keyframes dmWave { 0%, 100% { transform: translateX(-4%) scaleX(.9); opacity: .3; } 50% { transform: translateX(4%) scaleX(1); opacity: .8; } }

.dm-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.dm-fx-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.dm-cast { position: absolute; inset: 0; z-index: 3; }
.dm-fx-front { z-index: 10; }

/* Ambient effects */
.dm-fx { position: absolute; inset: 0; }
.dm-fx span { position: absolute; }
.dm-fx-stars span { width: 3px; height: 3px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 1px rgba(255, 255, 255, .8); animation: dmTwinkle 3s ease-in-out var(--d) infinite; transform: scale(var(--s)); }
@keyframes dmTwinkle { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.dm-fx-comets span {
    width: 18cqw; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, rgba(255, 246, 201, .9));
    animation: dmComet 6.5s linear var(--d) infinite; opacity: 0;
}
.dm-fx-comets span::after { content: ''; position: absolute; right: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #fff6c9; box-shadow: 0 0 10px 3px rgba(252, 211, 77, .8); }
@keyframes dmComet { 0% { transform: translate(-40cqw, 0) rotate(18deg); opacity: 0; } 8% { opacity: 1; } 40% { transform: translate(120cqw, 38cqh) rotate(18deg); opacity: 0; } 100% { opacity: 0; } }
.dm-fx-fireflies span { width: 6px; height: 6px; border-radius: 50%; background: #e9ff9a; box-shadow: 0 0 10px 4px rgba(214, 255, 120, .6); animation: dmDrift 5s ease-in-out var(--d) infinite alternate, dmTwinkle 2.2s ease-in-out var(--d) infinite; }
@keyframes dmDrift { from { transform: translate(0, 0); } to { transform: translate(var(--dx), var(--dy)); } }
.dm-fx-sparkles span { color: #fff1b3; font-size: calc(2.2cqw * var(--s)); text-shadow: 0 0 8px rgba(252, 211, 77, .9); animation: dmSparkle 2.8s ease-in-out var(--d) infinite; }
@keyframes dmSparkle { 0%, 100% { transform: scale(.3) rotate(0); opacity: 0; } 50% { transform: scale(1) rotate(90deg); opacity: 1; } }
.dm-fx-snow-glow span { width: 5px; height: 5px; border-radius: 50%; background: #fff; opacity: .7; animation: dmFall 7s linear var(--d) infinite; }
@keyframes dmFall { from { transform: translate(0, -20cqh); } to { transform: translate(var(--dx), 110cqh); } }

/* One-shot bursts */
.dm-burst { position: absolute; width: 0; height: 0; }
.dm-burst span {
    position: absolute; left: 0; top: 0; width: 8px; height: 8px; border-radius: 2px; margin: -4px 0 0 -4px;
    animation: dmBurst 1.7s cubic-bezier(.15, .7, .3, 1) var(--d) both;
}
.dm-burst .dm-star-bit, .dm-burst-hearts span, .dm-burst-sparkle span { width: auto; height: auto; font-size: 3cqw; line-height: 1; }
.dm-burst-hearts span { color: var(--pp-coral); }
.dm-burst-sparkle span { color: #fff1b3; text-shadow: 0 0 8px rgba(252, 211, 77, .9); }
@keyframes dmBurst {
    0% { transform: translate(0, 0) scale(.4); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translate(var(--dx), calc(var(--dy) + 70px)) rotate(var(--r)) scale(.5); opacity: 0; }
}
.dm-zzz { position: absolute; font-family: var(--font-playful); font-weight: 700; color: #cfe9ff; }
.dm-zzz span { position: absolute; left: 0; bottom: 0; font-size: 3.4cqw; opacity: 0; animation: dmZzz 2.7s ease-out var(--d) infinite; }
@keyframes dmZzz { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(5cqw, -9cqh) scale(1.3); opacity: 0; } }
.dm-trail { position: absolute; font-size: 2.6cqw; line-height: 1; transform: translate(-50%, -50%); text-shadow: 0 0 6px currentColor; animation: dmTrail 1.2s ease-out both; }
@keyframes dmTrail { from { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, 40%) scale(.3); } }

/* Actors */
.dm-actor { position: absolute; }
.dm-anchor-bottom { transform: translate(-50%, -100%); }
.dm-anchor-center { transform: translate(-50%, -50%); }
.dm-actor svg { display: block; width: 100%; height: auto; overflow: visible; }
.dm-actor-wait { visibility: hidden; }
.dm-actor-gone { opacity: 0; transition: opacity .6s ease; }
.dm-flip { transition: transform .35s ease; }
.dm-flip.is-flipped { transform: scaleX(-1); }
.dm-emoji { display: block; text-align: center; line-height: 1; font-size: calc(var(--size, 30) * .85cqw); filter: drop-shadow(0 6px 10px rgba(20, 10, 40, .35)); }

.dm-enter { animation: .9s cubic-bezier(.34, 1.4, .64, 1) both; }
.dm-enter-pop { animation-name: dmEnterPop; }
.dm-enter-fade { animation-name: dmEnterFade; animation-timing-function: ease; }
.dm-enter-fly-left { animation-name: dmEnterLeft; animation-duration: 1.3s; animation-timing-function: cubic-bezier(.25, 1, .5, 1); }
.dm-enter-fly-right { animation-name: dmEnterRight; animation-duration: 1.3s; animation-timing-function: cubic-bezier(.25, 1, .5, 1); }
.dm-enter-fall { animation-name: dmEnterFall; animation-duration: 1.1s; animation-timing-function: cubic-bezier(.5, 0, .75, 0); }
.dm-enter-rise { animation-name: dmEnterRise; animation-duration: 1.2s; }
.dm-enter-none { animation: none; }
@keyframes dmEnterPop { from { transform: scale(.15) rotate(-18deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dmEnterFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dmEnterLeft { from { transform: translateX(-110cqw); } to { transform: none; } }
@keyframes dmEnterRight { from { transform: translateX(110cqw); } to { transform: none; } }
@keyframes dmEnterFall { from { transform: translateY(-110cqh); } to { transform: none; } }
@keyframes dmEnterRise { from { transform: translateY(60cqh); opacity: 0; } to { transform: none; opacity: 1; } }

.dm-loop { animation: 4s ease-in-out var(--d, 0s) infinite; }
.dm-loop-bob { animation-name: dmBob; }
.dm-loop-float { animation-name: dmFloat; animation-duration: 5s; }
.dm-loop-sway { animation-name: dmSway; animation-duration: 3.4s; }
.dm-loop-breathe { animation-name: dmBreathe; animation-duration: 3.6s; }
.dm-loop-twinkle { animation-name: dmTwinkleBig; animation-duration: 2.4s; }
.dm-loop-spin { animation-name: dmSpin; animation-duration: 14s; animation-timing-function: linear; }
.dm-loop-none { animation: none; }
@keyframes dmBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
@keyframes dmFloat { 0%, 100% { transform: translate(0, 0) rotate(-3deg); } 50% { transform: translate(2%, -7%) rotate(3deg); } }
@keyframes dmSway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes dmBreathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, .98); } }
@keyframes dmTwinkleBig { 0%, 100% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.08); filter: brightness(1.25); } }
@keyframes dmSpin { to { transform: rotate(360deg); } }
.dm-loop-breathe { transform-origin: 50% 100%; }

.dm-say {
    position: absolute; left: 50%; bottom: 102%; transform: translateX(-50%); white-space: nowrap; z-index: 5;
    padding: .5em .9em; border-radius: 1.2em; background: #fff; color: var(--pp-ink);
    font-family: var(--font-playful); font-weight: 600; font-size: max(13px, 3.2cqw);
    box-shadow: 0 6px 14px rgba(0, 0, 0, .2); animation: dmSay .35s cubic-bezier(.34, 1.56, .64, 1) both;
}
.dm-say::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; }
@keyframes dmSay { from { transform: translateX(-50%) scale(.3); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.dm-flip.is-flipped .dm-say { transform: translateX(-50%) scaleX(-1); }

/* ══ Poppy rig ═══════════════════════════════════════════════════════════ */
.pp * { transform-box: fill-box; }
.pp .pp-root { transform-origin: 50% 100%; }
.pp .pp-wing-l { transform-origin: 95% 70%; animation: ppWingL 3.2s ease-in-out infinite; }
.pp .pp-wing-r { transform-origin: 5% 70%; animation: ppWingR 3.2s ease-in-out infinite; }
.pp .pp-tail { transform-origin: 0% 90%; animation: ppTail 2.6s ease-in-out infinite; }
.pp .pp-ear-l { transform-origin: 90% 85%; animation: ppEarL 7s ease-in-out infinite; }
.pp .pp-ear-r { transform-origin: 10% 85%; animation: ppEarR 7s ease-in-out .4s infinite; }
.pp .pp-head { transform-origin: 50% 95%; animation: ppHead 6s ease-in-out infinite; }
.pp .pp-eye { transform-origin: 50% 50%; animation: ppBlink 4.6s linear infinite; }
.pp .pp-scarf-end { transform-origin: 30% 0%; animation: ppScarf 2.2s ease-in-out infinite; }
.pp .pp-iris { transition: transform .3s ease; }
.pp .pp-arm-r { transform-origin: 40% 10%; }
@keyframes ppWingL { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-9deg); } }
@keyframes ppWingR { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(9deg); } }
@keyframes ppTail { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-7deg); } }
@keyframes ppEarL { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-9deg); } 94% { transform: rotate(3deg); } }
@keyframes ppEarR { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(9deg); } 94% { transform: rotate(-3deg); } }
@keyframes ppHead { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-2.5deg); } 70% { transform: rotate(2deg); } }
@keyframes ppBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes ppScarf { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(6deg); } }

/* Moods: every face part is hidden until the mood asks for it */
.pp .pp-eyes-closed, .pp .pp-eyes-happy, .pp .pp-brows, .pp .pp-mouth, .pp .pp-sweat { display: none; }
.pp-mood-happy .pp-m-smile { display: inline; }
.pp-mood-excited .pp-m-grin, .pp-mood-excited .pp-b-up { display: inline; }
.pp-mood-joy .pp-eyes-open { display: none; }
.pp-mood-joy .pp-eyes-happy, .pp-mood-joy .pp-m-grin { display: inline; }
.pp-mood-surprised .pp-m-o, .pp-mood-surprised .pp-b-up { display: inline; }
.pp-mood-surprised .pp-iris { transform: scale(.8); }
.pp-mood-angry .pp-m-frown, .pp-mood-angry .pp-b-angry { display: inline; }
.pp-mood-angry .pp-cheeks { opacity: .9; }
.pp-mood-nervous .pp-m-wobble, .pp-mood-nervous .pp-b-worried, .pp-mood-nervous .pp-sweat { display: inline; }
.pp-mood-nervous .pp-iris { transform: translate(-3px, 1px); }
.pp-mood-sad .pp-m-frown, .pp-mood-sad .pp-b-worried { display: inline; }
.pp-mood-sleep .pp-eyes-open { display: none; }
.pp-mood-sleep .pp-eyes-closed, .pp-mood-sleep .pp-m-sleep { display: inline; }
.pp .pp-bubble { transform-origin: 0% 50%; animation: ppBubble 3.6s ease-in-out infinite; }
@keyframes ppBubble { 0%, 100% { transform: scale(.4); } 50% { transform: scale(1.1); } }
.pp-mood-excited .pp-root { animation: ppBounce .9s ease-in-out infinite; }
@keyframes ppBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3%); } }

/* Poses */
.pp-pose-fly .pp-root { animation: ppHover 1.3s ease-in-out infinite; }
.pp-pose-fly .pp-wing-l { animation: ppFlapL .34s ease-in-out infinite; }
.pp-pose-fly .pp-wing-r { animation: ppFlapR .34s ease-in-out infinite; }
.pp-pose-fly .pp-feet { transform: translateY(-5px) scale(.9); transform-origin: 50% 0; }
.pp-pose-fly .pp-scarf-end { animation: ppScarfFly .5s ease-in-out infinite; }
.pp-pose-fly .pp-tail { animation-duration: 1s; }
@keyframes ppHover { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5%) rotate(2deg); } }
@keyframes ppFlapL { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-30deg); } }
@keyframes ppFlapR { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(30deg); } }
@keyframes ppScarfFly { 0%, 100% { transform: rotate(18deg) skewY(-4deg); } 50% { transform: rotate(32deg) skewY(4deg); } }
.pp-pose-hop .pp-root { animation: ppHop .55s ease-in-out infinite; }
@keyframes ppHop { 0%, 100% { transform: translateY(0) scale(1.04, .96); } 45% { transform: translateY(-9%) scale(.97, 1.03); } }
.pp-pose-sleep .pp-root { animation: ppBreathe 3.8s ease-in-out infinite; }
.pp-pose-sleep .pp-head { transform: rotate(-9deg) translateY(4%); animation: none; }
.pp-pose-sleep .pp-ear-l { transform: rotate(16deg); animation: none; }
.pp-pose-sleep .pp-ear-r { transform: rotate(-16deg); animation: none; }
.pp-pose-sleep .pp-wing, .pp-pose-sleep .pp-tail { animation-duration: 7s; }
.pp-pose-sleep .pp-eyes-open { display: none; }
.pp-pose-sleep .pp-eyes-closed { display: inline; }
.pp-pose-sleep .pp-mouth { display: none; }
.pp-pose-sleep .pp-m-sleep { display: inline; }
@keyframes ppBreathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.025, .985); } }

/* One-shot actions */
.pp-act-wave .pp-arm-r { animation: ppWave 1.4s ease-in-out; }
@keyframes ppWave { 0%, 100% { transform: rotate(0); } 20%, 60% { transform: rotate(-150deg); } 40%, 80% { transform: rotate(-115deg); } }
.pp-act-sneeze .pp-head { animation: ppSneeze 1.1s ease-in-out; }
.pp-act-sneeze .pp-eyes-open { display: none; }
.pp-act-sneeze .pp-eyes-closed { display: inline; }
@keyframes ppSneeze { 0% { transform: none; } 40% { transform: rotate(-10deg) translateY(-5%); } 55% { transform: rotate(9deg) translateY(4%) scale(1.05); } 100% { transform: none; } }
.pp-act-spin .pp-root { animation: ppSpin .9s ease-in-out; }
@keyframes ppSpin { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }
.pp-act-nod .pp-head { animation: ppNod .8s ease-in-out; }
@keyframes ppNod { 0%, 100% { transform: none; } 35% { transform: rotate(6deg) translateY(2%); } 70% { transform: rotate(-2deg); } }

/* ══ Supporting cast ═════════════════════════════════════════════════════ */
.bs .bs-frown, .bs .bs-tears { display: none; }
.bs-cry .bs-smile { display: none; }
.bs-cry .bs-frown, .bs-cry .bs-tears { display: inline; }
.bs .bs-glow { transform-box: fill-box; transform-origin: center; animation: bsGlow 2.4s ease-in-out infinite; }
.bs .bs-tear { transform-box: fill-box; animation: bsTear 1.3s ease-in infinite; }
.bs .bs-tear-2 { animation-delay: .6s; }
.bs .bs-eye { transform-box: fill-box; transform-origin: center; animation: ppBlink 3.8s linear infinite; }
@keyframes bsGlow { 0%, 100% { transform: scale(.92); opacity: .7; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes bsTear { from { transform: translateY(0); opacity: 1; } to { transform: translateY(16px); opacity: 0; } }
.tr .tr-light { animation: dmTwinkle 2.6s ease-in-out infinite; animation-delay: calc(var(--k) * -.37s); }
.tr .tr-canopy { transform-box: fill-box; transform-origin: 50% 100%; animation: dmSway 6s ease-in-out infinite; }
.cn .cn-star { transform-box: fill-box; transform-origin: center; animation: dmTwinkleBig 2s ease-in-out infinite; animation-delay: calc(var(--k) * -.4s); }
.cn .cn-lines { animation: cnDash 3s linear infinite; }
@keyframes cnDash { to { stroke-dashoffset: -28; } }
.rb .rb-band { stroke-dasharray: 300; stroke-dashoffset: 300; animation: rbDraw 1.2s ease-out both; animation-delay: calc(var(--k) * .14s); }
@keyframes rbDraw { to { stroke-dashoffset: 0; } }
.mn { animation: dmTwinkleBig 5s ease-in-out infinite; }

/* ── Small screens: picture above words, no page-flip leaf ── */
@media (max-width: 859px) {
    .dm-reader-header { padding: 8px 12px; }
    .dm-reader-title { font-size: 1.05rem; }
    .dm-control-wide span { display: none; }
    .dm-control-wide { padding: 0 12px; }
    .dm-reader-body { padding: 12px 12px 10px; justify-content: flex-start; }
    .dm-book { flex-direction: column; width: 100%; aspect-ratio: auto; flex: 1; min-height: 0; box-shadow: 0 20px 40px rgba(0, 0, 0, .45), 0 0 0 5px #2f6f62; }
    .dm-book::after { display: none; }
    .dm-page-picture { flex: 0 0 auto; height: min(46vh, 86vw); height: min(46dvh, 86vw); border-radius: 18px 18px 0 0; }
    .dm-plate { inset: 10px 10px 4px; }
    .dm-words { flex: 1 1 auto; min-height: 0; border-radius: 0 0 18px 18px; padding: 16px 20px 10px; }
    .dm-ribbon { right: 18px; width: 18px; height: 48px; }
    .dm-page-text { font-size: 1.12rem; line-height: 1.55; }
    .dm-cover-title { font-size: 1.5rem; }
    .dm-big-play { padding: 12px 24px 12px 18px; font-size: 1.05rem; }
    .dm-player { flex-wrap: wrap; gap: 10px 14px; margin-top: 14px; width: 100%; }
    .dm-player-buttons { order: 2; margin: 0 auto; }
    .dm-scarf { order: 1; flex-basis: 100%; }
    .dm-progress-label { order: 3; flex-basis: 100%; text-align: center; font-size: .85rem; }
    .dm-hint, .dm-mascot { display: none; }
}
@media (max-height: 640px) and (min-width: 860px) {
    .dm-hint { display: none; }
    .dm-player { margin-top: 16px; }
}

/* ── Calm mode: honour reduced motion. Scenes still compose; nothing moves on its own ── */
@media (prefers-reduced-motion: reduce) {
    .dm-reader, .dm-reader *, .dm-reader *::before, .dm-reader *::after {
        animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
        transition-duration: .001ms !important;
    }
    .dm-fx-comets, .dm-fx-snow-glow, .dm-trail { display: none; }
}
.dm-stage-still .dm-burst { display: none; }

/* Library card badge for books with animated scenes */
.dm-badge-anim { left: auto; right: 14px; background: #f07aa0; color: #3d0d20; }

/* ══════════════════════════════════════════════════════════════════════════
   MIDNIGHT STORYBOOK THEME (2026 redesign) — the reader embedded in dream-machine.html,
   restyled to the Stitch "Dream Machine Book Viewer": indigo spreads, amber highlights.
   ══════════════════════════════════════════════════════════════════════════ */
.dm-reader {
    --pp-cream: #1b1552;
    --pp-ink: #e2e0f4;
    --pp-teal-deep: #16123b;
    --pp-coral: #f59e0b;
    --pp-pink: #fbbf24;
    --scarf-pink: #fbbf24;
    --scarf-blue: #f59e0b;
    --scarf-yellow: #fbbf24;
    --scarf-orange: #f59e0b;
}
.dm-reader-inline {
    position: relative; inset: auto; z-index: 1; animation: none;
    border-radius: 2.25rem; overflow: hidden; scroll-margin-top: 96px;
    background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(124, 58, 237, .18), transparent 70%), linear-gradient(170deg, #1d1650, #16123b 60%);
    border: 1px solid #3b3272; box-shadow: 0 24px 50px rgba(5, 3, 20, .45);
}
.dm-reader-inline .dm-reader-scales { display: none; }
.dm-reader-inline .dm-reader-body { padding: 26px 28px 20px; }
.dm-reader:fullscreen { border-radius: 0; display: flex; flex-direction: column; }
.dm-reader:fullscreen .dm-reader-body { flex: 1; }

.dm-reader-header { background: rgba(17, 14, 46, .55); border-bottom: 1px solid rgba(59, 50, 114, .7); padding: 14px 24px; }
.dm-reader-title { font-family: 'Epilogue', var(--font-playful); font-weight: 700; color: #fbbf24; font-size: 1.15rem; }
.dm-reader-meta { color: #9890c7; }
.dm-control { background: #261f5b; border-color: #3b3272; color: #e2e0f4; font-family: 'Epilogue', var(--font-playful); font-size: .92rem; height: 42px; min-width: 42px; }
.dm-control:hover { background: #2d2470; border-color: #4d4294; }
.dm-control.active, .dm-control[aria-pressed="true"] { background: rgba(245, 158, 11, .16); border-color: rgba(251, 191, 36, .55); color: #fbbf24; }

.dm-book { box-shadow: 0 30px 60px rgba(0, 0, 0, .45), 0 0 0 1px #3b3272, 0 0 50px rgba(124, 58, 237, .18); }
.dm-book::after { background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .35) 45%, rgba(0, 0, 0, .5) 50%, rgba(0, 0, 0, .35) 55%, transparent); }
.dm-page { background-color: #1b1552; background-image: radial-gradient(circle at 92% 6%, rgba(124, 58, 237, .16), transparent 34%), radial-gradient(circle at 6% 96%, rgba(16, 185, 129, .08), transparent 36%); }
.dm-page-picture { background-color: #15103f; }
.dm-ghost, .dm-leaf-face { background: #1b1552; }
.dm-ribbon { width: 14px; right: 50px; height: 110px; background: linear-gradient(180deg, #fbbf24, #f59e0b 70%, #d97706); clip-path: none; border-radius: 0 0 7px 7px; box-shadow: 0 0 18px rgba(245, 158, 11, .45); }
.dm-page-text { color: #e2e0f4; font-family: 'Outfit', var(--font-playful); font-weight: 400; font-size: clamp(1.1rem, 1.7vw, 1.45rem); line-height: 1.75; }
.dm-page-text em { color: #fbbf24; font-style: normal; font-weight: 600; }
.dm-karaoke .dm-word { color: #6f68a3; }
.dm-karaoke .dm-word.is-read { color: #fefefe; }
.dm-karaoke em .dm-word.is-read { color: #fbbf24; }
.dm-karaoke .dm-word.is-now { color: #231300; background: #fbbf24; box-shadow: 0 0 0 3px #fbbf24, 0 0 18px rgba(245, 158, 11, .5); }
.dm-page-number { color: #9890c7; }
.dm-words-cta { background: linear-gradient(170deg, #241a5a, #2d1b4e); }
.dm-cta-note { color: #9890c7; }
.dm-cover-kicker { background: rgba(16, 185, 129, .12); color: #34d399; border: 1px solid rgba(52, 211, 153, .3); }
.dm-cover-title { color: #fefefe; font-family: 'Epilogue', var(--font-playful); font-weight: 800; }
.dm-cover-by { color: #fbbf24; }
.dm-big-play { color: #231300; background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 10px 26px rgba(245, 158, 11, .35); font-family: 'Epilogue', var(--font-playful); animation-name: dmBeckonAmber; }
@keyframes dmBeckonAmber { 0%, 100% { box-shadow: 0 10px 26px rgba(245, 158, 11, .35), 0 0 0 0 rgba(251, 191, 36, .5); } 50% { box-shadow: 0 10px 26px rgba(245, 158, 11, .35), 0 0 0 12px rgba(251, 191, 36, 0); } }
.dm-big-read { color: #e2e0f4; border-color: #3b3272; background: #16123b; font-family: 'Epilogue', var(--font-playful); }
.dm-big-read:hover { background: #261f5b; }
.dm-cover-art { background: radial-gradient(circle at 50% 30%, #2d2470, #110e2e 80%); }

/* Player bar: a panel of its own, amber play button in the middle */
.dm-player { margin-top: 22px; padding: 14px 22px; border-radius: 2rem; background: #1e184a; border: 1px solid #3b3272; }
.dm-pbtn { background: #261f5b; color: #e2e0f4; box-shadow: none; border: 1px solid #3b3272; }
.dm-pbtn:hover:not(:disabled) { background: #2d2470; }
.dm-pbtn-play { color: #231300; background: linear-gradient(135deg, #fbbf24, #f59e0b); border: 0; box-shadow: 0 8px 22px rgba(245, 158, 11, .4); }
.dm-pbtn-play:hover:not(:disabled) { background: linear-gradient(135deg, #fcd34d, #fbbf24); }
.dm-pbtn-play.is-playing { animation-name: dmPlayPulseAmber; }
@keyframes dmPlayPulseAmber { 0%, 100% { box-shadow: 0 8px 22px rgba(245, 158, 11, .4), 0 0 0 0 rgba(251, 191, 36, .5); } 50% { box-shadow: 0 8px 22px rgba(245, 158, 11, .4), 0 0 0 10px rgba(251, 191, 36, 0); } }
.dm-scarf-track { height: 6px; border-radius: 3px; background: #2d2470; box-shadow: none; }
.dm-scarf-track::before { display: none; }
.dm-scarf-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); border-radius: 3px; }
.dm-knot { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: #2d2470; border: 2px solid #4d4294; }
.dm-knot:last-child { margin-left: -14px; }
.dm-knot.is-done { background: #34d399; border-color: #34d399; }
.dm-knot.is-here { background: #fbbf24; border-color: #fff; box-shadow: 0 0 0 4px rgba(251, 191, 36, .3); }
.dm-progress-label { color: #9890c7; font-family: 'Epilogue', var(--font-playful); font-size: .88rem; }
.dm-is-frozen .dm-page-picture::after { background: rgba(17, 14, 46, .8); font-family: 'Epilogue', var(--font-playful); }
.dm-hint { display: none; }
.dm-guarantee { margin-top: 16px; text-align: center; font-size: .82rem; color: #9890c7; }

/* Viewer comforts */
.dm-reader.dm-warm .dm-book::before { content: ''; position: absolute; inset: 0; z-index: 8; pointer-events: none; border-radius: inherit; background: rgba(255, 150, 60, .16); mix-blend-mode: multiply; }
.dm-reader.dm-warm .dm-page-text { color: #f6e7c8; }
.dm-reader.dm-big-words .dm-page-text { font-size: clamp(1.3rem, 2.2vw, 1.9rem); }

@media (max-width: 859px) {
    .dm-reader-inline .dm-reader-body { padding: 14px 12px 12px; }
    .dm-reader-inline .dm-book { flex: none; }
    .dm-reader-inline .dm-words { min-height: 220px; }
    .dm-player { padding: 12px 14px; }
}

/* ── Library cards (rendered by js/dream-machine.js) in the new card style ── */
.dm-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; }
.dm-grid[aria-busy="true"]::before { color: #9890c7; font-family: 'Epilogue', var(--font-playful); }
.dm-card { background: #1e184a; border: 1px solid #3b3272; border-radius: 1.75rem; }
.dm-card:hover { border-color: #4d4294; box-shadow: 0 18px 40px rgba(5, 3, 20, .45); }
.dm-card-media { aspect-ratio: 4 / 4.2; background: #16123b; }
.dm-card-media img { object-position: center 38%; }
.dm-badge { font-family: 'Epilogue', var(--font-playful); border-radius: 8px; font-size: .72rem; padding: 4px 10px; top: 12px; left: 12px; }
.dm-badge-free, .dm-badge-peek { background: #fbbf24; color: #231300; }
.dm-badge-new, .dm-badge-anim { left: auto; right: 12px; background: rgba(45, 27, 78, .92); color: #fbbf24; border: 1px solid rgba(251, 191, 36, .3); }
.dm-card-title { font-family: 'Epilogue', var(--font-playful); font-size: 1.2rem; color: #fefefe; }
.dm-card-blurb { color: #9890c7; font-size: .9rem; }
.dm-card-meta { color: #34d399; font-size: .78rem; font-weight: 600; padding-top: 12px; border-top: 1px solid rgba(59, 50, 114, .7); }
.dm-card-actions .btn-primary { padding: 9px 16px; font-size: .88rem; }
.dm-filters { margin: 0; padding: 0; background: none; border: 0; width: auto; }
.dm-filter.pt-chip { padding: 8px 16px; font-size: .85rem; box-shadow: none; }
.dm-filter.pt-chip.active { background: #fbbf24; color: #231300; }
.dm-empty { color: #9890c7; }

#dm-free-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1024px) { #dm-free-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { #dm-free-grid { grid-template-columns: 1fr; } }

@media (max-width: 859px) {
    .dm-reader-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
    .dm-reader-titles { flex: 1 1 100%; }
    .dm-reader-title { white-space: normal; }
    .dm-reader-controls { flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; }
}
