:root {
    color-scheme: dark;
    --bg: #111318;
    --panel: #1b1f27;
    --line: #303744;
    --text: #f4f6fa;
    --muted: #aab3c2;
    --accent: #6a9bc5;
    --accent-strong: #9bc5e5;
    --accent-deep: #0f233b;
    --danger: #ff6b6b;
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

button,
.primary,
.ghost {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text);
    background: #242a34;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
}

.primary {
    border-color: transparent;
    background: linear-gradient(180deg, var(--accent-strong), var(--accent));
    color: #071220;
    font-weight: 700;
    box-shadow: 0 8px 22px rgba(106, 155, 197, 0.18);
}

.primary:hover {
    background: var(--accent-strong);
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #0f1217;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
}

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

h1 {
    margin-bottom: 2px;
    font-size: 24px;
}

h2 {
    font-size: 22px;
}

h3 {
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--muted);
    text-transform: uppercase;
}

.muted,
.meta,
.topbar p,
.table-row span {
    color: var(--muted);
}

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-panel,
.panel {
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.auth-panel {
    max-width: 420px;
}

.neutral-auth {
    max-width: 340px;
    padding: 16px;
}

.neutral-auth input {
    text-align: center;
    letter-spacing: 0;
}

.neutral-auth .primary {
    width: 100%;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.stack {
    display: grid;
    gap: 14px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(9, 18, 31, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.dashboard {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    gap: 16px;
}

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

.stat {
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stat strong {
    display: block;
    font-size: 24px;
}

.stat span {
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
}

.chips,
.genre-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chips a,
.genre-cloud span {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--muted);
    background: #11161d;
}

.chips a.selected {
    color: #071412;
    border-color: transparent;
    background: var(--accent);
    font-weight: 700;
}

.genre-cloud b {
    color: var(--text);
}

.recent-list {
    display: grid;
    margin-top: 12px;
    gap: 6px;
}

.link-row {
    justify-content: flex-start;
    width: 100%;
    min-height: 38px;
    text-align: left;
}

.catalog-panel {
    background: linear-gradient(180deg, rgba(27, 31, 39, 0.96), rgba(17, 22, 29, 0.98));
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.media-list {
    display: grid;
}

.media-row {
    display: grid;
    gap: 4px;
    width: 100%;
    min-height: 66px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    border-left: 0;
    border-right: 0;
    border-top: 0;
    border-radius: 0;
    text-decoration: none;
    text-align: left;
    background: transparent;
}

.media-row.active,
.media-row:hover {
    background: #242a34;
}

.title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.detail-body,
.placeholder {
    max-width: 900px;
    padding: 18px;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
}

.modal-panel {
    position: relative;
    width: min(960px, 100%);
    max-height: min(88vh, 900px);
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.modal-close {
    position: sticky;
    top: 10px;
    float: right;
    z-index: 2;
    margin: 10px;
}

.modal-nav {
    position: fixed;
    top: 50%;
    z-index: 23;
    transform: translateY(-50%);
    background: rgba(17, 22, 29, 0.88);
    backdrop-filter: blur(12px);
}

.modal-prev {
    left: max(12px, calc((100vw - 960px) / 2 - 56px));
}

.modal-next {
    right: max(12px, calc((100vw - 960px) / 2 - 56px));
}

.modal-nav:disabled {
    opacity: 0.28;
}

.modal-hero {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
}

.detail-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    gap: 16px;
    align-items: start;
}

.poster {
    width: 110px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.facts div {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #11161d;
}

.facts dt {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.personal-form {
    display: grid;
    grid-template-columns: minmax(0, 180px) minmax(0, 180px) minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #11161d;
}

.checkline {
    min-height: 44px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.checkline input {
    width: auto;
    min-height: auto;
}

.wide {
    min-width: 0;
}

.save-state {
    min-width: 86px;
    color: var(--muted);
}

.tagline {
    color: var(--accent-strong);
    font-weight: 700;
}

.cast-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.cast-item {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #11161d;
}

.cast-item span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.actions {
    display: flex;
    gap: 10px;
    margin: 18px 0;
}

.plot {
    line-height: 1.55;
    color: #d7dde8;
}

.path-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
}

code {
    display: block;
    min-height: 44px;
    padding: 12px;
    overflow-wrap: anywhere;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f1217;
    color: #dce9ff;
}

.admin {
    max-width: 980px;
    margin: 0 auto;
    padding: 18px;
    display: grid;
    gap: 16px;
}

.narrow {
    max-width: 440px;
}

.grid-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.table {
    display: grid;
    gap: 8px;
}

.table-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.table-row div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.alert,
.notice,
.empty {
    padding: 10px 12px;
    border-radius: 8px;
}

.alert {
    background: rgba(255, 107, 107, 0.14);
    color: #ffd0d0;
}

.notice {
    background: rgba(51, 184, 166, 0.14);
    color: #c5fff7;
}

.empty {
    margin: 12px;
    color: var(--muted);
    background: var(--panel);
}

@media (max-width: 780px), (hover: none) and (pointer: coarse), (any-pointer: coarse) and (max-device-width: 1200px) {
    .search,
    .grid-form,
    .path-box,
    .dashboard-grid,
    .personal-form,
    .facts,
    .cast-grid {
        grid-template-columns: 1fr;
    }

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

    .modal {
        padding: 0;
        align-items: stretch;
    }

    .modal-panel {
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-nav {
        top: auto;
        bottom: 14px;
        transform: none;
    }

    .modal-prev {
        left: 14px;
    }

    .modal-next {
        right: 14px;
    }
}

.mobile-only {
    display: none;
}

.app-topbar {
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid rgba(155, 197, 229, 0.28);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.brand-mark img,
.drawer-brand img {
    width: 100%;
    height: 100%;
    display: block;
}

.brand-copy {
    min-width: 0;
}

.brand-copy h1,
.brand-copy p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-actions,
.toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.icon-button {
    width: 44px;
    min-width: 44px;
    padding: 0;
}

.icon-link {
    gap: 8px;
}

.icon-link svg,
.icon-button svg,
.primary svg,
.badge svg,
.badge-link svg {
    width: 17px;
    height: 17px;
}

.app-shell {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    max-width: 1480px;
    margin: 0 auto;
}

.genre-rail {
    position: sticky;
    top: 69px;
    height: calc(100vh - 69px);
    overflow: auto;
    padding: 16px 10px;
    border-right: 1px solid var(--line);
}

.genre-rail h2 {
    padding: 0 8px;
    font-size: 15px;
}

.genre-rail a {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 8px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
}

.genre-rail a.selected,
.genre-rail a:hover {
    color: var(--text);
    background: #242a34;
}

.content-flow {
    min-width: 0;
    padding: 16px;
    display: grid;
    gap: 18px;
}

.list-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(15, 35, 59, 0.55), rgba(27, 31, 39, 0));
}

.list-context h2 {
    margin-bottom: 3px;
}

.list-context p {
    margin: 0;
    color: var(--muted);
}

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

.filter-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "icon count"
        "icon label";
    gap: 2px 10px;
    align-items: center;
    min-height: 76px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: linear-gradient(145deg, #1b1f27, #111925);
    text-decoration: none;
}

.filter-card:hover {
    border-color: rgba(155, 197, 229, 0.55);
    background: linear-gradient(145deg, #253042, #142033);
}

.filter-card svg {
    grid-area: icon;
    width: 24px;
    height: 24px;
    color: var(--accent-strong);
}

.filter-card strong {
    grid-area: count;
    font-size: 24px;
}

.filter-card span {
    grid-area: label;
    color: var(--muted);
}

.hero-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.hero-card,
.poster-card {
    display: grid;
    gap: 8px;
    min-height: 0;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
}

.poster-frame {
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 8px;
    background: #0f1217;
    border: 1px solid var(--line);
}

.poster-frame img,
.item-cover img,
.mini-card img,
.actor-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.poster-empty {
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.poster-title {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poster-meta {
    color: var(--muted);
    font-size: 13px;
}

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

.row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.row-head h2 {
    margin: 0;
}

.row-head a {
    color: var(--accent-strong);
    text-decoration: none;
}

.poster-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(130px, 170px);
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
}

.poster-row .poster-card {
    scroll-snap-align: start;
}

.catalog-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 18, 32, 0.38);
}

.quick-search {
    position: relative;
}

.quick-search svg {
    position: absolute;
    left: 12px;
    top: 13px;
    width: 18px;
    color: var(--muted);
}

.quick-search input[type="text"],
.quick-search input[name="q"] {
    padding-left: 38px;
}

.active-filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(15, 35, 59, 0.22);
}

.badge,
.badge-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid rgba(106, 155, 197, 0.28);
    background: rgba(15, 35, 59, 0.58);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}

.wrap {
    flex-wrap: wrap;
}

.media-results {
    padding: 10px;
}

.list-view {
    display: grid;
    gap: 8px;
}

.media-item {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 76px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: left;
    background: #121923;
}

.media-item:hover {
    border-color: rgba(155, 197, 229, 0.42);
    background: #1b2735;
}

.item-cover {
    display: grid;
    place-items: center;
    width: 54px;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 6px;
    background: #0f1217;
}

.item-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.item-copy strong,
.item-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-copy span {
    color: var(--muted);
}

.grid-view {
    display: grid;
    gap: 12px;
}

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

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

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

.grid-view .media-item {
    grid-template-columns: 1fr;
    align-items: start;
    min-height: 0;
}

.grid-view .item-cover {
    width: 100%;
}

.grid-wide .item-cover {
    aspect-ratio: 16 / 9;
}

.filter-drawer[hidden] {
    display: none;
}

.filter-drawer {
    position: fixed;
    inset: 0;
    z-index: 30;
}

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
}

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(420px, 100%);
    height: 100%;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(180deg, #111925, #1b1f27);
    border-left: 1px solid var(--line);
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-brand img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(155, 197, 229, 0.28);
}

.drawer-brand h2 {
    margin: 0;
}

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

.modern-detail {
    max-width: 1040px;
}

.detail-cover-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.big-poster {
    width: 100%;
    min-height: 360px;
    max-height: min(72vh, 720px);
    border-radius: 8px;
    overflow: hidden;
    background: #0f1217;
    border: 1px solid var(--line);
}

.big-poster img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.badge-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0;
}

.plot.collapsed {
    max-height: 7.2em;
    overflow: hidden;
}

.text-button {
    min-height: 0;
    padding: 0;
    border: 0;
    color: var(--accent-strong);
    background: transparent;
}

.compact-section {
    margin-top: 18px;
}

.actor-row,
.mini-card-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(120px, 150px);
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.actor-card,
.mini-card {
    display: grid;
    gap: 7px;
    color: var(--text);
    text-decoration: none;
    background: #11161d;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
}

.actor-card span {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    background: #0f1217;
}

.actor-card em {
    color: var(--muted);
    font-style: normal;
    font-size: 12px;
}

.mini-card {
    min-height: 0;
    text-align: left;
}

.mini-card span {
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 7px;
    background: #0f1217;
}

.fanart-section {
    min-height: 220px;
    margin-top: 18px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: end;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--line);
}

.fanart-section div {
    width: 100%;
    padding: 18px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

@media (max-width: 900px), (hover: none) and (pointer: coarse), (any-pointer: coarse) and (max-device-width: 1200px) {
    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: inline-flex;
    }

    .app-shell {
        display: block;
    }

    .content-flow {
        padding: 12px;
    }

    .hero-strip,
    .grid-poster,
    .grid-compact,
    .grid-wide,
    .filter-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .catalog-toolbar,
    .detail-cover-layout {
        grid-template-columns: 1fr;
    }

    .toolbar-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .big-poster {
        width: 100%;
        min-height: 320px;
        max-height: 68vh;
    }
}
