html { font-size: 22px; }
#nav-menu { position: relative; }
#nav-btn {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}
#nav-btn:hover { background: #3a3a3a; }
#nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    min-width: 140px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
#nav-dropdown a, .nav-action {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}
#nav-dropdown a:hover, .nav-action:hover { background: #3a3a3a; }
#nav-dropdown a.nav-active { color: #f0b429; font-weight: bold; }
.nav-action {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.nav-separator {
    padding: 4px 14px 2px;
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-top: 1px solid #3a3a3a;
    margin-top: 4px;
}
.nav-shortcut {
    margin-left: auto;
    padding-left: 16px;
    font-size: 0.75rem;
    color: #666;
}
@media (hover: none) and (pointer: coarse) {
    .nav-shortcut { display: none; }
}

body {
    display: flex;
    font-family: sans-serif;
    overflow: hidden; /* Prevent body scrolling */
    height: 100vh; /* Make body take full viewport height */
    background-color: #1a1a1a;
    color: #e0e0e0;
}
#app-root {
    display: flex;
    flex: 1;
    min-height: 0;
}
body.identify-page #app-root {
    display: block;
}
.highlight {
    background-color: #3a2e00;
}
.row-pinned-flash {
    background-color: #1a3a1a !important;
    transition: background-color 0.6s ease;
}
#movie-list-container {
    flex: 1;
    margin-right: 20px;
    overflow-y: auto;
    height: calc(100vh - var(--console-banner-height, 0px));
}
#movie-list-header {
    position: sticky;
    top: 0;
    background-color: #1a1a1a;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}
#movie-list-header h1,
.identify-header-row h1,
#catalog-header h1 {
    margin: 0;
    font-size: 1.3rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}
.write-mode-label {
    font-size: 0.85rem;
    color: #aaa;
    cursor: pointer;
    user-select: none;
}
/* ── Controls dropdown panel ───────────────────────────────────────────── */
#controls-menu { position: relative; flex-shrink: 0; }
#controls-btn {
    background: none;
    border: 1px solid #3a3a3a;
    color: #aaa;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    display: flex;
    align-items: center;
}
#controls-btn:hover { background: #3a3a3a; color: #e0e0e0; }
#controls-btn.active { background: #3a3a3a; color: #f0b429; border-color: #555; }
.controls-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 12px 16px;
    min-width: 210px;
    z-index: 200;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.controls-panel.open { display: flex; }
.controls-section { display: flex; flex-direction: column; gap: 8px; }
.controls-section-title {
    font-size: 0.72rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.controls-label {
    font-size: 0.85rem;
    color: #ccc;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 7px;
}
.controls-sep {
    border: none;
    border-top: 1px solid #3a3a3a;
    margin: 0;
}
#pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
#pagination-controls button {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 2px 7px;
    cursor: pointer;
    font-size: 0.8rem;
}
#pagination-controls button:disabled {
    opacity: 0.3;
    cursor: default;
}
#pagination-controls button:not(:disabled):hover {
    background: #3a3a3a;
}
#page-indicator {
    font-size: 0.9rem;
    color: #aaa;
    min-width: 60px;
    text-align: center;
}
#movie-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
#movie-table th, #movie-table td {
    border: 1px solid #3a3a3a;
    padding: 8px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}
