:root{color-scheme:light;--ink:#172938;--muted:#637688;--accent:#2e78b7;--line:#d9e4ec;--paper:#fff;--bg:#f5f8fb;font-family:system-ui,-apple-system,"Noto Sans JP",sans-serif;color:var(--ink);background:var(--bg);font-size:15px}
*{box-sizing:border-box}body{margin:0}[hidden]{display:none!important}
button,input,select,textarea{font:inherit}button,a,select,input[type=range]{touch-action:manipulation}
button{cursor:pointer;border:1px solid var(--line);border-radius:12px;background:white;padding:8px 12px;color:var(--ink);min-height:44px}
button:hover{background:#edf5fc}button:disabled{opacity:.5;cursor:default}
.primary{background:var(--accent);color:white;border-color:var(--accent);font-weight:650}.primary:hover{filter:brightness(.95);background:var(--accent)}
a{color:var(--accent);text-decoration:none}
input,select,textarea{width:100%;color:var(--ink);background:white;border:1px solid var(--line);border-radius:10px;padding:10px;min-height:44px}
textarea{resize:vertical;line-height:1.65}
label{display:block;font-size:12px;color:var(--muted);line-height:1.6}
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,summary:focus-visible{outline:3px solid #69a5d6;outline-offset:3px}
main{max-width:1220px;margin:auto;padding:0 32px 12px}
.topbar{height:52px;display:flex;align-items:center;gap:12px;border-bottom:1px solid var(--line);margin-bottom:10px}
.brand{font-size:15px;letter-spacing:-.5px;white-space:nowrap}.brand b{font-weight:500;color:var(--muted)}
.character-picker{margin-left:auto;width:170px}.character-picker select{padding:6px 10px;font-size:12px}
.icon-control{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;min-width:44px;padding:10px;flex:none}
a.icon-control{border-radius:12px;font-size:23px}
.icon-control svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.layout{display:grid;grid-template-columns:340px minmax(0,1fr);gap:30px;align-items:start}.character-column,.conversation-column{min-width:0}
.stage{height:380px;background:linear-gradient(155deg,#e9f3fc,#f2f7fc);border:1px solid #dce8f2;border-radius:24px;position:relative;overflow:hidden;display:flex;align-items:center;justify-content:center}
.stage-circle{position:absolute;width:310px;height:310px;border-radius:50%;background:#fff9;top:28px}
.sprite-window{width:330px;height:330px;position:relative;overflow:hidden;margin-top:-12px;animation:breathe 4s ease-in-out infinite;isolation:isolate}
.sprite-window img{position:absolute;width:400%;height:200%;max-width:none;object-fit:fill;pointer-events:none}
.app-version{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:2px 12px;font-size:12px;color:var(--ink);margin:4px 2px 0;line-height:18px;overflow-wrap:anywhere}.app-version span[hidden]{display:none}
.stage.waist-stage{height:490px}.sprite-window[data-framing=waist]{width:330px;height:440px;margin-top:-12px}
@media(max-width:679px){.stage.waist-stage{height:253px}.sprite-window[data-framing=waist]{width:190px;height:253px;margin-top:-16px}}
@media(max-height:500px){.stage.waist-stage{height:130px}.sprite-window[data-framing=waist]{width:95px;height:126px;margin-top:0}}
.nameplate{position:absolute;bottom:17px;left:20px;right:20px;display:flex;align-items:center;gap:8px;border-top:1px solid #ccdbe7;padding-top:13px;font-size:13px}
.nameplate>span:last-child{margin-left:auto;color:var(--muted);font-size:12px}.live-dot{width:6px;height:6px;border-radius:50%;background:#679b82}
.conversation-toolbar{display:flex;align-items:center;gap:6px;margin-bottom:8px}.conversation-toolbar label{flex:1;min-width:0}
.conversation-toolbar select{font-size:13px;padding:6px 10px}.conversation-toolbar button{color:var(--muted)}
.messages{height:390px;overflow:auto;overscroll-behavior:contain;padding:20px;border:1px solid var(--line);border-radius:20px;background:var(--paper);scrollbar-width:thin;scroll-padding:20px}
.empty{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:var(--muted)}
.empty>span{display:block;width:28px;height:36px;background:#8cb5d5;font-size:0;clip-path:polygon(50% 0,62% 36%,100% 50%,62% 64%,50% 100%,38% 64%,0 50%,38% 36%)}
.empty h2{color:var(--ink);font-size:17px;font-weight:500;margin-top:22px}.empty p{font-size:13px;line-height:1.8}
.message{margin-bottom:20px;display:flex;flex-direction:column;align-items:start}.message.user{align-items:end}
.message .speaker{font-size:10px;letter-spacing:1px;color:var(--muted);margin-bottom:6px}
.bubble{max-width:92%;border-radius:15px;padding:12px 16px;background:#eff5fa;line-height:1.9;white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px}
.user .bubble{background:#f3f2ef}.message.failed .bubble{border:1px solid #d9b2a2;background:#fff7f3;font-size:12px}
.activity{font-size:12px;color:var(--muted);margin:6px 4px;line-height:1.6}.activity:empty{display:none}
.composer{display:flex;align-items:end;gap:6px;background:white;border:1px solid var(--line);border-radius:16px;padding:8px;margin-top:8px;flex-wrap:wrap}
.composer textarea{flex:1;min-width:0;border:0;min-height:44px;height:44px;max-height:140px;padding:8px 4px;resize:vertical;font-size:14px}
.composer-actions{display:flex;align-items:center;gap:4px}.composer-actions>span{display:none}
.error{color:#9f4730;font-size:12px;line-height:1.6;margin:0;flex-basis:100%}.error:empty{display:none}
#tools-dialog{width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;border:1px solid var(--line);border-radius:20px;padding:16px;color:var(--ink);background:var(--bg)}
#tools-dialog::backdrop{background:#17293866}
.dialog-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}.dialog-heading h2{margin:0;font-size:17px;font-weight:600}.dialog-heading button{border-color:transparent;background:transparent}
.panel{border:1px solid var(--line);border-radius:14px;background:#fff9;padding:12px 14px;margin-top:8px}
.panel summary{cursor:pointer;min-height:44px;font-size:13px;font-weight:600;line-height:44px}
.panel summary span{float:right;font-size:11px;font-weight:400;color:var(--muted)}
.panel[open] summary{margin-bottom:8px}.panel label{margin-top:10px}.panel textarea{margin:8px 0}.panel output{float:right;color:var(--ink)}
input[type=range]{padding:0;accent-color:var(--accent);border:none;background:none}
.range-labels{display:flex;justify-content:space-between;font-size:10px;color:var(--muted);margin-bottom:8px}
.muted{color:var(--muted);line-height:1.7;margin:0}.small{font-size:12px}
.disclaimer{text-align:center;font-size:10px;color:#8193a1;margin:14px 0 0}
.settings-grid{display:grid;grid-template-columns:1.3fr .8fr;gap:10px}.settings-grid select{font-size:12px}.connection p{margin:8px 0}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.login{display:grid;min-height:100dvh;place-items:center;padding:24px}.login form{max-width:400px;background:white;padding:32px;border-radius:24px}
.login h1{font-size:25px;line-height:1.6}.eyebrow{font-size:11px;letter-spacing:2px;color:var(--accent)}.login input{margin:8px 0 18px}.login button{width:100%}
@keyframes breathe{0%,100%{transform:translateY(0)}50%{transform:translateY(2px)}}
.gm-memo{border-top:1px solid var(--line);margin-top:12px}.gm-memo>summary{min-height:44px;padding:12px 0;cursor:pointer}.gm-memo ul{padding-left:22px;margin:6px 0 12px;overflow-wrap:anywhere}.gm-memo li{margin:6px 0;line-height:1.7}
.actor-continuity{border-top:1px solid var(--line);margin-top:12px}.actor-continuity>summary{min-height:44px;display:flex;align-items:center;line-height:1.6}.actor-continuity h3{font-size:12px;margin:12px 0 4px}.actor-continuity ul{padding-left:20px;margin:4px 0 12px}.actor-continuity li{font-size:13px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0}.actor-continuity button{min-height:44px;font-size:12px;max-width:100%;white-space:normal}
@media(min-width:900px){.messages{height:clamp(320px,49vh,560px)}}
@media(max-width:899px){
 main{padding:0 20px 12px}.layout{grid-template-columns:1fr;gap:8px}
 .stage{height:240px}.sprite-window{width:240px;height:240px;margin-top:-10px}.stage-circle{width:220px;height:220px;top:8px}
 .nameplate{left:16px;right:16px;bottom:10px;background:#eff6fcd9;padding-top:8px}
 .messages{height:320px}
}
@media(max-width:599px){
 main{padding:0 14px 12px}.topbar{height:44px;margin-bottom:8px;gap:8px}.brand{font-size:12px}.brand b{display:none}.character-picker{width:150px}
 .stage{height:200px;border-radius:18px}.sprite-window{width:190px;height:190px;margin-top:-16px}.stage-circle{width:180px;height:180px;top:0}
 .nameplate{font-size:12px;bottom:9px}.nameplate>span:last-child{font-size:10px}
 .messages{height:240px;padding:15px;border-radius:16px}.bubble{font-size:13px;padding:10px 13px}
 .composer textarea{font-size:13px}
}
body.compact .stage{height:92px}body.compact .sprite-window{width:120px;height:120px;margin-top:30px;animation:none}
body.compact .stage-circle{display:none}body.compact .nameplate{left:12px;right:auto;border:0;background:none;bottom:10px}
body.compact .nameplate>span:last-child{display:none}
@media(max-height:500px){.stage{height:110px}.sprite-window{width:130px;height:130px;animation:none}.messages{height:160px}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;scroll-behavior:auto!important}}

@media(max-width:599px){#tools-dialog{position:fixed;inset:auto 12px 12px;margin:0;width:auto;max-height:60dvh}}

/* Adopted C layout: controls follow input in normal flow, with no transcript overlap. */
.stage-outfit{position:absolute;top:10px;right:10px;z-index:2;width:96px}
.stage-outfit select{font-size:11px;padding:6px 8px;background:#ffffffed}
.action-dock{display:flex;align-items:center;justify-content:space-around;gap:4px;height:44px;margin-top:6px;border-top:1px solid var(--line)}
.action-dock .icon-control{background:transparent;border-color:transparent;color:var(--muted)}
.action-dock .icon-control:hover{background:#e4f0fa;color:var(--accent)}
#history-panel .conversation-toolbar{margin:10px 0 0}
#history-panel select{font-size:13px}

.mode-nav{display:none}
@media(max-width:680px){
 main{padding-bottom:calc(84px + env(safe-area-inset-bottom))}
 .mode-nav{position:fixed;bottom:0;left:0;right:0;z-index:5;display:flex;gap:2px;padding:6px 4px calc(6px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:#f5f8fbf5;backdrop-filter:blur(12px)}
 .mode-nav a{flex:1;min-width:0;min-height:48px;display:flex;flex-direction:column;align-items:center;justify-content:center;border-radius:9px;color:var(--muted)}
 .mode-nav svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
 .mode-nav span{font-size:10px;margin-top:4px;white-space:nowrap}
 .mode-nav .selected{background:#e4f0fa;color:#205e90}
}

/* Group cards replace the participant strip without moving the speaker. */
.address-control{flex-basis:100%;margin:0}.address-control select{height:44px;padding:6px 10px;font-size:12px}
#participant-picker{border:0;padding:0;margin:12px 0;display:grid;gap:4px}
#participant-picker legend{font-size:12px;color:var(--muted);padding:0}
#participant-picker label{display:flex;align-items:center;gap:8px;min-height:44px;margin:0;font-size:13px;overflow-wrap:anywhere}
#participant-picker input{width:20px;min-height:20px;flex:none}
#participant-count{margin:8px 0}#create-group{width:100%}
.group-layout{grid-template-columns:minmax(0,1fr);gap:8px}
.stage.group-stage{container-type:inline-size;height:auto;padding:8px;display:block;overflow:visible}
.group-stage .stage-circle,.group-stage .nameplate{display:none}
.group-stage .participant-controls{display:block}
.participant-tabs{display:flex;flex-wrap:wrap;justify-content:center;align-items:start;gap:6px 2px;--portrait-size:190px}
.actor-card{display:flex;flex-direction:column;align-items:center;flex:none;width:100%;padding:0;border:0;background:transparent;border-radius:10px;color:var(--actor-name);min-height:44px}
.actor-card:hover{background:transparent}.actor-card:focus-visible{outline-offset:1px}
.actor-portrait{display:flex;position:relative;align-items:center;justify-content:center;width:100%;max-width:var(--portrait-size);aspect-ratio:3/4;border-radius:10px}
.actor-sprite{position:relative;overflow:hidden;width:100%;aspect-ratio:3/4;isolation:isolate}
.actor-sprite[data-framing=bust]{aspect-ratio:1}
.actor-sprite img{position:absolute;max-width:none;object-fit:fill;pointer-events:none}
.actor-name{display:flex;align-items:center;justify-content:center;gap:3px;min-height:24px;width:100%;font-size:11px;font-weight:700;line-height:14px;padding:2px 0}
.actor-name>span:first-child{min-width:0;overflow-wrap:anywhere}
.speaking-badge{flex:none;font-size:9px;line-height:16px;padding:0 2px;color:var(--actor-name);background:white;border:1px solid var(--actor-accent);border-radius:4px;visibility:hidden}
.actor-card[aria-pressed=true] .actor-name>span:first-child{text-decoration:underline;text-underline-offset:3px;text-decoration-thickness:2px}
.actor-card[data-speaking=true] .actor-portrait{box-shadow:inset 0 0 0 2px var(--actor-accent);background:var(--actor-tint)}
.actor-card[data-speaking=true] .speaking-badge{visibility:visible}
.participant-tabs[data-count="2"] .actor-card{width:calc((100% - 2px)/2);--portrait-size:154px}
.participant-tabs[data-count="3"] .actor-card{width:calc((100% - 4px)/3);--portrait-size:104px}
.participant-tabs[data-count="4"] .actor-card{width:calc((100% - 2px)/2);--portrait-size:116px}
.participant-tabs[data-count="5"] .actor-card{width:calc((100% - 4px)/3);--portrait-size:104px}
.participant-tabs[data-count="5"] .actor-card:nth-child(n+4){width:calc((100% - 2px)/2);--portrait-size:130px}
@container (min-width:820px){
 .participant-tabs[data-count] .actor-card:nth-child(n){width:calc((100% - (var(--participant-count) - 1)*2px)/var(--participant-count));--portrait-size:190px}
}
.group-layout .message.character[data-speaker] .speaker{font-size:13px;font-weight:700;letter-spacing:0;color:var(--actor-name,var(--muted))}
.group-layout .message.character[data-speaker] .bubble{background:var(--actor-tint,#eff5fa);border:1px solid var(--actor-border,var(--line))}
.stage-outfit .outfit-caption{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
#expression-actor:empty{display:none}
#group-outfit-slot label{margin:8px 0}
body.compact .stage.group-stage{height:auto}
@media(max-height:500px){.stage.group-stage{height:auto}.group-layout .messages{height:160px}}
/* Waist poses need their own name strip below all hands on full mobile views. */
@media(max-width:679px) and (min-height:501px){
 body:not(.compact) .stage.waist-stage:not(.group-stage){height:285px;padding-bottom:32px}
 body:not(.compact) .stage.waist-stage:not(.group-stage) .sprite-window[data-framing=waist]{margin-top:0}
}
/* Keep the opaque hem above the PC name line at the existing portrait size. */
@media(min-width:680px) and (min-height:501px){
 .stage.waist-stage:not(.group-stage){height:510px}
}

/* Explain unfinished presentation when that feature is opened. */
.feature-notice{margin:0 0 10px;padding:9px 12px;border:1px solid #d8cfae;border-radius:10px;background:#fffaf0;color:#655630;font-size:12px;line-height:1.6}
#group-feature-notice{margin-top:8px}

/* A visible history entry; browsing stays separate from creation and the current thread. */
.history-button{display:inline-flex;align-items:center;justify-content:center;gap:5px;width:68px;min-width:68px;height:44px;padding:6px;font-size:12px;background:#fff9}
.history-button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.character-picker{min-width:0;flex:0 1 170px}
#history-dialog{width:min(480px,calc(100vw - 24px));max-height:70dvh;overflow:auto;border:1px solid var(--line);border-radius:20px;padding:16px;color:var(--ink);background:var(--bg)}
#history-dialog::backdrop{background:#17293866}
.history-filters{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px}
.history-filters select{font-size:13px}
#history-list{list-style:none;padding:0;margin:12px 0 0;display:grid;gap:8px}
.history-entry{display:flex;flex-direction:column;gap:6px;width:100%;min-height:44px;padding:12px;text-align:left;background:#fff;overflow-wrap:anywhere}
.history-entry[aria-current=true]{border-color:var(--accent);box-shadow:inset 3px 0 var(--accent)}
.history-entry strong{font-size:13px;line-height:1.5;font-weight:600}
.history-preview{font-size:12px;color:var(--muted);line-height:1.6;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.history-meta{display:flex;justify-content:space-between;gap:10px;font-size:11px;color:var(--muted)}
.history-meta>span{color:var(--accent)}
.new-conversation{width:100%;margin-top:12px;font-size:13px}
.reply-limit-control{margin-top:12px}
.reply-limit-control select{font-size:12px}
/* Reserve the same space under every portrait, so changing speakers cannot move the cast. */
.actor-caption,.portrait-caption{height:40px;min-height:40px;box-sizing:border-box;line-height:16px;font-weight:400;color:var(--ink);padding:4px 5px;border-radius:8px;overflow:hidden;overflow-wrap:anywhere;white-space:pre-wrap;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.actor-caption{width:100%;font-size:11px;border:1px solid transparent;text-align:left}
.actor-card[data-speaking=true] .actor-caption{background:var(--actor-tint);border-color:var(--actor-border)}
.portrait-caption{font-size:12px;margin:4px 0 0}
.portrait-caption:not(:empty){background:#fff9;border:1px solid var(--line)}
.group-layout .portrait-caption{display:none}
.scene-bar{display:flex;gap:8px;margin:0 0 8px}
.scene-bar button{height:44px;font-size:12px;padding:8px 10px;display:flex;align-items:center;justify-content:center;gap:6px}
#open-location{flex:1;min-width:0;justify-content:flex-start;background:#fff9}
#current-location{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.location-copy{display:flex;flex-direction:column;min-width:0;line-height:16px;text-align:left}
#episode-chip{font-size:12px;line-height:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}
#open-location{padding-top:4px;padding-bottom:4px}
.episode-state{font-size:13px;font-weight:600;line-height:1.6;margin:12px 0 4px}
#episode-panel p{line-height:1.6;overflow-wrap:anywhere}
.episode-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.episode-actions button{flex:1;min-height:44px;font-size:13px}
#open-autochat{width:114px;flex:none}
.auto-status{font-size:12px;line-height:16px;color:var(--muted);margin:0 0 8px}
.auto-actions{display:flex;gap:8px;margin-top:10px}.auto-actions button{flex:1}
.autochat-origin{font-size:11px;color:var(--muted);text-align:center;margin:8px 0}
@media(max-width:599px){
 .character-picker{flex:1 1 100px;width:auto}
 #history-dialog{position:fixed;inset:auto 12px 16px;margin:0;width:auto;max-height:70dvh}
}

.scene-bar svg{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}

/* Reachable scene map and bounded GM controls; portrait/message geometry is unchanged. */
.location-map{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:12px 0}
.place-card{min-width:0;min-height:72px;text-align:left;padding:10px;display:flex;flex-direction:column;gap:3px;overflow-wrap:anywhere;font-size:13px}
.place-card.current{background:#e9f3fc;border:2px solid #2e78b7;color:var(--ink);opacity:1}.place-card .place-meta{font-size:11px;line-height:1.5;color:var(--ink)}
.scene-choices{border:0;padding:0;margin:8px 0;min-width:0}.scene-choices legend,.scene-subtitle{font-size:13px;font-weight:600;color:var(--ink);margin:10px 0 4px}
.scene-choice{display:flex;align-items:center;gap:10px;min-height:44px;margin:0!important;color:var(--ink);font-size:12px;overflow-wrap:anywhere}
.scene-choice input{width:18px;min-width:18px;min-height:18px;height:18px;padding:0;flex:none;accent-color:var(--accent)}
.roster-entry{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:6px;border-bottom:1px solid var(--line);padding:8px 0}.roster-name{display:block;font-size:14px;overflow-wrap:anywhere}.roster-place{display:block;font-size:12px;color:var(--muted);overflow-wrap:anywhere}.roster-actions{display:flex;flex-wrap:wrap;gap:4px;justify-content:flex-end}.roster-actions button{font-size:12px;padding:6px 8px}
.roster-entry.has-journey{grid-template-columns:minmax(0,1fr)}.roster-entry.has-journey .roster-actions{justify-content:flex-start}
.scene-editor{border-top:1px solid var(--line);margin-top:12px;padding-top:4px}.scene-editor summary{font-size:12px;font-weight:500;line-height:1.5;display:flex;align-items:center;min-height:44px}
#scene-events{padding-left:20px;font-size:12px;line-height:1.7;overflow-wrap:anywhere}#scene-events li{margin:8px 0}
.placement-entry{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px;align-items:end;margin:8px 0}.placement-entry label{min-width:0}.placement-entry button{font-size:12px}
.roster-activity,.journey-status{display:block;font-size:12px;line-height:1.5;overflow-wrap:anywhere}.arrival-meta{display:block}.activity-entry{display:grid;gap:6px;margin:8px 0 16px;padding:8px;border:1px solid var(--line);border-radius:10px;min-width:0}.activity-entry label{min-width:0}.activity-entry input:not([type=checkbox]),.activity-entry select{width:100%;min-height:44px}.activity-entry button{min-height:44px}.placement-entry button[data-actor]{grid-column:1/-1;justify-self:start}
.gm-settings{border-top:1px solid var(--line);margin-top:12px;padding-top:8px}#auto-budget{margin:8px 0;font-weight:600}#place-description{line-height:1.7;overflow-wrap:anywhere}
@media(max-width:390px){.roster-entry{grid-template-columns:minmax(0,1fr)}.roster-actions{justify-content:flex-start}}

/* 2026-10-05: one visible function per popup and a single history workspace. */
#tools-dialog>.panel[hidden]{display:none}
.action-dock{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.action-dock>.icon-control{width:auto;min-width:0;gap:7px;display:flex;justify-content:center;align-items:center;font-size:12px}
.scene-episode{display:flex;align-items:center;justify-content:center;gap:4px;min-height:44px;padding:6px 9px;white-space:nowrap;font-size:12px}.scene-episode svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
#history-dialog{width:min(720px,calc(100vw - 24px));max-height:78dvh;overflow:auto;padding:16px}#history-dialog[open]{display:flex;flex-direction:column;gap:8px}
.history-toolbar{display:flex;gap:8px;justify-content:space-between}.history-toolbar button{min-height:44px;font-size:13px}.history-search-label{display:block;font-size:12px}.history-search-label input{margin-top:4px;width:100%}
.history-filters{margin:0;gap:8px}.history-scroll{overflow:auto;min-height:80px;overscroll-behavior:contain}#history-list{margin:0;gap:10px}
.history-item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px;align-items:stretch}.history-entry{min-width:0;gap:5px}.history-manage{font-size:12px;min-width:48px;padding:8px}.history-participants{font-size:11px;color:var(--muted);line-height:1.5}.history-meta{flex-wrap:wrap;gap:4px 10px}.history-meta>span{white-space:normal}
#history-editor{padding:12px;border:1px solid var(--line);background:var(--paper);border-radius:14px;overflow:auto;max-height:40dvh}#history-editor[hidden]{display:none}#history-editor h3{font-size:14px;margin:0 0 8px}.history-edit-flags{display:flex;flex-wrap:wrap;gap:8px 16px}.history-edit-flags label{display:flex;align-items:center;gap:6px;min-height:44px}.history-edit-flags input{width:18px;min-height:18px;height:18px;margin:0}.history-editor-actions{display:flex;gap:6px;flex-wrap:wrap}.history-editor-actions button{font-size:12px;min-height:44px}#history-more{width:100%;margin-top:10px;min-height:44px}
@media(max-width:599px){#history-dialog{inset:auto 12px 16px;width:auto;max-height:78dvh}.scene-bar #open-autochat{padding:6px 9px;font-size:12px}.scene-bar #open-location{min-width:0}.action-dock>.icon-control{gap:5px}.history-filters label{min-width:0}.history-toolbar button{font-size:12px}.history-entry{padding:10px}.history-participants{font-size:11px}}

#history-dialog.history-editing>.history-toolbar,#history-dialog.history-editing>.history-search-label,#history-dialog.history-editing>.history-filters{display:none}#history-editor{flex-shrink:0}#history-editor>label{margin:0;font-size:12px}#history-editor input[type=text],#history-editor input:not([type]){margin-top:4px;min-height:44px}#history-editor .history-edit-flags label{margin:0}#history-editor>p{margin:4px 0 8px;font-size:11px;line-height:1.5}.history-editor-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.history-editor-actions button{padding:8px 6px;font-size:11px;line-height:1.4}

#history-dialog .dialog-heading h2{flex:1;min-width:0}#history-reload{font-size:12px;min-height:44px;padding:8px}
#encyclopedia-dialog{width:min(860px,calc(100vw - 24px));max-height:86dvh;border:1px solid var(--line);border-radius:20px;padding:18px;color:var(--ink);background:var(--bg);overflow:hidden}
#encyclopedia-dialog[open]{display:flex;flex-direction:column}
#encyclopedia-dialog::backdrop{background:#17293866}
#encyclopedia-dialog .dialog-heading{flex-shrink:0;margin-bottom:8px}
#encyclopedia-dialog .dialog-heading p{margin:5px 0 0}
#encyclopedia-dialog .dialog-heading button{flex-shrink:0;width:44px;height:44px}
#encyclopedia-error:empty+#encyclopedia-retry{display:none}
#encyclopedia-content{display:flex;flex-direction:column;min-height:0}
#encyclopedia-people{display:flex;gap:6px;flex-shrink:0;overflow-x:auto;padding:4px 2px 10px;scrollbar-width:thin}
#encyclopedia-people button{flex:1 0 auto;min-width:80px;min-height:44px;padding:8px 12px;font-size:13px;white-space:nowrap;background:var(--paper)}
#encyclopedia-people button[aria-pressed=true]{background:#e4f0fa;border-color:#2e78b7;color:#205e90;box-shadow:inset 0 -2px #2e78b7}
#encyclopedia-scroll{overflow-y:auto;overscroll-behavior:contain;min-height:0;padding:4px 8px 12px 2px;scrollbar-gutter:stable;overflow-wrap:anywhere}
.encyclopedia-hero{display:flex;align-items:center;gap:22px;padding:12px 18px 20px;border-bottom:1px solid var(--line);margin-bottom:18px}
#encyclopedia-portrait{flex-shrink:0;position:relative;overflow:hidden;width:112px;height:149px;border-radius:14px;background:linear-gradient(160deg,#fff,#e7edf5);border-bottom:3px solid var(--person-color,var(--accent))}
#encyclopedia-portrait[data-framing=bust]{height:112px}
#encyclopedia-image{position:absolute;max-width:none;object-fit:fill}
.encyclopedia-eyebrow{font-size:10px;letter-spacing:.16em;color:var(--muted);margin:0 0 8px}
#encyclopedia-name{margin:0 0 8px;font-size:24px;font-weight:650;letter-spacing:.05em}
#encyclopedia-tagline{font-size:14px;line-height:1.8;margin:0;color:#3c5467}
.encyclopedia-state{padding:16px;border:1px solid #cbdfea;border-radius:14px;background:#f0f7fc;margin-bottom:24px}
.encyclopedia-state-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}
.encyclopedia-state-heading h4{font-size:17px;margin:0}.encyclopedia-state-heading button{min-height:44px;font-size:12px;padding:7px 13px;background:var(--paper)}
#encyclopedia-context{font-size:13px;font-weight:600;margin:4px 0 8px}
#encyclopedia-state-intro{line-height:1.7;margin:6px 0 12px}
.encyclopedia-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:12px 0}
.encyclopedia-fact{background:#ffffffc9;border:1px solid #dce8f0;border-radius:9px;padding:10px 12px;min-width:0}
.encyclopedia-fact dt{font-size:11px;color:var(--muted);margin-bottom:4px}.encyclopedia-fact dd{font-size:13px;line-height:1.65;margin:0}
#encyclopedia-state-details{margin-top:10px;border-top:1px solid #d3e2ed;padding-top:4px}
#encyclopedia-state-details>summary,.encyclopedia-spoiler>summary{min-height:44px;cursor:pointer;line-height:1.6;padding:12px 2px;font-size:13px;font-weight:600}
#encyclopedia-state-details-content .encyclopedia-section{margin:12px 0}
#encyclopedia-state-details-content .encyclopedia-section p{font-size:13px;line-height:1.8}
#encyclopedia-observed{font-size:11px;margin:8px 0 0}
.encyclopedia-section{margin:0 0 24px}.encyclopedia-section h4{font-size:16px;margin:0 0 10px;color:#24465e}
.encyclopedia-section p{font-size:14px;line-height:1.85;margin:8px 0}
.encyclopedia-section strong{font-weight:600;color:#24465e}
.encyclopedia-spoiler{padding:0 14px;border:1px solid var(--line);border-radius:12px;background:var(--paper)}
.encyclopedia-spoiler p{font-size:14px;line-height:1.85;margin:6px 0 16px}
.encyclopedia-source{font-size:11px;line-height:1.8;color:var(--muted);margin:18px 0 0}
#encyclopedia-dialog :focus-visible{outline:2px solid #2e78b7;outline-offset:2px}
.action-dock:has(#open-encyclopedia){grid-template-columns:repeat(4,minmax(0,1fr))}
@media(max-width:599px){#encyclopedia-dialog{padding:12px;max-height:86dvh}.encyclopedia-hero{gap:15px;padding:10px 4px 16px}.encyclopedia-state{padding:12px}.encyclopedia-fact{padding:9px}#encyclopedia-portrait{width:84px;height:112px}#encyclopedia-portrait[data-framing=bust]{height:84px}#encyclopedia-name{font-size:21px}#encyclopedia-tagline{font-size:13px}#encyclopedia-scroll{padding-right:2px}#encyclopedia-people button{padding:8px 10px}.action-dock:has(#open-encyclopedia)>.icon-control{gap:4px;font-size:11px}}

/* Historical poses use their own portrait, including actors now away from the scene. */
.bubble.replayable{cursor:pointer}.bubble.replayable:focus-visible{outline:3px solid var(--accent,#427aaf);outline-offset:3px}
.bubble.replayable::after{content:'▷ ポーズ';display:block;font-size:11px;color:#57728d;margin-top:6px}
.retry-note{display:block;margin-top:8px}.retry-turn{display:block;margin-top:8px;min-height:44px}
.send-recovery{padding:10px;border:1px solid var(--line);border-radius:12px}.send-recovery button,#receive-retry{min-height:44px}
#pose-replay{width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;border:1px solid var(--line);border-radius:20px;padding:16px;color:var(--ink);background:var(--bg)}
#pose-replay h2{font-size:17px}#pose-replay button{min-height:44px}#pose-replay-text{white-space:pre-wrap;overflow-wrap:anywhere}
.replay-stage{display:flex;justify-content:center;align-items:center;background:linear-gradient(155deg,#e9f3fc,#f2f7fc);border-radius:16px;min-height:265px}
#replay-sprite{width:190px;height:190px;margin:0;animation:none}#replay-sprite[data-framing=waist]{width:190px;height:253px;margin:0}

#send-recovery-prompt{white-space:pre-wrap;overflow-wrap:anywhere;max-height:120px;overflow:auto}

.user-role-bar{margin:8px 16px;min-width:0}
.user-role-bar button{display:flex;flex-direction:column;align-items:flex-start;gap:3px;width:100%;min-height:44px;padding:8px 12px;text-align:left;white-space:normal;overflow-wrap:anywhere;font-size:14px}
.user-role-bar .role-hint{font-size:12px;opacity:.75;line-height:1.5}
#new-user-role,#history-user-role{max-width:100%;min-width:0}

/* Living state: the same saved state used for the next reply. */
.living-now{background:#edf5fc;border:1px solid #b7d5ec;border-radius:14px;padding:14px;margin:12px 0;color:var(--ink)}
.living-now h4,.living-changes h4{margin:0 0 8px;font-size:15px}.living-now p{margin:8px 0;line-height:1.7}.living-feeling{font-size:16px;font-weight:600}
.living-changes{margin:16px 0}.living-change{border-left:3px solid #75a9d0;padding:3px 0 3px 12px;margin:12px 0;overflow-wrap:anywhere}.living-change p{margin:4px 0;line-height:1.7}.living-kind{font-size:11px;color:#416d90}

/* Start selection follows the dated 960/300px timeline specification. */
#tools-dialog:has(#history-panel[open]){width:min(960px,calc(100vw - 48px));padding:24px;max-height:90dvh}
.start-picker{color:#172938;background:#f5f8fb;padding:16px;border:1px solid #d9e4ec;border-radius:16px;margin-bottom:16px}.start-picker h3{margin:0 0 12px}.start-kind{display:flex;gap:12px;border:0;padding:0;margin:0 0 12px}.start-kind label{display:flex;align-items:center;gap:8px;min-height:44px;padding:0 12px;border:1px solid #d9e4ec;border-radius:10px;background:#fff}.start-kind label:has(input:checked){border:2px solid #2e78b7;background:#edf5fc}.canon-picker{display:grid;grid-template-columns:300px minmax(0,1fr);gap:24px}.canon-picker[hidden]{display:none}.start-work,.start-eyebrow{color:#637688;font-size:12px}.start-timeline{border:0;padding:0 0 0 24px;margin:0;display:grid;gap:8px;position:relative}.start-timeline:before{content:"";position:absolute;left:12px;top:24px;bottom:28px;width:2px;background:#d9e4ec}.start-timeline legend{font-size:13px;padding-bottom:8px}.start-card{display:flex;align-items:center;gap:10px;min-height:72px;padding:12px;background:#fff;border:1px solid #d9e4ec;border-radius:12px;position:relative;cursor:pointer}.start-card:has(input:checked){border:2px solid #2e78b7;background:#edf5fc}.start-card span{display:grid;gap:6px;min-width:0}.start-card strong{font-size:14px}.start-card small{color:#637688;font-size:12px}.start-card input{width:18px;height:18px;flex-shrink:0}.start-detail{align-self:start;border:1px solid #d9e4ec;border-radius:12px;padding:20px;background:#fff;position:sticky;top:0;min-width:0}.start-detail h4{font-size:22px;margin:8px 0 12px}.start-detail p,.start-detail li{overflow-wrap:anywhere;line-height:1.7}.start-detail summary{min-height:44px;cursor:pointer}.start-people{display:flex;flex-wrap:wrap;gap:6px;margin:14px 0}.start-people span{font-size:12px;background:#edf5fc;border-radius:20px;padding:7px 10px}.start-unavailable{color:#637688}.start-unavailable:has(input:checked){outline:2px solid #b94c43}.start-summary{padding:12px;background:#edf5fc;border:1px solid #d9e4ec;border-radius:10px;font-size:12px;line-height:1.7;overflow-wrap:anywhere}.start-picker input:focus-visible,.start-picker select:focus-visible{outline:3px solid #69a5d6;outline-offset:3px}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
@media(max-width:899px){.canon-picker{grid-template-columns:minmax(0,1fr)}.start-detail{position:static}.start-timeline{gap:6px}.start-picker{padding:12px}#tools-dialog:has(#history-panel[open]){width:calc(100vw - 24px);padding:12px;max-height:90dvh}}
@media(max-width:599px){#tools-dialog:has(#history-panel[open]){inset:12px;margin:0;width:auto;max-height:calc(100dvh - 24px)}.start-detail{padding:14px}.start-kind{gap:8px}.start-kind label{padding:0 10px}.start-picker{padding:10px}}

.start-kind label{flex:1;min-width:0;justify-content:center;white-space:nowrap;color:#172938}.start-kind input{width:18px;height:18px;min-width:18px;flex:0 0 18px;padding:0;margin:0}.start-card strong{color:#172938}
