/* =========================================================
   Phone layer — Android first
   320 (small)  ·  360 (Galaxy S24 / A-series)  ·  412–430 (Pixel, S24+/Ultra)
   Loaded last; everything here is scoped to phones.
   ========================================================= */
@media (max-width:767px){
  :root{--tab-h:58px;--gut:14px}
  html{scroll-padding-top:60px}
  body{font-size:14px;overflow-x:clip}
  /* touch: no sticky hover lift on tap, bigger targets */
  .tile:hover .tile-media,.gcard:hover,.pack:hover{transform:none}
  button,a{touch-action:manipulation}

  /* ---------- app bar ---------- */
  .topbar{height:52px;margin:0 calc(var(--gut) * -1);padding:0 var(--gut);display:flex;align-items:center;justify-content:space-between;gap:6px;width:auto;max-width:100vw;box-sizing:border-box;overflow:hidden}
  .brand.mobile{flex:0 1 auto;min-width:0;gap:6px}
  .brand-mark{width:28px;height:28px;border-radius:8px;flex-shrink:0}
  .brand.mobile .brand-name{font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .top-actions{display:flex;align-items:center;gap:5px;flex-shrink:0;min-width:0}
  .topbar .credit-chip,.credit-chip{height:30px;padding:0 8px;font-size:11.5px;max-width:102px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .topbar .switch-normal-btn{height:30px;padding:0 8px;font-size:11.5px}
  .topbar .me-btn{width:32px;height:32px;flex-shrink:0}
  .main{padding:0 var(--gut) calc(var(--tab-h) + 28px + var(--safe-b))}

  /* ---------- hero: get the composer above the fold ---------- */
  .hero{margin:0 calc(var(--gut) * -1);padding:12px var(--gut) 14px;min-height:0}
  .hero-inner{margin-bottom:12px}
  .eyebrow{font-size:10.5px;padding:4px 10px;margin-bottom:10px}
  .hero-title{font-size:27px;line-height:1.02;letter-spacing:-.04em}
  .hero-sub{font-size:13.5px;margin-top:8px;color:var(--fg-3)}
  .wall{grid-template-columns:repeat(3,1fr);opacity:.32}
  .beams i:nth-child(n+3){display:none}

  /* ---------- composer: everything visible, nothing scrolls sideways ---------- */
  .composer-dock{gap:8px}
  .modes{display:grid;grid-template-columns:1fr 1fr;width:100%;padding:4px;border-radius:14px;gap:4px}
  .mode{width:auto;height:40px;flex-direction:row;gap:7px;border-radius:11px;font-size:13.5px}
  .mode svg{width:17px;height:17px}
  .composer{padding:6px;border-radius:20px}
  .director{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;overflow:visible;margin:0;padding:0 0 6px}
  .dchip{min-width:0;height:48px;padding:0 6px 0 5px;gap:7px;border-radius:12px;flex:initial}
  .dthumb{width:30px;height:30px;border-radius:8px}
  .dtext small{font-size:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .dtext small::after{content:attr(data-s);font-size:10px}
  .dtext b{font-size:12.5px;max-width:100%}
  .prompt-box{padding:6px;border-radius:16px;gap:8px}
  textarea#prompt{font-size:16px;min-height:56px;padding:8px 6px 6px}
  .tools{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;overflow:visible;margin:0;padding:0}
  .tools>*{min-width:0;justify-content:center}
  #modelBtn{grid-column:span 3;order:1;justify-content:flex-start}
  #modelBtn span:not(.mdot){overflow:hidden;text-overflow:ellipsis}
  .tgroup{grid-column:span 2;order:2;justify-content:space-around}
  #enhanceBtn{order:3;width:auto}
  #resBtn,#arBtn,#durBtn,#audioBtn{order:4;padding:0 4px;gap:4px;font-size:13px}
  #resBtn svg,#arBtn svg,#durBtn svg{display:none}
  .stepper{order:5;grid-column:span 2;justify-content:space-between;font-size:13px}
  .stepper button{width:30px}
  body.mode-image #resBtn,body.mode-image #arBtn{grid-column:span 2}
  .tpill,.tbtn,.tgroup,.stepper{height:40px;border-radius:11px}
  .tbtn{width:auto;min-width:36px}
  .generate{min-height:52px;margin-bottom:5px;border-radius:15px}

  /* ---------- blocks ---------- */
  .hero+.block{margin-top:22px}
  .block{margin-top:34px}
  .block-head{margin-bottom:12px;gap:10px}
  .block-head h3{font-size:18px}
  .block-head p{font-size:12.5px}
  .block-head .chips{margin:0 calc(var(--gut) * -1);padding:0 var(--gut);width:calc(100% + var(--gut) * 2)}
  .chip{height:34px}
  .preset-grid,.gen-grid{gap:8px}
  .preset{border-radius:14px}
  .preset .p-meta{padding:10px}
  .preset .p-meta b{font-size:13px}
  .preset .p-meta span{font-size:11px}
  .preset .p-tag{font-size:10px;top:8px;left:8px}
  .preset .p-dur{top:10px;right:8px;font-size:10px}
  .mrow{padding:12px}
  .mname .mdot{width:30px;height:30px}

  /* ---------- tab bar: calm, solid, thumb-friendly ---------- */
  .tabbar{left:8px;right:8px;bottom:calc(8px + var(--safe-b));height:var(--tab-h);border-radius:18px;padding:5px;background:rgba(22,23,26,.94)}
  .tabbar a{gap:2px;font-size:10.5px;border-radius:13px;position:relative}
  .tabbar a.active{background:var(--bg-4);box-shadow:none;color:#fff}
  .tabbar a.active::after{content:"";position:absolute;bottom:4px;width:4px;height:4px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent)}
  .tabbar a svg{width:19px;height:19px}

  /* ---------- sheets ---------- */
  .sheet,.sheet.small,.sheet.wide{padding:0 5px calc(5px + var(--safe-b));border-radius:22px 22px 0 0}
  .sheet.tall{height:94dvh;max-height:94dvh}
  .s-head{padding:6px 2px 10px 10px}
  .s-head h3{font-size:16px}
  .s-head .reset{height:32px;padding:0 13px;font-size:12.5px}
  .s-body{border-radius:18px}
  .s-main{padding:12px}
  .s-side{padding:12px}
  .s-foot{padding:10px 4px 2px}
  .sec-title{flex-direction:column;align-items:stretch;gap:10px;margin-bottom:12px}
  .sec-title h4{font-size:15px}
  .sec-title p{font-size:12px}
  .sec-tools{width:100%}
  .sec-tools .btn-ghost{padding:0 10px;flex:none}
  .sec-tools .search,.sec-title>.search{flex:1;width:auto!important}
  .tiles{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 8px}
  .tile-media{border-radius:12px}
  .tile-media::after{border-radius:12px}
  .tile-name{font-size:12.5px;margin-top:6px}
  .tile .check{width:30px;height:30px;margin:-15px}
  .film-stage{height:190px;border-radius:14px}
  .film-strip .tile{flex-basis:128px}
  .era-labels{font-size:10.5px}
  .era-labels button.on{transform:scale(1.12)}

  /* camera: three horizontal swipe rows instead of cramped vertical wheels */
  .s-main.cam-wheels,.s-main:has(.wheels){padding:0;overflow:visible;display:block}
  .wheels{display:flex;flex-direction:column;height:auto;gap:0}
  .wheel{border-right:0;border-bottom:1px solid var(--line);align-items:stretch;padding:12px 0 14px}
  .wheel:last-child{border-bottom:0}
  .wheel h5{padding:0 14px 10px;text-align:left}
  .wheel-arrow{display:none}
  .wheel-win{flex:none;height:112px;overflow-x:auto;overflow-y:hidden;touch-action:pan-x pan-y;cursor:default;scroll-snap-type:x mandatory;scrollbar-width:none;-webkit-mask:linear-gradient(90deg,transparent,#000 8%,#000 92%,transparent);mask:linear-gradient(90deg,transparent,#000 8%,#000 92%,transparent)}
  .wheel-win::-webkit-scrollbar{display:none}
  .wheel-track{position:static;flex-direction:row;gap:10px;padding:8px 40% 8px 40%;width:max-content;transform:none!important}
  .wpill{width:128px;height:94px;padding-bottom:10px;scroll-snap-align:center;opacity:.55}
  .wpill span{font-size:12px;white-space:nowrap}
  .wpill img{max-width:66%;max-height:60%}

  /* model / option pops as bottom sheets */
  .pop{padding:6px 6px calc(10px + var(--safe-b))}
  .opt{height:44px}
  .ar-grid .opt{height:64px}
  .mp{height:72dvh}
  .prov{padding:10px 8px}

  /* ---------- library pages ---------- */
  .toolbar{margin:6px 0 14px}
  .toolbar .chips{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;margin:0 calc(var(--gut) * -1);padding:0 var(--gut)}
  .gcard{border-radius:14px}
  .g-info{padding:9px}
  .g-info p{font-size:12px}
  .g-recipe span{font-size:9.5px}
  .g-acts button{width:30px;height:30px}
  .explainer{gap:10px}
  .ex-media{height:150px}
  .feature{border-radius:18px}
  .f-copy h2{font-size:24px}
  .masonry{column-gap:8px}

  /* ---------- pricing ---------- */
  .price-head{margin:18px auto 22px}
  .price-head h2{font-size:28px}
  .price-head p{font-size:13px}
  .plans{gap:10px;margin-bottom:34px}
  .plan{padding:18px;border-radius:20px}
  .plan .amount b{font-size:32px}
  .packs{gap:8px;margin-bottom:34px}
  .pack{padding:14px;border-radius:16px}
  .pack .c{font-size:19px}
  .pay-row{gap:12px;padding:14px}
  .co-l,.co-r{padding:16px}
  .apps{gap:6px}

  /* ---------- editor ---------- */
  .ed-top{padding:8px 10px 6px}
  .ed-actions{gap:6px;margin:0 -10px;padding:0 10px 2px;width:calc(100% + 20px)}
  .ed-actions .ed-btn[data-ed=done]{order:-1}
  .ed-btn{height:34px}
  .ed-icon{width:34px;height:34px}
  .ed-stage{padding:8px 10px}
  .ed-player{width:min(100%,calc((100dvh - 430px) * 9 / 16))}
  .ed-controls{gap:0;padding:3px 4px}
  .ec{width:34px;height:34px}
  .ec.play{width:44px}
  .ed-tabs .ed-tab{height:32px}
  .ed-row{display:flex;flex-wrap:wrap;align-items:center;gap:5px;min-width:0;max-width:100%}
  .ed-pill{height:34px;min-width:0;max-width:100%}
  .ed-send{width:40px;height:34px}

  /* ---------- Android performance: fewer live blurs & videos ---------- */
  .wall video{display:none}
  .beams{mix-blend-mode:normal;opacity:.7}
  .ed-details,.ed-toast,.preset .p-tag,.g-acts button{-webkit-backdrop-filter:none;backdrop-filter:none}
  .ed-details{background:var(--bg-1)}
}

/* small Androids (Galaxy A0x, older 320–359px) */
@media (max-width:359px){
  :root{--gut:10px}
  .hero-title{font-size:23px}
  .hero-sub,.eyebrow{display:none}
  .brand-name span{display:none}
  .dchip{padding:0 4px;gap:5px}
  .dthumb{width:24px;height:24px;border-radius:7px}
  .dtext small::after{font-size:9px}
  .dtext b{font-size:11.5px}
  #resBtn,#arBtn,#durBtn,#audioBtn{font-size:12px}
  #audioBtn svg{display:none}
  .tiles{gap:10px 6px}
  .wpill{width:112px;height:86px}
  .plan .amount b{font-size:28px}
  .packs{grid-template-columns:1fr 1fr}
  .tabbar a span{font-size:9.5px}
  .ed-controls .ec-time{display:none}
}

/* large Androids (Pixel 8 Pro, S24+/Ultra: 400–430px) */
@media (min-width:400px) and (max-width:767px){
  :root{--gut:16px}
  .hero-title{font-size:31px}
  .dchip{height:52px}
  .dthumb{width:32px;height:32px}
  .preset-grid,.gen-grid{gap:10px}
  .tiles{gap:14px 10px}
  .wpill{width:138px;height:100px}
}

/* landscape phones: keep the composer usable */
@media (max-height:500px) and (orientation:landscape){
  .hero-inner{display:none}
  .sheet.tall{height:96dvh}
  .wheel-win{height:100px}
}