#movie-table th[data-column="rating"]  { width: 50px; }
#movie-table th[data-column="year"]    { width: 55px; }
#movie-table th[data-column="watched"] { width: 95px; }
#movie-table th.fetch-col              { width: 30px; }
#movie-table td.rating-cell {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}
#movie-table.rating-icon-mode td.rating-cell,
#movie-table.rating-icon-mode th[data-column="rating"] {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}
#movie-table td.year-cell    { width: 55px; }
#movie-table td.watched-cell { width: 95px; }
.rating-half {
    font-size: 0.7em;
    vertical-align: 0.4em;
    margin-left: -0.1em;
}
.rating-stars {
    display: inline-flex;
    gap: 0;
    letter-spacing: -0.1em;
}
.rating-star {
    font-size: 0.85em;
    line-height: 1;
}
.rating-star-full  { color: #FFD700; }
.rating-star-empty { color: #555; }
.rating-star-half {
    position: relative;
    display: inline-block;
    color: #555;
}
.rating-star-half::before {
    content: '★';
    position: absolute;
    left: 0;
    top: 0;
    width: 50%;
    overflow: hidden;
    color: #FFD700;
}
.sort-arrow {
    font-size: 0.7em;
    vertical-align: 0.2em;
}
.fade-overflow {
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
}
#movie-table td.rating-cell input {
    padding: 0;
    margin: 0;
    border: none;
    outline: none;
    font-size: inherit;
    font-family: inherit;
    background: transparent;
    color: inherit;
}
#movie-table th {
    background-color: #2a2a2a;
}
#movie-table tr:hover {
    background-color: #242424;
}
/* List page hover overlay */
/* Shared hover overlay */
#cover-hover-overlay {
    position: fixed;
    top: 0;
    height: 100vh;
    width: calc(100vw - 480px); /* keep in sync with #plot-outline-container width below */
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    pointer-events: none;
}
#cover-hover-overlay.left { left: 0; }
#cover-hover-overlay.right { right: 0; }
#cover-hover-img {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
}

#plot-outline-container {
    flex: 0 0 480px; /* keep in sync with calc(100vw - 480px) in #cover-hover-overlay above */
    border-left: 1px solid #3a3a3a;
    overflow-y: auto;
    height: calc(100vh - var(--console-banner-height, 0px));
    background-color: #212121;
}
#plot-image {
    width: 100%;
    height: auto;
    min-height: 480px;
    display: none;
}
#plot-image-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(90deg, #252525 25%, #2e2e2e 50%, #252525 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
#plot-outline {
    padding: 12px 14px;
}
/* Mobile panel nav bar (hidden on desktop) */
#panel-mobile-nav {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #1a1a1a;
    border-bottom: 1px solid #3a3a3a;
    position: sticky;
    top: 0;
    z-index: 1;
}
#panel-close-btn, #panel-prev-btn, #panel-next-btn {
    background: #333;
    color: #e0e0e0;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 1rem;
    cursor: pointer;
}
#panel-close-btn { margin-right: auto; }

@media (max-width: 1024px) {
    #plot-outline-container {
        display: none;
        position: fixed;
        top: 0; left: 0;
        width: 100%; height: 100%;
        z-index: 200;
        flex: none;
        border-left: none;
        overflow-y: auto;
    }
    #plot-outline-container.panel-open {
        display: block;
    }
    #movie-list-container {
        margin-right: 0;
    }
    #cover-hover-overlay {
        display: none !important;
    }
    #panel-mobile-nav {
        display: flex;
    }
    #plot-image {
        min-height: auto;
        max-height: 45vh;
        width: auto;
        max-width: 100%;
        margin: 0 auto;
    }
    #plot-image-placeholder {
        max-height: 45vh;
        aspect-ratio: 2/3;
        width: auto;
        max-width: 100%;
        margin: 0 auto;
    }
}

