/* MEKI Mobile Polish · design consistency and touch ergonomics · v1.
   Scope changes to Studio, Account, Drama, and Creative Workspace. */
@media(max-width:760px){
  /* Prevent scroll traps and content clipping while preserving horizontal tool navigation. */
  body.meki-studio-web,body.account-dashboard,body.meki-drama-web,body.meki-workspace-tool{
    min-width:0;
  }
  :is(.meki-studio-web,.account-dashboard,.meki-drama-web,.meki-workspace-tool) :is(main,section,.panel,.grid,.hero,.item,.target){
    min-width:0;
  }
  :is(.meki-studio-web,.account-dashboard,.meki-drama-web,.meki-workspace-tool) :is(img,video,canvas,svg){
    max-width:100%;
  }
  :is(.meki-studio-web,.account-dashboard,.meki-drama-web,.meki-workspace-tool) :is(pre,code){
    max-width:100%;overflow-wrap:anywhere;white-space:pre-wrap;
  }

  /* iOS Safari avoids zooming into form controls at 16px. */
  :is(.meki-studio-web,.account-dashboard,.meki-drama-web,.meki-workspace-tool)
  :is(input:not([type=checkbox]):not([type=radio]),select,textarea){
    font-size:16px;max-width:100%;
  }
  :is(.meki-studio-web,.account-dashboard,.meki-drama-web,.meki-workspace-tool)
  :is(button,[role=button],.btn,.premium-primary,.premium-secondary,.action){
    -webkit-tap-highlight-color:transparent;
    touch-action:manipulation;
  }
  :is(.meki-studio-web,.account-dashboard,.meki-drama-web,.meki-workspace-tool)
  :is(button,.btn,.premium-primary,.premium-secondary,.action){
    min-height:44px;
  }

  /* Account's links become a single swipeable row instead of three crowded lines. */
  body.account-dashboard .topbar{
    display:flex;flex-direction:column;align-items:stretch;gap:10px;
    padding:14px 15px 11px;
  }
  .account-dashboard .topbar>a.brand{
    align-self:flex-start;white-space:nowrap;
  }
  .account-dashboard .topbar>div{
    display:flex;flex-wrap:nowrap!important;align-items:center;gap:8px;
    width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden;
    overscroll-behavior-x:contain;scrollbar-width:thin;
    padding:2px 0 9px;-webkit-overflow-scrolling:touch;
  }
  .account-dashboard .topbar>div>a{
    flex:none;white-space:nowrap;min-height:40px;
    display:inline-flex;align-items:center;
  }
  .account-dashboard .account-nav{
    flex-wrap:nowrap;overflow-x:auto;max-width:100%;padding:2px 0 10px;
    gap:8px;overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
  }
  .account-dashboard .account-nav a{flex:none;white-space:nowrap;min-height:42px;display:inline-flex;align-items:center}
  .account-dashboard .account-stats .stat{min-width:0}
  .account-dashboard .stat-value{overflow-wrap:anywhere}

  /* Home workspace: reliable horizontal menu and toast clear of bottom tab bar. */
  .meki-studio-web .sidebar .nav{
    flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;
    -webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;
    padding-bottom:7px;min-width:0;
  }
  .meki-studio-web .sidebar .nav :is(button,a.workspace-link){flex-shrink:0}
  .meki-studio-web .topbar{flex-wrap:wrap;gap:6px 10px}
  .meki-studio-web .topbar .pill{max-width:100%;white-space:normal;overflow-wrap:anywhere}
  .meki-studio-web .content :is(.panel,.tile,.plan){min-width:0}
  .meki-studio-web #toast{bottom:calc(91px + env(safe-area-inset-bottom,0px));z-index:950}
  .meki-studio-web .actions{max-width:100%}

  /* Full-screen labels and player controls remain usable on short narrow displays. */
  .meki-drama-web .cinema-nav nav{
    -webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;
    padding-bottom:9px;max-width:100%;
  }
  .meki-drama-web .cinema-nav nav a{
    display:inline-flex;align-items:center;min-height:42px;flex:none;
  }
  .meki-drama-web .cinema-controls{
    grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
  }
  .meki-drama-web .cinema-controls :is(button,span){min-width:0}
  .meki-drama-web #episodePosition{
    display:block;max-width:100px;text-align:center;overflow-wrap:anywhere;font-size:11px;
  }
  .meki-drama-web #playerStage.cinema-expanded{
    padding-bottom:max(14px,env(safe-area-inset-bottom,0px));
    max-height:100dvh;
  }
  .meki-drama-web #playerStage.cinema-expanded .cinema-video{min-height:0}

  /* Tool navigation: the selected tool stays visible; cards and inputs never exceed viewport. */
  .meki-workspace-tool .meki-workspace-header{overflow:visible}
  .meki-workspace-tool .meki-workspace-nav{
    max-width:100%;overflow-x:auto;overflow-y:hidden;
    -webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;
    padding-bottom:9px;
  }
  .meki-workspace-tool .meki-workspace-head{min-width:0;gap:9px}
  .meki-workspace-tool .meki-workspace-label{min-width:0;max-width:42vw}
  .meki-workspace-tool .meki-workspace-account{flex:none}
  .meki-workspace-tool :is(.toolbar,.bar,.actions,.buttons){min-width:0}
  .meki-workspace-tool .toolbar select{min-width:0;max-width:100%}
  .meki-workspace-tool :is(.panel,.item,.card,.shot,.frame){min-width:0}
  .meki-workspace-tool input[type=file]{width:100%;min-width:0}
}
@media(max-width:680px){
  /* Older tools used 2 columns on phone portrait. Use one readable input column. */
  .meki-workspace-tool :is(.grid,.two,.three):not(.stats):not(.board){
    grid-template-columns:minmax(0,1fr);
  }
  .meki-workspace-tool .board{grid-template-columns:minmax(0,1fr)}
  .meki-workspace-tool .stats{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .meki-workspace-tool .stats>div{min-width:0}
  .meki-workspace-tool .toolbar .file{max-width:100%;width:100%}
  .meki-workspace-tool .toolbar .file input{max-width:100%}
}
@media(max-width:480px){
  /* Mobile hero buttons and row actions wrap without overflowing. */
  .meki-studio-web .hero .actions :is(button,a.btn){flex:1 1 135px}
  .meki-studio-web .hero .actions :is(button,a.btn):last-child{flex-basis:100%}
  .meki-studio-web .quickgrid{gap:8px}
  .meki-studio-web .quickgrid .tile{padding:13px}
  .meki-studio-web .quickgrid .tile h3{font-size:14px;overflow-wrap:anywhere}
  .meki-drama-web .premium-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}
  .meki-drama-web .premium-actions>a{white-space:normal;text-align:center;padding:11px 9px}
  .meki-drama-web #catalog{grid-auto-columns:minmax(136px,58%)}
  .meki-workspace-tool .hero{padding:21px 17px}
  .meki-workspace-tool .meki-workspace-brand{font-size:16px}
  .meki-workspace-tool .meki-workspace-label{font-size:11px;max-width:34vw}
  .meki-workspace-tool :is(.toolbar,.bar,.actions,.buttons) button{
    flex:1 1 145px;
  }
  .meki-workspace-tool :is(.toolbar,.bar,.actions,.buttons) :is(a,.file,label){
    max-width:100%;
  }
  .meki-workspace-tool .preview,
  .meki-workspace-tool .target{min-width:0}
  .meki-workspace-tool.meki-publisher #socialConnections .target{
    flex-wrap:wrap;
  }
  .meki-workspace-tool.meki-publisher #socialConnections .target>button{
    flex-basis:100%;width:100%;
  }
}
@media(max-width:360px){
  .meki-workspace-tool .meki-workspace-label{max-width:27vw}
  .meki-drama-web .cinema-controls button{font-size:12px;padding:8px 5px}
  .meki-drama-web #episodePosition{max-width:65px;font-size:10px}
  .meki-studio-web .sidebar .nav :is(button,a.workspace-link){padding-inline:9px}
}
@media(prefers-reduced-motion:reduce){
  .meki-studio-web .sidebar .nav,
  .account-dashboard .topbar>div,
  .account-dashboard .account-nav,
  .meki-drama-web .cinema-nav nav,
  .meki-workspace-tool .meki-workspace-nav{scroll-behavior:auto!important}
}
