/* Mobile application layer for File Browser v2.42.5. Desktop is untouched. */
@media (max-width: 736px) {
  :root,
  :root.dark {
    --background: #f5f7fa;
    --surfacePrimary: #ffffff;
    --surfaceSecondary: #f0f3f7;
    --textPrimary: #697586;
    --textSecondary: #17202b;
    --action: #526170;
    --hover: #edf3fa;
    --borderPrimary: #e2e7ed;
    --borderSecondary: #cbd4de;
    --divider: rgba(23, 32, 43, .07);
    --dividerPrimary: rgba(23, 32, 43, .08);
    --dividerSecondary: rgba(255, 255, 255, .96);
    --iconPrimary: #287cc1;
    --iconSecondary: #ffffff;
    --iconTertiary: #aeb8c3;
    color-scheme: light;
  }

  html,
  body,
  #app {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 100%;
    overflow-x: hidden;
    background: var(--background) !important;
    color: var(--textSecondary) !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    padding: 64px 0 calc(80px + env(safe-area-inset-bottom));
    font-size: 16px !important;
    line-height: 1.35;
  }

  header {
    position: fixed;
    z-index: 1000;
    inset: 0 0 auto;
    width: 100%;
    height: 64px;
    min-height: 64px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: visible;
    background: #ffffff !important;
    border-bottom: 1px solid #e3e8ee;
    box-shadow: 0 2px 12px rgba(27, 39, 51, .07);
  }

  header > * {
    min-width: 0;
  }

  header .action,
  header .menu-button,
  header .search-button {
    width: 48px !important;
    min-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    display: inline-grid !important;
    flex: 0 0 48px !important;
    place-items: center;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 12px !important;
    color: #465a6b !important;
    touch-action: manipulation;
  }

  header .action i,
  header .menu-button i,
  header .search-button i {
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
    font-size: 28px !important;
    line-height: 1 !important;
  }

  /* Chrome can translate Material Icons ligature text (folder -> «папка»),
     turning icons into large words. Hide text nodes and draw immutable
     ligatures from CSS generated content instead. */
  header i.material-icons,
  nav i.material-icons {
    font-size: 0 !important;
  }

  header i.material-icons::before,
  nav i.material-icons::before {
    display: block;
    color: currentColor;
    font-family: "Material Icons";
    font-size: 27px;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
  }

  header .menu-button > i::before { content: "menu"; }
  header .search-button > i::before,
  header #input > i::before { content: "search"; }
  header #more > i::before { content: "more_vert"; }
  header #upload-button > i::before { content: "file_upload"; }
  header #dropdown button:nth-of-type(1) > i::before { content: "view_module"; }
  header #dropdown button:nth-of-type(2) > i::before { content: "file_download"; }
  header #dropdown button:nth-of-type(3) > i::before { content: "file_upload"; }
  header #dropdown button:nth-of-type(4) > i::before { content: "info"; }
  header #dropdown button:nth-of-type(5) > i::before { content: "check_circle"; }
  header #renew > i::before { content: "autorenew"; }

  header > .action > span {
    display: none !important;
  }

  nav > button.action:nth-of-type(1) > i::before { content: "person"; }
  nav > button.action:nth-of-type(2) > i::before { content: "folder"; }
  nav > div:nth-of-type(1) > button.action:nth-of-type(1) > i::before { content: "create_new_folder"; }
  nav > div:nth-of-type(1) > button.action:nth-of-type(2) > i::before { content: "note_add"; }
  nav button[aria-label="Settings"] > i::before,
  nav button[aria-label="Настройки"] > i::before { content: "settings_applications"; }
  nav button[aria-label="Logout"] > i::before,
  nav button[aria-label="Выйти"] > i::before { content: "exit_to_app"; }

  /* Keep navigation labels stable when Chrome translates the page. */
  nav button.action > span {
    font-size: 0 !important;
  }

  nav button.action > span::before {
    font-size: 15px;
    line-height: 20px;
  }

  nav > button.action:nth-of-type(1) > span::before { content: "Профиль"; }
  nav > button.action:nth-of-type(2) > span::before { content: "Файлы"; }
  nav > div:nth-of-type(1) > button.action:nth-of-type(1) > span::before { content: "Новая папка"; }
  nav > div:nth-of-type(1) > button.action:nth-of-type(2) > span::before { content: "Новый файл"; }
  nav button[aria-label="Settings"] > span::before,
  nav button[aria-label="Настройки"] > span::before { content: "Настройки"; }
  nav button[aria-label="Logout"] > span::before,
  nav button[aria-label="Выйти"] > span::before { content: "Выйти"; }

  header img {
    display: none !important;
  }

  main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0 12px;
  }

  .breadcrumbs {
    width: 100%;
    min-width: 0;
    height: 52px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    transform: none !important;
    color: #516273;
    border-bottom: 1px solid #e4e9ee;
  }

  .breadcrumbs::-webkit-scrollbar {
    display: none;
  }

  .breadcrumbs span,
  .breadcrumbs a {
    max-width: 70vw;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px !important;
  }

  .breadcrumbs i {
    flex: 0 0 auto;
    font-size: 22px !important;
  }

  #listing {
    width: 100%;
    min-width: 0;
    margin: 10px 0 70px !important;
    padding: 0;
    background: transparent;
  }

  #listing.list .item {
    width: 100%;
    min-width: 0;
    min-height: 66px;
    margin: 0 0 8px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: visible;
    background: #ffffff;
    border: 1px solid #e1e7ed;
    border-radius: 14px;
    box-shadow: 0 2px 7px rgba(27, 39, 51, .045);
  }

  #listing.list .item[aria-selected="true"] {
    color: var(--textSecondary) !important;
    background: #eaf4fd !important;
    border-color: #88bde7;
  }

  #listing.list .item i {
    width: 36px !important;
    min-width: 36px !important;
    height: 40px !important;
    display: inline-grid !important;
    flex: 0 0 36px !important;
    place-items: center;
    overflow: visible !important;
    padding: 0 !important;
    font-size: 34px !important;
    line-height: 40px !important;
  }

  #listing.list .item .name {
    width: auto !important;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #253341;
    font-size: 15px !important;
    line-height: 20px !important;
  }

  #listing.list .item .modified {
    width: auto !important;
    max-width: 78px;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #8793a0;
    font-size: 11px !important;
  }

  #listing.list .item .size {
    display: none !important;
  }

  #listing.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #listing.grid .item {
    width: auto !important;
    min-width: 0;
    min-height: 128px;
    margin: 0 !important;
    padding: 14px 8px 10px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e1e7ed;
    border-radius: 14px;
    box-shadow: 0 2px 7px rgba(27, 39, 51, .045);
  }

  #listing.grid .item i {
    overflow: visible !important;
    font-size: 52px !important;
    line-height: 58px !important;
  }

  #listing.grid .item .name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #253341;
    font-size: 13px !important;
  }

  #search.active {
    position: fixed;
    z-index: 99998;
    inset: 8px 64px 8px 8px;
    width: auto;
    height: 48px;
    margin: 0;
    padding: 0 10px;
    display: flex !important;
    align-items: center;
    background: #ffffff;
    border: 1px solid #cbd5df;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(27, 39, 51, .16);
  }

  #search input,
  .input,
  input,
  select,
  textarea {
    min-width: 0;
    font-size: 16px !important;
  }

  nav {
    position: fixed;
    z-index: 99999;
    top: 0;
    bottom: 0;
    left: -322px !important;
    width: 320px !important;
    max-width: 88vw !important;
    height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background: #ffffff !important;
    color: #263442 !important;
    border: 0;
    box-shadow: 10px 0 35px rgba(19, 29, 39, .22);
    transition: left .18s ease;
    font-size: 14px !important;
    line-height: 20px !important;
  }

  nav.active {
    left: 0 !important;
  }

  nav > div,
  nav ul,
  nav li,
  nav a,
  nav button,
  nav .action {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  nav a,
  nav button,
  nav .action {
    width: 100% !important;
    min-height: 56px !important;
    margin: 0 !important;
    padding: 8px 18px !important;
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    overflow: visible !important;
    white-space: nowrap !important;
    color: #31475a !important;
    background: transparent !important;
    border-radius: 0 !important;
    font-size: 15px !important;
    line-height: 20px !important;
  }

  nav a:hover,
  nav button:hover,
  nav .action:hover {
    background: #edf4fa !important;
  }

  nav a > span,
  nav button > span,
  nav .action > span,
  nav .name,
  nav .title {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font: inherit !important;
  }

  nav i,
  nav .material-icons {
    width: 30px !important;
    min-width: 30px !important;
    height: 32px !important;
    display: inline-grid !important;
    flex: 0 0 30px !important;
    place-items: center;
    overflow: visible !important;
    padding: 0 !important;
    font-size: 27px !important;
    line-height: 32px !important;
  }

  nav .credits,
  nav .credits * {
    font-size: 10px !important;
    line-height: 15px !important;
    white-space: normal !important;
  }

  nav .credits {
    max-width: calc(100% - 36px) !important;
    margin: 28px 18px !important;
  }

  nav progress,
  nav .usage,
  nav .used-space {
    max-width: calc(100% - 28px) !important;
  }

  #dropdown {
    position: fixed;
    z-index: 99999;
    top: 8px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    padding: 6px 0;
    background: #ffffff !important;
    border: 1px solid #dfe5eb;
    border-radius: 14px;
    box-shadow: 0 12px 35px rgba(19, 29, 39, .2);
  }

  #dropdown .action {
    width: 100% !important;
    min-height: 48px !important;
    padding: 8px 14px !important;
    display: flex !important;
    align-items: center;
    color: #263442 !important;
    white-space: nowrap !important;
  }

  #file-selection {
    position: fixed;
    display: flex !important;
    align-items: center;
    gap: 0;
    z-index: 1001;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-width: none;
    min-height: 58px;
    padding: 6px 7px 6px 12px;
    box-sizing: border-box;
    transform: none;
    overflow: hidden;
    background: #ffffff !important;
    border: 1px solid #dbe2e9;
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(19, 29, 39, .2);
  }

  #file-selection > span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px !important;
  }

  #file-selection .action {
    display: grid !important;
    place-items: center;
    width: 42px !important;
    min-width: 42px !important;
    height: 44px !important;
    padding: 0 !important;
    flex: 0 0 42px !important;
    border-radius: 10px;
  }

  #file-selection .action > span {
    display: none !important;
  }

  #file-selection .action > i.material-icons {
    width: 26px;
    height: 26px;
    overflow: hidden;
    font-size: 0 !important;
    line-height: 26px !important;
    text-align: center;
  }

  #file-selection .action > i.material-icons::before {
    font-family: "Material Icons";
    font-size: 24px;
    font-weight: normal;
    line-height: 26px;
    white-space: nowrap;
  }

  #file-selection .action[aria-label="Поделиться"] > i::before { content: "share"; }
  #file-selection .action[aria-label="Переименовать"] > i::before { content: "mode_edit"; }
  #file-selection .action[aria-label="Скопировать файл"] > i::before { content: "content_copy"; }
  #file-selection .action[aria-label="Переместить файл"] > i::before { content: "forward"; }
  #file-selection .action[aria-label="Удалить"] > i::before { content: "delete"; }

  @media (max-width: 350px) {
    #file-selection {
      right: 6px;
      left: 6px;
      padding-left: 9px;
    }

    #file-selection > span {
      font-size: 11px !important;
    }

    #file-selection .action {
      width: 39px !important;
      min-width: 39px !important;
      flex-basis: 39px !important;
    }
  }

  .card.floating {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 20px);
    transform: none;
    overflow-y: auto;
    background: #ffffff !important;
    border-radius: 18px;
  }

  .card .card-action {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .card .card-action .button {
    min-height: 44px;
    flex: 1 1 auto;
    border-radius: 10px;
  }

  .upload-files .card.floating {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-width: none;
  }

  #previewer {
    background: #10151b !important;
  }

  #previewer header {
    background: rgba(16, 21, 27, .92) !important;
  }

  #previewer .preview img,
  #previewer .preview video {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(100dvh - 64px);
    object-fit: contain;
  }

  #previewer .pdf {
    padding-top: 64px;
  }
}

@media (max-width: 350px) {
  main {
    padding-right: 8px;
    padding-left: 8px;
  }

  #listing.grid {
    grid-template-columns: 1fr;
  }

  nav {
    width: 286px !important;
    left: -288px !important;
  }

  nav.active {
    left: 0 !important;
  }
}