.preview-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e8e8e8;
    margin-bottom: 2px;
}
.preview-title-year {
    font-size: 0.82rem;
    font-weight: normal;
    color: #999;
}
.preview-title-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.preview-title-row .preview-title {
    margin-bottom: 0;
    flex: 1;
}
.preview-save-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    color: #888;
    flex-shrink: 0;
    position: relative;
    display: inline-block;
    line-height: 1;
}
.preview-save-btn:hover {
    color: #e0e0e0;
}
.preview-log-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    color: #888;
    flex-shrink: 0;
    display: inline-block;
    line-height: 1;
}
.preview-log-btn:hover { color: #e0e0e0; }
.preview-remove-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    display: inline-block;
}
.preview-remove-btn:hover { color: #e0e0e0; }
.preview-links-menu { position: relative; flex-shrink: 0; }
.preview-links-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    color: #888;
    flex-shrink: 0;
    display: inline-block;
    line-height: 1;
}
.preview-links-btn:hover, .preview-links-btn.active { color: #e0e0e0; }
.preview-links-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 10px 14px;
    z-index: 200;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    white-space: nowrap;
}
.preview-links-panel.open { display: flex; }
.preview-links-panel .preview-imdb-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    font-size: 0.82rem;
}
.preview-link-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.save-disk { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-save-btn--saving .save-disk,
.match-save-btn--saving .save-disk { display: inline-block; animation: spin 0.7s linear infinite; }
.save-check {
    position: absolute;
    top: -3px;
    right: -2px;
    font-size: 0.55rem;
    color: #4caf50;
    display: none;
    font-weight: bold;
    line-height: 1;
}
.preview-save-btn--saved .save-check,
.match-save-btn--saved .save-check { display: block; }
.match-save-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 2px;
    color: #888;
    position: relative;
    display: inline-block;
    line-height: 1;
}
.match-save-btn:hover { color: #e0e0e0; }
.preview-imdb-link {
    display: inline-block;
    font-size: 0.75rem;
    color: #7eb6ff;
    margin-bottom: 10px;
}
.preview-meta {
    font-size: 0.82rem;
    color: #999;
    margin-bottom: 3px;
}
.preview-plot-blurred {
    position: relative;
    font-size: 0.85rem;
    color: #c0c0c0;
    line-height: 1.5;
    margin-top: 10px;
    border-top: 1px solid #3a3a3a;
    padding-top: 10px;
    cursor: pointer;
    user-select: none;
}
.preview-plot-blurred .preview-plot-text {
    filter: blur(4px);
    transition: filter 0.25s ease;
}
.preview-plot-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e0e0e0;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.preview-plot-blurred:hover .preview-plot-hint {
    opacity: 1;
}
.preview-plot-blurred.revealed {
    cursor: default;
}
.preview-plot-blurred.revealed .preview-plot-text {
    filter: none;
}
.preview-plot-blurred.revealed .preview-plot-hint {
    display: none;
}
.preview-separator {
    border: none;
    border-top: 1px solid #3a3a3a;
    margin: 10px 0 0;
}
.preview-notes {
    font-size: 0.85rem;
    color: #a0a0a0;
    font-style: italic;
    line-height: 1.5;
    padding-top: 8px;
}
a {
    color: #7eb6ff;
}

.fetch-col, .fetch-cell {
    width: 24px;
    min-width: 24px;
    text-align: center;
    padding: 2px !important;
}
.row-fetch-btn {
    display: none;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 1px 4px;
    border-radius: 3px;
}
.row-fetch-btn:hover:not(:disabled) {
    color: #e0e0e0;
    background: #3a3a3a;
}
.row-fetch-btn:disabled {
    opacity: 0.3;
    cursor: default;
}
.row-sync-btn {
    display: none;
    background: none;
    border: none;
    color: #b8860b;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 1px 4px;
    border-radius: 3px;
}
.row-sync-btn:hover {
    color: #ffd050;
    background: #3a3a3a;
}

/* Identify page: overlay takes up half the screen */
body.identify-page #cover-hover-overlay {
    width: 50%;
}

/* Identify page */
body.identify-page {
    display: block;
    overflow: hidden;
    height: 100vh;
}
#identify-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--console-banner-height, 0px));
}
#identify-list-pane {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
    min-height: 60px;
}
#identify-table-wrapper {
    flex: 1 1 0;
    overflow-y: auto;
}
#identify-divider {
    flex: 0 0 6px;
    background: #2a2a2a;
    border-top: 1px solid #3a3a3a;
    border-bottom: 1px solid #3a3a3a;
    cursor: row-resize;
    user-select: none;
}
#identify-divider:hover, #identify-divider.dragging {
    background: #4a3a00;
}
#load-more-btn {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
#load-more-btn:hover:not(:disabled) { background: #3a3a3a; }
#load-more-btn:disabled { opacity: 0.4; cursor: default; }
#identify-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
#identify-table th[data-column="rating"]  { width: 50px; }
#identify-table th[data-column="year"]    { width: 55px; }
#identify-table th[data-column="watched"] { width: 95px; }
#identify-table th.identify-imdb-col,
#identify-table td:last-child { width: 20px; text-align: center; padding: 4px; }
#identify-table th,
#identify-table td {
    border: 1px solid #3a3a3a;
    padding: 6px 8px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}
