@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700;800&display=swap');

:root {
    color-scheme: dark;
    --bg: #141414;
    --panel: #181818;
    --panel-2: #2f2f2f;
    --text: #f5f5f5;
    --muted: #b8b8b8;
    --soft: #818181;
    --line: #3b3b3b;
    --accent: #e50914;
    --success: #46d369;
    --danger: #e06060;
    --nav-h: 72px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Geist", "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0;
    scrollbar-gutter: stable;
}

body.detail-open {
    overflow: auto;
}

body.search-open:not(.detail-open)::after {
    content: "";
    position: fixed;
    z-index: 23;
    inset: var(--nav-h) 0 0;
    background: rgba(0, 0, 0, .48);
}

body.detail-open::before {
    content: "";
    position: fixed;
    z-index: 25;
    inset: 0;
    background: rgba(0, 0, 0, .72);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.app-shell {
    min-height: 100vh;
    background: var(--bg);
}

.boot-loader {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: grid;
    place-items: center;
    gap: 18px;
    align-content: center;
    background: #050505;
}

.loader-mark {
    color: var(--accent);
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.loader-bar {
    width: 180px;
    height: 3px;
    overflow: hidden;
    background: #292929;
}

.loader-bar span {
    display: block;
    width: 46%;
    height: 100%;
    background: var(--accent);
    animation: load-sweep 1.05s ease-in-out infinite;
}

@keyframes load-sweep {
    0% {
        transform: translateX(-110%);
    }

    100% {
        transform: translateX(235%);
    }
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, .9), rgba(0, 0, 0, .52)),
        linear-gradient(140deg, #351013, #141414 48%, #050505);
}

.login-panel {
    width: min(100%, 430px);
    padding: 34px;
    background: rgba(0, 0, 0, .72);
    border: 1px solid rgba(255, 255, 255, .1);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(34px, 4.6vw, 62px);
    line-height: .98;
    font-weight: 800;
    overflow-wrap: anywhere;
}

h2 {
    margin: 0 0 12px;
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.15;
    font-weight: 800;
}

h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.muted {
    color: var(--muted);
    line-height: 1.55;
}

.login-form {
    margin-top: 28px;
}

label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.input-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

input,
select {
    height: 42px;
    color: var(--text);
    background: rgba(20, 20, 20, .95);
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 2px;
    outline: none;
}

input {
    width: 100%;
    padding: 0 12px;
}

select {
    padding: 0 34px 0 10px;
}

input:focus,
select:focus {
    border-color: #fff;
}

.button,
.icon-button {
    height: 44px;
    border: 0;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 800;
    transition: background .16s ease, transform .16s ease, opacity .16s ease;
}

.button svg,
.icon-button svg {
    width: 21px;
    height: 21px;
}

.button:active,
.icon-button:active {
    transform: scale(.98);
}

.button.primary {
    padding: 0 18px;
    color: #fff;
    background: var(--accent);
}

.button.primary:hover {
    background: #f40612;
}

.button.light {
    padding: 0 24px;
    color: #000;
    background: #fff;
}

.button.light:hover {
    background: rgba(255, 255, 255, .76);
}

.button.secondary,
.button.translucent {
    padding: 0 18px;
    color: #fff;
    background: rgba(109, 109, 110, .72);
    min-width: 0;
}

.button.slim {
    height: 36px;
    margin-top: 12px;
    padding: 0 12px;
    font-size: 13px;
}

.button.secondary:hover,
.button.translucent:hover {
    background: rgba(109, 109, 110, .5);
}

.icon-button {
    width: 42px;
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .56);
    border-radius: 999px;
}

.icon-button:hover {
    background: rgba(255, 255, 255, .12);
}

.form-message {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--danger);
    font-size: 13px;
}

.setup-note {
    margin-top: 20px;
    padding: 14px;
    color: var(--muted);
    background: rgba(229, 9, 20, .12);
    border-left: 3px solid var(--accent);
    line-height: 1.5;
}

.tracker-view {
    min-height: 100vh;
    padding-bottom: 36px;
}

.topbar {
    position: fixed;
    z-index: 20;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    padding: 0 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: linear-gradient(180deg, rgba(0, 0, 0, .82), rgba(0, 0, 0, .16));
}

.brand-nav,
.topbar-actions,
.hero-actions,
.meta-row,
.episode-meta,
.credits,
.row-heading {
    display: flex;
    align-items: center;
}

.brand-nav {
    min-width: 0;
    gap: 26px;
}

