/* Phase 13.68 — quiet, consistent editing surfaces; small screens never crop controls.
   Visual-only improvements. The stage/scene graph and stored project format are unchanged. */
:root{--novel-calm-border:#d9e3d5;--novel-calm-ink:#3e5945;--novel-calm-soft:#f7f9f5}
.studio-view,.studio-top,.studio-grid,.studio-grid .pane,.scene-editor,
.novel-workflow,.script-edit-layout,.script-workspace,.script-preview-frame,
.composition-shell,.composition-basic,.quick-asset-picker,.project-media-library,
.novel-asset-shelf,.asset-shelf-body,.formal-actor-shelf{min-width:0;max-width:100%}
.studio-view :is(button,select,input,textarea){max-width:100%}
.studio-view button{line-height:1.45;overflow-wrap:anywhere}
.studio-view :is(.scene-editor,.quick-asset-picker,.composition-shell,.project-media-library,.novel-asset-shelf) :is(h2,h3,strong,span,p,label,small){overflow-wrap:anywhere}
.studio-view :is(input,select,textarea){min-width:0}
.studio-top{gap:15px}
.studio-top .top-actions{align-items:center}
.novel-workflow{box-shadow:none;border-color:var(--novel-calm-border);background:#f7f9f5}
.workflow-steps button{box-shadow:none;min-width:0}
.workflow-steps button.is-active{box-shadow:inset 0 0 0 1px #9fbaa0}
.pane{box-shadow:0 5px 20px rgba(55,69,52,.045)}
.script-workspace,.script-preview-frame,.project-media-library,.quick-asset-picker{border-radius:13px}
.script-flow-nav{border-color:var(--novel-calm-border);background:#f7f9f5}
.composition-shell{box-shadow:none;background:#fafbf9;border-color:var(--novel-calm-border)}
.composition-basic{min-width:0}
.composition-basic label{min-width:0}
.composition-basic select{max-width:100%;min-width:0}
.composition-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:12px 12px 5px}
.composition-actions button{min-width:0;width:100%;padding:9px 6px;font-size:12px;min-height:42px;white-space:normal}
.composition-note{margin-top:5px;color:#728172}
.quick-asset-picker{gap:12px;background:#f8faf7;border:1px solid #d7e2d3;padding:14px}
.quick-asset-heading{align-items:start}
.quick-asset-heading strong{font-size:14px;color:#35553c}
.quick-asset-heading span{font-size:11px;line-height:1.55}
.quick-asset-tabs button{box-shadow:none}
/* A wrapping grid makes ALL choices visible instead of showing a misleading half-card. */
.quick-asset-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,135px),1fr));overflow:visible;gap:8px;padding:1px;margin-bottom:2px}
.quick-asset-choices .quick-asset-item{min-width:0;width:100%;white-space:normal;text-align:center;line-height:1.45;min-height:43px;padding:9px 7px;overflow-wrap:anywhere;flex:none}
.quick-asset-thumbs{max-height:300px;min-width:0;grid-template-columns:repeat(auto-fill,minmax(min(100%,130px),1fr));gap:9px}
.quick-asset-thumb{min-width:0}
.quick-asset-thumb img{height:100px}
.quick-asset-thumb span{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-height:30px;overflow:hidden}
.quick-media-row{flex-wrap:wrap;align-items:baseline;line-height:1.5}
.quick-asset-footer{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.quick-asset-footer button{min-width:0!important;max-width:100%;width:100%;min-height:45px;font-size:12px;line-height:1.5;white-space:normal;padding:9px 7px}
.quick-asset-footer button:first-child{background:#eaf2e6;border-color:#a9c2a1;font-weight:700}
.project-shelf-items{max-width:100%}
.project-shelf-item{min-width:0}
.project-media-grid,.formal-actor-grid{min-width:0}
.project-media-card .media-thumb-button{min-width:0}
.project-media-card .media-thumb-button img{max-width:100%}
.editor-tabs{min-width:0}
.editor-tabs button{line-height:1.4}

@media(max-width:880px){
 html,body{width:100%;min-width:0;max-width:100%;overflow-x:clip}
 .studio-top{padding:12px 12px 6px;gap:10px}
 .studio-grid{grid-template-columns:minmax(0,1fr);padding:0 10px max(80px,env(safe-area-inset-bottom))}
 .studio-grid>.pane{width:100%;min-width:0;padding:12px;border-radius:14px}
 .novel-workflow{margin:9px 10px 12px;padding:12px;border-radius:14px}
 .workflow-intro{margin-bottom:8px}
 .workflow-steps{gap:7px}
 .workflow-steps button{min-width:0;padding:9px 5px;min-height:57px}
 .workflow-steps button strong{font-size:12px}
 .workflow-steps button small{font-size:10px}
 .workflow-help{margin-top:7px;font-size:11px;line-height:1.5}
 .studio-top .top-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;width:100%}
 .studio-top .top-actions button{min-width:0;max-width:100%;min-height:40px;padding:7px 5px;white-space:normal;line-height:1.3;font-size:10.5px}
 .studio-top .top-actions #graphOpenBtn,.studio-top .top-actions #studioPlayBtn{grid-column:span 2;font-size:12px;min-height:43px}
 .studio-top .top-actions #graphOpenBtn{order:-2}.studio-top .top-actions #studioPlayBtn{order:-1}
 .editor-pane .pane-head{flex-wrap:wrap}
 .editor-pane .pane-head .pane-tools{flex:0 0 auto}
 .editor-tabs{max-width:100%}
 .script-workspace{margin-top:4px}
 .script-preview-frame{margin-top:12px;padding-top:12px}
 .script-flow-nav{padding:11px;margin:8px 0 13px}
 .script-flow-actions button{min-width:0;overflow-wrap:anywhere}
 .composition-actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
 .composition-basic{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .composition-basic label:last-child{grid-column:1/-1}
 .composition-stage.scene-preview-compose{max-height:205px}
 .composition-dialogue{padding:12px 13px}
 .quick-asset-picker{padding:12px;gap:11px}
 .quick-asset-thumbs{grid-template-columns:repeat(2,minmax(0,1fr))}
 .quick-asset-footer{grid-template-columns:1fr}
 .quick-asset-tabs{gap:7px}
 .quick-asset-tabs button{min-height:44px}
 .project-media-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 .project-media-grid.media-grid-large{grid-template-columns:repeat(2,minmax(0,1fr))}
 .project-media-card :is(.media-card-details,.media-card-options){min-width:0}
 .project-media-card .media-thumb-button.media-portrait{aspect-ratio:4/5}
 .project-media-card .media-card-options{flex-wrap:wrap}
 .asset-target-buttons{grid-template-columns:repeat(2,minmax(0,1fr))}
 .formal-actor-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;max-height:480px}
 .formal-actor-card img{height:145px}
 .quick-asset-heading span{flex-basis:100%}
}
@media(max-width:400px){
 .studio-grid>.pane{padding:10px}
 .novel-workflow{padding:10px}
 .workflow-steps button{padding:8px 4px;min-height:54px}
 .workflow-steps button strong{font-size:11.5px}
 .workflow-steps button small{font-size:9.5px}
 .quick-asset-picker{padding:10px}
 .quick-asset-choices{grid-template-columns:repeat(2,minmax(0,1fr))}
 .quick-asset-thumbs{grid-template-columns:repeat(2,minmax(0,1fr))}
 .quick-asset-thumb img{height:105px}
 .formal-actor-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 .formal-actor-card img{height:125px}
 .script-preview-top{flex-wrap:wrap}
 .script-preview-top button{min-height:41px}
 .script-flow-actions button{min-height:57px;padding:6px 3px;font-size:11px}
 .script-flow-actions button b{width:19px;height:19px}
 .mobile-tabs{gap:5px;padding:6px 9px}
 .mobile-tabs button{min-height:41px;padding:7px 4px;font-size:12px}
}
@media(max-width:340px){
 .studio-top .top-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
 .studio-top .top-actions #graphOpenBtn,.studio-top .top-actions #studioPlayBtn{grid-column:span 1}
 .workflow-steps button small{display:none}
 .quick-asset-choices{grid-template-columns:1fr 1fr}
}

/* iOS Safari: prevent text autosizing from changing control widths after scrolling. */
@media(max-width:880px){
 html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
 .studio-view :is(input,textarea,select){font-size:16px}
 .studio-view :is(.route-box,.action-box,.branch-quick-actions,.branch-connect-form,.asset-shelf-body,.inline-cue-more,.line-box){min-width:0;max-width:100%}
 .studio-view :is(.branch-quick-actions,.branch-connect-form,.scene-health-filters) button{min-width:0;white-space:normal;overflow-wrap:anywhere}
 .studio-view :is(.branch-connect-form,.branch-debug-list,.inline-cue-basic) > *{min-width:0}
 .studio-view :is(.branch-quick-actions,.branch-connect-form,.project-media-controls,.asset-target-buttons){max-width:100%}
}


/* Phase 13.69 — Mobile editing usability pass. Keeps all original actions and data. */
.studio-top .top-actions{min-width:0;display:flex;align-items:center;flex-wrap:wrap;gap:8px;}
.studio-main-actions,.studio-tools-grid{display:flex;align-items:center;gap:7px;flex-wrap:wrap;min-width:0;}
.studio-main-actions button,.studio-tools-grid button{min-width:0;}
.studio-tools-details>summary{cursor:pointer;display:none;}
/* Desktop: secondary actions stay visible; their original IDs and handlers are unchanged. */
@media(min-width:881px){
 .studio-tools-details:not([open])>.studio-tools-grid{display:flex!important;}
 .studio-tools-details>.studio-tools-grid{display:flex;align-items:center;gap:7px;flex-wrap:wrap;}
}
@media(max-width:880px){
 /* The header scrolls away: the tab bar must stick to the real viewport top, not a stale 92px gap. */
 .mobile-tabs{top:0!important;padding:7px 10px;background:#fafbf8;box-shadow:0 3px 12px rgba(38,58,36,.07);}
 .mobile-tabs button{min-height:44px;}
 .studio-grid{min-height:100dvh;}
 .studio-grid>.pane{scroll-margin-top:64px;}
 .studio-top{padding:12px 12px 9px;}
 .studio-top .top-actions{display:flex;flex-direction:column;align-items:stretch;gap:8px;width:100%;}
 .studio-main-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
 .studio-top .top-actions .studio-main-actions button{min-width:0;grid-column:auto;min-height:43px;order:0;font-size:12px;padding:8px 6px;}
 .studio-tools-details{width:100%;border:1px solid #d2decd;border-radius:11px;background:#f7faf5;overflow:hidden;}
 .studio-tools-details>summary{display:list-item;padding:9px 13px;font-size:12px;font-weight:750;min-height:42px;color:#456346;list-style:inside;cursor:pointer;}
 .studio-tools-details[open]>summary{border-bottom:1px solid #d5e1d1;}
 .studio-tools-details .studio-tools-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;padding:9px;}
 .studio-tools-details .studio-tools-grid button{width:100%;min-height:43px;font-size:11.5px;padding:7px 4px;white-space:normal;line-height:1.4;}
 /* A complete, discoverable pair of scene-editor tabs: no clipped horizontal label. */
 .editor-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;overflow:visible;white-space:normal;scroll-snap-type:none;padding:0 0 10px;}
 .editor-tabs[data-tab-group="assets"]{grid-template-columns:minmax(0,1fr);}
 .editor-tabs button{min-width:0;min-height:44px;max-width:100%;white-space:normal;overflow-wrap:anywhere;font-size:12px;padding:8px 6px;}
 .editor-swipe-hint{display:none;}
 .settings-dialog{width:calc(100vw - 20px);max-height:calc(100dvh - 28px);padding:15px;overscroll-behavior:contain;}
 .settings-dialog .dialog-footer{position:sticky;bottom:0;z-index:2;margin-bottom:-1px;background:#fffdf8;padding:12px 2px max(12px,env(safe-area-inset-bottom));}
 .settings-dialog .dialog-footer button{min-height:44px;}
 .toast{bottom:calc(17px + env(safe-area-inset-bottom,0px));max-width:calc(100vw - 24px);width:max-content;min-width:0;line-height:1.55;border-radius:15px;padding:11px 15px;box-shadow:0 7px 22px #20302235;overflow-wrap:anywhere;}
}
@media(max-width:340px){
 .studio-top .top-actions{display:flex;}
 .studio-main-actions{grid-template-columns:repeat(2,minmax(0,1fr));}
 .studio-top .top-actions .studio-main-actions button{grid-column:auto;font-size:11px;}
}


/* Phase 13.70 — One clear set of editor destinations instead of two competing menus. */
.novel-help-shell{border:0;box-shadow:none;margin:0 0 11px;padding:0;max-width:100%;background:transparent;}
.novel-help-shell .novel-quick-guide{margin:0;background:#f7faf5;border:1px solid #dbe5d6;border-radius:10px;padding:7px 11px;}
.novel-help-shell .novel-quick-guide>summary{font-size:12px;min-height:31px;color:#4c664d;}
.editor-pane .pane-head{align-items:center;gap:9px;margin-bottom:12px;}
.editor-pane .scene-heading{min-width:0;flex:1;}
.editor-context-caption{display:block;color:#72816c;font-size:11px;line-height:1.5;}
.editor-pane .scene-heading h2{font-size:clamp(17px,1.8vw,20px);margin:1px 0 3px;line-height:1.35;overflow-wrap:anywhere;}
.editor-scene-position{font-size:11px;color:#667967;}
.editor-pane .pane-tools{justify-content:flex-end;gap:5px;}
.editor-pane .pane-tools button{padding:7px 10px;min-height:37px;font-size:11px;}
.editor-pane .scene-switch-btn{color:#436747;border-color:#b6c8b2;background:#eff6eb;font-weight:750;}
.editor-path-title{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;margin:7px 1px 9px;}
.editor-path-title strong{font-size:13px;color:#3b5340;}
.editor-path-title span{font-size:11px;color:#737c70;}
.editor-tabs,.editor-tabs[data-tab-group="assets"]{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;overflow:visible;scroll-snap-type:none;white-space:normal;margin:0;padding:0;}
.editor-tabs button{display:flex;align-items:center;justify-content:center;min-width:0;min-height:43px;border-radius:9px;border:1px solid #d4dfd0;background:#fffdfa;padding:8px 5px;white-space:normal;overflow-wrap:anywhere;letter-spacing:0;line-height:1.4;font-weight:650;font-size:12px;text-align:center;}
.editor-tabs button.active{border:1px solid #8aac83;background:#e6f0e2;box-shadow:inset 0 -2px #6b8e64;color:#355839;font-weight:800;}
.editor-tabs button:focus-visible,.scene-switch-btn:focus-visible,.mobile-tabs button:focus-visible{outline:3px solid #81a879;outline-offset:2px;}
.editor-tab-guide{font-size:11px;line-height:1.6;color:#576b58;min-height:19px;margin:8px 2px 12px;padding:0;}
.novel-shelf-handoff[hidden]{display:none!important;}
@media(max-width:880px){
 .masthead{position:static;min-height:0;padding:8px 11px;display:flex;gap:8px;}
 .masthead .home-link,.masthead .novel-return-link,.masthead #playTopBtn{display:none!important;}
 .masthead #libraryBtn{flex:0 0 auto;width:auto;min-height:38px;padding:8px 13px;grid-column:auto;grid-row:auto;}
 .masthead #saveLabel{display:inline-flex!important;margin-left:auto;text-align:right;max-width:52%;white-space:normal;line-height:1.35;font-size:11px;}
 .studio-top{padding:13px 13px 12px;}
 .studio-top .top-actions{gap:8px;}
 .studio-main-actions{order:1;}
 .studio-tools-details{order:2;background:#f9faf7;}
 .studio-tools-details>summary{list-style:none;display:flex;align-items:center;gap:9px;min-height:41px;padding:9px 13px;}
 .studio-tools-details>summary::-webkit-details-marker{display:none;}
 .studio-tools-details>summary::before{content:'▸';font-size:15px;color:#708d6c;}
 .studio-tools-details[open]>summary::before{content:'▾';}
 .mobile-tabs{top:0!important;min-height:64px;padding:8px 10px;gap:7px;z-index:14;background:#fbfcf9;border-bottom:1px solid #d6e0d0;box-shadow:0 3px 13px #27472c12;}
 .mobile-tabs button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:0;padding:6px 3px;border-radius:10px;min-height:48px;line-height:1.35;}
 .mobile-tabs button span{font-size:13px;font-weight:750;}
 .mobile-tabs button small{font-size:10px;font-weight:500;color:#738071;}
 .mobile-tabs button.selected small{color:#4a704a;}
 .studio-grid{padding:10px 10px max(90px,env(safe-area-inset-bottom));}
 .studio-grid>.pane{scroll-margin-top:75px;}
 .editor-pane .pane-head{align-items:center;flex-direction:column;gap:7px;}
 .editor-pane .scene-heading{width:100%;}
 .editor-pane .pane-tools{width:100%;display:flex;justify-content:flex-start;}
 .editor-pane .pane-tools button{min-height:40px;flex:0 1 auto;}
 .editor-pane .scene-switch-btn{flex:1 1 auto!important;}
 .editor-tabs,.editor-tabs[data-tab-group="assets"]{grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;}
 .editor-tabs button{grid-column:span 2;min-height:44px;font-size:12px;padding:9px 4px;}
 .editor-tabs button:nth-child(4),.editor-tabs button:nth-child(5){grid-column:span 3;}
 .editor-path-title{margin-top:4px;}
 .editor-tab-guide{margin-bottom:9px;}
 .novel-help-shell .novel-quick-guide>summary{min-height:37px;}
 .novel-help-shell .novel-guide-actions button{min-height:44px;}
}
@media(max-width:360px){
 .mobile-tabs button small{font-size:9px;}
 .editor-pane .pane-tools button{padding:7px 5px;font-size:10.5px;}
 .editor-tabs button{font-size:11.5px;}
}

/* Phase13.70 final balance — secondary jumps appear only when requested. */
.script-flow-nav{padding:0;overflow:hidden;margin:6px 0 12px;border-color:#e0e7dd;background:#f8faf7;}
.script-flow-nav>summary{list-style:none;cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:38px;font-size:12px;font-weight:700;padding:8px 12px;color:#4d674e;}
.script-flow-nav>summary::-webkit-details-marker{display:none;}
.script-flow-nav>summary::before{content:'▸';color:#7c9a77;}
.script-flow-nav[open]>summary::before{content:'▾';}
.script-flow-nav>summary small{margin-left:auto;font-size:10px;font-weight:500;color:#829081;}
.script-flow-nav .script-flow-actions{padding:6px 10px 10px;}
@media(min-width:881px){
 .scenes-pane #graphPaneBtn{display:none;}
}


/* Phase 13.71 — editing-area wayfinding, round-trip links, clear asset scope. */
.writing-workflow-hint{margin:8px 1px 12px;padding:10px 12px;border-left:3px solid #bdd4b6;background:#f7faf5;border-radius:0 9px 9px 0;color:#57705a;font-size:11.5px;line-height:1.7}
.asset-orientation{scroll-margin-top:78px;display:flex;align-items:center;justify-content:space-between;gap:11px;margin:2px 0 12px;min-width:0}
.asset-orientation .asset-shelf-head{flex:1;min-width:0;margin:0}
.asset-orientation .asset-shelf-head h3{font-size:17px;letter-spacing:.02em}
.asset-return-top{flex:0 0 auto;min-height:41px;padding:9px 11px;border:1px solid #b8cdb2;border-radius:9px;background:#eef5e9;font-weight:750;color:#436348;font-size:12px}
.asset-section-intro{display:flex;align-items:baseline;flex-wrap:wrap;gap:5px 9px}
.asset-section-intro strong{color:#35583c;font-size:13px}
.asset-section-intro small{color:#758773;font-size:10.5px}
.asset-apply-target{background:#f9fbf6;border:1px solid #d4e1ce;box-shadow:none}
.asset-apply-target .asset-target-buttons button{border-color:#cfdbca;background:#fffdf9}
.asset-apply-target .asset-target-buttons button.is-active{background:#e6f1e0;border-color:#8eae86;box-shadow:inset 0 -2px #8eae86;color:#35593a}
.asset-current-summary{display:flex;flex-wrap:wrap;gap:6px 9px;align-items:center;padding:8px 10px;border-radius:8px;background:#edf4e9;color:#496149;font-size:11px;line-height:1.5}
.asset-current-summary strong{font-size:11px;margin-right:3px}
.asset-current-summary span{white-space:normal}
.asset-choice-label{display:flex;justify-content:space-between;align-items:baseline;flex-wrap:wrap;gap:3px 10px;margin:13px 1px 8px}
.asset-choice-label strong{color:#3f5b44;font-size:12.5px}
.asset-choice-label span{font-size:10.5px;color:#718071}
.novel-asset-categories{margin:0 0 13px}
.novel-asset-categories button{background:#fffdf9;min-height:55px}
.asset-scene-preview.scene-preview-compose{margin-top:0}
.asset-choice-label-select{border-top:1px solid #e3e8df;padding-top:11px;margin-bottom:7px}
.asset-next-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin:19px 1px 5px;padding:12px 0 3px;border-top:1px solid #e3e9df}
.asset-next-actions button{min-width:0;width:100%;min-height:43px;padding:9px 8px;font-size:12px;font-weight:700;border:1px solid #bfcfbb;background:#f6faf2;color:#456647;border-radius:9px}
.asset-next-actions button:nth-child(2){background:#fffdf8;border-color:#ddd8ca;color:#62583e}
.cue-line-shortcuts{display:flex;gap:7px;flex-wrap:wrap;margin:0 0 11px}
.cue-line-shortcuts button{min-height:38px;font-size:11.5px;padding:8px 11px;border:1px solid #d2dfcf;border-radius:8px;background:#f5f8f3;color:#4c654d;font-weight:700}
.cue-line-head{gap:7px}
@media(max-width:520px){
 .asset-orientation{align-items:center;gap:7px}
 .asset-return-top{font-size:11px;padding:8px 9px}
 .asset-choice-label{margin:11px 0 7px}
 .asset-apply-target{padding:11px}
 .asset-current-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;font-size:10.5px}
 .asset-current-summary strong{grid-column:1/-1}
 .asset-next-actions{gap:7px}
 .asset-next-actions button{padding:9px 6px;font-size:11px}
 .cue-line-shortcuts button{flex:1 1 0;min-width:0;font-size:11px;padding:8px 5px}
 .writing-workflow-hint{font-size:11px}
 .toast{bottom:calc(86px + env(safe-area-inset-bottom,0px));max-width:calc(100vw - 32px);z-index:120}
}
