/* ============================================
   Library Manager — Design System
   Dark cinematic theme
   ============================================ */

:root {
    --bg: #0d1117;
    --bg-gradient: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    --surface: #161b22;
    --card: #1c2128;
    --card-hover: #22272e;
    --accent: #d4a053;
    --accent-hover: #e0b36a;
    --accent-subtle: rgba(212, 160, 83, 0.15);
    --text: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --border: #30363d;
    --border-light: #3d444d;
    --danger: #f85149;
    --success: #3fb950;
    --warning: #d29922;
    --info: #58a6ff;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
}

/* ---- Reset & Base ---- */

* { box-sizing: border-box; }

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

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

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 600;
}

/* ---- Navbar ---- */

.navbar-library {
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.navbar-library .navbar-brand {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}
.navbar-library .navbar-brand:hover { color: var(--accent-hover); }

.navbar-library .nav-link {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.75rem 0.85rem;
    transition: color var(--transition);
    border-bottom: 2px solid transparent;
}
.navbar-library .nav-link:hover,
.navbar-library .nav-link.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.navbar-library .nav-link i {
    margin-right: 0.35rem;
    font-size: 1rem;
}

.navbar-search .form-control {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 20px;
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    width: 220px;
    transition: border-color var(--transition), width var(--transition);
}
.navbar-search .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
    outline: none;
    width: 280px;
}
.navbar-search .form-control::placeholder { color: var(--text-muted); }

/* ---- Page Container ---- */

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ---- Cards ---- */

.card-dark {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.media-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.media-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}
.media-card a {
    color: inherit;
    text-decoration: none;
}
.media-card a:hover {
    color: inherit;
}

.media-card-cover-wrap {
    position: relative;
}

.media-card-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--surface);
    display: block;
}

.media-card-cover.cover-square {
    aspect-ratio: 1 / 1;
}

.plex-link-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(30, 30, 30, 0.85);
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.65rem;
}

.media-card-body {
    padding: 0.85rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.media-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.2rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-card-main-link {
    display: block;
}

.media-card-footer {
    padding: 0 0.85rem 0.85rem;
}

.media-card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.media-card-meta {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* ---- Results Grid ---- */

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
}

/* ---- Badges ---- */

.badge-dark {
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.badge-accent {
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
}

/* Status badges */
.badge-status-completed { background: rgba(63, 185, 80, 0.15); color: var(--success); }
.badge-status-failed { background: rgba(248, 81, 73, 0.15); color: var(--danger); }
.badge-status-running { background: rgba(88, 166, 255, 0.15); color: var(--info); }
.badge-status-skipped { background: rgba(210, 153, 34, 0.15); color: var(--warning); }

/* ---- Person / Editor page ---- */

.person-banner {
    position: relative;
    width: 100%;
    height: 280px;
    overflow: hidden;
    margin-bottom: -60px;
    border-radius: var(--radius);
}
.person-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.person-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, var(--bg) 100%);
}

a.badge-link {
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}
a.badge-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

a.badge-link-inline {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
}
a.badge-link-inline:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.text-accent { color: var(--accent); }

.year-group {
    margin-bottom: 1.5rem;
}
.year-group-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.75rem;
}

/* ---- Tables (dark) ---- */

.table-dark-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-dark-custom th {
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.table-dark-custom td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
    vertical-align: middle;
}

.table-dark-custom tbody tr {
    transition: background var(--transition);
}
.table-dark-custom tbody tr:hover {
    background: var(--card);
}

/* ---- Sidebar / Filters ---- */

.sidebar-dark {
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}

.sidebar-dark h4, .sidebar-dark h5 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.sidebar-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: background var(--transition), color var(--transition);
}
.sidebar-nav-list li a:hover {
    background: var(--card);
    color: var(--text);
}

/* ---- Forms (dark) ---- */

.form-control, .form-select {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-subtle) !important;
    outline: none;
}
.form-control::placeholder { color: var(--text-muted); }

.form-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

/* Dark select2 override */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    background-color: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
    min-height: 38px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
}
.select2-dropdown {
    background-color: var(--card) !important;
    border: 1px solid var(--border) !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--accent) !important;
    color: var(--bg) !important;
}
.select2-container--default .select2-results__option {
    color: var(--text-secondary) !important;
}
.select2-search__field {
    background: var(--surface) !important;
    color: var(--text) !important;
}

/* ---- Buttons ---- */

.btn-accent {
    background: var(--accent);
    color: var(--bg);
    border: none;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    transition: background var(--transition), transform var(--transition);
}
.btn-accent:hover {
    background: var(--accent-hover);
    color: var(--bg);
    transform: translateY(-1px);
}