#identify-table th {
    background-color: #2a2a2a;
    position: sticky;
    top: 0;
    z-index: 1;
}
.identify-row { cursor: pointer; }
.identify-row.highlight {
    background-color: #3a2e00;
}
.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
}
.status-dot-pending { background: #f0c040; }
.status-dot-success { background: #40c040; }
.status-dot-error   { background: #c04040; }
.status-ready { color: #888; font-size: 0.8rem; }
.status-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #444;
    border-top-color: #aaa;
    border-radius: 50%;
    animation: status-spin 0.8s linear infinite;
    vertical-align: middle;
}
/* Slow spinner for queued (waiting for a worker), fast for actively loading */
.status-spinner-slow { animation-duration: 15s; }
@keyframes status-spin { to { transform: rotate(360deg); } }
#identify-bottom-pane {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
}
#match-panels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    flex: 1 1 0;
    overflow: hidden;
}
.match-panel {
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 8px;
    overflow-y: auto;
    background: #212121;
    font-size: 0.85rem;
}
.match-panel-empty {
    background: #1a1a1a;
    border-style: dashed;
}
.match-number {
    font-size: 1.4rem;
    font-weight: bold;
    color: #c0c0c0;
    margin-bottom: 4px;
    display: inline-block;
    width: 1.6em;
    height: 1.6em;
    line-height: 1.6em;
    text-align: center;
    border-radius: 50%;
}
.match-number-pending { color: #000; background-color: #f0b429; }
.match-number-success { color: #000; background-color: #4caf50; }
.match-number-error   { color: #000; background-color: #ff5555; }
.match-cover {
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
    display: block;
    margin-bottom: 4px;
}
.match-no-cover {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.8rem;
    border: 1px dashed #444;
    margin-bottom: 4px;
}
.match-title {
    font-weight: bold;
    margin-bottom: 2px;
}
.match-original-title {
    color: #aaa;
    font-style: italic;
    margin-bottom: 2px;
    font-size: 0.85rem;
}
.match-year {
    color: #aaa;
    margin-bottom: 2px;
}
.match-director,
.match-cast,
.detail-director,
.detail-cast {
    padding-left: 10px;
    text-indent: -10px;
}
.match-director,
.match-cast {
    color: #aaa;
    margin-bottom: 2px;
    font-size: 0.8rem;
}
.match-genres {
    color: #888;
    font-style: italic;
    margin-bottom: 4px;
    font-size: 0.8rem;
}
.match-plot {
    color: #c0c0c0;
    margin-bottom: 6px;
    font-size: 0.8rem;
    line-height: 1.3;
}
.match-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.match-imdb-link,
.match-ext-link {
    font-size: 0.8rem;
}
.match-loading,
.match-error {
    color: #777;
    font-style: italic;
    padding: 8px 0;
}
.match-error {
    color: #ff5555;
}
#identify-hint {
    margin: 6px 0 0 0;
    font-size: 0.85rem;
    color: #777;
    text-align: center;
}

/* Catalog page */
#catalog-list-container {
    flex: 1;
    overflow-y: auto;
    height: calc(100vh - var(--console-banner-height, 0px));
}
#catalog-header {
    position: sticky;
    top: 0;
    background-color: #1a1a1a;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0 8px 8px;
}
/* Letter-level grouping (director / actor) */
.letter-section {
    border-bottom: 1px solid #2a2a2a;
}
.letter-section > summary.letter-summary {
    list-style: none;
    padding: 4px 8px;
    background: #1e1e1e;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.08em;
    color: #888;
}
.letter-section > summary.letter-summary::-webkit-details-marker { display: none; }
.letter-section > summary.letter-summary::before {
    content: '▶';
    font-size: 0.55rem;
    color: #555;
    transition: transform 0.12s;
    flex-shrink: 0;
}
.letter-section[open] > summary.letter-summary::before { transform: rotate(90deg); }
.letter-section > summary.letter-summary:hover { background: #242424; }

/* Name-level grouping (director / actor name, or year) */
.group-section {
    border-bottom: 1px solid #252525;
}
/* Indent group-sections that live inside a letter-section */
.letter-section > .group-section > summary.group-summary {
    padding-left: 20px;
}
.group-section > summary.group-summary {
    list-style: none;
    padding: 6px 8px;
    background: #232323;
    border-bottom: 1px solid #2a2a2a;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    font-size: 0.88rem;
}
.group-section > summary.group-summary::-webkit-details-marker { display: none; }
.group-section > summary.group-summary::before {
    content: '▶';
    font-size: 0.6rem;
    color: #666;
    transition: transform 0.12s;
    flex-shrink: 0;
}
.group-section[open] > summary.group-summary::before { transform: rotate(90deg); }
.group-section > summary.group-summary:hover { background: #2b2b2b; }

.group-count {
    font-size: 0.75rem;
    color: #777;
    font-weight: normal;
}
.group-table {
    width: 100%;
    border-collapse: collapse;
}
.group-table td {
    border: 1px solid #252525;
    padding: 5px 8px;
    text-align: left;
    font-size: 0.88rem;
}
.group-table .movie-row { cursor: pointer; }
.group-table .movie-row:hover { background: #242424; }
.group-table .movie-row.highlight { background: #3a2e00; }
.group-table .rating-cell {
    width: 44px;
    min-width: 44px;
    white-space: nowrap;
}
.watched-cell {
    color: #888;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Keyboard shortcuts help popup */
#help-popup {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
#help-popup.open { display: flex; }
#help-popup-dialog {
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 20px 28px 24px;
    min-width: 300px;
    max-width: 90vw;
    color: #e0e0e0;
}
#help-popup-dialog h2 {
    margin: 0 0 14px;
    font-size: 0.85rem;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#help-popup-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
}
#help-popup-close:hover { color: #e0e0e0; }
#help-popup-dialog table { border-collapse: collapse; width: 100%; }
#help-popup-dialog td { padding: 3px 6px; vertical-align: top; }
#help-popup-dialog td:first-child {
    font-family: monospace;
    color: #f0c040;
    white-space: nowrap;
    text-align: right;
    padding-right: 14px;
    min-width: 80px;
}
#help-popup-dialog td:last-child { color: #ccc; }

/* Keyboard navigation focus indicator */
.nav-item.nav-focus {
    outline: 1px solid #5a5030;
    outline-offset: -1px;
}
.letter-summary.nav-focus  { background: #242018 !important; }
.group-summary.nav-focus   { background: #2e2a1a !important; }
.movie-row.nav-focus       { background: #3a2e00 !important; }

/* ── Warning banners ────────────────────────────────────────────────────── */
.missing-zid-warning {
    background: #fff3cd;
    border: 1px solid #b8860b;
    padding: 8px 12px;
    margin-bottom: 8px;
    color: #7a5800;
}
.duplicate-warning {
    background: #ffe0e0;
    border: 1px solid #c00;
    padding: 8px 12px;
    margin-bottom: 8px;
    color: #900;
}
.warning-item { margin-top: 4px; }
.warning-group { margin-top: 6px; }
.warning-actions { margin-top: 8px; }
.warning-fix-btn {
    background: #7a5800;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}
.warning-status { margin-left: 8px; font-size: 0.85rem; }

/* ── Shared header controls ─────────────────────────────────────────────── */
#search-icon-btn, #identify-search-icon-btn {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    color: #888;
    padding: 4px;
    cursor: pointer;
    flex-shrink: 0;
}
#search-icon-btn:hover, #identify-search-icon-btn:hover { color: #e0e0e0; }
#search-input, #identify-search-input {
    display: none;
}
#search-input.search-open, #identify-search-input.search-open {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 500;
    padding: 10px 12px;
    font-size: 1rem;
    border-radius: 0;
    border: none;
    border-bottom: 2px solid #555;
    background: #1a1a1a;
    color: #e0e0e0;
}
#movie-table th[data-column] { cursor: pointer; }
.header-action-btn {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* ── Watch History page ─────────────────────────────────────────────────── */
#problems-btn {
    display: none;
    background: #c00;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
}
#fetch-all-btn { display: none; }
tr[data-unidentified="y"] { display: none; }

/* ── Modal overlays (shared) ────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
#problems-modal { z-index: 1100; }
.modal-dialog {
    background: #2a2a2a;
    border: 1px solid #555;
    padding: 20px;
    min-width: 360px;
    max-width: 90vw;
    border-radius: 4px;
}
#problems-modal .modal-dialog { border-color: #c00; width: 480px; min-width: 0; }
#confirm-modal .modal-dialog  { min-width: 380px; }
#manual-modal .modal-dialog   { min-width: 420px; }
#sync-modal .modal-dialog     { min-width: 520px; max-height: 80vh; overflow-y: auto; }

/* modal content elements */
.modal-heading { margin: 0 0 12px; color: #e0e0e0; font-weight: bold; }
#sync-modal   .modal-heading { margin-bottom: 6px; }
#manual-modal .modal-heading { margin-bottom: 8px; }
.modal-sub  { margin: 0 0 10px; color: #aaa; font-size: 0.9rem; }
.modal-body { margin-bottom: 16px; color: #ccc; font-size: 0.95rem; line-height: 1.7; }
.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
#manual-modal   .modal-actions { margin-top: 10px; }
#sync-modal     .modal-actions { margin-top: 14px; }
#problems-modal .modal-actions { margin-top: 0; }
.modal-actions button {
    font-size: 1rem;
    font-family: inherit;
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 5px 14px;
    cursor: pointer;
}
.modal-actions button:hover    { background: #383838; }
.modal-actions button:disabled { opacity: 0.5; cursor: default; }
.modal-actions button:focus    { outline: 2px solid #888; outline-offset: 2px; }
.modal-status { color: #aaa; font-size: 0.9rem; }
.modal-form-grid {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 8px 12px;
    align-items: center;
}
.modal-form-label { color: #aaa; font-size: 0.95rem; }
.modal-form-input {
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 5px 8px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
}
.modal-form-title { color: #e0e0e0; font-size: 1rem; }
.modal-full-input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 3px;
    font-size: 1rem;
}

/* ── Problems modal body helpers ────────────────────────────────────────── */
.problems-movie-row { display: flex; align-items: baseline; gap: 4px; }
.problems-label     { color: #aaa; white-space: nowrap; }

/* ── Problems modal ─────────────────────────────────────────────────────── */
#problems-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}
#problems-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0 0 8px;
    line-height: 1;
}
#problems-close-btn:hover { color: #e0e0e0; }
#problems-counter { margin: 0; color: #aaa; font-size: 0.9rem; }
#problems-type    { margin: 0 0 12px; color: #e0e0e0; font-weight: bold; font-size: 1rem; }
#problems-body .problem-movie-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* ── Sync modal table ───────────────────────────────────────────────────── */
#sync-modal-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.sync-modal-header { color: #888; border-bottom: 1px solid #444; }
.sync-modal-th      { text-align: left; padding: 4px 8px; }
.sync-modal-th-icon { padding: 4px; }
#sync-modal tr       { border-bottom: 1px solid #333; }
#sync-modal .sync-no-diff { color: #aaa; padding: 8px; }
.sync-td-label   { padding: 6px 8px; color: #aaa; font-weight: bold; vertical-align: top; white-space: nowrap; }
.sync-td-val-old { padding: 6px 8px; color: #ccc; vertical-align: top; max-width: 200px; word-break: break-word; }
.sync-td-arrow   { padding: 6px 4px; color: #555; vertical-align: top; }
.sync-td-val-new { padding: 6px 8px; color: #e0e0e0; vertical-align: top; max-width: 200px; word-break: break-word; }
.sync-td-action  { padding: 6px 4px; vertical-align: top; }
.sync-use-cache-btn { white-space: nowrap; }

/* ── Confirm modal ──────────────────────────────────────────────────────── */
#confirm-heading    { margin: 0 0 10px; color: #e0e0e0; font-weight: bold; }
#confirm-movie-info { margin-bottom: 12px; color: #ccc; font-size: 0.95rem; line-height: 1.5; }
#confirm-actions    { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* ── Identify page header ───────────────────────────────────────────────── */
.identify-header-row { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
#identify-pagination { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#identify-pagination button {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 1rem;
}
#identify-pagination button:disabled { opacity: 0.3; cursor: default; }
#identify-pagination button:not(:disabled):hover { background: #3a3a3a; }
#identify-page-indicator { font-size: 0.9rem; color: #aaa; min-width: 60px; text-align: center; }
#identify-search-input {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9rem;
    width: 160px;
}
.search-source-label { font-size: 0.85rem; color: #aaa; }
#search-source-select {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 2px 6px;
}
.controls-select {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.85rem;
    width: 100%;
}

/* ── Catalog page ───────────────────────────────────────────────────────── */
.catalog-control-label { font-size: 0.85rem; color: #aaa; }
#sort-label { white-space: nowrap; }
.header-select {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: 4px;
}
#catalog-search-input {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.85rem;
    width: 160px;
    display: none;
}
#catalog-status { font-size: 0.85rem; color: #888; }

/* Top progress bar */
#page-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: #f0b429;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
}

/* Settings page */
#settings-container { display: flex; flex-direction: column; width: 100%; height: 100vh; overflow: hidden; }
#settings-header { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid #3a3a3a; flex-shrink: 0; }
#settings-title { margin: 0; font-size: 1.1rem; color: #e0e0e0; }
#settings-content { padding: 24px 32px; overflow-y: auto; }
.settings-section { margin-bottom: 32px; }
.settings-section h2 { font-size: 0.9rem; color: #888; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px 0; border-bottom: 1px solid #2a2a2a; padding-bottom: 6px; }
.settings-row { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; }
.settings-label { color: #888; font-size: 0.85rem; min-width: 160px; flex-shrink: 0; }
.settings-value { color: #e0e0e0; font-size: 0.85rem; }
.settings-mono { font-family: monospace; font-size: 0.8rem; color: #b0b0b0; }
#sheet-value a { color: #f0b429; text-decoration: none; font-size: 0.85rem; }
#sheet-value a:hover { text-decoration: underline; }
.settings-control { display: flex; align-items: center; gap: 8px; }
.settings-number-input { background: #2a2a2a; border: 1px solid #444; color: #e0e0e0; border-radius: 4px; padding: 4px 8px; font-size: 0.85rem; width: 70px; }
.settings-checkbox-input { width: 18px; height: 18px; cursor: pointer; accent-color: #4285f4; }
.settings-save-btn { background: #2a4a2a; border: 1px solid #3a6a3a; color: #e0e0e0; border-radius: 4px; padding: 4px 10px; font-size: 0.8rem; cursor: pointer; }
.settings-save-btn:hover { background: #3a5a3a; }
.settings-save-btn:disabled { opacity: 0.5; cursor: default; }
.settings-reset-btn { background: none; border: none; color: #666; font-size: 1rem; cursor: pointer; padding: 0 2px; line-height: 1; }
.settings-reset-btn:hover { color: #aaa; }
.settings-reset-btn:disabled { opacity: 0.4; cursor: default; }
.settings-status { font-size: 0.8rem; color: #888; }
.settings-status.ok { color: #5a5; }
.settings-status.err { color: #a55; }

/* Help page */
#help-container { display: flex; flex-direction: column; width: 100%; height: 100vh; overflow: hidden; }
#help-header { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid #3a3a3a; flex-shrink: 0; }
#help-title { margin: 0; font-size: 1.1rem; color: #e0e0e0; }
#help-content { padding: 24px 32px; overflow-y: auto; max-width: 860px; }
.help-section { margin-bottom: 40px; }
.help-section h2 { font-size: 0.9rem; color: #888; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px 0; border-bottom: 1px solid #2a2a2a; padding-bottom: 6px; }
.help-subsection { font-size: 0.78rem; color: #777; text-transform: uppercase; letter-spacing: 0.05em; margin: 16px 0 8px 0; }
.help-description { color: #ccc; font-size: 0.85rem; line-height: 1.55; margin: 0 0 12px 0; }
.help-shortcuts-table { border-collapse: collapse; margin-bottom: 4px; }
.help-shortcuts-table td { padding: 3px 6px; vertical-align: top; font-size: 0.85rem; }
.help-shortcuts-table td:first-child { font-family: monospace; color: #e0e0e0; white-space: nowrap; min-width: 100px; }
.help-shortcuts-table td:last-child { color: #ccc; }
.help-list { color: #ccc; font-size: 0.85rem; line-height: 1.6; margin: 0; padding-left: 20px; }
.help-list li { margin-bottom: 6px; }
.help-list strong { color: #e0e0e0; }

/* ── sheets_bridge overlays — auth, popup-blocked, setup wizard ─────────── */
.sb-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); display: none;
    align-items: center; justify-content: center; z-index: 9999;
}
.sb-overlay--dark { background: rgba(0,0,0,0.8); }
.sb-modal {
    background: #2a2a2a; border: 1px solid #555; border-radius: 8px;
    padding: 32px; max-width: 480px; width: 90%;
    color: #e0e0e0; font-family: sans-serif;
}
.sb-modal--wide         { max-width: 520px; }
.sb-modal h2            { margin: 0 0 12px; font-size: 1.2rem; }
.sb-modal p             { color: #aaa; font-size: 0.9rem; margin: 0 0 12px; }
.sb-modal p:last-of-type { margin-bottom: 20px; }
.sb-btn-primary {
    background: #4285f4; color: #fff; border: none; border-radius: 4px;
    padding: 10px 20px; font-size: 1rem; cursor: pointer; width: 100%;
}
.sb-btn-primary--sm    { padding: 6px 14px; font-size: 0.85rem; width: auto; white-space: nowrap; }
.sb-btn-primary--error { background: #c33; }
.sb-setup-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 10px; padding: 10px 12px;
    background: #1e1e1e; border-radius: 6px; border: 1px solid #3a3a3a;
}
.sb-setup-row--done { opacity: 0.4; }
.sb-setup-row-info  { flex: 1; }
.sb-setup-tab-name  { font-size: 0.95rem; font-weight: bold; }
.sb-setup-tab-desc  { font-size: 0.82rem; color: #aaa; margin-top: 2px; }

/* ── Watch History page: preview panel extras ────────────────────────────── */
.preview-not-identified { color: #b8860b; }
#manual-imdb-input { margin-top: 4px; width: 100%; box-sizing: border-box; }
#manual-imdb-btn   { margin-top: 4px; }

/* ── Identify page: TMDb key missing card ───────────────────────────────── */
.tmdb-missing-card {
    max-width: 520px; margin: 60px auto; padding: 32px;
    background: #2a2a2a; border: 1px solid #555; border-radius: 8px;
    color: #e0e0e0; font-family: sans-serif;
}
.tmdb-missing-card h2   { margin: 0 0 16px; font-size: 1.2rem; }
.tmdb-missing-card p    { color: #aaa; font-size: 0.9rem; margin: 0 0 16px; }
.tmdb-missing-card ol   { color: #aaa; font-size: 0.9rem; margin: 0 0 16px; padding-left: 20px; line-height: 1.8; }
.tmdb-missing-card a    { color: #4285f4; }
.tmdb-missing-card code { background: #1e1e1e; padding: 1px 4px; border-radius: 3px; }

/* ── Identify page: title-mismatch confirm info ─────────────────────────── */
.title-mismatch-info        { margin-bottom: 8px; font-size: 0.9rem; color: #aaa; }
.title-mismatch-info strong { color: #e0e0e0; }

/* ── Console monitor (dev error overlay) ────────────────────────────────── */
#console-monitor-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 99999;
    background: #7a2020; color: #f0c0c0; font-family: monospace;
    font-size: 13px; padding: 6px 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.console-monitor-dismiss { opacity: 0.7; font-size: 11px; }
#console-monitor-overlay {
    position: fixed; top: 32px; left: 0; right: 0; z-index: 99998;
    background: #1a1a1a; color: #e0e0e0; font-family: monospace;
    font-size: 12px; max-height: 40vh; overflow-y: auto;
    border-bottom: 2px solid #7a2020; display: none; padding: 8px 12px;
}
.console-monitor-row      { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; border-bottom: 1px solid #333; }
.console-monitor-tag-error { color: #ff6b6b; }
.console-monitor-tag-warn  { color: #ffa94d; }
.console-monitor-msg       { flex: 1; white-space: pre-wrap; word-break: break-all; }
.console-monitor-copy {
    flex-shrink: 0; background: #333; color: #aaa; border: 1px solid #555;
    border-radius: 3px; padding: 1px 6px; font-size: 11px;
    cursor: pointer; font-family: monospace;
}