.brand-mark {
    color: var(--accent);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.brand-nav nav {
    display: flex;
    gap: 18px;
    color: #e5e5e5;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.brand-nav nav a:first-child {
    color: #fff;
}

.topbar-actions {
    gap: 10px;
}

.nav-search {
    width: min(28vw, 330px);
}

.nav-search input,
.nav-type select {
    height: 36px;
    background: rgba(0, 0, 0, .5);
}

.nav-type {
    width: 112px;
}

.hero {
    position: relative;
    min-height: 78vh;
    padding: 176px 60px 150px;
    display: flex;
    align-items: center;
    background:
        linear-gradient(90deg, rgba(20, 20, 20, .98), rgba(20, 20, 20, .5) 42%, rgba(20, 20, 20, .16) 70%),
        linear-gradient(0deg, #141414 0%, rgba(20, 20, 20, .72) 16%, rgba(20, 20, 20, 0) 36%),
        var(--hero-image, linear-gradient(135deg, #2c1114, #141414));
    background-size: cover;
    background-position: center;
}

.hero-copy {
    width: min(620px, 92vw);
}

.hero-text {
    max-width: 620px;
    margin-bottom: 28px;
    color: #f1f1f1;
    font-size: clamp(17px, 1.55vw, 24px);
    font-weight: 400;
    line-height: 1.42;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .65);
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.hero-actions {
    flex-wrap: wrap;
    gap: 12px;
}

.search-results,
.rows {
    position: relative;
    z-index: 2;
    padding: 0 0 0 60px;
}

.search-results:empty {
    display: none;
}

.search-results {
    position: fixed;
    z-index: 24;
    top: var(--nav-h);
    left: 0;
    right: 0;
    max-height: min(470px, calc(100vh - var(--nav-h) - 18px));
    margin-top: 0;
    padding: 18px 58px 24px;
    overflow: auto;
    background: linear-gradient(180deg, rgba(8, 8, 8, .99), rgba(18, 18, 18, .98));
    border-top: 1px solid rgba(255, 255, 255, .08);
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    box-shadow: 0 22px 44px rgba(0, 0, 0, .58);
}

.search-panel {
    display: grid;
    gap: 14px;
}

.search-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
}

.search-heading button {
    min-height: 32px;
    padding: 0;
    color: #d8d8d8;
    background: transparent;
    border: 0;
    font-size: 12px;
    font-weight: 800;
}

.search-heading button:hover {
    color: #fff;
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
}

.rows {
    display: grid;
    gap: 34px;
    margin-top: 0;
}

.search-results:empty + .rows {
    margin-top: -92px;
}

.row-section {
    min-width: 0;
}

.row-section h2 {
    font-size: 24px;
}

.row-heading {
    justify-content: space-between;
    padding-right: 60px;
}

.count-pill,
.type-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 7px;
    color: #d7d7d7;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 2px;
    font-size: 12px;
    font-weight: 800;
}

.poster-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 1px 60px 14px 0;
    min-height: 156px;
}

.poster-row::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.season-tabs::-webkit-scrollbar {
    height: 8px;
}

.poster-row::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.season-tabs::-webkit-scrollbar-thumb {
    background: #4a4a4a;
}

.item-card,
.result-card {
    position: relative;
    flex: 0 0 252px;
    height: 150px;
    padding: 0;
    overflow: hidden;
    color: #fff;
    text-align: left;
    background: #242424;
    border: 0;
    border-radius: 3px;
}

.search-grid .result-card {
    width: 100%;
    height: 136px;
    flex: none;
}

.item-card:hover,
.result-card:hover {
    transform: translateY(-2px) scale(1.018);
    z-index: 3;
}

.item-card.active {
    outline: 1px solid rgba(255, 255, 255, .42);
    outline-offset: -1px;
}

.item-card.primary-item {
    outline: 1px solid rgba(255, 255, 255, .32);
    outline-offset: -1px;
}

.poster,
.thumb {
    position: absolute;
    inset: 0;
    background: #242424;
}

.poster img,
.thumb img,
.episode-still img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #777;
    font-size: 13px;
    font-weight: 800;
}

.item-card > span,
.result-card > span:not(.thumb) {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 94px;
    padding: 38px 12px 10px;
    background: linear-gradient(0deg, rgba(0, 0, 0, .88), rgba(0, 0, 0, 0));
}

