:root {
    --bg: #0f1115;
    --panel: #181b22;
    --line: #262b35;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --accent: #e50914;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

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

.site-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 1.4rem; color: var(--accent); letter-spacing: .5px; }
.search { flex: 1; min-width: 180px; }
.search input {
    width: 100%;
    padding: .55rem .9rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
}
.filters { display: flex; gap: .5rem; }
.filters a {
    padding: .4rem .8rem;
    border-radius: 8px;
    color: var(--muted);
    border: 1px solid transparent;
}
.filters a.active, .filters a:hover { color: var(--text); border-color: var(--line); }

main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.card { display: block; transition: transform .15s ease; }
.card:hover { transform: translateY(-4px); }
.poster {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: 10px;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-placeholder {
    display: flex; align-items: center; justify-content: center;
    height: 100%; padding: 1rem; text-align: center; color: var(--muted); font-size: .9rem;
}
.badge {
    position: absolute; top: .5rem; left: .5rem;
    background: rgba(0,0,0,.7); color: #fff;
    font-size: .7rem; padding: .15rem .5rem; border-radius: 6px;
}
.meta { display: flex; justify-content: space-between; gap: .5rem; margin-top: .5rem; }
.meta .name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .year { color: var(--muted); font-size: .85rem; }

.empty { color: var(--muted); grid-column: 1 / -1; }

.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 2rem; color: var(--muted); }
.pagination a { color: var(--text); }

/* detail */
.detail { display: grid; grid-template-columns: 300px 1fr; gap: 2rem; }
.detail-poster img, .detail-poster .poster-placeholder {
    width: 100%; border-radius: 12px; border: 1px solid var(--line);
}
.detail-info h1 { margin: 0 0 .25rem; }
.detail-info .original { color: var(--muted); margin: 0 0 1rem; }
.tags { display: flex; gap: .75rem; align-items: center; color: var(--muted); }
.tags .badge { position: static; }
.overview { max-width: 70ch; }
.links { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1.2rem 0; }
.btn {
    padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line);
    background: var(--panel);
}
.btn.trailer { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover { filter: brightness(1.15); }

.torrents { border-top: 1px solid var(--line); padding-top: 1rem; }
.torrent { display: flex; gap: .75rem; align-items: baseline; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.torrent a:first-child { flex: 1; min-width: 200px; }
.t-meta { color: var(--muted); font-size: .85rem; }
.magnet { color: var(--accent); font-size: .85rem; }

.links form { margin: 0; }
.btn.watched-btn { background: #1f7a3d; border-color: #1f7a3d; color: #fff; }
.logout button {
    padding: .4rem .8rem; border-radius: 8px; cursor: pointer;
    background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.logout button:hover { color: var(--text); }

.login { max-width: 320px; margin: 4rem auto; }
.login h1 { margin-bottom: 1rem; }
.login form { display: flex; flex-direction: column; gap: .75rem; }
.login input, .login button {
    padding: .6rem .9rem; border-radius: 8px;
    border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.login button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.login-error { color: var(--accent); }

.site-footer { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: .85rem; }

@media (max-width: 640px) {
    .detail { grid-template-columns: 1fr; }
    .detail-poster { max-width: 240px; }
}