.btn-outline-light {
    border-color: var(--border) !important;
    color: var(--text-secondary) !important;
}
.btn-outline-light:hover {
    background: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--border-light) !important;
}
.btn-check:checked + .btn-outline-light {
    background: var(--accent) !important;
    color: #000 !important;
    border-color: var(--accent) !important;
}
.btn-check:checked + .btn-outline-light .plex-filter-logo {
    filter: invert(1);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    transition: all var(--transition);
}
.btn-ghost:hover {
    background: var(--card);
    color: var(--text);
    border-color: var(--border-light);
}

/* ---- Hero (Home) ---- */

.hero-home {
    position: relative;
    width: 100vw;
    height: 100vh;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-top: -1.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-home img.hero-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.hero-home::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(13, 17, 23, 0.3) 0%,
        rgba(13, 17, 23, 0.5) 50%,
        rgba(13, 17, 23, 0.85) 100%
    );
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem;
}

.hero-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.hero-search {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.hero-search .form-control {
    background: rgba(22, 27, 34, 0.8) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    border-radius: 30px;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    width: 100%;
}
.hero-search .form-control:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-subtle) !important;
}
.hero-search .form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.hero-search .btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg);
}

/* Login form on hero */
.hero-login {
    background: rgba(22, 27, 34, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 380px;
    margin: 0 auto;
}

.hero-login h3 {
    color: var(--text);
    text-align: center;
    margin-bottom: 1.5rem;
}

.hero-login input[type="text"],
.hero-login input[type="password"] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.hero-login input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.hero-login label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 0.3rem;
}

/* ---- Detail View ---- */

