/*
 * Responsive application shell shared by public links and the customer Cloud.
 * Desktop remains governed by public-share.php; this module owns the compact
 * navigation and touch layout at widths where the permanent sidebar no longer
 * leaves a useful content area.
 */
.mobile-app-bar,
.mobile-nav-backdrop,
.side-panel__close {
  display: none;
}

@media (max-width: 860px) {
  :root {
    --meta-dl-mobile-safe-top: env(safe-area-inset-top, 0px);
    --meta-dl-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --meta-dl-mobile-bar-content-height: 48px;
    --meta-dl-mobile-bar-height: calc(var(--meta-dl-mobile-bar-content-height) + var(--meta-dl-mobile-safe-top));
  }

  html {
    min-width: 320px;
    overflow-x: hidden;
    scroll-padding-top: calc(var(--meta-dl-mobile-bar-height) + 96px);
  }

  body {
    min-width: 320px;
    overflow-x: hidden;
    overscroll-behavior-x: none;
  }

  body.meta-mobile-nav-open {
    overflow-x: hidden;
    overscroll-behavior-x: none;
  }

  .page {
    width: 100%;
    min-height: 100dvh;
    overflow: clip;
    border: 0;
  }

  .app-shell {
    min-height: 100dvh;
    display: block;
    padding-top: var(--meta-dl-mobile-bar-height);
  }

  .mobile-app-bar {
    width: 100%;
    height: var(--meta-dl-mobile-bar-height);
    padding: var(--meta-dl-mobile-safe-top) 10px 0 12px;
    position: fixed;
    z-index: 1000;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(60, 60, 67, .14);
    background: rgba(251, 251, 253, .94);
    box-shadow: 0 1px 8px rgba(15, 23, 42, .045);
    -webkit-backdrop-filter: saturate(150%) blur(18px);
    backdrop-filter: saturate(150%) blur(18px);
  }

  .mobile-brand {
    min-width: 0;
    height: 100%;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #1d1d1f;
    text-decoration: none;
  }

  .mobile-brand .side-logo {
    width: clamp(24px, calc(var(--meta-public-brand-logo-size, 34px) - 2px), 48px);
    height: clamp(24px, calc(var(--meta-public-brand-logo-size, 34px) - 2px), 48px);
    flex-basis: clamp(24px, calc(var(--meta-public-brand-logo-size, 34px) - 2px), 48px);
    border-radius: 9px;
  }

  .mobile-brand .side-logo img { width: 100%; height: 100%; }
  .mobile-brand .side-brand-copy { min-width: 0; }
  .mobile-brand .side-brand-copy strong {
    max-width: min(55vw, 260px);
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-brand .side-brand-copy small {
    max-width: min(55vw, 260px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav-toggle,
  .side-panel__close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    color: #3f4752;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-toggle:hover,
  .mobile-nav-toggle:active,
  .side-panel__close:hover,
  .side-panel__close:active { background: rgba(0, 0, 0, .045); }

  .mobile-nav-toggle:focus-visible,
  .side-panel__close:focus-visible {
    outline: 2px solid rgba(0, 113, 227, .62);
    outline-offset: -2px;
  }

  .mobile-nav-toggle svg { width: 23px; height: 23px; }
  .side-panel__close svg { width: 19px; height: 19px; }

  .mobile-nav-backdrop {
    margin: 0;
    padding: 0;
    position: fixed;
    z-index: 990;
    inset: 0;
    display: block;
    visibility: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  body.meta-mobile-nav-open .mobile-nav-backdrop {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .side-panel {
    width: min(244px, calc(100vw - 20px));
    height: auto;
    min-height: 0;
    max-height: calc(100dvh - var(--meta-dl-mobile-bar-height) - 18px - var(--meta-dl-mobile-safe-bottom));
    padding: 0;
    position: fixed;
    z-index: 1050;
    top: calc(var(--meta-dl-mobile-bar-height) + 8px);
    right: 10px;
    bottom: auto;
    left: auto;
    display: block;
    visibility: hidden;
    overflow: hidden;
    border: 1px solid rgba(60, 60, 67, .16);
    border-radius: 13px;
    background: var(--meta-public-side-panel-bg);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
    opacity: 0;
    transform: translate3d(0, -6px, 0) scale(.98);
    transform-origin: top right;
    transition: opacity .18s ease, transform .18s cubic-bezier(.22, .61, .36, 1), visibility 0s linear .18s;
    will-change: opacity, transform;
  }

  body.meta-mobile-nav-open .side-panel {
    visibility: visible;
    opacity: 1;
    transform: translate3d(0, 0, 0);
    transition-delay: 0s;
  }

  .side-panel__viewport {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: inherit;
    padding: 8px;
    position: relative;
    top: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .side-panel__header {
    display: none;
  }

  .side-nav {
    min-height: 0;
    margin-top: 0;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0;
    overflow: visible;
    transform: none;
  }

  .side-nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .side-nav .side-nav-group--account {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(60, 60, 67, .12);
  }

  .side-files-link,
  .side-action-item,
  .side-nav-item {
    width: 100%;
    max-width: none;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0 8px;
    grid-template-columns: 28px minmax(0, 1fr);
    justify-items: stretch;
    gap: 8px;
    border-radius: 9px;
    text-align: left;
  }

  .side-more-toggle { grid-template-columns: 28px minmax(0, 1fr); }
  .side-nav-icon { width: 28px; height: 28px; display: grid; }
  .side-nav-icon img,
  .side-nav-icon svg { width: 20px; height: 20px; }
  .side-files-link .side-nav-icon img,
  .side-files-link .side-nav-icon svg { width: 22px; height: 22px; }
  .side-nav-copy { display: flex; transform: none; text-align: left; }
  .side-nav-copy strong { font-size: 13px; }

  .side-more { width: 100%; }
  .side-more-menu {
    width: calc(100% - 4px);
    max-width: none;
    left: 2px;
    top: calc(100% + 5px);
    padding: 5px;
    border-radius: 11px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .13);
  }
  .side-more-menu a { min-height: 40px; padding-inline: 11px; font-size: 12px; }

  .side-spacer {
    width: 100%;
    height: 1px;
    min-height: 1px;
    flex: 0 0 1px;
    margin: 8px 0;
    border: 0;
    background: #d9d9de;
  }

  .side-assistance { padding: 0; flex: 0 0 auto; }
  .platform-links {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .platform-link { width: 100%; min-width: 0; justify-content: center; }

  .main {
    min-width: 0;
    min-height: calc(100dvh - var(--meta-dl-mobile-bar-height));
    padding: 0;
  }

  .main-content {
    min-height: calc(100dvh - var(--meta-dl-mobile-bar-height));
    padding-bottom: max(96px, 12vh);
  }

  .public-banner-slot {
    width: 100%;
    margin: 0;
    overflow: hidden;
  }

  .meta-share-banner-frame {
    width: 100%;
    height: clamp(118px, min(34vw, var(--meta-public-banner-height, 180px)), 180px);
    border-inline: 0;
    border-radius: 0;
  }

  .hero {
    min-height: 210px;
    border-inline: 0;
    border-radius: 0;
  }
  .hero-copy { padding: 28px 20px; }
  .hero h1 { font-size: clamp(29px, 8vw, 40px); }

  .catalog { width: 100%; min-width: 0; }

  .catalog-header {
    width: 100%;
    height: auto;
    min-height: 92px;
    max-height: none;
    margin: 0;
    padding: 8px 12px 10px;
    position: sticky;
    z-index: 80;
    top: var(--meta-dl-mobile-bar-height);
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "heading view"
      "search search";
    column-gap: 10px;
    row-gap: 8px;
    border-bottom: 1px solid rgba(60, 60, 67, .1);
    background: rgba(245, 245, 247, .94);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .045);
    -webkit-backdrop-filter: saturate(145%) blur(16px);
    backdrop-filter: saturate(145%) blur(16px);
  }

  .catalog-header.meta-public-controls-header {
    height: 46px;
    min-height: 46px;
    max-height: 46px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: none;
    row-gap: 0;
  }

  .meta-public-controls-header .search {
    grid-column: 1;
    grid-area: auto;
  }

  .meta-public-controls-header .view-switch {
    grid-column: 2;
    grid-area: auto;
  }

  .meta-public-selection-toolbar {
    width: 100%;
    margin-inline: 0;
    padding-inline: 12px;
  }

  .catalog-breadcrumbs {
    min-width: 0;
    grid-area: heading;
    overflow: hidden;
    font-size: 13px;
  }
  .catalog-breadcrumbs ol {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
  }
  .catalog-breadcrumbs ol::-webkit-scrollbar { display: none; }
  .catalog-breadcrumbs li { flex: 0 0 auto; }
  .catalog-breadcrumbs a,
  .catalog-breadcrumbs [aria-current="page"] { max-width: min(42vw, 180px); }

  .search {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 38px;
    padding-inline: 12px 8px;
    grid-area: search;
    border-radius: 20px;
  }
  .search input { height: 36px; font-size: 14px; }
  .search-clear { width: 28px; height: 28px; flex-basis: 28px; }

  .view-switch {
    width: 80px;
    height: 36px;
    padding: 2px;
    grid-area: view;
    grid-template-columns: repeat(2, 36px);
    align-self: center;
  }
  .view-switch::before { width: 36px; }
  .view-switch[data-active="grid"]::before { transform: translateX(38px); }
  .view-button { width: 36px; height: 30px; }
  .view-button svg { width: 17px; height: 17px; }

  .items {
    padding: 12px;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 10px;
  }
  .item-icon,
  .item-main .meta-media-thumb-shell { width: 78px; height: 78px; flex-basis: 78px; }
  .item-copy strong { font-size: 13px; }
  .copy-download-link { width: 36px; height: 36px; min-height: 36px; padding: 7px; }
  .copy-download-link img { width: 22px; height: 22px; }
  .download-button { height: 32px; min-height: 32px; }


  .items.is-list { padding: 6px 6px max(18px, var(--meta-dl-mobile-safe-bottom)); }
  #catalog-items.items.is-list { --meta-dl-list-icon-size: 22px; }
  .items.is-list .item {
    width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    margin: 1px 0;
    border-radius: 7px;
  }
  .items.is-list .item-main {
    height: 44px;
    min-width: 0;
    padding: 0 8px;
    gap: 9px;
  }
  .items.is-list .item-icon,
  .items.is-list .item-main .meta-media-thumb-shell {
    width: var(--meta-dl-list-icon-size);
    height: var(--meta-dl-list-icon-size);
    flex: 0 0 var(--meta-dl-list-icon-size);
  }
  .items.is-list .media-icon svg { width: 11px; height: 11px; }
  .items.is-list .item-copy { min-width: 0; gap: 8px; }
  .items.is-list .item-copy strong {
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .items.is-list .item-copy small { display: none; }
  .items.is-list .item-actions {
    height: 44px;
    margin: 0 4px 0 0;
    gap: 1px;
  }
  .items.is-list .copy-download-link { width: 36px; height: 36px; flex: 0 0 36px; }
  .items.is-list .download-button {
    width: 36px;
    height: 36px;
    min-height: 36px;
    flex: 0 0 36px;
    padding: 0;
    font-size: 0;
  }

  .empty-state { min-height: 240px; padding: 24px; }
  .search-notice { padding-inline: 12px; }

  .public-trash { min-height: calc(100dvh - var(--meta-dl-mobile-bar-height)); }
  .public-trash__header { min-height: 56px; padding: 8px 12px; }
  .public-trash__empty-button { min-height: 40px; }
  .public-trash__table-head { display: none; }
  .public-trash__row {
    min-height: 56px;
    padding: 6px 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .public-trash__location,
  .public-trash__date,
  .public-trash__size { display: none; }
  .public-trash__actions { min-width: 80px; }
  .public-trash__action { width: 38px; height: 38px; }
  .public-trash__access { min-height: 340px; padding: 32px 18px; }

  .footer {
    margin: 0;
    padding: 24px 16px calc(20px + var(--meta-dl-mobile-safe-bottom));
  }
  .footer-directory {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
  }
  .footer-bottom { min-height: 44px; }

  .meta-cloud .side-panel__viewport { overflow-y: auto; }
  .meta-cloud .side-spacer { margin: 14px 0 12px; }
  .cloud-storage { width: 100%; padding: 0 2px 12px; }
  .cloud-toolbar {
    min-height: 52px;
    margin: 0;
    padding: 8px 12px;
    align-items: center;
    border-bottom: 1px solid #eceff3;
  }
  .cloud-button { min-height: 40px; padding-inline: 12px; }
  .cloud-button.is-quiet { padding-left: 4px; }
  .cloud-upload-picker .meta-upload-menu { width: 164px; }
  .cloud-upload-picker .meta-upload-menu button { height: 42px; font-size: 13px; line-height: 42px; }
  .cloud-transfer {
    right: 10px;
    bottom: calc(10px + var(--meta-dl-mobile-safe-bottom));
    width: calc(100vw - 20px);
    max-width: none;
  }
  .cloud-dialog {
    width: calc(100vw - 24px);
    max-width: 420px;
    max-height: calc(100dvh - 24px - var(--meta-dl-mobile-safe-top) - var(--meta-dl-mobile-safe-bottom));
  }
  .cloud-dialog header { height: 44px; }
  .cloud-dialog header button { width: 40px; height: 40px; }
  .cloud-dialog input { height: 40px; }
  .cloud-dialog footer { padding-bottom: 12px; }
  #cloud-dialog-cancel,
  #cloud-dialog-confirm { min-height: 40px; }
  .cloud-account { max-width: none; padding: 20px 16px 36px; }
}

@media (max-width: 420px) {
  .mobile-brand .side-brand-copy strong,
  .mobile-brand .side-brand-copy small { max-width: 54vw; }
  .items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
  .item-icon,
  .item-main .meta-media-thumb-shell { width: 70px; height: 70px; flex-basis: 70px; }
  .footer-directory { gap: 18px; }
}

@media (max-width: 350px) {
  .mobile-brand .side-brand-copy small { display: none; }
  .catalog-header { padding-inline: 10px; }
  .catalog-breadcrumbs a,
  .catalog-breadcrumbs [aria-current="page"] { max-width: 43vw; }
}

@media (max-width: 860px) and (orientation: landscape) and (max-height: 520px) {
  .side-panel { width: min(244px, calc(100vw - 20px)); }
  .side-panel__viewport { padding: 6px; }
  .side-nav { min-height: 0; margin-top: 0; }
  .side-nav .side-nav-group--account { padding-top: 8px; }
  .side-spacer { margin-block: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav-backdrop,
  .side-panel { transition: none; }
}
