:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1a2744;
    --bg-input: #0f3460;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-soft: rgba(233, 69, 96, 0.15);
    --border: #2a2a4a;
    --success: #4ecca3;
    --warning: #f9a825;
    --fsk0: #4ecca3;
    --fsk6: #4ecca3;
    --fsk12: #f9a825;
    --fsk16: #e94560;
    --fsk18: #ff2e63;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Layout ─────────────────────────────── */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    text-align: center;
    padding: 2rem 0 1rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #ff6b81);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* ── Profile Selector ───────────────────── */

.profile-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.profile-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.profile-btn.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.2);
}

.profile-btn .fsk-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.fsk-0, .fsk-6 { background: var(--fsk0); color: #000; }
.fsk-12 { background: var(--fsk12); color: #000; }
.fsk-16 { background: var(--fsk16); color: #fff; }
.fsk-18 { background: var(--fsk18); color: #fff; }

/* ── Search ─────────────────────────────── */

.search-section {
    padding: 1rem 0;
}

.mood-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

.mood-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.mood-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.mood-btn.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text-primary);
}

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    border-color: var(--accent);
}

.search-box button {
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
    white-space: nowrap;
}

.search-box button:hover {
    background: var(--accent-hover);
}

.search-box button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.search-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ── Results ────────────────────────────── */

.results-section {
    padding: 1rem 0 3rem;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.results-header h2 {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.results-header .back-btn {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.results-header .back-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.movie-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.movie-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.2rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.movie-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.movie-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.movie-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.movie-year {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.movie-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.movie-similarity {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 50px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.movie-plot {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.5rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.movie-tags {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 50px;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.movie-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.btn-jellyfin {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    background: #00a4dc;
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-jellyfin:hover {
    background: #00bfff;
}

.btn-similar {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-similar:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ── Source Movie (Similar View) ────────── */

.source-movie {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 2px solid var(--accent);
    margin-bottom: 1.5rem;
}

.source-movie .movie-title {
    font-size: 1.3rem;
}

.source-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ── Admin Section ──────────────────────── */

.admin-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.admin-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    user-select: none;
}

.admin-toggle:hover {
    color: var(--text-secondary);
}

.admin-panel {
    display: none;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.2rem;
    border: 1px solid var(--border);
}

.admin-panel.open {
    display: block;
}

.admin-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.admin-row label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 80px;
}

.admin-row input, .admin-row select {
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.btn-admin {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-index {
    background: var(--success);
    color: #000;
}

.btn-index:hover {
    filter: brightness(1.1);
}

.btn-index:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-info {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.status-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-item .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.3rem;
}

.dot.ok { background: var(--success); }
.dot.err { background: var(--accent); }

.progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── PIN Modal ──────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 2rem;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 360px;
    text-align: center;
}

.modal h3 {
    margin-bottom: 1rem;
}

.modal input {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 0.3em;
    width: 100%;
    outline: none;
    margin-bottom: 0.5rem;
}

.modal input:focus {
    border-color: var(--accent);
}

.modal .error {
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.modal-buttons button {
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-confirm {
    background: var(--accent);
    color: #fff;
}

.btn-cancel {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border) !important;
}

/* ── Loading ────────────────────────────── */

.loading {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

/* ── Responsive ─────────────────────────── */

@media (max-width: 640px) {
    .container {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .search-box {
        flex-direction: column;
    }

    .search-box button {
        width: 100%;
    }

    .movie-card {
        padding: 1rem;
    }

    .movie-card-header {
        flex-direction: column;
    }

    .mood-selector {
        gap: 0.3rem;
    }

    .mood-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .profile-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
    }
}
