:root {
    color-scheme: dark;
    --bg: #111318;
    --panel: #1b1f27;
    --line: #303744;
    --text: #f4f6fa;
    --muted: #aab3c2;
    --accent: #33b8a6;
    --accent-strong: #48d0bd;
    --danger: #ff6b6b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    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: var(--accent);
    color: #071412;
    font-weight: 700;
}

.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;
}

.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(17, 19, 24, 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: var(--panel);
    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-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) {
    .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;
    }
}
