.story-toolbar { position: absolute; z-index: 4; top: max(.5rem, env(safe-area-inset-top)); right: max(.5rem, env(safe-area-inset-right)); display: flex; flex-wrap: wrap; gap: .15rem; padding: .1rem .3rem; border: 1px solid #ccb58b35; background: #0b0c0cd9; }
.story-toolbar button, .show-ui, .story-history button { min-height: 44px; padding: .3rem .65rem; border: 0; background: transparent; font-size: .95rem; }
.story-toolbar [aria-pressed="true"] { color: #fff4de; box-shadow: inset 0 -2px var(--accent); background: #c5a37519; }
.show-ui { position: absolute; top: .5rem; right: .5rem; background: #0b0c0ca6; border: 1px solid #ccb58b35; }
.ui-hidden .story-toolbar, .ui-hidden .dialogue, .ui-hidden .dialogue-next, .ui-hidden .artwork-id, .ui-hidden .story-copy, .ui-hidden #story-interaction, .ui-hidden #story-hotspots { display: none !important; }
.ui-hidden #advance { cursor: pointer; }
.story-history { width: min(42rem, calc(100vw - 2rem)); max-height: 85dvh; padding: 1rem 1.5rem; color: var(--foreground); background: #10120ff5; border: 1px solid #c5a37570; font-size: 1.1rem; }
.story-history::backdrop { background: #000b; }
.story-history header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; top: -1rem; background: #10120f; }
.story-history h2 { font-size: 1.3rem; font-weight: 400; }
.story-history ol { padding: 0; list-style: none; }
.story-history li { border-top: 1px solid #c5a37530; padding: .9rem 0; }
.story-history li p { margin: .4rem 0; white-space: pre-line; }
.story-history small { color: var(--muted); font: .75rem ui-monospace, monospace; }
.story-copy { position: absolute; left: 4%; bottom: 6%; width: 45%; padding: 1rem; background: #0b0c0ceb; font-size: clamp(1rem, 1.6cqw, 1.5rem); }
.story-copy p { margin: .3rem 0; white-space: pre-line; }
.story-interaction { position: absolute; z-index: 3; right: 4%; bottom: 7%; width: min(42%, 30rem); max-height: 68%; overflow-y: auto; padding: .8rem 1rem; background: #0b0c0ced; border-left: 1px solid #c5a37580; font-size: clamp(1rem, 1.5cqw, 1.3rem); }
.story-interaction p { margin: .25rem 0 .65rem; }
.story-interaction button { min-height: 44px; padding: .5rem .8rem; border: 1px solid #ccb58b66; background: #c5a3750c; }
.story-option { display: block; width: 100%; text-align: left; margin: .3rem 0; }
.story-interaction progress { display: block; width: 100%; height: 5px; margin: .6rem 0 1rem; accent-color: var(--accent); }
.story-interaction small { display: block; color: var(--muted); margin-top: .5rem; font-size: .8rem; }
.story-interaction .qte-pad { width: 100%; min-height: 72px; touch-action: none; user-select: none; }
.story-hotspot { position: absolute; z-index: 2; min-width: 44px; min-height: 44px; border: 0; background: transparent; cursor: pointer; text-shadow: 0 1px 4px #000; }
.story-hotspot:active, .story-hotspot:focus-visible { background: #c5a37545; }
.rhythm-track { position: relative; height: 24px; margin: .8rem .4rem; border-bottom: 1px solid #c5a37570; }
.rhythm-track i { position: absolute; bottom: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: translateX(-50%); }
.rhythm-track b { position: absolute; bottom: -7px; height: 24px; width: 2px; background: var(--foreground); }
.story-shake { animation: story-shake .22s ease-out; }
.story-crossfade { position: absolute; inset: 0; animation: panel-fade .35s ease-out forwards; }
.art-stage { position: absolute; inset: 0; overflow: hidden; }
.main-actions [data-action="demo"] small { display: block; font-size: .55em; color: var(--muted); line-height: 1.4; padding-bottom: .3em; }
.story-device { position: absolute; left: 30%; top: 21%; width: 19%; height: 47%; display: flex; flex-direction: column; align-items: center; padding-top: 9%; gap: .65em; transform: rotate(-8deg); color: #deddd5; font-family: system-ui, sans-serif; pointer-events: none; }
.story-device time { font-size: 4.2cqw; font-weight: 300; letter-spacing: -.05em; }
.story-device span { max-width: 90%; text-align: center; font-size: 1cqw; }
#viewer[data-session="demo"] .story-copy { width: 49%; padding: .8em 1em; line-height: 1.45; border: 1px solid #bca17470; pointer-events: none; }
#viewer[data-session="demo"][data-scene="EL-0007"] .story-copy:is([data-kind="speech"], [data-kind="thought"]) { left: 37%; top: 17%; bottom: auto; width: 45%; }
#viewer[data-session="demo"][data-scene="EL-0007"] .story-copy[data-kind="speech"] { left: 22%; top: 8%; width: 26%; font-size: clamp(1.1rem, 2.1cqw, 2rem); }
#viewer[data-session="demo"] .story-interaction { left: 4%; right: auto; bottom: 5%; width: 48%; background: #0b0c0cd9; font-size: clamp(.95rem, 1.4cqw, 1.25rem); }
#viewer[data-session="demo"] .comic-balloon {
  display: grid;
  grid-template-columns: 15% 70% 15%;
  grid-template-rows: 18fr 50fr 32fr;
  max-height: none;
  overflow: visible;
  padding: 0;
  color: #201e19;
  background: none;
  border: 0;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
}
/* The spanning spacer preserves the drawn proportions, while fractional rows
   let a long paragraph enlarge the whole balloon, including its paper margins. */
#viewer[data-session="demo"] .comic-balloon::before { content: ''; grid-area: 1 / 1 / 4 / 4; width: 100%; aspect-ratio: 20 / 11; }
#viewer[data-session="demo"] .comic-balloon > p { position: relative; grid-area: 2 / 2; align-self: center; min-width: 0; margin: 0; text-wrap: balance; overflow-wrap: break-word; }
#viewer[data-scene="EL-0008"] .story-copy { left: 56%; width: 40%; bottom: 20%; }
#viewer[data-scene="EL-0009"] .story-copy { left: 54%; width: 42%; bottom: 15%; }
#viewer[data-session="demo"] .story-hotspot { border: 0; border-radius: 50%; background: transparent; box-shadow: none; }
#story-hotspots[data-hint] .story-hotspot:not([data-option="back"])::before { content: ''; position: absolute; inset: 4%; border-radius: 47% 53% 48% 52%; border-bottom: 1px solid #e3bf8580; background: radial-gradient(ellipse, #e3bf8525, transparent 70%); opacity: 0; animation: hotspot-hint 1.3s ease-in-out 1; pointer-events: none; }
#story-hotspots[data-hint="clear"] .story-hotspot::before { border: 1px solid #e3bf85b0; }
#story-hotspots[data-reviewing="true"] { pointer-events: none; }
#story-hotspots[data-reviewing="true"] .story-hotspot { pointer-events: none; }
@media (hover: hover) { #viewer .story-hotspot:hover { background: #e3bf8510; box-shadow: inset 0 0 0 1px #e3bf8530; } }
#viewer[data-session="demo"] .story-hotspot span { position: absolute; width: max-content; max-width: min(14rem, 45vw); bottom: 100%; left: 50%; transform: translateX(-50%); padding: .25rem .5rem; background: #0b0c0ced; color: var(--foreground); font-size: .85rem; opacity: 0; pointer-events: none; }
#viewer[data-session="demo"] .story-hotspot:focus-visible, #viewer[data-session="demo"] .story-hotspot:active { background: #e3bf852a; animation: none; }
#viewer[data-session="demo"] .story-hotspot:focus-visible span, #viewer[data-session="demo"] .story-hotspot:active span { opacity: 1; }
#viewer[data-session="demo"] .story-hotspot[data-option="door"] span { left: auto; right: 0; transform: none; }
#viewer[data-session="demo"] .story-hotspot[data-option="back"] { border-radius: 2px; background: #0b0c0ca9; border: 1px solid #ccb58b55; animation: none; }
#viewer[data-session="demo"] .story-hotspot[data-option="back"] span { position: static; transform: none; background: transparent; opacity: 1; }
.demo-end { position: absolute; z-index: 5; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; background: #0b0c0cf5; text-align: center; }
.demo-end h2 { margin: 0; font: 700 clamp(2rem, 6cqw, 5rem)/1.1 Kalam, cursive; letter-spacing: .12em; }
.demo-end p { margin: 0; color: var(--muted); }
.demo-end button { min-height: 44px; padding: .35rem 1.5rem; border: 1px solid #ccb58b66; background: #c5a3750c; }
.ui-hidden .story-device, .ui-hidden .demo-end { display: none !important; }
@keyframes hotspot-hint { 0%, 100% { opacity: 0; } 45% { opacity: .8; } }
@keyframes story-shake { 25% { translate: -3px 1px; } 60% { translate: 3px -1px; } }
@keyframes panel-fade { to { opacity: 0; } }
@media (max-width: 600px) and (orientation: portrait) {
  .story-toolbar { position: fixed; top: max(.5rem, env(safe-area-inset-top)); left: .5rem; right: .5rem; justify-content: center; }
  .story-toolbar button { padding: .3rem .5rem; font-size: .9rem; }
  .show-ui { top: -3.5rem; }
  .story-below { position: absolute; top: calc(100% + 1rem); left: 4%; width: 92%; max-height: calc(82dvh - 56.25vw - 2rem); display: flex; flex-direction: column; gap: .75rem; overflow-y: auto; overflow-anchor: none; }
  .story-below .story-interaction, .story-below .story-copy { position: static; width: 100%; max-height: none; flex-shrink: 0; }
  #viewer[data-session="demo"] .story-below .story-copy, #viewer[data-session="demo"] .story-below .story-interaction { position: static; width: 100%; line-height: 1.5; }
  #viewer[data-session="demo"] .story-below { top: calc(100% + .5rem); left: 3%; width: 94%; padding: 1.5rem .5rem .5rem; gap: 1.25rem; }
  #viewer[data-session="demo"][data-scene] .story-below .story-copy { position: relative; inset: auto; width: 100%; min-width: 0; max-width: 100%; font-size: 1.1rem; }
  #viewer[data-session="demo"] .story-below .comic-balloon { position: relative; line-height: 1.25; }
  #viewer[data-session="demo"] .story-below .dialogue-next { position: static; align-self: flex-end; flex-shrink: 0; }
  .story-device span { display: none; }
  .demo-end { position: fixed; inset: 4rem 0 0; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .story-toolbar { top: .3rem; }
  .story-toolbar button { padding: .2rem .6rem; }
  .story-interaction { bottom: 6%; max-height: 68%; padding: .5rem .7rem; }
  #viewer[data-session="demo"][data-scene="EL-0008"] .story-copy { left: 51%; width: 45%; }
  #viewer[data-session="demo"][data-scene="EL-0009"] .story-copy { left: 48%; width: 48%; bottom: 20%; }
  #viewer[data-session="demo"][data-scene="EL-0007"] .story-copy[data-kind="thought"] { left: 36%; top: 16%; width: 54%; }
  #viewer[data-session="demo"][data-scene="EL-0007"] .story-copy[data-kind="speech"] { left: 37%; top: max(17%, 3.5rem); }
}
@media (prefers-reduced-motion: reduce) { .story-shake, .story-crossfade, #viewer[data-session="demo"] .story-hotspot { animation: none; } .story-crossfade { display: none; } }

/* The slice uses small lettering surfaces; silent images retain their full area. */
#story-back { min-width: 44px; font: 1.6rem/1 system-ui, sans-serif; }
#viewer[data-reviewing="true"] .artwork-id::before { content: '‹ '; }
.story-history li button { width: 100%; text-align: left; }
.story-history [aria-current="step"] { box-shadow: inset 2px 0 var(--accent); }
.story-option[data-chosen="true"] { border-color: var(--accent); opacity: .8; }
#viewer[data-session="demo"] .story-copy.comic-balloon,
#viewer[data-session="demo"] .story-interaction.comic-balloon { width: 27%; font-size: clamp(1rem, 1.8cqw, 1.7rem); }
#viewer[data-scene="EL-0016"] .story-copy.comic-balloon { left: 60%; bottom: 40%; }
#viewer[data-session="demo"][data-scene="EL-0017"] .story-interaction { left: 4%; bottom: 4%; width: 25%; }
#viewer[data-session="demo"][data-scene="EL-0010"] .story-copy { left: 4%; bottom: 64%; }
#viewer[data-session="demo"][data-scene="EL-0020"] .story-copy { left: 2%; bottom: 52%; }
#viewer[data-session="demo"][data-scene="EL-0021"] .story-copy { left: 65%; bottom: 50%; }
#viewer[data-session="demo"][data-scene="EL-0022"] .story-interaction.comic-balloon { left: 58%; bottom: 8%; }
#viewer[data-session="demo"][data-scene="EL-0023"] .story-copy { left: 68%; bottom: 55%; }
#viewer[data-session="demo"][data-scene="EL-0025"] .story-copy { left: 67%; bottom: 15%; }
#viewer[data-session="demo"][data-scene="EL-0013"] .story-copy { left: 39%; bottom: 58%; }
#viewer[data-scene="EL-0022"] .story-device { left: 25%; top: 18%; width: 25%; height: 60%; padding-top: 12%; transform: none; }
.story-messages { position: absolute; left: 57%; top: 16%; width: 39%; max-height: 65%; padding: .8em 1em; overflow-y: auto; background: #131715f2; border: 1px solid #9b9a7c65; box-shadow: 0 8px 30px #0005; font: clamp(.9rem, 1.25cqw, 1.1rem)/1.35 system-ui, sans-serif; pointer-events: auto; }
.story-messages h2 { font: inherit; font-weight: 600; color: #d5c7aa; margin: 0 0 .65em; padding-bottom: .5em; border-bottom: 1px solid #c5a37535; }
.message-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4em; }
.message-thread li { align-self: flex-start; max-width: 93%; padding: .45em .65em; border-radius: .2em .7em .7em .7em; background: #303630; color: #f1ecde; }
.message-draft, .message-sent { margin: .65em 0 0 auto; padding: .5em .65em; width: fit-content; max-width: 94%; color: #f3e9d6; border: 1px solid #b09d6e55; border-radius: .6em .2em .6em .6em; }
.message-sent { background: #4b503c; }
.message-draft::after { content: ''; display: inline-block; height: 1em; margin-left: 2px; border-right: 1px solid #e9d8ae; vertical-align: text-bottom; }
.message-status { display: block; text-align: right; color: #c3c5b3; margin: .35em 0 0; font-size: .75em; }
.message-keyboard { margin-top: .7em; opacity: .45; }
.message-keyboard > div { display: flex; justify-content: center; gap: 3px; margin-top: 3px; }
.message-keyboard i { width: 8%; height: .6em; border: 1px solid #c9cabb80; border-radius: 2px; }
#viewer[data-device="chat"] .story-interaction { left: 57%; bottom: 5%; width: 39%; padding: 0; border: 0; background: transparent; }
#viewer[data-device="chat"] .story-interaction .story-option { text-align: center; background: #303630; }
#viewer[data-review-controls="true"] .dialogue-next { left: 4%; right: auto; }
#viewer[data-device="chat"] .story-device span { font-size: 1.1cqw; }
.ui-hidden .story-messages { display: none !important; }
@media (max-width: 600px) and (orientation: portrait) {
  .story-toolbar button { padding: .25rem .4rem; }
  #viewer[data-session="demo"] .story-below { padding-top: .2rem; gap: .65rem; }
  #viewer[data-session="demo"] .story-below .comic-balloon { width: min(72%, 18rem); align-self: center; }
  #viewer[data-session="demo"][data-scene] .story-below .story-copy.comic-balloon { width: min(72%, 18rem); }
  #viewer[data-session="demo"] .story-below .story-interaction { position: relative; inset: auto; }
  .story-messages { position: static; flex-shrink: 0; width: 100%; max-height: none; font-size: .95rem; padding: .65em .8em; }
  #viewer[data-device="chat"] .story-below .story-interaction { width: 100%; }
  .message-thread li { padding: .35em .55em; }
  .message-keyboard { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .story-messages { top: 16%; max-height: 62%; font-size: .875rem; padding: .5em .7em; }
  .story-messages h2 { margin-bottom: .4em; padding-bottom: .3em; }
  .message-thread { gap: .25em; }
  .message-thread li { padding: .25em .5em; }
  .message-draft, .message-sent { margin-top: .35em; padding: .3em .5em; }
  .message-keyboard { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #story-hotspots[data-hint] .story-hotspot::before { animation-name: hotspot-hint-still; animation-timing-function: steps(1); }
}
@keyframes hotspot-hint-still { 0% { opacity: .5; } 100% { opacity: 0; } }
