.cb-story-overlay.res-host{opacity:1;backdrop-filter:none;position:absolute;inset:0;z-index:94;display:flex;align-items:flex-end;justify-content:center;padding:clamp(8px,2vw,28px);background:linear-gradient(0deg,#101e2af0,#101e2a18 76%);box-sizing:border-box;overflow:auto}
.res-host .res-dialogue{width:min(960px,100%);max-height:100%;display:grid;grid-template-columns:minmax(0,26%) minmax(0,1fr);align-items:end;gap:14px;overflow:auto;outline:none}
.res-host .res-portrait{display:block;width:100%;max-height:50vh;object-fit:contain;object-position:bottom;filter:drop-shadow(0 10px 20px #08131c88)}
.res-host .res-portrait[hidden]{display:none}.res-host .res-dialogue:has(.res-portrait[hidden]){grid-template-columns:1fr}
.res-host .res-body{min-width:0;padding:clamp(12px,2.4vw,26px);background:#172b39f5;color:#f6ebd7;border:1px solid #bc9f6f;border-radius:12px;box-shadow:0 14px 45px #08131c80}
.res-host .res-speaker{font:700 15px var(--cb-font-body);color:#edcf98;margin:0 0 9px}
.res-host .res-line{font:500 clamp(15px,1.5vw,20px)/1.6 var(--cb-font-body);min-height:2.8em;overflow-wrap:anywhere;margin:0 0 12px}
.res-host .res-controls,.res-host .res-choices{display:flex;flex-wrap:wrap;gap:7px}
.res-host button,.res-host select{border:1px solid #b69e79;background:#2a4352;color:#f6ebd7;border-radius:7px;min-height:44px;padding:8px 12px;font:650 12px var(--cb-font-body);cursor:pointer}
.res-host button:disabled{opacity:.42;cursor:default}.res-host .res-choices{margin-bottom:10px}.res-host .res-choices button{flex:1 1 180px;text-align:left;background:#3b4c50}
.res-host .res-history{max-height:20vh;overflow:auto;color:#d8d7c8;font:13px/1.5 var(--cb-font-body);margin-top:10px}
.res-host .res-dialogue[data-error] .res-body{border-color:#e38f80}
@media(max-width:700px){.res-host{padding:8px}.res-host .res-dialogue{display:flex;flex-direction:column;align-items:stretch;gap:5px}.res-host .res-portrait{height:clamp(100px,27vh,230px);width:auto;align-self:center}.res-host .res-controls{gap:5px}.res-host button,.res-host select{padding:7px 9px;font-size:11px}.res-host .res-line{font-size:15px}}
@media(max-height:480px) and (orientation:landscape){.res-host .res-dialogue{display:grid;grid-template-columns:22% minmax(0,1fr)}.res-host .res-portrait{height:auto;max-height:42vh}.res-host .res-body{padding:10px}.res-host .res-line{min-height:2em;font-size:14px}}

.res-host [hidden]{display:none!important}.res-host .res-choices:not(:empty)~.res-controls{margin-top:6px}.res-host .res-body:has(.res-choices:not(:empty)) .res-line{min-height:0;font-size:13px;color:#c3cdc7;margin-bottom:10px}

.res-key-panel{width:min(820px,100%);max-height:100%;overflow:auto;background:#172b39f5;border:1px solid #bc9f6f;border-radius:12px;color:#f6ebd7;padding:clamp(10px,2vw,20px);box-sizing:border-box}.res-key-panel h2{font:650 clamp(18px,2.5vw,28px) var(--cb-font-display);color:#edcf98;margin:0 0 8px}.res-key-hint,.res-key-message{font:500 14px/1.4 var(--cb-font-body);margin:4px 0}.res-key-message{color:#e38f80;min-height:1.4em}.res-key-board{height:clamp(145px,32vh,300px);position:relative;overflow:hidden;touch-action:none;background:linear-gradient(110deg,#253f45,#142b36);border:1px solid #826d4f;border-radius:9px}.res-key-recipient{position:absolute;left:77%;top:54%;transform:translate(-50%,-50%);width:32%;height:90%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;pointer-events:none}.res-key-recipient img{width:100%;min-height:0;flex:1;object-fit:contain}.res-key-recipient strong{font-size:12px;color:#edcf98;text-align:center}.res-host .res-key-piece{position:absolute;transform:translate(-50%,-50%);width:clamp(86px,24%,180px);height:auto;min-height:44px;background:none;padding:0;border:0;touch-action:none;cursor:grab;z-index:2;filter:drop-shadow(0 6px 8px #07121a88)}.res-key-piece img{width:100%;height:auto;pointer-events:none;display:block}.res-key-piece:focus-visible{outline:2px solid #edcf98}.res-key-panel .res-controls{justify-content:flex-end}
@media(max-height:450px) and (orientation:landscape){.res-key-board{height:34vh}.res-key-panel h2{font-size:18px;margin-bottom:3px}.res-key-panel{padding:8px}}

#stage .res-chapter-cinematic{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:0!important;margin:0!important;box-sizing:border-box;padding:0;display:block;z-index:2300;opacity:1;overflow:hidden;transform:none!important;backdrop-filter:none}
#stage .res-chapter-cinematic .cbcp-shell{min-height:0!important;height:100%;width:100%;box-sizing:border-box}
#stage .res-chapter-cinematic[hidden]{display:none!important}
.res-finale-latch>div{width:min(32rem,100%);margin:auto;padding:1.3rem;background:#172d3c;color:#f5e3c3;border:1px solid #bc9460;border-radius:12px;text-align:center}
.res-finale-latch progress{display:block;margin:1rem auto;width:88%;accent-color:#ecc687}
.res-finale-latch button{margin:5px;padding:.7rem 1rem;color:#f5e3c3;background:#304954;border:1px solid #bc9460;border-radius:6px;min-height:44px;touch-action:none}

/* Harbor chapter: the actual painted scene remains visible behind canonical dialogue. */
.res-host[data-scene^="harbor:"] .res-harbor-context{margin:0 0 12px;color:#c5e1d9;font:500 clamp(11px,1.3vw,15px)/1.45 var(--cb-font-body);max-width:65ch}
.res-host[data-scene="harbor:H-04"],.res-host[data-scene="harbor:H-05"]{isolation:isolate;background:#132b38}
.res-host[data-scene="harbor:H-04"]::before,.res-host[data-scene="harbor:H-05"]::before{content:"";position:absolute;inset:0;z-index:-2;background:center/cover no-repeat;pointer-events:none}
.res-host[data-scene="harbor:H-04"]::before{background-image:url("../assets/resonance-world-v2/harbor.webp");filter:brightness(.68) saturate(.78)}
.res-host[data-scene="harbor:H-05"]::before{background-image:url("../assets/cinematics/prologue/harbor-at-twilight.webp");animation:harbor-reveal 8s ease-out both}
.res-host[data-scene="harbor:H-04"]::after,.res-host[data-scene="harbor:H-05"]::after{content:"";position:absolute;inset:0;z-index:-1;background:linear-gradient(0deg,#0c1c29e6 0%,#162e3850 48%,transparent 76%);pointer-events:none}
.res-host[data-scene^="harbor:"] .res-dialogue[data-speaker="qilan"] .res-portrait{animation:harbor-navigator 3s ease-in-out infinite}
.res-host[data-scene^="harbor:"] .res-dialogue[data-speaker="jiedeng"] .res-portrait{animation:harbor-keeper 5s ease-in-out infinite}
@keyframes harbor-reveal{from{opacity:.38;transform:scale(1.035)}to{opacity:1;transform:scale(1)}}
@keyframes harbor-navigator{50%{transform:translateY(-3px) rotate(-.35deg)}}
@keyframes harbor-keeper{50%{transform:translateY(-1px)}}
@media(max-width:700px){.res-host[data-scene="harbor:H-05"]::before{background-position:62% center}.res-host[data-scene^="harbor:"] .res-harbor-context{margin-bottom:6px}}
@media(prefers-reduced-motion:reduce){.res-host[data-scene^="harbor:"]::before,.res-host[data-scene^="harbor:"] .res-portrait{animation:none!important}}

/* Chapter V painted cinematic camera, cast blocking and memory/present staging. */
.res-host.res-library-reveal{isolation:isolate;background:#141d32;overflow:hidden}
.library-reveal-stage{position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:-2;background:#172237}
.library-reveal-back,.library-reveal-painting,.library-reveal-shade{position:absolute;inset:0;width:100%;height:100%}
.library-reveal-painting{object-fit:cover;opacity:0;transform:scale(1.055);transition:opacity .65s ease;object-position:50% 46%}
.library-reveal-painting.is-current{opacity:1;animation:library-reveal-camera 13s ease-out both}
.library-reveal-stage[data-mode="mural"] .library-reveal-painting,.library-reveal-stage[data-mode="memory"] .library-reveal-painting{filter:saturate(.69) sepia(.16)}
.library-reveal-shade{z-index:2;background:linear-gradient(0deg,#101a2dfb 0%,#101a2d85 26%,transparent 65%,#121c324d 100%)}
.library-reveal-cast{position:absolute;inset:5% 10% 17%;z-index:1;display:flex;align-items:flex-end;justify-content:space-around;gap:12%}
.library-reveal-actor{width:min(42%,430px);height:90%;min-width:0;object-fit:contain;object-position:bottom;filter:drop-shadow(0 12px 18px #07102088) brightness(.79);transform:translateY(4px);transition:filter .3s,transform .3s;animation:library-cast-enter .6s ease-out both}
.library-reveal-actor.speaking{filter:drop-shadow(0 12px 18px #07102088) brightness(1.04);transform:translateY(0)}
.library-reveal-stage[data-mode="mural"] .library-reveal-actor,.library-reveal-stage[data-mode="memory"] .library-reveal-actor{filter:sepia(.25) saturate(.7) drop-shadow(0 0 18px #dbca8d55)}
.library-reveal-stage[data-mode="departure"] .library-reveal-cast{justify-content:flex-end;animation:library-departure 7s ease-in-out both}
.library-reveal-caption{position:absolute;z-index:3;top:4%;left:50%;transform:translateX(-50%);margin:0;width:min(85%,780px);text-align:center;font:600 clamp(13px,1.8vw,21px)/1.45 var(--cb-font-body);color:#f4e6c1;text-shadow:0 2px 6px #11192a,0 0 12px #11192a}
.res-host.res-library-reveal .res-dialogue{position:relative;z-index:1;grid-template-columns:1fr;width:min(930px,100%);max-height:55%;overflow:auto}
.res-host.res-library-reveal .res-portrait{display:none}
.res-host.res-library-reveal .res-body{background:linear-gradient(145deg,#1c2845f5,#15213cf5);border-color:#ad9ac5;box-shadow:0 10px 28px #090e2460}
.res-host.res-library-reveal .res-speaker{color:#dfccf3}.res-host.res-library-reveal .res-line{min-height:1.8em}
@keyframes library-reveal-camera{from{transform:scale(1.055) translateX(-.5%)}to{transform:scale(1.13) translateX(.6%)}}
@keyframes library-cast-enter{from{opacity:0}to{opacity:1}}
@keyframes library-departure{from{transform:translateX(0);opacity:1}to{transform:translateX(12%);opacity:.48}}
@media(max-width:700px){.library-reveal-cast{inset:9% 2% 40%;gap:2%}.library-reveal-actor{width:48%;height:85%}.res-host.res-library-reveal .res-dialogue{max-height:64%;gap:0}.library-reveal-caption{font-size:13px;top:3%;width:94%}}
@media(max-height:480px) and (orientation:landscape){.library-reveal-cast{inset:4% 10% 18%}.res-host.res-library-reveal .res-dialogue{max-height:61%}.res-host.res-library-reveal .res-body{padding:8px}.res-host.res-library-reveal .res-line{font-size:13px;margin-bottom:5px}.res-host.res-library-reveal button{min-height:34px}.library-reveal-caption{top:2%;font-size:13px}}
@media(prefers-reduced-motion:reduce){.library-reveal-painting,.library-reveal-actor,.library-reveal-cast{animation:none!important;transition:none!important}}

/* Chapter V close-up staging: distinct memory light and separated blocking after confession. */
.res-host.res-library-reveal .library-reveal-stage[hidden]{display:none}
.library-reveal-stage[data-mode="anchor"] .library-reveal-painting{filter:saturate(.8) sepia(.24)}
.library-reveal-stage[data-mode="anchor"] .library-reveal-shade{background:radial-gradient(ellipse at 50% 27%,#ffeac12b,transparent 56%),linear-gradient(0deg,#101a2dfb,transparent 68%)}
.library-reveal-stage[data-mode="fracture"] .library-reveal-cast{justify-content:space-between;inset-inline:3%}
.library-reveal-stage[data-mode="fracture"] .library-reveal-actor:not(.speaking){filter:brightness(.66) saturate(.7)}
.library-reveal-stage[data-mode="fracture"] .library-reveal-shade{background:linear-gradient(90deg,#17203155,transparent 42%,#0d152d77),linear-gradient(0deg,#11192dfb,transparent 65%)}
.library-reveal-stage[data-mode="departure"] .library-reveal-actor{transform-origin:50% 100%;animation:library-departure-actor 5s ease-in-out both}
@keyframes library-departure-actor{0%{transform:translateX(0) scale(1);opacity:1}100%{transform:translateX(15%) scale(.78);opacity:.55}}
@media(prefers-reduced-motion:reduce){.library-reveal-stage[data-mode="departure"] .library-reveal-actor{animation:none}}

.library-reveal-stage[data-mode="departure"] .library-reveal-actor{animation-duration:3s}

/* The anchor cutaway is the right-hand painted chamber detail, not the fixed-breed keeper. */
.library-anchor-detail{position:absolute;right:5%;top:13%;width:clamp(88px,17%,220px);aspect-ratio:1;z-index:2;background-size:450% auto;background-position:right top;background-repeat:no-repeat;border:1px solid #e5ca90;border-radius:8px;box-shadow:0 7px 25px #0b122a99;animation:library-cast-enter .65s ease-out both}
.library-anchor-detail[hidden]{display:none}.library-reveal-stage[data-mode="anchor"] .library-reveal-cast{inset-inline:4% 24%}.library-reveal-stage[data-mode="anchor"] .library-reveal-painting{object-position:22% 46%}
@media(max-width:700px){.library-anchor-detail{right:4%;top:9%;width:22%;min-width:0}.library-reveal-stage[data-mode="anchor"] .library-reveal-cast{inset-inline:2% 23%}}
@media(max-height:480px) and (orientation:landscape){.library-anchor-detail{top:8%;width:12%;min-width:0}}
@media(prefers-reduced-motion:reduce){.library-anchor-detail{animation:none}}

/* A chapter painting must fully own the viewport even during image decode/crossfade. */
#stage .res-chapter-cinematic.cbcp-root:not([hidden]){background:#ead7c1!important}
#stage:has(.res-chapter-cinematic:not([hidden]))>.rw-world{visibility:hidden!important;pointer-events:none!important}

/* Cinematics own input while the final frame or title card is visible. */
body:has(.res-ending-title) #cb-system-toggle,body:has(.res-ending-title) #cb-system-menu,body:has(.res-chapter-cinematic[data-ready="true"]:not([hidden])) #cb-system-toggle{visibility:hidden!important;pointer-events:none!important}
#stage .res-ending-title{z-index:2401!important;isolation:isolate}
#stage .res-ending-title>img{object-fit:cover!important}
#stage .res-ending-skip{top:max(12px,env(safe-area-inset-top,0px));right:max(12px,env(safe-area-inset-right,0px));min-width:44px}

/* Consent and restitution remain an interactive scene, not a silent completion. */
.res-accountability-panel{position:relative;display:grid;grid-template-columns:minmax(64px,110px) 1fr;gap:8px 16px;align-items:center;max-width:min(520px,90vw);padding:18px;text-align:left}.res-accountability-luna{grid-row:1/4;width:100%;max-height:155px;object-fit:contain}.res-accountability-bell{grid-column:2;width:54px;height:65px;object-fit:contain;filter:grayscale(.8);justify-self:center}.res-accountability-bell[data-repaired="true"]{filter:drop-shadow(0 0 9px #f3cb78)}.res-accountability-panel h2,.res-accountability-panel p{grid-column:2;margin:0}.res-accountability-panel button{grid-column:1/-1;min-height:44px}.res-accountability-panel p{line-height:1.55}
#battle-ui #mv-e[hidden],#battle-ui .battle-enemy-track[hidden],#battle-ui .battle-poise-row[hidden]{display:none!important}

/* One image owns each emotional composition. No giant overlapping dialogue sprites. */
.library-reveal-stage[data-composed="true"] .library-reveal-cast,.library-reveal-stage[data-composed="true"] .library-reveal-caption{display:none!important}
.library-reveal-stage[data-composed="true"] .library-reveal-painting{object-fit:contain;object-position:center top;transform:none;animation:none;transition:opacity .25s ease}
.res-host.res-library-reveal .res-dialogue:has(.res-portrait:not([hidden])){grid-template-columns:minmax(70px,19%) minmax(0,1fr)}
.res-host.res-library-reveal .res-portrait:not([hidden]){display:block;width:100%;height:auto;max-height:clamp(72px,19vh,160px);object-fit:contain;align-self:end}
.res-host[data-scene="sky:S-04"] .res-dialogue:has(.sky-lookout-view[data-pose="sit"]){grid-template-columns:1fr;max-height:92%;overflow:auto}
.res-host[data-scene="sky:S-04"] .sky-lookout-painting{background:transparent!important}
@media(orientation:portrait) and (max-width:700px){.res-host.res-library-reveal .res-dialogue:has(.res-portrait:not([hidden])){display:grid;grid-template-columns:minmax(55px,18%) minmax(0,1fr)}.res-host.res-library-reveal button,.res-host[data-scene="sky:S-04"] button{min-height:44px}}

/* Final key exchange uses the authored two-character painting, not a prop modal. */
#stage .res-host.res-homecoming{position:absolute!important;inset:0!important;padding:0!important;display:flex;align-items:flex-end;justify-content:center;overflow:hidden;background:#292a25!important;isolation:isolate}
#stage .res-homecoming-art{position:absolute;inset:0;display:block;z-index:-1;pointer-events:none}#stage .res-homecoming-art img{width:100%;height:100%;object-fit:contain;display:block}
#stage .res-homecoming-copy,#stage .res-homecoming .res-dialogue{position:relative!important;inset:auto!important;z-index:2!important;width:min(720px,92%)!important;max-width:92%!important;max-height:33%!important;margin:0 auto 3%!important;background:#242b32ed!important;border:1px solid #e5c58d!important;border-radius:12px!important;color:#fff4dc!important;padding:12px 18px!important;overflow:auto;text-align:center;display:block!important;box-shadow:0 6px 24px #15181d44}
#stage .res-homecoming-copy h2{font:700 clamp(18px,2.5vw,26px) var(--cb-font-display);color:#f4d59e;margin:0 0 5px}#stage .res-homecoming-copy p{margin:0 0 9px;color:#fff4dc;line-height:1.5}#stage .res-homecoming-copy button{min-height:44px;padding:8px 22px;background:#f2d8a7!important;color:#3e2b21!important;border:1px solid #b28c52;border-radius:9px;font-weight:700}#stage .res-homecoming .res-dialogue .res-body{background:transparent!important;color:#fff4dc!important;width:100%!important;padding:0!important}#stage .res-homecoming .res-dialogue .res-line,#stage .res-homecoming .res-dialogue .res-speaker{color:#fff4dc!important}#stage .res-homecoming .res-portrait{display:none!important}
@media(orientation:portrait){#stage .res-homecoming-art img{object-fit:cover}#stage .res-homecoming-copy,#stage .res-homecoming .res-dialogue{margin-bottom:5%!important;max-height:29%!important}}

/* The emotional story painting is the scene, not a second picture under a portrait. */
#stage .res-host.res-reconciliation-illustrated{isolation:isolate;overflow:hidden!important;background:#263641!important}
#stage .res-host.res-reconciliation-illustrated::before,#stage .res-host.res-reconciliation-illustrated::after{content:none!important;display:none!important}
#stage .res-host .res-reconciliation-painting{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;pointer-events:none;z-index:-1}
#stage .res-host.res-reconciliation-illustrated .res-dialogue{position:relative!important;z-index:2!important;display:grid!important;grid-template-columns:minmax(0,1fr)!important;max-height:35%!important;width:min(760px,100%)!important;overflow:auto!important;margin:0 auto!important}
#stage .res-host.res-reconciliation-illustrated .res-portrait{display:none!important}
#stage .res-host.res-reconciliation-illustrated .res-body{grid-column:1!important}
@media(orientation:portrait){#stage .res-host.res-reconciliation-illustrated .res-dialogue{max-height:31%!important}}

#stage .res-host[data-reconciliation-loading] .res-dialogue,#stage .res-host[data-reconciliation-loading] .res-skip-top{visibility:hidden!important;pointer-events:none!important}
#stage .res-host[data-reconciliation-failed] .res-dialogue{visibility:visible!important}
