@font-face {
    font-family: "Open Sans";
    src: url("./static/open-sans.woff") format("woff");
    font-weight: 400;
}

@font-face {
    font-family: "Open Sans";
    src: url("./static/open-sans-semibold.woff") format("woff");
    font-weight: 600;
}

@font-face {
    font-family: "Open Sans";
    src: url("./static/open-sans-bold.woff") format("woff");
    font-weight: 700;
}

:root {
    --bg: #0b0b0d;
    --panel: rgba(24, 24, 27, 0.82);
    --panel-strong: rgba(18, 18, 20, 0.95);
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --accent: #5db6e7;
    --accent-strong: #2b86c2;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --poster-w: 184px;
    --topbar-h: 84px;
    --sidebar-w: 280px;
    --sidebar-collapsed-w: 88px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
}

body {
    color: var(--text);
    font: 400 16px/1.5 "Open Sans", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(93, 182, 231, 0.16), transparent 30%),
        linear-gradient(180deg, rgba(11, 11, 13, 0.82), rgba(11, 11, 13, 0.98)),
        #0b0b0d url("./static/preset-light.png") center / cover no-repeat fixed;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.app-frame {
    height: 100vh;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
}

.frame-body {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    height: calc(100vh - var(--topbar-h));
    min-height: calc(100vh - var(--topbar-h));
    transition: grid-template-columns 180ms ease;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
}

body.sidebar-collapsed .frame-body {
    grid-template-columns: var(--sidebar-collapsed-w) minmax(0, 1fr);
}

.frame-content {
    min-width: 0;
    height: 100%;
    padding: 24px 32px 40px;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.plex-topbar,
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: var(--topbar-h);
    padding: 14px 28px;
    background: linear-gradient(180deg, rgba(9, 9, 10, 0.98), rgba(9, 9, 10, 0.88));
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.plex-topbar-left,
.plex-topbar-center,
.plex-topbar-right,
.brandblock,
.nav-cluster,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.plex-topbar-center {
    flex: 1 1 auto;
    justify-content: center;
}

.plex-topbar-right {
    flex: 0 0 auto;
    justify-content: flex-end;
}

.brandblock-link {
    color: inherit;
}

.brandmark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
}

.brandmark img {
    width: 32px;
    height: 32px;
}

.brandlabel,
.eyebrow,
.details-eyebrow,
.field-label,
.meta-line,
.category-count,
.latest-label,
.popuptitle,
.sectiontitle {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.brandtitle,
.rail-title {
    font-weight: 700;
}

.brandtitle {
    font-size: 22px;
    letter-spacing: -0.03em;
}

.nav-button,
.actionlink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    transition: 160ms ease;
}

.nav-button-icon {
    width: 42px;
    min-width: 42px;
    padding: 0;
    color: var(--muted);
}

.nav-button-icon::before {
    content: "";
    display: block;
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: 18px 18px;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: 18px 18px;
}

.nav-button-up::before {
    -webkit-mask-image: url("./common/arrowup.svg");
    mask-image: url("./common/arrowup.svg");
}

.nav-button-search::before {
    -webkit-mask-image: url("./common/search.svg");
    mask-image: url("./common/search.svg");
}

.nav-button-random::before {
    -webkit-mask-image: url("./common/random.svg");
    mask-image: url("./common/random.svg");
}

.nav-button-settings::before {
    -webkit-mask-image: url("./common/settings.svg");
    mask-image: url("./common/settings.svg");
}

.nav-button-first::before {
    -webkit-mask-image: url("./common/arrowleft10.svg");
    mask-image: url("./common/arrowleft10.svg");
}

.nav-button-prev::before {
    -webkit-mask-image: url("./common/arrowleft.svg");
    mask-image: url("./common/arrowleft.svg");
}

.nav-button-next::before {
    -webkit-mask-image: url("./common/arrowright.svg");
    mask-image: url("./common/arrowright.svg");
}

.nav-button-last::before {
    -webkit-mask-image: url("./common/arrowright10.svg");
    mask-image: url("./common/arrowright10.svg");
}

