/* The same 1080 × 1350 canvas is both on-screen poster and exported PNG. */
html,body{overflow-x:clip}
.app-container{min-width:0}
.app-content{min-width:0;overflow-x:clip;overflow-y:visible;padding-bottom:92px}
.poster-wrapper{overflow:hidden}
#exportCanvas{display:block!important;width:100%;height:100%;aspect-ratio:4/5;object-fit:contain}
.category-scroll{display:flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;max-height:none;scrollbar-width:none;overscroll-behavior-x:contain;touch-action:pan-x}
.category-scroll::-webkit-scrollbar{display:none}
.category-scroll .cat-pill{min-height:28px}
.poster-meta{min-width:0;max-width:55%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
#posterIdLabel{overflow:hidden;text-overflow:ellipsis}
.btn-floating-edit{bottom:12px;right:12px}
.feed-pager{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:10px}
.feed-pager button{border:1px solid #cbd5e1;border-radius:22px;background:#fff;padding:6px 12px;color:#334155}
#feedPosition{font-size:12px;color:#64748b}
.action-btn{min-height:46px;min-width:0;text-align:center;font-size:clamp(10px,3vw,13px);line-height:1.25}
.feed-message{margin:12px 4px;font-size:12px;color:#64748b;min-height:18px}
.bottom-nav{position:fixed;left:50%;transform:translateX(-50%);width:min(100%,440px);max-width:440px;bottom:0;z-index:80;padding-bottom:env(safe-area-inset-bottom);height:calc(64px + env(safe-area-inset-bottom))}
.bottom-nav button{border:0;background:transparent;cursor:pointer}
.bottom-nav .nav-ai-pill{color:#9943b3}
.unified-dialog{border:0;border-radius:18px;width:min(440px,calc(100vw - 24px));max-height:90vh;overflow:auto;padding:18px;color:#1f2937;box-shadow:0 20px 70px #0008}
.unified-dialog::backdrop{background:#111827a8}
.unified-dialog label{display:block;margin:12px 0;font-size:13px;font-weight:600}
.unified-dialog input,.unified-dialog textarea{display:block;width:100%;margin-top:5px;border:1px solid #cbd5e1;border-radius:10px;padding:10px;font:inherit;font-weight:400}
.dialog-title{display:flex;justify-content:space-between;align-items:center}
.dialog-title h2{font-size:18px}
.dialog-title button{font-size:24px;border:0;background:none}
.dialog-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px}
.dialog-actions button,#searchSubmit{border:1px solid #b9aec9;border-radius:9px;background:#f7f3fb;padding:9px 14px;cursor:pointer}
.dialog-actions button[type=submit],#searchSubmit{background:#433582;color:white}
.help{font-size:12px;margin-top:12px}.help a{text-decoration:underline}
@media(max-width:599px){.app-container{overflow:visible}.category-header{padding:7px 9px}.category-scroll{gap:5px;max-height:none}.cat-pill{font-size:11px;padding:5px 9px}.app-content{padding:3px 8px calc(88px + env(safe-area-inset-bottom))}.action-btn-row{gap:5px}.action-btn{padding:8px 2px}.bottom-nav{background:white}}

/* The phone must occupy its own viewport, including browsers using a wide
   desktop-style layout viewport on a touch device. */
@media(max-width:799px),(pointer:coarse){
  html,body{background:#fff;min-height:100%;overflow-x:hidden}
  .desktop-viewport-wrapper{display:block;width:100%;min-height:100dvh;padding:0;background:#fff}
  .app-container{width:100%;max-width:none;min-height:100dvh;margin:0;border:0;border-radius:0;box-shadow:none;overflow:visible}
  .category-header{padding:8px 10px;background:#fff}
  .category-scroll{gap:7px}
  .cat-pill{flex-shrink:0;font-size:clamp(11px,1.5vw,16px);padding:7px 12px}
  .poster-toolbar{padding:10px 14px 7px}
  .poster-meta,.btn-change-design{font-size:clamp(12px,1.5vw,16px)}
  .app-content{padding:4px 10px calc(94px + env(safe-area-inset-bottom));overflow:visible}
  .poster-wrapper{width:100%;border-radius:12px}
  .action-btn{font-size:clamp(12px,1.5vw,16px);padding:10px 4px}
  .bottom-nav{position:fixed;left:0;right:0;bottom:0;transform:none;width:100%;max-width:none;height:calc(64px + env(safe-area-inset-bottom));border-radius:0}
}

/* Laptop and desktop use the available space for the poster and controls. */
@media(min-width:800px) and (hover:hover) and (pointer:fine){
  html,body{background:#f3f5f9}
  .desktop-viewport-wrapper{padding:24px;background:linear-gradient(135deg,#f5f6fb,#e9edf4)}
  .app-container{width:100%;max-width:1120px;min-height:calc(100dvh - 48px);border:0;border-radius:20px;margin:0;box-shadow:0 15px 45px rgba(23,35,64,.13)}
  .category-header{padding:16px 24px}
  .cat-pill{font-size:13px;padding:8px 14px}
  .poster-toolbar{padding:18px 32px 10px}
  .poster-meta,.btn-change-design{font-size:15px}
  .app-content{display:grid;grid-template-columns:minmax(0,550px) minmax(260px,1fr);grid-template-rows:auto auto 1fr;align-content:start;column-gap:28px;width:100%;padding:10px 32px 28px;overflow:visible}
  .poster-wrapper{grid-column:1;grid-row:1 / 4;width:100%}
  .feed-pager{grid-column:2;grid-row:1;align-self:start;margin:0 0 16px}
  .feed-pager button{padding:10px 12px;font-size:13px}
  .action-btn-row{grid-column:2;grid-row:2;grid-template-columns:1fr 1fr;margin:0;gap:12px}
  .action-btn{min-height:52px;font-size:14px}
  .btn-change-photo{grid-column:1 / -1}
  .feed-message{grid-column:2;grid-row:3;margin:16px 0}
  .bottom-nav{position:sticky;left:0;bottom:0;transform:none;width:100%;max-width:none;min-height:64px;margin-top:auto}
  .nav-item{font-size:13px}
}

/* Keep the creative and its actions together on laptops. The spare column in
   the earlier layout left half of the page empty while the poster continued. */
@media (min-width:800px) and (hover:hover) and (pointer:fine){
  .app-container{max-width:660px}
  .app-content{display:flex;flex-direction:column;align-items:stretch;gap:0;padding:8px 32px 28px}
  .poster-wrapper{width:100%;max-width:560px;margin-inline:auto}
  .feed-pager{width:100%;max-width:560px;margin:14px auto 0}
  .action-btn-row{width:100%;max-width:560px;grid-template-columns:repeat(3,minmax(0,1fr));margin:12px auto 0}
  .btn-change-photo{grid-column:auto}
  .feed-message{width:100%;max-width:560px;margin:12px auto}
}

/* Keep the phone feed compact without shrinking the 4:5 creative. */
@media(max-width:799px),(pointer:coarse){
  .app-container{min-height:0}
  .app-content{padding-bottom:calc(76px + env(safe-area-inset-bottom))}
  .feed-pager{margin-top:8px}
  .action-btn-row{margin-top:8px}
}

@media (min-width:800px) and (hover:hover) and (pointer:fine){
  .poster-wrapper,.feed-pager,.action-btn-row,.feed-message{max-width:clamp(480px,calc((100dvh - 320px)*.8),560px)}
}

/* Show the complete category menu in rows, as in the approved reference. */
.category-scroll{flex-wrap:wrap;overflow:visible;max-height:none;justify-content:flex-start;gap:6px 7px;touch-action:auto}
.category-scroll .cat-pill{flex-shrink:0}
.category-scroll:not(.expanded) .cat-pill.is-extra{display:none}

/* Readable, finger-sized category tabs; wrapping supplies the extra rows. */
.category-scroll .cat-pill{font-size:15px;line-height:1.3;min-height:42px;padding:9px 14px;letter-spacing:0}
@media(max-width:799px),(pointer:coarse){
  .category-scroll .cat-pill{font-size:14px;min-height:40px;padding:8px 12px}
  .category-scroll{gap:7px}
}

/* Mobile readability: the phone may expose a wide layout viewport. Use the
   touch pointer as well as viewport width so its controls remain legible. */
@media(max-width:799px),(pointer:coarse){
  .category-header{padding:10px 12px}
  .category-scroll{gap:9px 8px}
  .category-scroll .cat-pill{font-size:clamp(22px,2.6vw,25px);line-height:1.25;min-height:60px;padding:13px 17px;font-weight:600}
  .poster-meta,.btn-change-design{font-size:17px}
  .btn-change-design{min-height:44px;padding:9px 14px}
  .feed-pager button{font-size:16px;min-height:44px;padding:8px 12px}
  #feedPosition{font-size:16px}
  .action-btn-row{gap:7px}
  .action-btn{font-size:clamp(17px,2.1vw,20px);min-height:60px;padding:9px 5px;line-height:1.25;overflow-wrap:anywhere}
  .btn-floating-edit{font-size:16px;min-height:42px}
  .bottom-nav{height:calc(96px + env(safe-area-inset-bottom));min-height:96px}
  .bottom-nav .nav-item{min-width:0;gap:4px;padding:8px 2px;font-size:20px;font-weight:600}
  .bottom-nav .nav-item span:first-child{font-size:34px;line-height:1}
  .bottom-nav .nav-item span:last-child{font-size:20px;line-height:1.15}
  .app-content{padding-bottom:calc(112px + env(safe-area-inset-bottom))}
}
