/* Unified mobile layout for internal pages. Homepage and checkout intentionally exclude this file. */

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

.admin-main,
.admin-content,
.panel,
.panel-body,
.shop-main,
.pd-grid,
.track-grid,
.auth-wrap {
  min-width: 0;
}

@media (max-width: 1023.98px) {

  .admin {
    display: block;
    min-height: 100dvh;
  }

  .admin-side {
    width: min(88vw, 320px);
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.48);
  }

  .admin-main {
    width: 100%;
  }

  .admin-top {
    min-height: 64px;
    height: auto;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .admin-search {
    order: 10;
    width: 100%;
    max-width: none;
  }

  .admin-content {
    width: 100%;
    padding: 18px 12px 92px;
    overflow-x: hidden;
  }

  .admin-h {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }

  .admin-h h1 {
    font-size: clamp(1.35rem, 6vw, 1.8rem);
    line-height: 1.45;
  }

  .stat-grid,
  .panel-grid,
  .story-manage-grid,
  .chat-grid,
  .acct-grid,
  .form-grid,
  .story-preview-wrap,
  .model-scope-grid,
  .mail-compose-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .panel-head {
    padding: 15px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .panel-body {
    padding: 8px 12px 18px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Only tablets keep the wide scrolling table. Below 768px pages.css turns
     each row into a card, and a min-width here would defeat it. */
  @media (min-width: 768px) {
    table.admin-table,
    .admin-table {
      min-width: 680px;
    }
  }

  .prod-toolbar,
  .row-actions,
  .story-toolbar,
  .mail-toolbar,
  .cmp-actions,
  .mpv-actions,
  .qb-actions {
    flex-wrap: wrap;
  }

  .admin input,
  .admin select,
  .admin textarea,
  .amodal input,
  .amodal select,
  .amodal textarea {
    max-width: 100%;
    font-size: 16px;
  }

  .amodal {
    padding: 0;
    place-items: end center;
  }

  .amodal-card {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
  }

  .amodal-head {
    padding: 16px;
  }

  .amodal-body {
    padding: 16px;
  }

  .amodal-body [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .amodal-foot {
    padding: 4px 16px 16px;
    flex-wrap: wrap;
  }

  .mail-side {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .mail-compose,
  .mail-folders,
  .mail-folder {
    flex: none;
  }

  .mail-row {
    padding: 12px 10px;
  }

  .mail-who {
    width: 92px;
  }

  .mail-av {
    display: none;
  }
}

@media (max-width: 767.98px) {
  .page-hero {
    padding-block: 32px;
  }

  .page-hero h1 {
    font-size: clamp(1.65rem, 8vw, 2.35rem);
    line-height: 1.35;
  }

  #specWrap {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 20px !important;
    padding-bottom: 40px !important;
  }

  .panel,
  .stat-card,
  .admin-h,
  .pd-card,
  .track-card,

  .shop-grid,
  .pd-grid,
  .track-grid,
  .auth-wrap {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .shop-bar,
  .shop-tools,

  .shop-search,
  .shop-sort {
    width: 100%;
    min-width: 0;
  }

  .vendors-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .product-card:hover {
    transform: none;
  }

  /* The notifications popover is anchored to its bell and ran 36px past the
     right edge of a 390px screen, so its last column was unreachable. */
  .notif-pop {
    position: fixed;
    inset-inline: var(--sp-3);
    width: auto;
    max-width: none;
    max-height: 70dvh;
    overflow-y: auto;
  }

  /* One 180px card per row meant four screens of scrolling before any table. */
  .stat-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
  }

  /* Sizing and object-fit now live in style.css. This file loads last, so the
     old copy here (object-fit: contain + 4px padding) was silently reverting
     the fill-the-frame card on every phone. Only the paint-cost trims stay. */
  .pc-media img {
    filter: none;
    transform: none;
    transition: none;
  }

}

@media (max-width: 479.98px) {
  .admin-content {
    padding-inline: 10px;
  }

  #adminContent [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #adminContent [style*="display:grid"],
  #adminContent [style*="display: grid"] {
    min-width: 0;
  }

  .pk-ov {
    align-items: flex-end;
    padding: 0;
  }

  .pk-modal {
    width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: 22px 22px 0 0;
  }

  .pk-modal .modal-head,
  .pk-modal .modal-body,
  .pk-modal .modal-foot {
    padding-inline: 16px;
  }

  .prod-toolbar > *,
  .story-toolbar > *,
  .row-actions > *,
  .cmp-actions > * {
    width: 100%;
    min-width: 0;
  }

  .ptb-search,
  .ptb-sel {
    width: 100%;
    min-width: 0;
  }

  .img-pick {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .vendors-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .auth-visual {
    display: none;
  }

  .auth-wrap {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    min-height: 100dvh;
    overflow-x: clip;
  }

  .auth-panel {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100dvh;
    padding: 72px 14px 28px !important;
  }

  .auth-card {
    width: 100% !important;
    max-width: 440px !important;
    min-width: 0 !important;
    margin-inline: auto;
    padding-inline: 0 !important;
  }

  .auth-form,
  .auth-form .field,
  .auth-form input,
  .auth-form button,
  .otp-boxes {
    min-width: 0;
    max-width: 100%;
  }

  .auth-form [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .otp-boxes {
    gap: 6px;
  }

  .otp-boxes input {
    width: min(48px, calc((100vw - 64px) / 6));
    height: 52px;
  }

  .amodal-foot .btn,
  .amodal-foot button {
    flex: 1 1 140px;
  }
}
