/* WeEdit — phone layout. Everything here applies only on screens up to 760px wide; the PC layout is untouched. */
#mNav, #mBack { display: none; }

@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { font-size: 15px; }

  /* Sidebar becomes a slide-out menu */
  .sidebar { width: 272px !important; padding: 22px 14px calc(18px + env(safe-area-inset-bottom)) !important; transform: translateX(-105%); transition: transform .25s ease; z-index: 41 !important; box-shadow: none; overflow-y: auto; }
  body.m-menu .sidebar { transform: none; box-shadow: 0 0 60px #0007; }
  .sidebar .brand { padding: 0 8px 22px !important; }
  .sidebar .brandname, .sidebar .navlabel, .sidebar .workspace, .sidebar .help { display: block !important; }
  .sidebar .nav button span:not(.ico) { display: inline !important; }
  .sidebar .profile > div:not(.avatar) { display: block !important; }
  .sidebar .nav button { justify-content: flex-start !important; padding: 0 14px !important; height: 48px; font-size: 15px; gap: 14px; }
  .sidebar .side-bottom .profile { justify-content: flex-start !important; }
  #mBack { position: fixed; inset: 0; background: #0009; z-index: 40; }
  body.m-menu #mBack { display: block; }

  /* Full-width content, room for the bottom bar */
  .main { margin-left: 0 !important; width: 100% !important; padding: 0 16px calc(96px + env(safe-area-inset-bottom)) !important; }
  .topbar { position: sticky; top: 0; z-index: 30; background: var(--paper); height: 62px !important; margin: 0 -16px 18px !important; padding: 0 16px; }
  .crumb { font-size: 0 !important; }
  .crumb b { font-size: 18px; font-weight: 700; }
  .top-right { gap: 7px !important; }
  .top-right > .avatar { display: none; }
  .iconbtn { width: 40px; height: 40px; }
  #weeditCloudSignout { font-size: 12px !important; padding: 9px 11px !important; }
  #weeditChangePw { padding: 9px 10px !important; }

  /* Page headers and buttons */
  .eyebrow { font-size: 10px; }
  .pagehead { flex-direction: column; align-items: stretch !important; gap: 14px; margin-bottom: 18px !important; }
  .pagehead h1 { font-size: 27px !important; line-height: 1.15; }
  .subtitle { font-size: 14px !important; }
  .head-actions { flex-wrap: wrap; width: 100%; gap: 8px !important; }
  .head-actions > * { flex: 1 1 auto; }
  .primary, .secondary, .select { min-height: 44px; font-size: 14px !important; border-radius: 11px !important; padding: 10px 14px !important; }
  .tinybtn { font-size: 12px !important; padding: 8px 10px !important; border-radius: 8px !important; }

  /* Cards: bigger, easier to read */
  .cards { gap: 12px !important; margin-bottom: 14px !important; }
  .card { padding: 18px !important; min-height: 0 !important; border-radius: 16px !important; }
  .cardtop { font-size: 13px !important; }
  .cardicon { width: 34px !important; height: 34px !important; border-radius: 10px !important; }
  .metric { font-size: 29px !important; margin: 14px 0 6px !important; }
  .metric small { font-size: 13px !important; }
  .trend { font-size: 12.5px !important; }

  /* Panels, lists, tables */
  .panel { border-radius: 16px !important; margin-bottom: 14px; }
  .panelhead { flex-wrap: wrap; gap: 10px; padding: 16px !important; }
  .paneltitle { font-size: 15.5px !important; }
  .panelsub { font-size: 12px !important; }
  .columns, .insights { grid-template-columns: 1fr !important; gap: 14px !important; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 13px; }
  .table-scroll td { white-space: nowrap; }
  .table-scroll .entityactions { flex-wrap: nowrap !important; }
  .table-scroll td:first-child { min-width: 200px; white-space: normal; }
  .table-scroll td:first-child b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 210px; }
  th { font-size: 10.5px !important; }
  td, th { padding: 12px 11px !important; }
  .tx { padding: 13px 16px !important; font-size: 13.5px; }
  .tx small { font-size: 12px; }
  .tabletools { width: 100%; flex-wrap: wrap; }
  .tabletools .search { flex: 1 1 160px; width: auto !important; height: 42px !important; font-size: 15px !important; }
  .tabletools .filter, .tabletools select { height: 42px !important; font-size: 14px !important; }

  /* Forms open as a bottom sheet; 16px inputs stop iPhone from zooming in */
  .modalveil { padding: 0 !important; place-items: end center !important; z-index: 46 !important; }
  .modal { width: 100% !important; max-height: 92vh !important; border-radius: 20px 20px 0 0 !important; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)) !important; }
  .modalhead h2 { font-size: 20px; }
  .formgrid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .formfield.full { grid-column: auto !important; }
  .formfield label { font-size: 12.5px !important; }
  .formfield input, .formfield select, .formfield textarea, .modal input:not([type=range]):not([type=checkbox]), .modal select { font-size: 16px !important; min-height: 46px; border-radius: 10px !important; }
  .modalactions { gap: 10px; }
  .modalactions button { flex: 1; min-height: 48px; }
  .profile-kpis { grid-template-columns: 1fr 1fr !important; }

  /* Project details panel uses the full screen */
  .detailback { z-index: 43 !important; }
  .drawer { z-index: 44 !important; width: 100vw !important; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)) !important; }

  /* Editor board */
  .board-grid { grid-template-columns: 1fr !important; padding: 0 14px 14px !important; }
  .board-card h3 { font-size: 16px !important; }
  .board-card p { font-size: 13px !important; }
  .team-kpis b { font-size: 18px; }

  /* Bottom tab bar */
  #mNav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: #172522; border-top: 1px solid #ffffff14; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  body.dark #mNav { background: #0e1310; }
  #mNav button { background: none; border: 0; color: #a9b4ae; display: grid; justify-items: center; gap: 3px; font: 600 11px 'DM Sans', sans-serif; padding: 7px 0 5px; border-radius: 12px; cursor: pointer; }
  #mNav button .i { font-size: 21px; line-height: 1; }
  #mNav button.on { color: #fff; background: #ffffff10; }

  /* Editors only have one page: no tab bar */
  body.cloud-editor #mNav { display: none; }
  body.cloud-editor .main { padding-bottom: calc(28px + env(safe-area-inset-bottom)) !important; }
}

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr !important; }
}
