/* v0.8.2 mobile stabilization. Desktop visual tokens and business flows stay unchanged. */
html,body{max-width:100%}img,video,iframe,canvas,svg{max-width:100%}textarea{max-width:100%}

@media(max-width:768px){
  :root{--site-gutter:16px}
  body{overflow-x:hidden}
  header.site-header,.home-page>header.site-header{min-height:0;padding:10px 16px;gap:6px}
  header.site-header>.brand{min-height:40px;display:inline-flex;align-items:center}
  header.site-header>nav{width:100%;gap:clamp(7px,2.7vw,13px);overflow:visible;font-size:clamp(.88rem,3.7vw,1rem)}
  header.site-header>nav>a,.nav-menu__trigger{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center}
  .nav-popover{max-width:calc(100vw - 24px)}
  main:not(.home-main){width:auto;max-width:none;margin-inline:16px;padding-top:16px;padding-bottom:40px}
  h1{font-size:clamp(2rem,10vw,2.8rem);overflow-wrap:anywhere}
  h1,h2{text-wrap:balance}
  h2,h3,p,li,dd,td,th,label,a,button{min-width:0}
  .page-head,.resource-browser-head,.resource-upload-title-row,.resource-studio-head{align-items:stretch;flex-direction:column}
  .actions,.head-actions,.resource-browser-head__actions,.resource-studio-actions{width:100%}
  .actions>.button,.actions>button,.head-actions>.button,.head-actions>button{min-height:44px}
  input,select,textarea,.button,button{font-size:16px}
  input,select,.button,button{min-height:44px}
  .module-shell{grid-template-columns:minmax(0,1fr);gap:16px}
  .module-sidebar{position:static;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 10px;max-height:none;overflow:visible;padding:12px}
  .module-sidebar a{display:flex;align-items:center;min-height:44px;padding:9px 10px;overflow-wrap:anywhere}
  .module-label{grid-column:1/-1}
  .module-content,.panel,.card,.grid>*,.task-row>*,.table-wrap{min-width:0}
  .table-wrap{width:100%;overflow-x:auto;overscroll-behavior-inline:contain}
  .workspace-dialog-layer,.modal-layer{padding:10px}
  .workspace-dialog,[role="dialog"]{max-width:100%;max-height:calc(100dvh - 20px)}
  .resource-detail-layout,.resource-preview-layout{height:auto!important;min-height:0!important;max-height:none!important;grid-template-columns:minmax(0,1fr)!important}
  .resource-detail-sidebar,.resource-preview-sidebar{position:static!important;max-height:none!important}
  .resource-preview-canvas,.resource-preview-frame,.preview-frame{max-width:100%;min-width:0}
  .resource-preview-media,.embedded-preview__media,.preview-attachment-gallery__image{width:auto;max-width:100%;height:auto;object-fit:contain}
  .resource-upload-page{width:100%;padding-bottom:32px}
  .resource-upload-card{width:100%}
  .resource-upload-dropzone{min-height:150px;padding:18px}
  .resource-upload-tree{max-height:45dvh}
  .resource-upload-category-create{max-height:none}
  .resource-home-main,.resource-browser-main{width:auto!important;max-width:none!important;margin-inline:12px!important}
  .resource-home-page,.resource-browser-page{overflow-x:hidden}
  .site-return,.resource-browser-breadcrumb .site-return,.resource-upload-return{min-height:44px;display:inline-flex;align-items:center}
  .resource-browser-head__actions .button{min-height:44px!important;display:inline-flex;align-items:center;justify-content:center}
  .resource-detail-alert a,.resource-detail-table a{min-height:44px;display:inline-flex;align-items:center}
  .resource-studio,.resource-preview-frame,.studio-preview{height:auto!important;max-height:none!important}
  .resource-preview-frame{min-height:0!important}
  .resource-module-preview{min-height:0}
  .studio-activity,.studio-carousel,.studio-featured,.studio-publish{min-height:420px;height:auto}
  .resource-settings,.resource-settings-scroll{height:auto;max-height:none;overflow:visible}
  .resource-library{max-height:86dvh;padding:16px}
  .resource-library-grid{grid-template-columns:1fr}
  .resource-workspace-page .resource-workspace{min-height:0}
  .resource-folder-list{max-height:42dvh}
  .resource-workspace-table{max-width:100%;overflow-x:auto}
  .resource-management-group__content .table-wrap{overflow-x:auto}
  .login-card,.narrow{width:100%;max-width:100%}
  .notification-toast-region,.configuration-toast-region{max-width:calc(100vw - 24px)}
}

@media(max-width:430px){
  header.site-header>nav{justify-content:space-between;gap:6px}
  .resource-browser-head__actions,.head-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .resource-browser-head__actions>*{width:100%;min-height:44px;text-align:center}
  .resource-file-row__title{align-items:flex-start;flex-direction:column;gap:5px}
  .resource-review-badge{min-height:26px}
  .resource-settings-foot{padding-inline:14px}
  .resource-settings-foot button{min-width:0;flex:1}
  .studio-activity,.studio-carousel,.studio-featured,.studio-publish{min-height:360px}
  .studio-featured-card{grid-template-columns:72px minmax(0,1fr)}
  .studio-featured-card img{width:72px;height:72px}
  .resource-workspace-page .head-actions{grid-template-columns:1fr}
}

@media(prefers-reduced-motion:reduce){
  .resource-upload-category-create,.resource-upload-category-placeholder,.resource-library-layer,.resource-library,.workspace-dialog-layer,.workspace-dialog{transition-duration:80ms!important}
}
