/* Calendar Studio — css/mobile.css  (casca de celular ≤ 820 px) */

#mroot{display:none}
.m-scrim{display:none}
.mob-only{display:none}
.m-grab{display:none}

@media (max-width:820px){
  #app{display:none!important}
  #mroot{display:grid;grid-template-rows:auto 1fr auto;position:fixed;inset:0;background:var(--stage);z-index:5}
  /* tela inicial sem menus: some com a barra de cima e as abas de baixo */
  body.onboarding #mroot{grid-template-rows:0 1fr 0}
  body.onboarding #mtop,body.onboarding #mtabs{overflow:hidden;visibility:hidden}
  body.onboarding #mstageWrap #stage{padding:0}
  body.onboarding #sheets{display:none}

  /* ---------- barra de cima ---------- */
  #mtop{display:flex;align-items:center;gap:6px;padding:8px 10px;background:var(--surface);
    border-bottom:1px solid var(--line);box-shadow:var(--sh-1)}
  .mbrand{font-family:var(--display);font-weight:700;font-size:14px;color:var(--ink);white-space:nowrap}
  .mpg{font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums;margin-left:6px;white-space:nowrap}
  #mtop .miconbtn{margin-left:auto;width:40px;height:40px;padding:9px}
  #mtop .miconbtn+.miconbtn{margin-left:0}
  .miconbtn{border:1px solid var(--line);background:var(--surface);border-radius:var(--r-sm);
    display:inline-flex;align-items:center;justify-content:center}
  .miconbtn svg{width:20px;height:20px}
  .miconbtn:disabled{opacity:.4}

  /* ---------- corpo / palco ---------- */
  #mbody{position:relative;overflow:hidden}
  #mstageWrap{position:absolute;inset:0}
  #mstageWrap #stage{position:absolute;inset:0;padding:16px}
  #mstageWrap[hidden]{display:none}

  /* ---------- folhas de aba (Documento / Seção / Exportar) ---------- */
  .msheet{position:absolute;inset:0;background:var(--paper);
    overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;touch-action:pan-y;
    padding:14px 14px calc(104px + env(safe-area-inset-bottom))}
  /* o ÚNICO container que rola é .msheet — os painéis reaproveitados perdem
     o próprio overflow (senão o gesto de rolar fica preso neles). */
  .msheet>#left,.msheet>#right{background:transparent;padding:0;border:0;
    overflow:visible!important;overscroll-behavior:auto;height:auto;min-height:0}

  /* barra de seleção curta (aba "Página") — ver mSyncRight() em mobile.js */
  .msel-bar{display:flex;align-items:center;gap:10px;position:sticky;top:-14px;
    margin:-14px -14px 12px;padding:14px;background:var(--paper);z-index:2;
    border-bottom:1px solid var(--line)}
  .msel-bar .msel-name{flex:1;min-width:0;font-weight:700;font-size:15px;color:var(--ink);
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  #msheet_pag.collapsed>#right{display:none}
  .msheet .aside-title{font-size:15px;margin:2px 2px 12px}
  .msheet .aside-title.mt16{margin-top:22px}
  .msheet h3{font-size:12px;letter-spacing:.09em;text-transform:uppercase;color:var(--faint);
    font-weight:700;margin:16px 2px 8px}
  .msheet h3:first-child{margin-top:2px}
  .msheet .hint{font-size:12.5px;line-height:1.55}
  .msheet>#left>.hint,#d_privadoNote{margin-top:16px}

  /* alvos de toque confortáveis */
  .msheet label{margin-bottom:13px;font-size:13px}
  .msheet input[type=text],.msheet input[type=number],.msheet input[type=date],
  .msheet select,.msheet textarea{min-height:48px;font-size:16px;padding:12px 13px;border-radius:10px}
  .msheet textarea{min-height:110px}
  .msheet input[type=range]{height:44px}
  .msheet .row{min-height:46px;align-items:center;font-size:14px}
  .msheet button{min-height:46px}
  .msheet .grp{gap:8px}
  .msheet .grp .chip{min-height:42px;padding:0 16px;font-size:13.5px}
  .msheet .field-inline{display:grid;grid-template-columns:1fr 1fr;gap:10px}

  /* painéis recolhidos: cartões limpos com chevron */
  .msheet #left>details{border:1px solid var(--line);border-radius:12px;background:var(--surface);
    margin:0 0 10px;overflow:hidden}
  .msheet #left>details>summary{min-height:52px;display:flex;align-items:center;gap:10px;
    padding:0 14px;font-weight:700;font-size:14px;color:var(--ink);cursor:pointer;list-style:none}
  .msheet #left>details>summary::-webkit-details-marker{display:none}
  .msheet #left>details>summary .caret{margin-left:auto}
  .msheet #left>details>summary svg{width:17px;height:17px;color:var(--brand)}
  .msheet #left>details[open]>summary{border-bottom:1px solid var(--line-2)}
  .msheet #left>details>.sect{padding:12px 14px 4px}
  .msheet #left>details:first-of-type{margin-top:2px}

  /* lista de páginas: linhas altas, alvo de toque confortável */
  #monList{gap:7px}
  .msheet .mon-row{grid-template-columns:22px 1fr auto;gap:10px;padding:12px 10px;
    touch-action:pan-y;border-radius:11px}
  .msheet .mon-row .mon-name{font-size:13.5px}
  .msheet .mon-grid{grid-template-columns:repeat(2,1fr);gap:10px}
  .msheet .mon-viewsw .chip{min-height:44px;padding:0 14px}

  /* ---------- aba EXPORTAR ---------- */
  #msheet_export{padding-top:16px}
  .mx-card{background:var(--surface);border:1px solid var(--line);border-radius:14px;
    padding:16px 15px;margin:0 0 12px}
  .mx-card h3{margin:0 0 12px}
  .mx-card .hint{margin:12px 0 0}
  .mx-card>label{display:block;margin-bottom:14px}
  .mx-card>label:last-child{margin-bottom:0}
  /* o <details> "Exportação e impressão" foi movido pra cá: sem moldura,
     sem título próprio (o cartão já diz "Formato"). */
  #mx_settings>details{border:0!important;background:transparent!important;margin:0!important}
  #mx_settings>details>summary{display:none!important}
  #mx_settings>details>.sect{padding:0!important}
  #mx_settings .hint{font-size:12px;background:var(--surface-2);border:1px solid var(--line-2);
    border-radius:10px;padding:11px 12px;margin-top:4px}

  .mbig{width:100%;justify-content:center;padding:14px;font-size:14.5px;margin-bottom:8px;min-height:50px}
  .mbig:last-child{margin-bottom:0}
  .m2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
  .m2 .mbig{margin-bottom:0}

  /* ---------- abas de baixo ---------- */
  #mtabs{display:grid;grid-template-columns:repeat(4,1fr);background:var(--surface);
    border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
  #mtabs button{flex-direction:column;gap:3px;border:0;border-radius:0;background:transparent;color:var(--muted);
    font-size:10px;padding:9px 2px;min-height:58px}
  #mtabs button i{font-style:normal}
  #mtabs button svg{width:22px;height:22px}
  #mtabs button.on{color:var(--brand)}

  /* ---------- scrim + folhas de baixo (menus, editor) ---------- */
  .m-scrim{display:block;position:fixed;inset:0;background:rgba(20,24,22,.34);z-index:88;
    animation:mScrimIn .16s ease}
  @keyframes mScrimIn{from{opacity:0}to{opacity:1}}
  @keyframes mSheetUp{from{transform:translateY(14px);opacity:.5}to{transform:translateY(0);opacity:1}}

  /* pega pra arrastar-pra-fechar — portado do Polaroide Studio. Só ela recebe
     o gesto (touch-action:none), o resto da folha continua rolando normal. */
  .m-grab{flex:none;height:26px;margin:-2px 0 2px;display:flex;align-items:center;justify-content:center;
    touch-action:none;cursor:grab}
  .m-grab i{width:40px;height:5px;border-radius:3px;background:var(--line);display:block}

  #menu{position:fixed;left:0;right:0;bottom:0;top:auto;width:auto;max-width:none;min-width:0;
    border-radius:18px 18px 0 0;border:0;border-top:1px solid var(--line);
    padding:8px 10px calc(10px + env(safe-area-inset-bottom));z-index:90;
    max-height:82vh;overflow:auto;animation:mSheetUp .18s ease;box-shadow:var(--sh-pop)}
  #menu button,#menu a{min-height:54px;font-size:15px;padding:13px 12px;border-radius:11px}
  #menu button svg,#menu a svg{width:20px;height:20px}
  #menu .msep{margin:6px 10px}

  .popmenu.pop-sheet{position:fixed;left:0;right:0;bottom:0;top:auto;width:auto;max-width:none;min-width:0;
    border-radius:18px 18px 0 0;border:0;border-top:1px solid var(--line);
    padding:8px 10px calc(10px + env(safe-area-inset-bottom));z-index:90;
    max-height:82vh;overflow:auto;animation:mSheetUp .18s ease;box-shadow:var(--sh-pop)}
  .popmenu.pop-sheet button{min-height:54px;font-size:15px;padding:13px 12px;border-radius:11px}
  .popmenu.pop-sheet button svg{width:20px;height:20px}
  .popmenu.pop-sheet .tm-head{display:flex;align-items:center;justify-content:space-between;
    background:var(--surface);margin:0 -10px;padding:14px 14px 11px;
    border-bottom:1px solid var(--line-2);font:700 16px/1 var(--display);color:var(--ink)}
  .popmenu.pop-sheet .tm-head .iconbtn{width:38px;height:38px;padding:8px;flex:none}

  .mob-only{display:block}
  .desk-only{display:none}

  dialog{max-width:94vw}
  #zenExit{display:none!important}
}

/* casca nova — celular */
@media (max-width:820px){
  #mx_settings>#xp_prevHost{margin:0 -14px 14px;padding:16px 14px;background:var(--stage);display:flex;flex-direction:column;gap:12px;border:0}
  #mx_settings .ep-sheet__stage{flex-direction:column;gap:14px}
  #mx_settings .ep-sheet__svg{max-height:none}
  #msheet_export .pane-h{padding:0;border:0;margin:0 0 14px}
  #toast{bottom:calc(84px + env(safe-area-inset-bottom));max-width:calc(100vw - 32px);text-align:center;border-radius:12px}
  .style-cards{grid-template-columns:repeat(3,1fr)}
}
