* {
  box-sizing: border-box;
}

input[title^="Search project"] {
  max-width: 50%;
}

div.page_header,
div.page_footer {
  height: unset;
  overflow: auto;
}

div.page_body,
div.title_text {
  overflow-x: scroll;
}

html {
  min-height: 100%;
  height: 100%;
}

table.projects_list tr td:first-child {
  /* "last change" text */
  white-space: nowrap;
}

table.project_list {
  tr td:first-child {
    /* ".git" name */
    font-weight: bold;
  }
}

table.project_list,
table.heads,
table.shortlog,
table.diff_tree,
table.commit_search,
table.project_list,
div.page_body {
  flex: 1 0 auto;
}

td.link {
  font-size: 100%;
}

@media screen and (max-width: 720px) {
  body {
    box-sizing: border-box;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100%;

    & > * { flex: 0 0 auto; }
  }

  input { min-width: 0 }

  td.link { text-align: right; }

  div.header a .age {
    display: block;
    float: none;
    margin-bottom: 5px;
  }

  div.title_text {
    display: flex;
    flex-direction: column;

    .author_date {
      display: block;
      padding: 0 8px;
    }

    .log_link {
      display: block;
      float: none;
      font-size: 100%;
      width: 100%;
      order: 1;
      margin-top: 5px;
      text-align: right;
    }
  }

  div.log_body {
    padding: 8px;
  }

  table.shortlog {
    tr {
      &:has(th) {
        display: none;
      }

      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      padding-top: 5px;
      padding-bottom: 5px;

      td:nth-child(1) {
        /* commit date */
        flex: 0 0 auto;
        order: 2;
        text-align: right;
      }

      td:nth-child(2) {
        /* committer */
        flex: 1 0 auto;
        order: 1;
      }

      td:nth-child(3) {
        /* commit message */
        flex: 1 0 100%;
        order: 3;
      }

      td:nth-child(4) {
        /* links */
        flex: 1 0 100%;
        order: 4;
      }
    }
  }

  table.project_list {
    tr {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      padding-top: 5px;
      padding-bottom: 5px;

      &:has(th) {
        display: none;
      }

      td:nth-child(1) {
        /* ".git" name */
        flex: 0 0 auto;
        order: 1;
      }

      td:nth-child(2) {
        /* description */
        flex: 1 0 100%;
        order: 3;
      }

      td:nth-child(3) {
        /* last change */
        flex: 1 0 auto;
        text-align: right;
        order: 2;
      }

      td:nth-child(4) {
        /* links */
        flex: 1 0 100%;
        order: 4;
      }
    }
  }

  table.tree {
    padding: 0;
    width: 100%;

    tr {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;

      td:nth-child(1) {
        /* permissions */
        flex: 1 0 25%;
        order: 2;
      }

      td:nth-child(2) {
        /* size */
        flex: 1 0 25%;
        order: 3;
      }

      td:nth-child(3) {
        /* title */
        flex: 1 0 100%;
        order: 1;
      }

      td:nth-child(4) {
        /* links */
        flex: 1 0 50%;
        text-align: right;
        order: 4;
      }
    }
  }

  div.search {
    display: flex;
    align-items: center;
    gap: 3px;
    float: none;

    & > * {
      flex: 0 1 auto;
    }

    & > :last-child {
      flex: 0 0 40px;
    }
  }
}
