/* common stuff */

.max-lines-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}

.max-lines-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* shared layout */

body {
    margin: 48px 0;
    padding: 0;
    font-family: sans-serif;
}

html {
    background-color: var(--app-background);
}

body.noguide {
    grid-template-areas: "top-bar top-bar" "app app";
}

* {
    box-sizing: border-box;
    color: var(--text-secondary);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;

    display: flex;
    align-items: center;
    padding: 0 16px;

    box-shadow: #0004 0 2px 5px;
    background-color: var(--top-bar-background);

    z-index: 9999;
}

.top-bar > form {
    display: none;
}

.top-bar > .divider {
    flex-grow: 1;
}

.guide {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 48px;

    border-top: 1px solid var(--border-color);

    display: flex;
    flex-direction: row;
    justify-content: space-around;

    background-color: var(--guide-background);
}

.top-bar.full-size-search > .logo,
.top-bar.full-size-search > .divider,
.top-bar.full-size-search > .search-button,
.top-bar.full-size-search > .account {
    display: none;
}

.top-bar.full-size-search > form {
    height: 40px;
    flex-grow: 1;
    display: flex !important;
}

.top-bar.full-size-search > form > input {
    box-sizing: border-box;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 0;
    color: var(--text-primary);
    background-color: var(--item-active-background);
}

.top-bar.full-size-search > form > input[type=text] {
    flex-grow: 1;
}

.top-bar.full-size-search > form > input[type=submit] {
    width: 64px;
    flex-basis: 64px;
}

.app {
    background-color: var(--app-background);
    margin-top: 48px;
}

a.icon-link, a.icon-link > i {
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
}

.noguide > .guide {
    display: none;
}

/* guide */

.guide-item > a {
    height: 100%;
    padding: 0 24px;
    display: flex;
    text-align: center;
    flex-direction: column;
    font-size: x-small;
    align-items: center;
    text-decoration: none;
    justify-content: center;

    color: var(--text-primary);
}

.guide-item > a > .icon {
    width: 24px;
    height: 24px;
    line-height: 24px;
    font-size: initial;
    margin-right: 0;
}

.guide-item:hover {
    background-color: var(--item-hover-background);
}

.guide-item.active {
    background-color: var(--item-active-background);
}

.hide-on-minmode {
    display: none;
}

.show-on-minmode {
    display: none;
}

/* top bar */

.logo {
    color: var(--text-primary) !important;
    text-decoration: none;
    font-size: larger;
}

