.h5-only{display:none!important}
/* H5 layout: shared mobile rules for the live workspace. */
@media(max-width:620px){
 :root{--page-gutter:16px}
 html{scroll-padding-top:116px}
 .app-header{height:auto;min-height:104px;padding:8px 16px 0;display:flex;flex-wrap:wrap;gap:4px 8px;align-content:center}
 .app-header .brand{font-size:22px;line-height:32px;margin-right:auto}
 .app-header>.header-actions{margin-left:auto;gap:8px}
 .app-header>.header-actions>[data-action="start"]{display:none}
 .app-header>nav{display:flex!important;order:3;flex:0 0 100%;height:44px;gap:0;margin:0;justify-content:space-between;align-items:center;overflow:auto}
 .app-header>nav a{display:flex;align-items:center;justify-content:center;min-height:44px;flex:1;padding:0 8px;font-size:14px;white-space:nowrap}
 .app-header>nav a.active{color:#000;background:linear-gradient(transparent calc(100% - 3px),#EEF200 0);border:0}
 #workspace{min-height:calc(100dvh - 104px)}
 .single-page-workflow .creation-section{scroll-margin-top:116px}
 .single-page-workflow .cast-grid.compact-cast-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;width:100%;max-width:100%}
 .single-page-workflow .cast-slot{width:100%;min-width:0}
 .single-page-workflow .cast-slot .cast-photo.cast-upload{width:100%;height:auto;aspect-ratio:1}
 .cast-slot-footer{width:100%;margin-top:8px}.cast-name-label{max-width:100%}
 .cast-name-label strong{font-size:13px}
 .cast-slot .photo-placeholder>.ph{font-size:24px}.cast-slot .photo-placeholder strong{font-size:11px}
 .cast-slot-actions>.icon-button[data-action^="remove-person:"]{width:28px;height:28px;right:-2px;top:-2px}
 .creation-section{margin-top:32px}.creation-section-heading{margin-bottom:20px}
 .creation-section-heading h2{font-size:22px}.creation-section-heading>p{font-size:13px;line-height:1.7;margin-top:8px}
 .single-page-workflow .style-selection-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}
 .style-body b{font-size:13px}
 .story-entry-card:has(.story-compose-actions){bottom:calc(8px + env(safe-area-inset-bottom));width:calc(100% - 32px)}
 .story-entry-card .story-compose>.story-area{height:184px;min-height:184px;max-height:184px;font-size:16px;padding:12px 44px 102px 12px}
 .story-entry-card .story-compose-toolbar{bottom:58px;left:10px;right:10px;gap:4px;flex-wrap:nowrap;justify-content:space-between}
 .story-entry-card .story-ideas-trigger{padding:6px 4px;font-size:12px;min-height:40px}
 .story-setting-trigger{padding:6px 4px;font-size:13px;height:40px;gap:4px}
 .setting-value{max-width:76px}
 .story-compose-actions{bottom:10px;left:12px;right:12px;justify-content:flex-end;gap:10px}
 .story-compose-actions .button{min-height:44px;font-size:14px;padding:8px 16px}
 .story-compose-actions small{font-size:12px}
 body:has(.story-compose-actions) .single-page-workflow{padding-bottom:calc(248px + env(safe-area-inset-bottom))}
 .story-entry-card.is-expanded .story-compose>.story-area{height:min(58dvh,440px);min-height:min(58dvh,440px);max-height:min(58dvh,440px)}
 body:has(.story-entry-card.is-expanded) .single-page-workflow{padding-bottom:calc(min(58dvh,440px) + 64px + env(safe-area-inset-bottom))}
 #dialog{max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);overscroll-behavior:contain}
 #dialog .dialog-body{padding:16px}
 #dialog :is(input,textarea,select){font-size:16px}
 #dialog .dialog-actions{bottom:-16px;padding-bottom:calc(16px + env(safe-area-inset-bottom));gap:10px}
 #dialog .dialog-actions .button{min-height:44px}
 #dialog.ai-character-modal{height:640px;max-height:calc(100dvh - 24px)}
 #dialog.ai-character-modal .dialog-body{padding:16px}
 #dialog.ai-character-modal .ai-role-form{height:440px;padding-right:4px}
 #dialog.ai-character-modal .ai-role-fields{grid-template-columns:minmax(0,1fr) 112px}
 #dialog.ai-character-modal .ai-role-styles{gap:12px 8px}
 #dialog.ai-character-modal .ai-role-style-card span{font-size:11px}
 #dialog.ai-character-modal .dialog-actions{position:sticky;bottom:-16px;padding:12px 0 calc(16px + env(safe-area-inset-bottom));width:100%}
 .account-banner-main,.account-banner-actions{flex-wrap:wrap;gap:12px}.account-banner-actions>.button{min-height:44px}
 .membership-page .vip-plan-option{padding:20px}.membership-page .vip-plan-option strong{font-size:32px;margin:16px 0}
 .membership-intro-row{align-items:flex-start}.membership-intro-row h1{font-size:22px}
 .library-wrap .project-grid{grid-template-columns:minmax(0,1fr)}
 #creation-output .result-inspector.card{padding:16px}
 #creation-output .comic-reader{grid-template-columns:28px minmax(0,1fr) 28px;gap:6px}
 #creation-output .comic-page-arrow{width:28px;min-width:28px;padding:0}
}
@media(max-width:360px){.app-header .brand{font-size:19px}.app-header>.header-actions{gap:4px}.app-header #header-membership{padding:4px 6px}.single-page-workflow .cast-grid.compact-cast-grid{gap:12px}.story-setting-trigger{font-size:12px}.setting-value{max-width:65px}}

/* H5-only navigation and creation controls; tablet and desktop retain their markup/layout. */
@media(max-width:620px){
 .h5-only{display:block!important}
 html{scroll-padding-top:72px}
 .app-header{height:60px;min-height:60px;padding:8px 16px;flex-wrap:nowrap}
 .app-header>nav{display:none!important}
 #workspace{min-height:calc(100dvh - 60px)}
 .single-page-workflow .creation-section{scroll-margin-top:72px}
 .single-page-workflow .creation-section,.h5-setting-section{margin:32px 0 0!important}
 .single-page-workflow #creation-cast{margin-top:0!important}
 .creation-title-row{display:flex;align-items:center;justify-content:space-between;gap:8px}
 .h5-character-link{font-size:14px;white-space:nowrap;text-decoration:none;color:#333}
 .single-page-workflow .creation-section-heading{margin-bottom:12px}
 .single-page-workflow .creation-section-heading h2{font-size:20px}
 .h5-setting-section h2{font-size:20px;line-height:1.5;margin:0 0 12px}
 .single-page-workflow .style-selection-grid{display:grid;grid-template-rows:repeat(2,auto);grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:80px;gap:12px;overflow-x:auto;padding:4px 2px 6px;scroll-snap-type:none}
 html body #creation-style .style-card{width:80px;aspect-ratio:auto;border:0;background:none;box-shadow:none!important;outline:none!important;transform:none!important;overflow:visible;scroll-snap-align:none}
 .single-page-workflow #creation-style .style-card>img{display:block;width:80px;height:80px;aspect-ratio:1;border:2px solid #000;border-radius:8px;margin:0 auto;box-sizing:border-box}
 .single-page-workflow #creation-style .style-body{position:static;padding:2px 0 0;text-align:center;background:none}
 .single-page-workflow #creation-style .style-body b{font-size:12px;line-height:18px;padding:0;background:none!important;color:#333!important;font-weight:400;white-space:nowrap}
 .single-page-workflow #creation-style .style-card.selected>img{border-color:#000;box-shadow:inset 0 0 0 2px #EEF200;outline:2px solid #EEF200;outline-offset:0}
 .single-page-workflow #creation-style .style-card.selected .style-body b{font-weight:600}
 .h5-option-list{display:flex;gap:12px;overflow-x:auto;padding:2px 2px 6px;scroll-snap-type:none}
 .h5-option-list>.button{flex:0 0 auto;min-height:44px;white-space:nowrap;scroll-snap-align:none}
 .story-compose-toolbar>.story-setting-trigger{display:none!important}
 .story-entry-card .story-compose-toolbar{bottom:10px;right:auto}
 .story-entry-card .story-compose>.story-area{height:150px;min-height:150px;max-height:150px;padding-bottom:62px}
 body:has(.story-compose-actions) .single-page-workflow{padding-bottom:calc(214px + env(safe-area-inset-bottom))}
 .h5-account-functions{margin:32px 0}
 .account-menu-row.h5-only{display:flex!important}
}
@media(max-width:620px){
 html body #workspace #creation-style .style-card:is(.selected,[aria-pressed=true],:hover,:active){background:transparent!important;box-shadow:none!important;outline:none!important;border:0!important;transform:none!important}
}

@media(max-width:620px){.h5-setting-select{display:block;width:100%;min-height:44px;font-size:16px;padding:8px 36px 8px 12px}}

@media(max-width:620px){
 *,*::before,*::after{scrollbar-width:none}
 *::-webkit-scrollbar{display:none;width:0;height:0}
 .single-page-workflow .creation-section-heading h2{margin-bottom:0}
 .single-page-workflow .creation-section-heading>p{margin-top:12px}
 .story-entry-card .story-compose::after{content:"";position:absolute;left:3px;right:3px;bottom:3px;height:62px;background:#fff;border-radius:0 0 5px 5px;z-index:2;pointer-events:none}
 .story-entry-card .story-compose-toolbar,.story-entry-card .story-compose-actions{z-index:3}
 #cast-source-popover{width:180px;max-width:calc(100vw - 24px);padding:8px}
 #cast-source-popover::backdrop{background:transparent}
 #cast-source-popover .button{justify-content:flex-start;min-height:44px}
}
@media(max-width:620px){
 .single-page-workflow #creation-style .style-body{display:block;width:100%;text-align:center}
 .single-page-workflow #creation-style .style-body b{width:100%;text-align:center}
}
/* Keep the original bold image-card treatment at the compact H5 size. */
@media(max-width:620px){
 .single-page-workflow #creation-style .style-card>img{border:3px solid #000;box-shadow:2px 2px 0 #000}
 .single-page-workflow #creation-style .style-card.selected>img{border:3px solid #000;outline:none;box-shadow:2px 2px 0 #000}
 .single-page-workflow #creation-style .style-card.selected::after{content:"";position:absolute;top:3px;left:3px;width:74px;height:74px;box-sizing:border-box;border:3px solid #EEF200;border-radius:5px;pointer-events:none}
}
@media(max-width:620px){
 .story-entry-card .story-compose>.story-area{font-size:14px;font-weight:500}
}

@media(max-width:620px){.story-entry-card .story-ideas-trigger .ph{display:inline-block;flex-shrink:0;font-size:16px;color:#b5a000}.story-entry-card .inspiration-ink{gap:4px}}
/* H5 character library actions remain reachable below the scrolling card list. */
@media(max-width:620px){
 #workspace .library-wrap:has(.character-shelf-grid){padding-bottom:calc(100px + env(safe-area-inset-bottom))}
 #workspace :is(.character-add-tile,.character-empty-actions){position:fixed;left:0;right:0;bottom:0;z-index:25;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:0;padding:12px 16px calc(16px + env(safe-area-inset-bottom));border:0;border-radius:0;background:#fff}
 #workspace :is(.character-add-tile,.character-empty-actions) .button{width:100%;min-width:0;min-height:44px;margin:0;padding:10px 6px;font-size:13px;gap:6px;white-space:nowrap}
 #workspace :is(.character-add-tile,.character-empty-actions) [data-action="create-character"]{order:0}
 #workspace :is(.character-add-tile,.character-empty-actions) [data-action="ai-character-open"]{order:1}
 #workspace :is(.character-add-tile,.character-empty-actions) .button .ph{font-size:16px}
}

/* Touch portraits open directly; no hover veil or editing hint on H5. */
@media(max-width:620px){
 .character-portrait-edit>img,.character-portrait-edit:hover>img{filter:none;transition:none}
 .character-portrait-edit .character-edit-hint{display:none}
 .library-wrap .project-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:20px 12px}
 .library-wrap .project-card,.library-wrap .project-card:hover{border:0;border-radius:0;box-shadow:none;background:transparent;overflow:visible}
 .project-card .project-excerpt,.project-card .draft-art,.project-card .project-locked{display:grid;width:100%;aspect-ratio:3/4;padding:0;gap:0;grid-template-columns:1fr;border:3px solid #000;border-radius:12px;box-shadow:2px 2px 0 #000;overflow:hidden}
 .project-card .project-excerpt.has-cover .excerpt-content,.project-card .project-excerpt.without-cover .excerpt-cover{display:none}
 .project-card .excerpt-cover{border-radius:0;box-shadow:none}
 .project-card .project-excerpt:hover .excerpt-cover>img{transform:none}
 .project-card .excerpt-label{display:none}
 .project-card .project-card-body{padding:10px 0 0}
 .project-card .project-title-row{display:block}
 .project-card h3.project-title{font-size:14px;line-height:21px;font-weight:600;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;height:42px;overflow:hidden;overflow-wrap:anywhere;margin:0}
 .project-card .project-text-more,.project-card-body>p,.project-card .project-card-actions{display:none}
}
/* Paired character fields share one control height on mobile. */
@media(max-width:620px){
 html body #dialog .cast-dialog-fields>label>input:not([type=checkbox]),html body #dialog .cast-dialog-fields>label>select{height:48px;min-height:48px;box-sizing:border-box;padding-top:0;padding-bottom:0;font-size:14px;line-height:normal;margin-top:9px}
}
/* A compact crop preview leaves room for the mobile form and actions. */
@media(max-width:620px){
 #dialog .portrait-crop{margin:12px auto;max-width:100%}
 #dialog .portrait-crop-stage{width:clamp(180px,34dvh,240px);height:auto;aspect-ratio:1}
 #dialog .portrait-crop>p{margin:8px 0;font-size:11px}
}

/* H5 reader: compact title and tap/swipe pagination below the artwork. */
@media(max-width:620px){
 #creation-output .step-heading h2:has(.result-title-text){font-size:16px;line-height:24px;gap:8px;align-items:flex-start}
 #creation-output .result-title-text{font-size:16px;line-height:24px}
 html body #creation-output .result-title-more,html body #creation-output .result-title-more:hover{flex:0 0 28px;width:28px;height:28px;padding:0;margin:0;min-height:0;border:0;background:transparent;box-shadow:none!important;transform:none;transition:none!important}
 #creation-output .result-title-more .ph{font-size:16px}
 #creation-output .step-heading>div>p{font-size:12px;line-height:20px;margin-top:8px}
 #creation-output .comic-reader{display:block}
 #creation-output .comic-page-arrow{display:none}
 #creation-output #result-canvas{width:100%;max-width:100%}
 #creation-output .comic-page-dots{display:flex;justify-content:center;flex-wrap:wrap;gap:0;margin-top:12px}
 #creation-output .comic-page-dots button{display:grid;place-items:center;width:16px;height:32px;padding:0;border:0;background:none;box-shadow:none}
 #creation-output .comic-page-dots span{width:6px;height:6px;border-radius:50%;background:#ccc}
 #creation-output .comic-page-dots [aria-current=page] span{background:#333}
 #creation-output .comic-page-number{display:none}
}
@media(max-width:620px){
 html body #creation-output button.button.result-title-more:not(:disabled):not([aria-disabled="true"]),html body #creation-output button.button.result-title-more:not(:disabled):not([aria-disabled="true"]):hover{box-shadow:none!important}
}
