/* mwalon AI Studio V4.0 — Responsive Foundation (mobile first overlay)
   Isolated styles: leaves desktop layout and rendering pipelines untouched. */
:root { --m4-accent:#63dcc0; --m4-edge:#29445e; }
html { scroll-padding-top:72px; }
:focus-visible { outline:3px solid var(--m4-accent); outline-offset:3px; }
.output-drawer { overscroll-behavior:contain; }
.drawer-body { min-height:0; }
.drawer-body input, .drawer-body select, .drawer-body textarea { max-width:100%; }
.drawer-body select { min-height:44px; background:#112944; color:#eef8ff; border:1px solid #42617f; border-radius:9px; padding:9px; }
.mwalon-mobile-dock { display:none; }
.mwalon-tools-toggle, .mwalon-benefits-toggle { display:none; }
@media (max-width:820px) {
  html { scroll-padding-top:88px; }
  body { padding-bottom: env(safe-area-inset-bottom,0px); }
  .wrap, .project-wrap, .home-wrap { max-width:100%; padding-inline: max(12px, env(safe-area-inset-left,0px)); padding-inline-end:max(12px,env(safe-area-inset-right,0px)); padding-bottom: calc(106px + env(safe-area-inset-bottom,0px)); }
  .card { border-radius:18px; box-shadow:0 10px 30px rgba(0,0,0,.12); }
  .topbar { align-items:stretch; }
  .brand-block h1 { font-size:clamp(25px,7vw,33px); letter-spacing:-.02em; }
  .source-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; }
  .source-card { min-width:0; padding:17px; }
  .source-card form { gap:11px; }
  .source-card input, .source-card button, .login-card input, .login-card button { min-height:48px; font-size:16px; }
  .source-card input[type=file] { width:100%; }
  .source-card.cloud { border-color:#346b70; }
  .mwalon-benefits-toggle { display:block; width:100%; margin:12px 0 0; padding:9px 12px; min-height:44px; border-radius:10px; background:#142d3c; color:#d8f2fc; border:1px solid #326070; font-size:14px; }
  .mwalon-v400-ready .source-card.cloud .cloud-list:not(.mwalon-benefits-expanded) { display:none; }
  .mwalon-benefits-expanded { display:block; }
  .online-pill { border-radius:12px; }
  .projects-section .grid { grid-template-columns:1fr; gap:12px; }
  .project { border-radius:16px; }
  .project-link { padding:17px 16px 9px; }
  .project-footer { padding:0 16px 15px; }
  .project-wrap .project-nav { top:0; display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; border-bottom:1px solid #23384f; padding:10px 4px; margin-bottom:15px; }
  .project-nav .back { display:inline-flex; align-items:center; justify-content:center; min-height:44px; margin:0; padding:0 13px; border:1px solid #294762; border-radius:11px; text-decoration:none; }
  .mwalon-tools-toggle { display:inline-flex; align-items:center; justify-content:center; gap:5px; border:1px solid #3b5a72; background:#142c40; color:#def5f7; min-height:44px; padding:9px 13px; border-radius:11px; font-size:14px; }
  .mwalon-v400-ready .project-nav .nav-actions { display:none; order:3; width:100%; flex-direction:column; align-items:stretch; padding:10px; background:#112138; border:1px solid #314c64; border-radius:12px; }
  .mwalon-v400-ready[data-mwalon-tools-open="true"] .project-nav .nav-actions { display:flex; }
  .project-nav .nav-actions form, .project-nav .nav-actions button { width:100%; margin:0; }
  .project-wrap > header { display:flex; flex-direction:column; align-items:stretch; gap:8px; }
  .project-wrap > header h1 { font-size:clamp(23px,6vw,31px); overflow-wrap:anywhere; }
  .project-wrap > header .badge { align-self:flex-start; max-width:100%; border-radius:12px; line-height:1.5; white-space:normal; }
  .project-wrap .card, .project-wrap .clip-card { min-width:0; }
  .project-wrap .clip-grid { display:grid; grid-template-columns:minmax(0,1fr); }
  .clip-card.compact { background:linear-gradient(140deg,#12233b,#0b1729); border-color:#345372; border-radius:18px; padding:15px; }
  .clip-card.compact .clip-video, .clip-card video, .final-video, .motion-video { display:block; width:100%; height:auto; object-fit:contain; border-radius:12px; background:#050a12; }
  .clip-card.compact .clip-video { max-height:min(52dvh,430px); }
  .quick-outputs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .quick-outputs button, .decision-row button, .download-file { min-width:0; min-height:48px; white-space:normal; line-height:1.5; }
  .settings-collapsible { border-radius:14px; }
  .settings-collapsible summary { min-height:42px; display:list-item; align-content:center; }
  .source-grid, .v3-grid, .v3-fields, .secret-row, .oauth-upload, .publish-actions { min-width:0; }
  .v3-grid, .v3-fields { grid-template-columns:minmax(0,1fr); }
  .v3-scene { min-width:0; }
  .v3-fields > *, .v3-grid > * { min-width:0; max-width:100%; }
  input, select, textarea { font-size:16px; min-width:0; }
  textarea { resize:vertical; }
  .drawer-shade { background:rgba(2,8,18,.7); }
  .output-drawer {
    left:0; right:0; top:auto; bottom:0; width:100%; height:min(89dvh,830px);
    border:1px solid #3c5d75; border-bottom:0; border-radius:24px 24px 0 0;
    box-shadow:0 -22px 65px rgba(0,0,0,.45);
    background:linear-gradient(165deg,#152d42,#0b172b 75%);
    padding-bottom:env(safe-area-inset-bottom,0px);
  }
  .drawer-top { flex:0 0 auto; position:relative; padding:24px 18px 12px; min-height:69px; }
  .drawer-top::before { content:""; position:absolute; width:42px; height:5px; background:#5d7790; border-radius:5px; top:8px; left:calc(50% - 21px); }
  .drawer-top h2 { font-size:1.02rem; line-height:1.55; }
  .drawer-close { min-width:44px; min-height:44px; }
  .drawer-body { overflow-x:hidden; overflow-y:auto; padding:14px 14px calc(20px + env(safe-area-inset-bottom,0px)); -webkit-overflow-scrolling:touch; }
  .drawer-body .scene-item { min-width:0; padding:12px; }
  .drawer-body input[type=text], .drawer-body input[type=number], .drawer-body textarea, .drawer-body select { font-size:16px; min-height:46px; }
  .drawer-body .scene-item textarea { min-height:74px; }
  .drawer-body .primary, .drawer-body .drawer-action { min-height:48px; }
  .mwalon-mobile-dock {
    position:fixed; inset-inline:0; bottom:0; z-index:50;
    display:grid; grid-template-columns:repeat(3,minmax(0,1fr));
    gap:6px; padding:9px max(11px,env(safe-area-inset-left,0px)) calc(9px + env(safe-area-inset-bottom,0px)) max(11px,env(safe-area-inset-right,0px));
    background:rgba(12,24,39,.97); border-top:1px solid #34536b;
    box-shadow:0 -7px 30px rgba(0,0,0,.35); backdrop-filter:blur(18px);
  }
  .mwalon-mobile-dock a, .mwalon-mobile-dock button {
    display:flex; align-items:center; justify-content:center; flex-direction:column;
    gap:3px; min-height:51px; padding:6px 4px; border:1px solid transparent;
    background:transparent; color:#b4c9de; border-radius:12px; font:600 12px Tahoma,Arial,sans-serif;
    text-align:center; text-decoration:none; cursor:pointer;
  }
  .mwalon-mobile-dock .mwalon-dock-icon { font-size:19px; line-height:1; }
  .mwalon-mobile-dock :is(a,button):is(:active,.is-current) { background:#173c46; color:#bffff0; border-color:#296875; }
  .mwalon-v400-ready:has(.output-drawer:not([hidden])) .mwalon-mobile-dock { visibility:hidden; pointer-events:none; }
}
@media (max-width:370px) {
  .project-wrap, .home-wrap { padding-inline:9px; }
  .source-card, .card { padding:13px; }
  .clip-card.compact { padding:12px; }
  .quick-outputs { gap:7px; }
  .quick-outputs button { font-size:13px; }
  .mwalon-mobile-dock a, .mwalon-mobile-dock button { font-size:11px; }
}
@media (max-width:820px) and (orientation:landscape) and (max-height:520px) {
  .output-drawer { height:96dvh; border-radius:15px 15px 0 0; }
  .drawer-top { padding-top:14px; }
  .drawer-top::before { display:none; }
}
@media (prefers-reduced-motion:no-preference) {
  .mwalon-mobile-dock :is(a,button), .quick-outputs button { transition:background-color .18s ease,border-color .18s ease; }
}