.item-title,
.result-title {
    display: block;
    margin-bottom: 5px;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.18;
    overflow: hidden;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.meta-row,
.episode-meta {
    flex-wrap: nowrap;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
}

.item-card .meta-row,
.result-card .meta-row {
    white-space: nowrap;
}

.item-card .meta-row > span:not(.status-badge),
.result-card .meta-row > span:not(.type-pill) {
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar {
    display: block;
    height: 3px;
    margin-top: 9px;
    background: rgba(255, 255, 255, .25);
}

.progress-bar span {
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    background: var(--accent);
}

.progress-text {
    display: block;
    margin-top: 5px;
    color: #d7d7d7;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state,
.loading-state {
    flex: 0 0 360px;
    min-height: 96px;
    padding: 18px;
    color: var(--muted);
    background: rgba(255, 255, 255, .08);
    line-height: 1.45;
    display: grid;
    align-content: center;
}

.poster-row.is-empty {
    min-height: 34px;
    overflow: visible;
    padding-bottom: 0;
}

.row-empty {
    margin: 0;
    color: #8d8d8d;
    font-size: 14px;
}

.detail-pane {
    position: fixed;
    z-index: 30;
    inset: 32px auto 32px 50%;
    width: min(920px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    transform: translateX(-50%);
    overflow: auto;
    background: #181818;
    box-shadow: 0 24px 90px rgba(0, 0, 0, .78);
    border-radius: 4px;
    overscroll-behavior: contain;
}

.detail-pane::backdrop {
    background: rgba(0, 0, 0, .72);
}

.empty-detail {
    padding: 30px;
}

.detail-hero {
    position: relative;
    min-height: 470px;
    padding: 250px 42px 38px;
    display: flex;
    align-items: end;
    background:
        linear-gradient(0deg, #181818 4%, rgba(24, 24, 24, .5) 32%, rgba(24, 24, 24, 0) 62%),
        linear-gradient(90deg, rgba(24, 24, 24, .86), rgba(24, 24, 24, .08)),
        var(--backdrop, none);
    background-size: cover;
    background-position: center;
}

.modal-close {
    position: absolute;
    z-index: 2;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    color: #fff;
    background: rgba(0, 0, 0, .64);
    border: 0;
    border-radius: 999px;
    font-size: 28px;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(0, 0, 0, .9);
}

.detail-hero-content {
    max-width: 660px;
}

.detail-hero h2 {
    margin-bottom: 14px;
    font-size: clamp(34px, 4.6vw, 54px);
    line-height: .95;
    overflow-wrap: anywhere;
}

.detail-copy {
    max-width: 620px;
    color: #e8e8e8;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.45;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.detail-body {
    padding: 26px 42px 42px;
}

.detail-body > .empty-state,
.detail-body > .progress-summary {
    width: 100%;
    flex-basis: auto;
}

.progress-summary {
    padding: 18px;
    color: var(--muted);
    background: rgba(255, 255, 255, .08);
    line-height: 1.45;
}

.summary-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #fff;
    font-size: 15px;
}

.next-up {
    margin: 10px 0 0;
    color: #dedede;
    font-size: 14px;
}

.season-tabs {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    overflow-x: auto;
    margin: 30px 0 18px;
}

.season-tabs button {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 0 44px 0 16px;
    color: #fff;
    background: #242424;
    border: 1px solid #4d4d4d;
    border-radius: 2px;
    font-weight: 800;
}

.season-tabs button.active {
    background: #333;
}

.episodes {
    display: grid;
}

.episode-row {
    display: grid;
    grid-template-columns: 54px minmax(132px, 150px) minmax(0, 1fr) 50px;
    gap: 16px;
    align-items: center;
    min-height: 118px;
    padding: 18px 0;
    border-bottom: 1px solid #363636;
    min-width: 0;
}

.episode-row.watched {
    color: var(--success);
}

.episode-still {
    aspect-ratio: 16 / 9;
    background: #242424;
    overflow: hidden;
}

.episode-row h4 {
    margin: 0 0 6px;
    color: #fff;
    font-size: 17px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.episode-row p {
    margin: 0;
    color: #cfcfcf;
    font-size: 15px;
    line-height: 1.38;
    overflow-wrap: anywhere;
}

.episode-number {
    color: #d2d2d2;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
}

.episode-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.episode-check,
.episode-rewatch {
    width: 38px;
    height: 38px;
    margin-left: auto;
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 999px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 20px;
    line-height: 1;
}

.episode-rewatch {
    color: #dcdcdc;
    border-color: rgba(255, 255, 255, .28);
}

.episode-check svg,
.episode-rewatch svg {
    width: 18px;
    height: 18px;
}

.episode-check svg {
    opacity: 0;
}

.episode-row.watched .episode-check {
    color: #000;
    background: var(--success);
    border-color: var(--success);
}

.episode-row.watched .episode-check svg {
    opacity: 1;
}

.credits {
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 34px 20px 0;
    color: #808080;
    font-size: 12px;
}

.stats-page {
    display: grid;
    gap: 22px;
    min-height: calc(100vh - var(--nav-h));
    padding: 124px 60px 46px;
    background: #141414;
}

.stats-page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.stat-card {
    min-height: 106px;
    padding: 16px;
    background: rgba(255, 255, 255, .08);
}

.stat-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 12px;
    color: #fff;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1;
}

.stat-card p {
    margin: 10px 0 0;
    color: #c9c9c9;
    font-size: 13px;
}

.stats-breakdown {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr);
    gap: 12px;
}

.stats-breakdown section {
    padding: 18px;
    background: rgba(255, 255, 255, .06);
}

.stats-breakdown h3 {
    margin-bottom: 14px;
}

.stats-line {
    width: 100%;
    min-height: 42px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 0;
    color: #fff;
    background: transparent;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, .1);
    text-align: left;
}

.stats-line span,
.stats-line em,
.stats-pairs span {
    color: var(--muted);
    font-style: normal;
    font-size: 13px;
}

.stats-line strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-pairs {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px 18px;
}

.stats-empty {
    margin: 0;
    color: var(--muted);
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 60px 0;
    color: #777;
    font-size: 12px;
}

.app-footer button {
    padding: 0;
    color: #d5d5d5;
    background: transparent;
    border: 0;
    font-weight: 800;
}

[hidden] {
    display: none !important;
}

@media (max-width: 980px) {
    .topbar {
        padding: 0 22px;
    }

    .brand-nav nav {
        display: none;
    }

    .nav-search {
        width: 42vw;
    }

    .hero {
        min-height: 70vh;
        padding: 138px 24px 130px;
    }

    .search-results,
    .rows {
        padding-left: 24px;
    }

    .search-results {
        padding-right: 24px;
    }

    .row-heading,
    .poster-row {
        padding-right: 24px;
    }

    .stats-page {
        padding: 108px 24px 34px;
    }

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

    .stats-breakdown {
        grid-template-columns: 1fr;
    }

    .detail-pane {
        inset: 12px 12px auto;
        width: auto;
        max-height: calc(100vh - 24px);
        transform: none;
    }
}

@media (max-width: 1180px) {
    .brand-nav nav {
        display: none;
    }

    .nav-search {
        width: min(40vw, 320px);
    }
}

@media (max-width: 680px) {
    body.search-open:not(.detail-open)::after {
        inset: 150px 0 0;
    }

    .topbar {
        height: auto;
        min-height: var(--nav-h);
        align-items: flex-start;
        flex-direction: column;
        padding: 14px;
        background: rgba(0, 0, 0, .92);
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: 108px 42px 42px minmax(0, 1fr);
        width: 100%;
        align-items: stretch;
        justify-content: start;
        gap: 10px;
    }

    .nav-search {
        grid-column: 1 / -1;
        width: 100%;
    }

    .nav-type {
        width: 108px;
    }

    #refreshButton,
    #logoutButton {
        min-width: 0;
        width: auto;
    }

    #logoutButton {
        width: 42px;
        padding: 0;
        gap: 0;
        overflow: hidden;
        font-size: 0;
    }

    #logoutButton svg {
        width: 20px;
        height: 20px;
    }

    .search-results {
        top: 150px;
        max-height: calc(100vh - 162px);
        padding: 12px 14px 18px;
    }

    .search-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: 620px;
        padding-top: 174px;
    }

    .detail-pane {
        inset: 0;
        width: auto;
        max-height: 100vh;
        border-radius: 0;
    }

    .hero-actions,
    .input-row {
        align-items: stretch;
        flex-direction: column;
    }

    .hero-actions .button {
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 44px;
        padding-top: 12px;
        padding-bottom: 12px;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: center;
    }

    .item-card,
    .result-card {
        flex-basis: 220px;
        height: 132px;
    }

    .detail-hero {
        min-height: 360px;
        padding: 180px 20px 28px;
    }

    .detail-body {
        padding: 22px 20px 30px;
    }

    .detail-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .detail-actions .button {
        width: 100%;
    }

    .episode-row {
        grid-template-columns: 34px minmax(0, 1fr) 42px;
    }

    .episode-still {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-page-head,
    .app-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .app-footer {
        padding: 18px 24px 0;
    }
}