.detail-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.detail-cover {
    flex-shrink: 0;
    width: 300px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.detail-cover img {
    width: 100%;
    display: block;
}

.detail-info {
    flex: 1;
    min-width: 0;
}

.detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.detail-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-meta-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-meta-list li {
    padding: 0.4rem 0;
    display: flex;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.detail-meta-list li strong {
    color: var(--text-muted);
    font-weight: 500;
    min-width: 140px;
    flex-shrink: 0;
}

.detail-meta-list li span {
    color: var(--text-secondary);
}

/* Support icons in detail */
.support-icons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.support-icons img {
    height: 50px;
    opacity: 0.85;
    transition: opacity var(--transition);
}
.support-icons img:hover { opacity: 1; }

/* Track table */
.track-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 1rem;
}

.track-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.track-table td {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(48, 54, 61, 0.4);
}

.track-table tbody tr:hover {
    background: var(--card);
}

/* ---- Poster Gallery (IMDb/Plex) ---- */

.poster-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.poster-gallery .poster-item {
    position: relative;
}

.poster-gallery .poster-item > a,
.poster-gallery > a {
    display: block;
    text-decoration: none;
    color: var(--text-secondary);
    text-align: center;
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: transform var(--transition);
}
.poster-gallery .poster-item > a:hover,
.poster-gallery > a:hover {
    transform: translateY(-3px);
}

/* Review-issue detail: horizontal film cards (poster | title + notes).
   2-col on desktop, 1-col on mobile. Variable height — the grid does
   NOT force equal-height rows, so a card with long notes can stretch
   without dragging its row-mate along. */
.film-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
}
.film-card {
    position: relative;
    display: flex;
    gap: 0.85rem;
    background: var(--surface, #161b22);
    border: 1px solid var(--border, #30363d);
    border-radius: var(--radius);
    padding: 0.75rem;
    align-items: flex-start;
}
/* Reuse the audio Plex-link badge style but flip it to the top-right
   corner of the card. The default `.plex-link-badge` lives top-left
   (overlaid on audio covers); on a film card the title is right-aligned
   so right-corner reads cleaner. */
.film-card .plex-link-badge {
    left: auto;
    right: 0.5rem;
}
.film-card-poster {
    flex: 0 0 96px;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2, #0d1117);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.film-card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.film-card-poster .poster-text {
    font-size: 0.75rem;
    text-align: center;
    padding: 0.5rem;
    color: var(--text-muted, #8b949e);
}
.film-card-body {
    flex: 1;
    min-width: 0;  /* lets long titles wrap instead of overflowing */
}
.film-card-title {
    line-height: 1.35;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
}
.film-card-notes {
    font-size: 0.85rem;
    color: var(--text-secondary, #c9d1d9);
    background: var(--surface-2, #0d1117);
    border-left: 3px solid var(--accent, #d4a053);
    border-radius: 4px;
    padding: 0.45rem 0.6rem;
}
/* When the homepage's poster-plex / poster-jw classes hit a .film-card
   they overwrite the card's padding. Keep the card layout intact. */
.film-card.poster-plex,
.film-card.poster-jw {
    padding: 0.75rem;
}

/* Notes badge: top-left of the poster artwork, mirroring the resync
   tools in the top-right. The expanded panel sits below the poster
   (overlays the caption) so long notes don't break the grid layout. */
.movie-notes {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 4;
}
.movie-notes-badge {
    list-style: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(13, 17, 23, 0.85);
    color: var(--text-primary, #f0f6fc);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}
.movie-notes-badge::-webkit-details-marker { display: none; }
.movie-notes-badge:hover,
.movie-notes[open] .movie-notes-badge {
    background: var(--accent, #d4a053);
    color: #0d1117;
}
.movie-notes-body {
    position: absolute;
    top: 36px;
    left: 0;
    width: 240px;
    max-height: 240px;
    overflow-y: auto;
    background: rgba(13, 17, 23, 0.96);
    border: 1px solid var(--border, #30363d);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.85rem;
    color: var(--text-primary, #f0f6fc);
    box-shadow: var(--shadow);
    z-index: 5;
}

.poster-tools {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}
.poster-item:hover .poster-tools,
.poster-tools:focus-within {
    opacity: 1;
}
.poster-resync {
    margin: 0;
}
.poster-resync button,
.poster-override > summary {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(13, 17, 23, 0.85);
    color: var(--text-primary, #f0f6fc);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 28px;
    box-shadow: var(--shadow);
}
.poster-resync button:hover,
.poster-override > summary:hover {
    background: var(--accent, #d4a053);
    color: #0d1117;
}

.poster-override {
    position: relative;
}
.poster-override > summary {
    list-style: none;
    text-align: center;
}
.poster-override > summary::-webkit-details-marker { display: none; }
.poster-override[open] > summary {
    background: var(--accent, #d4a053);
    color: #0d1117;
}
.poster-override-form {
    position: absolute;
    top: 32px;
    right: 0;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--border, #30363d);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    gap: 4px;
    width: 240px;
    z-index: 5;
    box-shadow: var(--shadow);
}
.poster-override-form input[type="url"] {
    flex: 1;
    min-width: 0;
    background: var(--surface, #161b22);
    border: 1px solid var(--border, #30363d);
    border-radius: 4px;
    color: var(--text-primary, #f0f6fc);
    padding: 4px 6px;
    font-size: 0.8rem;
}
.poster-override-form button {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: var(--accent, #d4a053);
    color: #0d1117;
    cursor: pointer;
}

.poster-gallery img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.poster-gallery .poster-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    padding: 0.75rem;
    word-wrap: break-word;
    color: var(--text-muted);
}

/* ---- Home dual-panel overlay ---- */

.home-overlay {
    position: relative;
    width: 100vw;
    height: calc(100vh - 56px);
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-top: -1.5rem;
    overflow: hidden;
}

.home-overlay .hero-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.home-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(13, 17, 23, 0.25) 0%,
        rgba(13, 17, 23, 0.4) 100%
    );
    z-index: 1;
}

.home-panels {
    position: relative;
    z-index: 2;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    box-sizing: border-box;
}

.home-panel {
    background: rgba(22, 27, 34, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.25rem 0.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.home-panel > h2 {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.home-panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.home-panel-scroll::-webkit-scrollbar { width: 8px; }
.home-panel-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.home-panel-section {
    margin-bottom: 1.25rem;
}


.home-panel-section > h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.home-empty {
    margin: 0.5rem 0 1rem;
    font-style: italic;
}

.home-poster-gallery {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.home-poster-gallery--square img,
.home-poster-gallery--square .poster-text {
    aspect-ratio: 1 / 1;
}

.poster-plex,
.poster-jw {
    padding: 4px;
    border-radius: var(--radius);
    border: 3px solid transparent;
    transition: border-color var(--transition), filter var(--transition);
}

.poster-plex {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.poster-jw {
    border-color: rgba(255, 255, 255, 0.45);
}

.poster-jw img {
    filter: grayscale(0.25);
    transition: filter var(--transition);
}

.poster-jw:hover img {
    filter: none;
}

.poster-album-meta {
    display: block;
    font-size: 0.75rem;
    line-height: 1.2;
    text-align: left;
    margin-top: 0.4rem;
    color: var(--text-secondary);
}

.poster-album-title {
    display: block;
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poster-album-artist {
    display: block;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-load-more {
    grid-column: 1 / -1;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.home-load-more.is-loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(212, 160, 83, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: home-spin 0.8s linear infinite;
}

.home-load-more.has-error,
.home-load-retry {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.home-load-retry:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

@media (max-width: 992px) {
    .home-overlay {
        height: auto;
        min-height: calc(100vh - 56px);
    }
    .home-panels {
        grid-template-columns: 1fr;
        height: auto;
    }
    .home-panel-scroll {
        max-height: 70vh;
    }
}

/* ---- Highcharts dark theme ---- */

.highcharts-figure {
    margin: 1rem 0;
}

.highcharts-bar-container {
    height: 600px;
    border-radius: var(--radius);
    overflow: hidden;
}

/* ---- Alerts ---- */

.alert-dark {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}

/* ---- Loading ---- */

.loading-spinner {
    display: none;
    text-align: center;
    padding: 2rem;
}

.loading-spinner .spinner-border {
    color: var(--accent);
}

/* ---- Form page layout ---- */

.form-sidebar .card-dark {
    margin-bottom: 1rem;
}

.form-sidebar h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.form-main .control-group {
    margin-bottom: 1rem;
}

.form-main .control-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    display: block;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .detail-cover { width: 200px; }
    .detail-meta-list li { flex-direction: column; gap: 0; }
    .detail-meta-list li strong { min-width: unset; }
    .results-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .hero-content h1 { font-size: 1.75rem; }
}

/* ---- Misc Utilities ---- */

.text-accent { color: var(--accent) !important; }
.text-muted-custom { color: var(--text-muted) !important; }
.bg-surface { background: var(--surface) !important; }
.border-dark { border-color: var(--border) !important; }

/* Form validation */
.is-invalid, .is-invalid + .select2-container .select2-selection {
    border-color: var(--danger) !important;
}

.field-error {
    color: var(--danger);
}

/* ---- Composer Hierarchical View ---- */

.composer-form-group {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin-bottom: 2rem;
}

.form-section-header {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.form-icon {
    font-size: 1.3rem;
    color: var(--accent);
    width: 1.5rem;
    text-align: center;
}

.composer-instrument-group {
    margin-left: 0.75rem;
    margin-bottom: 1.5rem;
}

.instrument-section-header {
    padding-bottom: 0.25rem;
}

.instrument-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.composer-artist-group {
    border-left: 2px solid var(--border);
    padding-left: 1rem;
    margin-left: 0.75rem;
    margin-bottom: 1.5rem;
}

.artist-group-label {
    font-size: 0.95rem;
    font-weight: 500;
}

.badge-link-inline {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}
.badge-link-inline:hover {
    color: var(--accent);
}

.media-card-cover-wrap {
    position: relative;
}

.instrument-badge {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    background: rgba(13, 17, 23, 0.85);
    padding: 0.2rem 0.35rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    line-height: 1;
}

/* Hide old Bootstrap 2 artifacts */
.hidden-field, .hidden-form { display: none; }

/* === Console (curation hub) === */
.console-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    padding: 1.5rem;
}

.console-sidebar {
    flex: 0 0 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 0.5rem;
    position: sticky;
    top: 1rem;
}

.console-sidebar-header {
    color: var(--accent);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.25rem 0.75rem 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.console-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.console-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
    transition: background var(--transition), color var(--transition);
}

.console-sidebar-link:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

.console-sidebar-link.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 500;
}

.console-sidebar-link i {
    width: 1.1rem;
    text-align: center;
}

.console-sidebar-label {
    flex: 1;
    min-width: 0;
}

.console-sidebar-badge {
    flex: 0 0 auto;
    background: var(--accent);
    color: var(--bg);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
}

.console-main {
    flex: 1 1 auto;
    min-width: 0;
}

.console-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.console-card {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: border-color var(--transition), transform var(--transition);
}

.console-card:hover {
    border-color: var(--accent);
    color: var(--text-secondary);
    transform: translateY(-1px);
}

.console-card-icon {
    font-size: 1.4rem;
    color: var(--accent);
    width: 2rem;
    text-align: center;
    flex-shrink: 0;
}

.console-card-body {
    flex: 1 1 auto;
    min-width: 0;
}

.console-card-title {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.console-card-count {
    background: var(--accent);
    color: var(--bg);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    margin-left: 0.4rem;
}

.console-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .console-layout { flex-direction: column; padding: 1rem; }
    .console-sidebar { width: 100%; flex: none; position: static; }
}

/* Capture flow (issue #79 phase C) */
.text-pre-wrap { white-space: pre-wrap; }

.ratio-2x3 { --bs-aspect-ratio: calc(3 / 2 * 100%); }

.capture-issue-tile {
    transition: transform 0.1s ease;
}
.capture-issue-tile:hover { transform: translateY(-2px); }

.capture-candidate-card { cursor: pointer; }
.capture-candidate-card .card-dark {
    border: 2px solid transparent;
    transition: border-color 0.15s ease;
}
.capture-candidate-card.selected .card-dark {
    border-color: var(--accent);
}

/* Min-height keeps every chip a comfortable thumb-sized tap target on
   mobile, even when the label is just one short word. */
.capture-list-chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-check:checked + .capture-list-chip {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #0d1117;
}
