/* In-world controls borrow the main menu's paper, brass and serif type. */
.world-toolbar { position:absolute; z-index:12; top:max(12px,env(safe-area-inset-top)); left:max(14px,env(safe-area-inset-left)); display:flex; align-items:center; gap:5px; padding:3px 8px; border:1px solid #b2a17a; border-radius:4px; background:#f6f0e2f2; color:#403a30; box-shadow:0 2px 10px #0002; }
.world-toolbar[hidden] { display:none; }
body[data-scene="world"] .world-toolbar .frame-history { gap:0; }
.world-toolbar .frame-history button { color:#504938; height:34px; min-height:34px; width:30px; }
.world-toolbar .frame-history button:disabled { color:#aaa08d; }
.world-toolbar .frame-history #frame-position:disabled { color:#776d59; }
.world-toolbar .frame-history button:hover:not(:disabled) { color:#30291d; background:#e3d7bb; border-color:#b5a580; }
body[data-scene="world"] .world-toolbar .save-chip { display:flex; align-items:center; gap:5px; width:auto; height:34px; min-height:34px; padding:4px 8px; border:0; border-radius:3px; background:transparent; color:#504938; font:13px Georgia,serif; }
.world-toolbar .save-chip svg { width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.5; }
body[data-scene="world"] .world-toolbar .save-chip:hover { background:#e3d7bb; }
body[data-scene="world"] .world-toolbar .advanced-tools { flex:0 0 auto; }
body[data-scene="world"] .world-toolbar .advanced-tools summary { color:#504938; min-height:34px; padding:6px 8px; font:12px Georgia,serif; letter-spacing:.06em; }
body[data-scene="world"] .world-toolbar .advanced-popover { left:0; right:auto; top:calc(100% + 12px); bottom:auto; width:min(310px,calc(100vw - 40px)); }
body[data-scene="world"] .scene-menu:not([hidden]) { top:66px; left:14px; right:auto; bottom:auto; max-height:calc(100dvh - 145px); }
body[data-scene="world"] #simulation-ui .simulation-panel { background:#f6f0e2; border-top:1px solid #a99977; }
body[data-scene="world"] .simulation-input { color:#403a30; -webkit-text-fill-color:#403a30; background:#fffbf3 !important; border-color:#b3a482; }
body[data-scene="world"] .simulation-input::placeholder { color:#81745e; }
body[data-scene="world"] #simulation-submit { color:#675637; }
.scene-narrative { display:flex; flex-direction:column; padding:0; overflow:hidden; border:1px solid #c6bda433; border-radius:3px; }
.scene-narrative[hidden] { display:none; }
.narrative-bar { display:flex; flex:0 0 30px; align-items:stretch; background:#2d2a27de; border-bottom:1px solid #c6bda44d; }
.narrative-bar button { margin:0; border:0; background:transparent; color:#eee7d8; border-radius:0; min-height:30px; font:12px Georgia,serif; }
#narrative-drag { flex:1; text-align:left; padding:5px 10px; cursor:grab; touch-action:none; user-select:none; letter-spacing:.035em; }
#narrative-drag:active { cursor:grabbing; }
#narrative-drag span { margin-right:7px; opacity:.7; }
#narrative-toggle { width:34px; font:20px/1 sans-serif; cursor:pointer; }
.narrative-bar button:hover { background:#ffffff12; }
.narrative-bar button:focus-visible { outline:2px solid #c6ae79; outline-offset:-2px; }
#narrative-content { flex:1 1 auto; min-height:0; overflow:clip; padding:12px 15px; }
#narrative-content[hidden] { display:none; }
@media(max-width:600px) {
 .world-toolbar { left:8px; top:8px; padding:3px 4px; gap:1px; }
 body[data-scene="world"] .world-toolbar .save-chip { padding:4px 6px; }
 .scene-narrative { padding:0; }
 #narrative-content { padding:10px 12px; }
}

body[data-scene="world"] .simulation-input[readonly] { color:#776d59; -webkit-text-fill-color:#776d59; border-color:#c9bea8; }

/* Artwork fills the viewport; controls have no shared backing plates. */
body[data-scene="world"] .engine-frame { top:0; bottom:0; height:100%; }
.world-toolbar { background:transparent; border:0; box-shadow:none; padding:3px 0; }
.world-toolbar .frame-history button,
.world-toolbar .frame-history #frame-position:disabled,
body[data-scene="world"] .world-toolbar .save-chip,
body[data-scene="world"] .world-toolbar .advanced-tools summary { color:#fff8e8; text-shadow:0 1px 3px #000,0 0 7px #0009; }
.world-toolbar .save-chip svg { filter:drop-shadow(0 1px 2px #000); }
.world-toolbar .frame-history button:disabled { color:#e8e0cf88; }
body[data-scene="world"] .world-toolbar .save-chip:hover,
.world-toolbar .frame-history button:hover:not(:disabled) { background:#19171466; color:#fff8e8; border-color:transparent; }
body[data-scene="world"] #simulation-ui .simulation-panel { background:transparent; border:0; box-shadow:none; }
body[data-scene="world"] .simulation-input { background:#1c1a164d !important; border:1px solid #eee4cc66; color:#fff8e8; -webkit-text-fill-color:#fff8e8; text-shadow:0 1px 3px #000; box-shadow:none; }
body[data-scene="world"] .simulation-input::placeholder { color:#fff8e8; opacity:.9; }
body[data-scene="world"] .simulation-input[readonly] { color:#ddd4c4; -webkit-text-fill-color:#ddd4c4; border-color:#eee4cc44; }
body[data-scene="world"] #simulation-submit { color:#fff8e8; text-shadow:0 1px 3px #000; }
#narrative-content { flex:0 1 auto; overflow:clip; }
.narrative-bar button[hidden] { display:none; }

/* A compact adventure command line, with no full-width backing panel. */
body[data-scene="world"] .simulation-form { grid-template-columns:auto minmax(0,1fr) auto auto; align-items:center; gap:8px; }
body[data-scene="world"] .speaker-label { display:block; position:static; width:auto; height:auto; min-height:0; max-height:none; overflow:visible; clip:auto; clip-path:none; white-space:normal; padding:0; grid-column:auto; margin:0; color:#f4dfad; font:bold 21px/1 monospace; text-shadow:0 1px 3px #000; }
body[data-scene="world"] .simulation-input { height:42px; min-height:42px; padding:8px 10px; border:1px solid #bba778; border-radius:0; background:#14140ee0 !important; font:16px/1.35 "Courier New",monospace; color:#f4dfad; -webkit-text-fill-color:#f4dfad; text-shadow:none; box-shadow:inset 0 0 0 1px #0008; }
body[data-scene="world"] .simulation-input::placeholder { color:#d8c69b; }
body[data-scene="world"] #simulation-submit,
body[data-scene="world"] #advance-button { display:inline-flex; align-items:center; justify-content:center; grid-column:auto; width:auto; height:42px; min-height:42px; margin:0; padding:8px 13px; border:1px solid #bba778; border-radius:0; background:#14140ee0; color:#f4dfad; font:15px/1.2 "Courier New",monospace; text-shadow:none; }
body[data-scene="world"] #simulation-submit:hover:not(:disabled),
body[data-scene="world"] #advance-button:hover:not(:disabled) { background:#3e3729; }
body[data-scene="world"] #simulation-submit:disabled,
body[data-scene="world"] #advance-button:disabled { opacity:.45; cursor:default; }
@media(max-width:600px) {
 body[data-scene="world"] .simulation-form { gap:5px; padding:8px; }
 body[data-scene="world"] #simulation-submit,body[data-scene="world"] #advance-button { padding-inline:8px; font-size:13px; }
 body[data-scene="world"] .simulation-input { font-size:14px; padding-inline:7px; }
}

/* New frames blend over the preserved old image. History navigation commits instantly. */
.engine-stage.frame-staging .engine-frame.is-standby { visibility:visible; opacity:0; clip-path:none; transform:none; filter:none; will-change:opacity; }
.engine-stage.frame-crossfading .engine-frame.is-standby { z-index:2; }
@keyframes engine-frame-crossfade { from { opacity:0; } to { opacity:1; } }
.world-tools-button { display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; min-height:44px; padding:5px; margin-left:7px; border:1px solid #d4ba7c80; border-radius:3px; background:#191a17b8; color:#f2d9a2; box-shadow:inset 0 1px #fff2,0 2px 5px #0005; cursor:pointer; }
.world-tools-button svg { width:30px; height:30px; fill:currentColor; stroke:#2f2b20; stroke-width:1.5; }
.world-tools-button:hover { background:#494332; }
.world-tools-button:focus-visible { outline:2px solid #ffe2a6; outline-offset:2px; }
.simulation-tools { width:min(650px,calc(100vw - 24px)); max-height:calc(100dvh - 36px); overflow:auto; margin:auto; padding:0; border:2px solid #727c87; border-radius:3px; background:#242b32; color:#e2e5e8; box-shadow:0 18px 80px #000c,inset 0 0 0 1px #151b20; font:14px/1.4 Tahoma,Verdana,sans-serif; }
.simulation-tools::backdrop { background:#080d1480; }
.tools-titlebar { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid #131920; background:linear-gradient(#45515d,#303944); }
.tools-titlebar h2 { margin:0; font:bold 17px Tahoma,Verdana,sans-serif; color:#f0d296; }
.tools-titlebar small { display:block; margin-top:3px; color:#b6bfc9; font-size:11px; }
.simulation-tools button { min-height:34px; padding:7px 13px; border:1px solid #71808d; border-radius:2px; background:linear-gradient(#4e5a66,#36414c); color:#f2f3f4; font:13px Tahoma,Verdana,sans-serif; cursor:pointer; box-shadow:inset 0 1px #ffffff16; }
.simulation-tools button:hover:not(:disabled) { background:#596773; }
.simulation-tools button:disabled { opacity:.4; cursor:default; }
.simulation-tools button:focus-visible,.simulation-tools input:focus-visible,.simulation-tools textarea:focus-visible,.simulation-tools select:focus-visible { outline:2px solid #e2c07a; outline-offset:2px; }
.tools-titlebar button { min-height:28px; padding:2px 10px; font-size:22px; }
.tools-tabs { display:flex; gap:3px; padding:12px 14px 0; }
.tools-tabs button { flex:1; border-bottom:0; border-radius:3px 3px 0 0; font-size:12px; }
.tools-tabs button[aria-selected="true"] { background:#39434c; color:#ffe4ac; box-shadow:inset 0 2px #d7b675; }
#simulation-tools-form { padding:0 14px 14px; }
.tools-pane { min-height:238px; padding:14px; border:1px solid #66737e; background:#303942; }
.tools-pane label { display:block; margin:0 0 12px; color:#dce1e6; font-size:12px; }
.tools-pane label:last-child { margin-bottom:0; }
.tools-pane input:not([type="checkbox"]):not([type="range"]),.tools-pane textarea,.tools-pane select { display:block; box-sizing:border-box; width:100%; min-width:0; margin-top:5px; padding:8px; border:1px solid #141b21; border-top-color:#10161b; border-radius:2px; background:#1d252c; color:#f0f2f3; font:13px/1.4 Tahoma,Verdana,sans-serif; box-shadow:inset 0 1px 3px #0005; }
.tools-pane textarea { resize:vertical; }
.tools-pane input::placeholder,.tools-pane textarea::placeholder { color:#8997a5; }
.tools-row { display:grid; grid-template-columns:1fr 1.5fr; gap:12px; }
.tools-pane input[type="range"] { display:block; width:100%; accent-color:#dcc38b; margin:9px 0; }
.tools-pane output { float:right; color:#f0d296; }
.tools-pane small { display:block; font-size:11px; color:#a6b2bc; }
.tools-pane .tools-check { display:flex; align-items:center; gap:8px; margin:15px 0; }
.tools-staged { margin-top:12px; border:1px solid #52606b; background:#1c242b; }
.tools-staged>div { display:flex; justify-content:space-between; padding:6px 9px; background:#303c46; font-size:11px; color:#bfccd7; }
.tools-staged pre { max-height:100px; overflow:auto; margin:0; padding:9px; white-space:pre-wrap; overflow-wrap:anywhere; font:12px/1.4 "Courier New",monospace; color:#dbc899; }
#tools-status,.tools-live-status { margin:10px 0; font-size:11px; color:#abb7c2; }
.tools-live-status:empty { display:none; }
.tools-live-status { color:#b8ddb9; }
.tools-footer { display:flex; justify-content:space-between; gap:12px; margin-top:12px; }
#tools-apply { border-color:#c5ab6d; color:#ffe9b9; background:linear-gradient(#655b42,#4a4232); }
.turn-progress { position:absolute; z-index:14; bottom:16px; left:50%; transform:translateX(-50%); width:min(510px,calc(100% - 32px)); box-sizing:border-box; padding:10px 16px; background:#131b22e8; border:1px solid #75879360; border-radius:3px; color:#e2e8e9; box-shadow:0 2px 14px #0003; pointer-events:none; }
.turn-progress p { margin:0 0 9px; font:13px Tahoma,Verdana,sans-serif; }
.generation-lights { list-style:none; display:flex; justify-content:space-between; gap:10px; padding:0; margin:0; font:11px Tahoma,Verdana,sans-serif; }
.generation-lights li { display:flex; align-items:center; gap:7px; color:#87969e; }
.generation-lights span { display:inline-block; width:8px; height:8px; border-radius:50%; background:#34434d; border:1px solid #5c6a71; }
.generation-lights li[data-state="active"] { color:#f4d89d; }
.generation-lights li[data-state="active"] span { background:#e5ba65; box-shadow:0 0 8px #e5ba6570; animation:stage-light 1.6s ease-in-out infinite alternate; }
.generation-lights li[data-state="done"] { color:#c4e4c6; }
.generation-lights li[data-state="done"] span { background:#9ddb9f; border-color:#9ddb9f; box-shadow:0 0 7px #9ddb9f65; }
.world-loading-steps { grid-template-columns:repeat(4,minmax(0,1fr)); }
.world-loading-steps li[data-state="done"] span { color:#112719; background:#a5d6a8; border-color:#a5d6a8; box-shadow:0 0 12px #86c68b66; }
.world-loading-steps li[data-state="active"] span { box-shadow:0 0 12px #e7c27666; animation:stage-light 1.6s ease-in-out infinite alternate; }
@keyframes stage-light { from { opacity:.6; } to { opacity:1; } }
@media(prefers-reduced-motion:reduce) { .generation-lights li[data-state="active"] span,.world-loading-steps li[data-state="active"] span { animation:none; } }
@media(max-width:600px) { .world-tools-button { width:40px;height:40px;min-height:40px;margin-left:2px; } .tools-tabs { padding-inline:8px; } #simulation-tools-form { padding-inline:8px; } .tools-pane { padding:10px; } .tools-tabs button { padding:8px 5px; font-size:11px; } .tools-row { grid-template-columns:1fr; gap:0; } }

/* Prose uses the original responsive italic sizing from styles.css. */
.turn-progress-bar { height:7px; overflow:hidden; border:1px solid #adb3bb; background:#33383d70; margin:0 0 12px; }
.turn-progress-bar span { display:block; width:28%; height:100%; background:#d3d9df; animation:world-activity-forward 8.5s cubic-bezier(.42,0,.58,1) infinite; }
.turn-progress[data-connection="interrupted"] .turn-progress-bar span { animation-play-state:paused; opacity:.4; }
body[data-saving="true"],body[data-saving="true"] * { cursor:progress!important; }
.control-guide { position:fixed; inset:0; width:100vw; height:100dvh; max-width:none; max-height:none; margin:0; padding:0; border:0; background:transparent; color:#fff5dc; overflow:hidden; }
.control-guide::backdrop { background:#0005; }
.control-guide svg { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.control-guide .guide-note { position:absolute; width:min(280px,calc(100vw - 32px)); padding:10px 12px; background:#161714ed; border:1px solid #d6c79e88; border-radius:4px; color:#fff5dc; font:16px/1.4 Georgia,serif; box-shadow:0 2px 10px #0008; }
.control-guide .guide-hint { position:absolute; bottom:24px; left:50%; transform:translateX(-50%); white-space:nowrap; padding:10px 18px; color:#fff5dc; background:#161714ed; border:1px solid #d6c79e88; font:15px Georgia,serif; cursor:pointer; }
@media(prefers-reduced-motion:reduce){.turn-progress-bar span{animation:none;margin-left:36%}}

.frame-prompt { position:absolute; z-index:12; top:76px; left:18px; width:min(420px,calc(100% - 36px)); color:#f6ecd0; background:rgba(15,14,12,.88); border:1px solid #746b50; padding:9px 12px; font:16px/1.45 system-ui,sans-serif; box-sizing:border-box; }
.frame-prompt[hidden] { display:none; }
.frame-prompt summary { cursor:pointer; overflow-wrap:anywhere; }
#frame-prompt-text { white-space:pre-wrap; overflow-wrap:anywhere; max-height:25vh; overflow:auto; margin-top:10px; }
@media(max-width:600px) { .frame-prompt { top:100px; font-size:14px; } }

.engine-allowance { color:inherit; padding:0 8px; white-space:nowrap; font:13px/1.4 Georgia,serif; font-variant-numeric:tabular-nums; }
.load-generation-warning { padding:10px 14px; color:#f4d68b; font:14px/1.5 system-ui,sans-serif; }
body[data-world-loading="true"] #scene-menu:not([hidden]) { z-index:100; position:fixed; top:24px; left:16px; right:auto; bottom:auto; max-height:calc(100dvh - 48px); }
#world-loading-open-load { margin-top:12px; cursor:pointer; }
@media(max-width:600px) { .world-toolbar { flex-wrap:wrap; max-width:calc(100% - 28px); } .engine-allowance { font-size:12px; padding:0 4px; } }

/* Tinker: choose, stage, apply to the next submission. */
.tinker-v2 { width:min(820px,calc(100vw - 24px)); background:#141513; border:1px solid #8b7954; color:#eee7d7; font:15px/1.45 system-ui,sans-serif; }
.tinker-v2 .tools-titlebar { background:#1e201c; border-bottom:1px solid #484434; }
.tinker-v2 .tools-titlebar h2 { font:24px Georgia,serif; color:#f0dbab; }
.tinker-flow { display:flex; flex-wrap:wrap; gap:10px; padding:0 18px; font-size:12px; color:#e8c981; }
.tinker-intro { margin:8px 18px 16px; color:#c6c5b9; font-size:13px; }
.tinker-v2 .tools-tabs { padding:0 14px 10px; }
.tinker-v2 button { background:#25271f; border:1px solid #595a46; border-radius:5px; box-shadow:none; font:14px/1.3 system-ui,sans-serif; }
.tinker-v2 button:hover:not(:disabled) { background:#3c402f; }
.tinker-v2 button[aria-pressed="true"],.tinker-v2 .tools-tabs button[aria-selected="true"] { background:#e4c27c; color:#171b13; border-color:#e4c27c; box-shadow:none; }
.tinker-layout { display:grid; grid-template-columns:1.3fr 1fr; gap:14px; }
.tinker-v2 .tools-pane { background:transparent; border:0; min-height:0; padding:4px 0 12px; }
.tinker-v2 h3 { font:13px system-ui,sans-serif; color:#c9cabc; margin:14px 0 8px; }
.tinker-buttons { display:flex; flex-wrap:wrap; gap:7px; }
.tinker-v2 .tools-staged { margin:0; background:#1c1e18; border:1px solid #494c3b; border-radius:6px; padding:12px; min-width:0; }
.tinker-hint { font:12px/1.5 system-ui,sans-serif; color:#aeb19f; }
#tools-stage-list { list-style:none; padding:0; margin:0 0 12px; max-height:260px; overflow:auto; }
#tools-stage-list li { display:flex; align-items:start; gap:8px; border-bottom:1px solid #373b2e; padding:9px 0; font-size:13px; overflow-wrap:anywhere; }
#tools-stage-list li span { flex:1; }
#tools-stage-list button { flex:none; min-height:25px; padding:1px 7px; }
.tinker-custom { padding:10px 0; }
.tinker-custom label { display:block; font-size:13px; margin-bottom:7px; }
.tinker-custom textarea { box-sizing:border-box; width:100%; resize:vertical; background:#080b08; color:#f0eadc; border:1px solid #555a44; padding:10px; font:14px/1.5 system-ui,sans-serif; margin-bottom:8px; }
.tinker-v2 .tools-footer { align-items:center; justify-content:space-between; border-top:1px solid #454a35; padding-top:12px; }
.tinker-v2 .tools-footer span { font-size:12px; color:#b5b9a6; }
.tinker-v2 #tools-apply { background:#e4c27c; color:#172015; }
.tinker-fine { margin-top:14px; font-size:13px; }
@media(max-width:600px) { .tinker-layout { grid-template-columns:1fr; } #tools-stage-list { max-height:140px; } .tinker-flow { gap:5px; font-size:11px; } .tinker-v2 .tools-footer { flex-wrap:wrap; gap:8px; } }

body[data-scene="world"] #simulation-ui .simulation-panel { flex-direction:row; align-items:center; }
.tinker-v2 .tools-staged > div { background:transparent; color:#ecd59f; padding:0; }
#engine-allowance { color:#f1dfb8; text-shadow:0 1px 3px #000; }

#engine-allowance{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;width:108px;flex:0 0 108px;padding:0 8px;font:11px/1.2 Georgia,serif;}
#engine-allowance[hidden]{display:none;}
.engine-allowance-track{display:block;width:100%;height:8px;border:1px solid #e6d5a6aa;border-radius:2px;background:#171913bb;overflow:hidden;}
.engine-allowance-fill{display:block;height:100%;background:#e4cb86;}
@media(max-width:600px){#engine-allowance{width:88px;flex-basis:88px;padding:0 4px;font-size:10px;}}

/* A readable toolbar and a compact narrative beside the action row. */
.world-toolbar { padding:4px 8px; background:#191b17eb; border:1px solid #d4ba7c55; border-radius:4px; box-shadow:0 2px 10px #0003; }
.scene-narrative { font-size:15px; line-height:1.3; background:#252723df; }
.narrative-bar { flex-basis:28px; }
.narrative-bar button { min-height:28px; }
#narrative-content { padding:9px 12px; }
body[data-scene="world"] #simulation-ui,
body[data-scene="world"] #simulation-ui:has(#advanced-tools[open]) { position:absolute; inset:auto calc(var(--narrative-width,360px) + 44px) 22px 22px; width:auto; height:auto; }
body[data-scene="world"] #simulation-ui .simulation-panel { height:auto; padding:0; }
body[data-scene="world"] .simulation-form { padding:0; }
@media(max-width:600px) {
 body[data-scene="world"] #simulation-ui,
 body[data-scene="world"] #simulation-ui:has(#advanced-tools[open]) { inset:auto 12px 12px; }
 .scene-narrative { font-size:14px; }
 #narrative-content { padding:8px 12px; }
}

/* Narrative is one complete passage, never a scroll box or paged excerpt. */
.scene-narrative { max-height:none; overflow:visible; }
#narrative-content { flex:0 0 auto; max-height:none; overflow:visible; }

/* Saved message history: independent of generation controls. */
.message-history { position: relative; color: #222; font-family: Manrope, sans-serif; }
.message-history summary { cursor: pointer; padding: .6rem .8rem; border: 1px solid #7775; border-radius: 8px; background: #fffef7; font-size: 13px; }
.message-history section { position: fixed; top: 76px; left: 16px; width: min(440px, calc(100vw - 32px)); max-height: min(65vh, 620px); overflow: auto; padding: 20px; border: 1px solid #aaa; border-radius: 12px; background: #fffef7; box-shadow: 0 8px 40px #0003; text-align: left; }
.message-history h2 { margin: 0 0 8px; font-size: 19px; }
.message-history p { font-size: 12px; line-height: 1.5; color: #555; }
.message-history ol { padding-left: 22px; }
.message-history li { margin: 18px 0; }
.message-history strong { font-size: 12px; }
.message-history pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.55 Manrope, sans-serif; margin: 6px 0 12px; user-select: text; }