.nav-button:hover,
.actionlink:hover,
.rootlink:hover,
.actionbutton:hover,
.details_button:hover,
.sidebar-link:hover,
.sidebar-link.active {
    color: var(--text);
    border-color: rgba(93, 182, 231, 0.34);
    background-color: rgba(255, 255, 255, 0.08);
}

.home-sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    height: 100%;
    min-height: 100%;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(12, 12, 14, 0.98), rgba(18, 18, 20, 0.94));
    transition: width 180ms ease;
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.sidebar-footer {
    margin-top: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 48px;
    padding: 0 12px;
    border-radius: 14px;
    color: var(--muted);
}

.sidebar-link.active {
    box-shadow: inset 3px 0 0 var(--accent);
    background:
        linear-gradient(90deg, rgba(43, 134, 194, 0.22), rgba(43, 134, 194, 0.02) 38%),
        rgba(255, 255, 255, 0.06);
}

.sidebar-link-icon {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    font-size: 20px;
}

.sidebar-link-icon-image {
    border-radius: 6px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
}

.sidebar-link[data-category-id="comics"] .sidebar-link-icon-image {
    background-image: url("./common/comics.png");
}

.sidebar-link[data-category-id="books"] .sidebar-link-icon-image {
    background-image: url("./common/books.png");
}

.sidebar-link-icon-files {
    background-color: currentColor;
    -webkit-mask-image: url("./common/file.svg");
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: 18px 18px;
    mask-image: url("./common/file.svg");
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: 18px 18px;
}

.sidebar-link-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link-footer,
.sidebar-link-footer:hover {
    color: var(--text);
}

.sidebar-toggle {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    font-size: 24px;
    cursor: pointer;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar-link-text {
    display: none;
}

.shell,
.login-shell {
    padding: 0;
}

.hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
    padding: 36px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 6px);
    background:
        linear-gradient(135deg, rgba(93, 182, 231, 0.18), transparent 40%),
        linear-gradient(180deg, rgba(32, 32, 36, 0.95), rgba(15, 15, 17, 0.95));
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 8px 0 0;
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.rail {
    margin-top: 24px;
}

.rail-header {
    margin-bottom: 16px;
}

.dynamic-rails {
    display: grid;
    gap: 28px;
}

.subrail-title {
    margin-bottom: 12px;
    color: #f0f0f2;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.row-strip {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 14px;
    scroll-behavior: smooth;
}

.row-strip-loading {
    display: block;
    color: var(--muted);
    padding: 8px 0;
}

.row-strip .cellcontainer {
    flex: 0 0 220px;
    width: 220px;
    max-width: 220px;
}

.row-strip .thumb {
    width: 220px;
    min-width: 220px;
    max-width: 220px;
    height: 330px;
    aspect-ratio: 2 / 3;
}

.row-strip .thumb img {
    width: 220px;
    height: 330px;
    object-fit: cover;
}

.row-strip .label {
    white-space: normal;
}

.poster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--poster-w), 1fr));
    gap: 24px 18px;
}

.cellcontainer {
    min-width: 0;
}

.thumb {
    position: relative;
    overflow: hidden;
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb:hover {
    transform: translateY(-2px);
    border-color: rgba(93, 182, 231, 0.45);
}

.label {
    margin-top: 10px;
    color: #ececf1;
    font-size: 14px;
    line-height: 1.35;
}

.tile-chip {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 12px;
}

.reading-mask,
#details_progress_wrapper {
    position: absolute;
    inset: auto 0 0 0;
    height: 7px;
    background: rgba(255, 255, 255, 0.08);
}

.cover_progress_bar_fill,
.details_progress_bar_fill {
    display: block;
    height: 100%;
    width: var(--value);
    background: linear-gradient(90deg, #7bc9f3, #2b86c2);
}

.reading-mask.status_unread,
#details_progress_wrapper.status_unread {
    visibility: hidden;
}

.reading-mask.status_finished .cover_progress_bar_fill,
#details_progress_wrapper.status_finished .details_progress_bar_fill {
    background: linear-gradient(90deg, #4ade80, #16a34a);
}

.reading-mask.plex-v3-loading .cover_progress_bar_fill {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.35));
}