.account {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account > img {
    width: 32px;
    height: 32px;
}

.account-menu {
    display: none;
}

.search-button {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* rich video grid */

@media screen and (min-width: 850px) {
    .rich-video-grid {
        width: 100%;

        display: flex;
        flex-wrap: wrap;
        gap: 16px 16px;
        padding-top: 16px;
        justify-content: space-evenly;
    }

    .rich-video-grid > .video {
        display: grid;
        grid-template-columns: 52px 1fr;
        grid-template-rows: min-content min-content;
        grid-auto-flow: row;
        grid-gap: 10px 0;
        grid-template-areas:
    "thumbnail thumbnail"
    "avatar info";

        margin-bottom: 16px;
        width: 400px;
    }
}

@media screen and (max-width: 850px) {
    .rich-video-grid {
        width: 100%;
    }

    .rich-video-grid > .video {
        display: grid;
        grid-template-columns: 52px 1fr;
        grid-template-rows: min-content min-content;
        grid-auto-flow: row;
        grid-gap: 10px 0;
        grid-template-areas:
    "thumbnail thumbnail"
    "avatar info";

        margin-bottom: 16px;
    }
}

/* list video item */

.video a {
    text-decoration: none;
    color: #606060;
}

.video > .thumbnail {
    grid-area: thumbnail;
    background-color: #CCC;
    width: 100%;
    height: fit-content;
    aspect-ratio: 16 / 9;

    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 4px;

    background-position-y: center;
    background-size: cover;
}

.video > .thumbnail.img-thumbnail {
    padding: 0 !important;
}

.video > .thumbnail > img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.video > .thumbnail > span {
    font-size: smaller;

    background-color: #0008;
    color: #fff;
    padding: 2px;
    border-radius: 2px;
}

.video > .avatar {
    grid-area: avatar;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background-color: #E3E3E3;

    margin-left: 12px;
}

.video > .avatar > img {
    width: 36px;
    height: 36px;
    border-radius: 18px;
}

.video > .info {
    grid-area: info;
}

.video > .info > div {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    color: #606060;
    column-gap: 8px;
    overflow-y: hidden;
}

.video > .info > .title {
    color: var(--text-primary) !important;
}

/* playlist video item */

.playlist-video a {
    text-decoration: none;
    color: #606060;
}

.playlist-video > .thumbnail {
    grid-area: thumbnail;
    background-color: #CCC;
    width: 100%;
    height: fit-content;
    aspect-ratio: 16 / 9;

    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 4px;

    background-position-y: center;
    background-size: cover;
}

.playlist-video > .thumbnail > span {
    font-size: smaller;

    background-color: #0008;
    color: #fff;
    padding: 2px;
    border-radius: 2px;
}

.playlist-video > .avatar {
    grid-area: avatar;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background-color: #E3E3E3;

    margin-left: 12px;
}

.playlist-video > .avatar > img {
    width: 36px;
    height: 36px;
    border-radius: 18px;
}

.playlist-video > .info {
    grid-area: info;
}

.playlist-video > .info > div {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    color: #606060;
    column-gap: 8px;
    overflow-y: hidden;
}

.playlist-video > .info > .title {
    color: var(--text-primary) !important;
}

.playlist-video > .index {
    grid-area: index;
    display: none;
}

.playlist-video > .edit {
    grid-area: edit;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* list playlist item */

.playlist a {
    text-decoration: none;
    color: var(--text-secondary);
}

.playlist > .thumbnail {
    grid-area: thumbnail;

    background-color: #CCC;

    display: flex;
    justify-content: flex-end;
    align-items: center;

    background-position-y: center;
    background-size: cover;
}

.playlist > .thumbnail > div {
    font-size: smaller;

    background-color: #0008;
    color: #fff;
    padding: 2px;
    width: 50%;
    height: 100%;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    row-gap: 8px;
}

.playlist > .thumbnail > div > * {
    color: #fff;
}

.playlist > .thumbnail > div > *:nth-child(1) {
    font-size: x-large;
}

.playlist > .info {
    grid-area: info;
    font-size: small;
}

.playlist > .info > div > ul {
    display: none;
}

.playlist > .info > .title {
    color: var(--text-primary) !important;
    font-weight: bold;
    font-size: initial;
    margin-bottom: 8px;
}

/* list playlist item */

.channel a {
    text-decoration: none;
    color: var(--text-secondary);
}

.channel > .avatar {
    grid-area: thumbnail;

    display: flex;
    justify-content: center;
    align-items: center;
}

.channel > .avatar > img {
    background-color: #CCC;

    height: 90px;
    width: 90px;
}

.channel > .info {
    grid-area: info;
    font-size: small;
}

.channel > .info > .name {
    color: var(--text-primary) !important;
    font-weight: bold;
    font-size: initial;
    margin-bottom: 8px;
}

.channel > .info p {
    display: none;
}

/* watch page */

.watch-page {
    display: grid;
    grid-template-columns: 1fr 256px;
    grid-template-rows: 1fr;
    grid-template-areas: "primary secondary";
}

@media screen and (max-width: 900px) {
    .watch-page {
        grid-template-areas: "primary" "secondary";
        grid-template-columns: 1fr;
        grid-template-rows: max-content 1fr;
    }
}

.primary {
    grid-area: primary;
}

.video-player-container {
    max-width: 100%;
    margin: auto;
    max-height: 75vh;
    aspect-ratio: 16 / 9;
    background-color: #000;
}

.player {
    width: 100%;
    height: 100%;
}

.player.error {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ccc;
    background-image: url('/img/player-error.png') !important;
    background-size: contain;
}

.player.error > * {
    background-color: #000;
    color: #fff;
}

.video-info {
    padding: 12px;
}

.video-title {
    font-size: large;
    color: var(--text-primary);
}

.video-info-bar {
    font-size: small;
    display: grid;
    grid-auto-columns: 1fr;
    grid-template-columns: max-content max-content max-content 1fr max-content;
    grid-template-rows: max-content max-content;
    gap: 0 8px;
    grid-template-areas:
    "views . uploaddate divider"
    "buttons buttons buttons buttons";
}

.video-info-bar > span:nth-child(1) {
    grid-area: views;
}

.video-info-bar > .divider {
    grid-area: divider;
}

.video-info-bar > span:nth-child(3) {
    grid-area: uploaddate;
}

.video-info-bar > .video-info-buttons {
    grid-area: buttons;
}

.video-info-buttons {
    display: flex;
    justify-content: space-evenly;
    flex-direction: row;
    column-gap: 8px;
    padding: 8px 0;
}

.video-info-buttons > * {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    column-gap: 4px;
    text-decoration: none;
}

.video-info-buttons > * > i.bi {
    font-size: x-large;
}

.channel-info, .channel-info__bordered {
    display: grid;
    grid-template-columns: 34px max-content 1fr min-content;
    grid-template-rows: 34px;
    grid-auto-columns: 1fr;
    gap: 8px;
    grid-auto-flow: row;
    grid-template-areas: "avatar name . subscribe-button";

    padding: 8px 0;

    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.avatar {
    grid-area: avatar;
}

.avatar > img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.name {
    grid-area: name;

    display: flex;
    flex-direction: column;
    justify-content: center;
}

.name > a {
    color: var(--text-primary);
    text-decoration: none;
}

.name > span {
    font-size: small;
    color: var(--text-secondary);
}

.subscribe-button {
    grid-area: subscribe-button;

    background-color: #0000;
    color: #c00;
    text-transform: uppercase;
    border: none;

    height: 100%;
}

.subscribe-button.subscribed {
    color: var(--text-secondary);
}

.secondary {
    grid-area: secondary;

    padding: 16px 8px;
}

.resolutions-list {
    width: 100%;
    padding: 4px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.resolutions-list > div {
    display: flex;
    flex-direction: column;
    column-gap: 16px;
}

.resolutions-list > div > * {
    line-height: 32px;
}

.recommended-list {
    display: flex;
    flex-direction: column;
    row-gap: 16px;
}

.recommended-list > .video {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr max-content;
    grid-auto-flow: row;
    grid-gap: 0 8px;
    grid-template-areas: "thumbnail" "info";

    color: var(--text-secondary);
}

.recommended-list > .video > .info {
    font-size: small;
}

.recommended-list > .video > .info > a {
    font-size: initial;
}

.recommended-list > .video > .info > div {
    flex-wrap: wrap;
    max-height: unset;
}

/* channel page */

.channel-banner {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 6.2;
    background-color: #000a;
    background-size: contain;
}

.channel-info-container {
    background-color: var(--channel-info-background);
}

.channel-info-container > .channel-info {
    grid-template-columns: 50px 1fr;
    grid-template-rows: 50px min-content;
    grid-template-areas: "avatar name" ". subscribe-button";
    column-gap: 16px;
    padding: 16px;
}

.channel-info-container > .channel-info > .subscribe-button {
    width: max-content;
}

.channel-info-container > .channel-info > .name > *:first-child {
    font-size: larger;
    color: var(--text-primary);
}

.channel-info-container > .channel-info > .name > * {
    color: var(--text-secondary);
}

.channel-page > p {
    color: var(--text-secondary)
}

.channel-page .video-grid {
    background-color: var(--channel-contents-background);
}

/* card list item */

.card-list {
    display: flex;
    flex-direction: row;
    overflow-x: scroll;
    column-gap: 16px;
}

.card {
    width: 150px;
    background: var(--context-menu-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
}

.card > img {
    aspect-ratio: 16 / 9;
    width: 150px;
    height: fit-content;
}

.card > span {
    text-decoration: none;
    color: var(--text-primary);
    margin: 0 8px;
}

/* channel video "grid" */

.video-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    column-gap: 16px;
    row-gap: 12px;
    padding: 0 12px;
}

.video-grid > .video {
    display: grid;
    grid-template-columns: 160px 1fr;
    grid-template-rows: 90px;
    grid-auto-flow: row;
    grid-gap: 10px 10px;
    grid-template-areas:
    "thumbnail info";

    color: var(--text-secondary);
    text-decoration: none;
}

.video-grid > .avatar {
    display: none;
}

.video-grid > .video > .info > span {
    font-weight: bold;
    font-size: initial;
}

.video-grid > .video > .info > div > div {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
}

/* Pagination links */

.pagination-buttons {
    border-top: 1px solid var(--border-color);
    width: 100%;
    display: flex;
}

.pagination-buttons > * {
    height: 3rem;
    line-height: 3rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.pagination-buttons > .divider {
    flex-grow: 1;
}

/* normal video list */

.video-list {
    margin: auto;
    display: flex;
    flex-direction: column;
    row-gap: 16px;
    padding: 16px;
}

.video-list > .video {
    text-decoration: none;
    display: grid;
    grid-template-columns: 160px;
    grid-template-rows: 90px;
    grid-auto-flow: row;
    grid-gap: 0 16px;
    grid-template-areas: "thumbnail info";

    color: var(--text-secondary);
    font-size: small;
}

.video-list > .playlist-video {
    text-decoration: none;
    display: grid;
    grid-template-columns: 160px 1fr 50px;
    grid-template-rows: 90px;
    grid-auto-flow: row;
    grid-gap: 0 16px;
    grid-template-areas: "thumbnail info edit";

    color: var(--text-secondary);
    font-size: small;
}

.video-list > .video > .info > .title,
.video-list > .playlist-video > .info > .title {
    font-weight: bold;
}

.video-list > .video > .info > div > a > img {
    display: none;
}

.video-list > .playlist {
    text-decoration: none;
    display: grid;
    grid-template-columns: 160px;
    grid-template-rows: 90px;
    grid-auto-flow: row;
    grid-gap: 0 16px;
    grid-template-areas: "thumbnail info";

    color: var(--text-secondary);
}

.video-list > .channel {
    text-decoration: none;
    display: grid;
    grid-template-columns: 160px 1fr max-content;
    grid-template-rows: 90px;
    grid-auto-flow: row;
    grid-gap: 0 16px;
    grid-template-areas: "thumbnail info subscribe-button";

    color: var(--text-secondary);
}

.video-list > .channel > .subscribe-button {
    display: none;
}

/* Playlist page */

.playlist-info > .thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    background-color: var(--thumbnail-background);
    background-size: contain;
}

.playlist-info > .thumbnail > a {
    display: none;
}

.playlist-info > .title {
    font-size: x-large;
    color: var(--text-primary);
}

.playlist-info {
    background-color: var(--channel-contents-background);
    padding-bottom: 16px;
}

.playlist-info > .title,
.playlist-info > .info,
.playlist-info > .description {
    display: block;
    padding: 0 16px;
}

.playlist-info > .channel-info {
    display: none;
}

/* horizontal channel list */

.horizontal-channel-list {
    display: flex;
    column-gap: 16px;
    padding: 16px;
    overflow-x: scroll;
    background-color: var(--item-hover-background);
}

.horizontal-channel-list > .channel {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    row-gap: 4px;
    color: var(--text-secondary);
}

.horizontal-channel-list > .channel > div {
    font-size: small;
    text-align: center;
    width: 48px;
    color: var(--text-secondary);
}

.horizontal-channel-list > .channel > img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--thumbnail-background);
}

.horizontal-channel-list > .channel > i {
    font-size: 24px;
    line-height: 48px;
    text-align: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--thumbnail-background);
}

/* Login / Register / Delete pages */

.login-container {
    display: flex;
    flex-direction: row;
    padding: 24px;
}

@media screen and (max-width: 1300px) {
    .login-container {
        flex-direction: column;
    }
}

.login-container > * {
    flex: 1 1 0;
}

.login-container > * > div {
    max-width: 600px;
    margin: auto;
}

.login-form {
    display: flex;
    flex-direction: column;
    max-width: 400px;
    row-gap: 10px;
    margin: auto;
}

.login-form > input, .login-button {
    background-color: var(--item-active-background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px;
    max-width: 400px;
    row-gap: 10px;
    margin: auto;
}

.playlist-form {
    display: flex;
    flex-direction: column;
    max-width: 400px;
    row-gap: 10px;
    margin: auto;
}

.playlist-form > input, .playlist-form > select, .login-button {
    background-color: var(--item-active-background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px;
    width: 80%;
    row-gap: 10px;
    margin: auto;
}

.login-button {
    background-color: var(--item-active-background);
    color: var(--text-primary);
    display: block;
    text-align: center;
    text-decoration: none;
    width: fit-content;
}

.login-button.danger {
    color: red;
    font-weight: bold;
}

.login-form > h1 {
    text-align: center;
}

.login-message {
    width: calc(100% - 96px);
    margin: 48px;
    padding: 16px;
    border: 1px solid var(--border-color);
    background-color: var(--item-active-background);
    border-radius: 5px;
}


/* Account Menu */

.fullscreen-account-menu > .guide-item:hover {
    background-color: var(--item-hover-background);
}

.fullscreen-account-menu > .guide-item > a {
    height: 40px;
    display: flex;
    align-items: start;
    color: var(--text-primary);
    text-decoration: none;
    font-size: initial;
    padding: 0;
}

.fullscreen-account-menu > .guide-item > a > .icon {
    height: 24px;
    width: 24px;
    margin-right: 24px;
}

.fullscreen-account-menu > .guide-item.active {
    background-color: var(--item-active-background);
}

/* download page */

.download-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    column-gap: 32px;
}

.download-format {
    max-width: 400px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    row-gap: 8px;
}

.download-format > div {
    color: var(--text-primary);
}

.download-format > a {
    padding: 8px;
    background-color: var(--channel-contents-background);
    border: 1px solid var(--border-color);
    text-decoration: none;
}

/* settings page */

.settings-categories {
    background-color: var(--context-menu-background);
    display: flex;
    column-gap: 16px;
    padding: 0 16px;
}

.settings-categories > a {
    height: 3rem;
    line-height: 3rem;
    padding: 0 8px;
    text-decoration: none;
}

.settings-content {
    max-width: 400px;
    margin: auto;
}

.settings-content > div {
    width: 100%;
    padding: 8px;
}

.settings-content > div > label {
    width: 45%;
    display: inline-block;
    font-weight: bold;
    color: var(--text-primary);
}

.settings-content > div > select {
    width: 50%;
    display: inline-block;
    border: 1px solid var(--border-color);
    padding: 8px;
    background-color: var(--context-menu-background);
    color: var(--text-primary);
}

/* logins page */

.logins-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-evenly;
    gap: 16px;
    padding: 16px;
}

.login {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 500px;
    padding: 8px;
}