:root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-2: #232733;
    --text: #e8eaf0;
    --text-dim: #9aa1b0;
    --accent: #e5a00d;
    --danger: #e05c5c;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }

/* --- Top bar --- */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.7rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid #2b303c;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.brand span, .login-card h1 span { color: var(--accent); }

.search { flex: 1; max-width: 420px; }
.search input {
    width: 100%;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    border: 1px solid #2b303c;
    background: var(--bg);
    color: var(--text);
}

.usermenu { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.usermenu .username { color: var(--text-dim); }
.usermenu form { display: inline; }
.usermenu button {
    background: none;
    border: 1px solid #2b303c;
    color: var(--text-dim);
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
}
.usermenu button:hover { color: var(--text); border-color: var(--text-dim); }

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

/* --- Filter bar --- */
.filterbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}
.filters { display: flex; align-items: center; gap: 1rem; }
.filters select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid #2b303c;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
}
.checkbox { color: var(--text-dim); display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.count { margin-left: auto; color: var(--text-dim); font-size: 0.9rem; }

/* --- Poster grid --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.1rem;
}

.card {
    position: relative;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    color: var(--text);
    transition: transform 0.12s ease;
    display: flex;
    flex-direction: column;
}
.card:hover { transform: scale(1.04); }

.card img, .noposter {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    background: var(--surface-2);
}
.noposter {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    color: var(--text-dim);
}

.badge {
    position: absolute;
    top: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.rating { right: 0.5rem; background: rgba(0, 0, 0, 0.75); color: var(--accent); }
.badge.review { left: 0.5rem; background: var(--danger); color: #fff; }

.cardinfo { padding: 0.6rem 0.7rem; }
.cardtitle { font-size: 0.9rem; font-weight: 600; line-height: 1.25; }
.cardyear { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.15rem; }

/* --- Infinite scroll --- */
#scroll-sentinel { height: 1px; }
.scroll-status { text-align: center; color: var(--text-dim); margin: 1rem 0; }

/* --- Alphabet jump rail --- */
.alpharail {
    position: fixed;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    z-index: 20;
}
.alpharail a {
    color: var(--text-dim);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.06rem 0.45rem;
    border-radius: 5px;
    line-height: 1.3;
}
.alpharail a:hover { color: var(--accent); background: var(--surface-2); }
.alpharail a.active { color: #1a1400; background: var(--accent); }

@media (max-width: 700px) {
    .alpharail { display: none; }
}

/* --- Detail page --- */
.detail { display: flex; gap: 2rem; align-items: flex-start; flex-wrap: wrap; }
.detail-poster img, .noposter.tall { width: 280px; border-radius: 12px; }
.detail-info { flex: 1; min-width: 300px; }
.detail-info h1 { margin: 0 0 0.3rem; }
.detail-info h1 .year { color: var(--text-dim); font-weight: 400; }
.original-title { color: var(--text-dim); margin-top: 0; }
.meta { display: flex; align-items: center; gap: 0.8rem; }
.meta .badge { position: static; }
.overview { line-height: 1.6; max-width: 65ch; color: #c9cedb; }

.files { border-collapse: collapse; width: 100%; margin-top: 0.4rem; font-size: 0.9rem; }
.files th, .files td { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 1px solid #2b303c; }
.files th { color: var(--text-dim); font-weight: 600; }
.files .path { color: var(--text-dim); word-break: break-all; }

.attrs th { width: 12rem; }
.attrs .stars { color: var(--accent); letter-spacing: 0.15em; }

/* --- People chips --- */
.chips, .genres { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
    background: var(--surface-2);
    color: var(--text);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
}
.chip:hover { background: var(--accent); color: #1a1400; }
.chip.static { color: var(--text-dim); }
.chip.static:hover { background: var(--surface-2); color: var(--text-dim); }

.badge.cert { background: var(--surface-2); color: var(--text); border: 1px solid #3a4050; }

/* --- Embedded metadata --- */
.embedded-tags { margin-top: 1.4rem; }
.embedded-tags summary { cursor: pointer; color: var(--text-dim); font-weight: 600; }
.embedded-tags[open] summary { margin-bottom: 0.5rem; }

/* --- Person page --- */
.person-header h1 { margin-bottom: 0.2rem; }
.person-roles { color: var(--text-dim); margin-top: 0; }
.sortbar { color: var(--text-dim); display: flex; gap: 0.8rem; }
.sortbar a.active { color: var(--accent); font-weight: 700; }

.back { display: inline-block; margin-top: 1rem; }

/* --- Cloud upload column + flash messages --- */
.cloud { white-space: nowrap; }
.cloud form { display: inline; }
.btn-small {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid #3a4050;
    padding: 0.2rem 0.7rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}
.btn-small:hover { border-color: var(--accent); color: var(--accent); }
.btn-small.play { background: var(--accent); color: #1a1400; border-color: var(--accent); font-weight: 700; }
.badge.queued { position: static; background: var(--surface-2); color: var(--text-dim); }
.expiry { color: var(--text-dim); font-size: 0.75rem; margin-left: 0.4rem; }

.messages { margin-bottom: 1rem; }
.msg { padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 0.5rem; }
.msg.success { background: #1d3325; color: #8ee6a1; }
.msg.error { background: #3a2023; color: #f0a1a8; }
.empty { color: var(--text-dim); }

/* --- Login --- */
.login-card {
    max-width: 340px;
    margin: 10vh auto 0;
    background: var(--surface);
    padding: 2rem;
    border-radius: 14px;
    text-align: center;
}
.login-card h1 { margin: 0 0 1.2rem; }
.login-card input {
    width: 100%;
    margin-bottom: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #2b303c;
    background: var(--bg);
    color: var(--text);
}
.login-card button {
    width: 100%;
    padding: 0.6rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #1a1400;
    font-weight: 700;
    cursor: pointer;
}
.login-error { color: var(--danger); font-size: 0.9rem; }