.root-list {
    display: grid;
    gap: 12px;
}

.rootlink {
    display: block;
    padding: 16px 20px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

#dimoverlay {
    visibility: hidden;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 70;
}

.popupmenu {
    display: none;
    position: fixed;
    z-index: 80;
    top: 88px;
    right: 24px;
    width: min(420px, calc(100vw - 48px));
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-strong);
    box-shadow: var(--shadow);
}

#settingsbox {
    top: 50%;
    left: 50%;
    right: auto;
    width: min(560px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    transform: translate(-50%, -50%);
    overflow: auto;
}

.details-popup {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(1080px, calc(100vw - 48px));
    max-width: min(1080px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    transform: translate(-50%, -50%);
    overflow: auto;
}

.popupbody {
    color: var(--text);
}

.textbox,
select,
input[type="text"],
input[type="password"] {
    width: 100%;
    margin-bottom: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.actionbutton,
#loginbutton,
.details_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: none;
    border-radius: 999px;
    color: #07131b;
    font-weight: 700;
    background: linear-gradient(135deg, #7bc9f3, #2b86c2);
    cursor: pointer;
}

.details_button_secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.details_button_icon {
    width: 46px;
    min-width: 46px;
    padding: 0;
}

.details_button_icon::before {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: 20px 20px;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: 20px 20px;
}

.details_button_download::before {
    -webkit-mask-image: url("./common/download.svg");
    mask-image: url("./common/download.svg");
}

.details_button_read::before {
    -webkit-mask-image: url("./common/read.svg");
    mask-image: url("./common/read.svg");
}

.details_button_unread::before {
    -webkit-mask-image: url("./common/mark-unread.svg");
    mask-image: url("./common/mark-unread.svg");
}

.details_button_finished::before {
    -webkit-mask-image: url("./common/mark-finished.svg");
    mask-image: url("./common/mark-finished.svg");
}

.radiolabel {
    display: block;
    margin: 10px 0;
    color: var(--text);
}

#details {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(20, 20, 23, 0.98), rgba(12, 12, 14, 0.98));
    box-shadow: var(--shadow);
}

#details_close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
}

#details_close::before {
    content: "";
    display: block;
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask-image: url("./common/close.svg");
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: 18px 18px;
    mask-image: url("./common/close.svg");
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: 18px 18px;
}

#details_close:hover {
    color: var(--text);
    border-color: rgba(93, 182, 231, 0.34);
    background-color: rgba(255, 255, 255, 0.08);
}

.details-backdrop {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(93, 182, 231, 0.14), transparent 35%);
}

.details-content {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(220px, 300px) 1fr;
    gap: 28px;
    padding: 32px;
}

#details_title {
    margin-top: 6px;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.02;
    letter-spacing: -0.04em;
}

#details_authors,
.details-meta {
    margin-top: 8px;
    color: var(--muted);
}

.details-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px 0;
}

#details_description {
    max-width: 70ch;
    color: #dedee3;
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(460px, calc(100vw - 32px));
    padding: 28px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(16, 16, 18, 0.9);
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.site-footer {
    padding: 36px 24px 48px;
    text-align: center;
}

#poweredby {
    color: var(--muted);
    font-size: 13px;
}

.empty-panel {
    padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
}

@media (max-width: 900px) {
    .frame-body {
        grid-template-columns: 1fr;
    }

    body.sidebar-collapsed .frame-body {
        grid-template-columns: 1fr;
    }

    .home-sidebar {
        min-height: auto;
        padding: 12px 16px;
    }

    body.sidebar-collapsed .home-sidebar {
        display: none;
    }

    .plex-topbar,
    .topbar {
        padding: 12px 16px;
    }

    .frame-content {
        padding: 18px 16px 32px;
    }

    .details-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .row-strip .cellcontainer {
        flex-basis: 160px;
        width: 160px;
        max-width: 160px;
    }

    .row-strip .thumb,
    .row-strip .thumb img {
        width: 160px;
        min-width: 160px;
        max-width: 160px;
        height: 240px;
    }

    .poster-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .popupmenu {
        right: 16px;
        width: calc(100vw - 32px);
    }
}
