/* ── Public gallery — modern dark theme ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Dev environment indicator ───────────────────────────────────────────── */
#dev-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: repeating-linear-gradient(
        -45deg,
        #f59e0b,
        #f59e0b 12px,
        #1a0f00 12px,
        #1a0f00 24px
    );
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
    padding: 4px 0;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
    pointer-events: none;
}

body { padding-top: 24px; }

body.dev-mode {
    --bg:        #130a00;
    --bg-raised: #1c1000;
    --bg-card:   #1a1100;
}

:root {
    --bg:           #080e1a;
    --bg-raised:    #0d1526;
    --bg-card:      #101c2e;
    --bg-card-h:    #162338;
    --border:       rgba(148,163,184,0.09);
    --border-h:     rgba(148,163,184,0.18);
    --accent:       #4f87ff;
    --accent-2:     #a78bfa;
    --accent-grd:   linear-gradient(135deg, #4f87ff, #a78bfa);
    --text:         #e2e8f5;
    --text-meta:    #8b99b2;
    --text-muted:   #4a5568;
    --danger:       #f87171;
    --radius-sm:    6px;
    --radius:       10px;
    --radius-lg:    14px;
    --shadow-md:    0 4px 18px rgba(0,0,0,.45);
    --shadow-lg:    0 8px 36px rgba(0,0,0,.55);
    --shadow-xl:    0 20px 64px rgba(0,0,0,.7);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    font-size: 15px;
    line-height: 1.5;
}

a            { color: var(--accent); text-decoration: none; }
a:visited    { color: var(--accent-2); }
a:hover      { color: var(--accent); opacity: 0.9; }

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 1.25rem 0 0.75rem;
}

h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-meta);
    margin: 0.25rem 0 0.75rem;
}

/* ── Main container ─────────────────────────────────────────────────────── */
.main-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* ── Breadcrumbs ────────────────────────────────────────────────────────── */
.breadcrumbs {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.breadcrumbs a {
    color: var(--text-meta);
    transition: color .12s;
}

.breadcrumbs a:hover { color: var(--accent); }

/* ── Search / controls form ─────────────────────────────────────────────── */
form.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

form.controls label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

input[type=text] {
    flex: 1;
    min-width: 160px;
    max-width: 340px;
    padding: 9px 13px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}

input[type=text]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,135,255,0.15);
}

input[type=text]::placeholder { color: var(--text-muted); }

select {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}

select:focus { border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
input[type=submit], button, a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity .12s, transform .12s, box-shadow .12s;
    border: none;
    white-space: nowrap;
    line-height: 1.4;
}

a.button, .button {
    background: var(--accent-grd);
    color: #fff !important;
    box-shadow: 0 2px 10px rgba(79,135,255,0.25);
}

a.button:hover, .button:hover:not([disabled]):not([aria-disabled="true"]) {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(79,135,255,0.38);
}

a.button.secondary, button.secondary {
    background: var(--bg-card);
    color: var(--text) !important;
    border: 1px solid var(--border);
    box-shadow: none;
}

a.button.secondary:hover, button.secondary:hover {
    background: var(--bg-card-h);
    border-color: var(--border-h);
}

.button.disabled {
    opacity: 0.32;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Result grid ────────────────────────────────────────────────────────── */
.result-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}

.thumb {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: visible;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: border-color .15s, box-shadow .15s;
}

.thumb:hover, .thumb.is-hovered {
    border-color: var(--border-h);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}
.thumb.is-hovered {
    z-index: 11;
}

.thumb.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79,135,255,0.28), var(--shadow-md);
}

/* Image wrapper: 16/9 aspect ratio so images always display fully */
.thumb > a {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #04080f;
    flex-shrink: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .2s ease, filter .2s ease;
}

.thumb img.playing {
    transform: scale(1.04);
    filter: saturate(115%);
}

/* ── Thumb metadata ─────────────────────────────────────────────────────── */
.meta {
    padding: 9px 11px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-meta);
    flex: 1;
}

.meta b a { color: var(--text); font-weight: 600; }
.meta b a:hover { color: var(--accent); }
.meta a { color: var(--text-meta); }
.meta a:hover { color: var(--accent); }
.meta small { font-size: 11.5px; }

/* Compact subtitle strip — always visible below the image */
.meta-sub {
    padding: 5px 10px 7px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    flex-shrink: 0;
    min-height: 26px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
    z-index: 2;
}

/* Details panel — drops below the card on hover */
.meta-hover {
    position: absolute;
    top: 100%;
    left: -1px;
    right: -1px;
    display: flex;
    flex-direction: column;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-meta);
    padding: 0 10px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .22s ease, opacity .22s ease, padding .22s ease;
    pointer-events: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-h);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    z-index: 10;
}

.thumb:hover .meta-hover, .thumb.is-hovered .meta-hover {
    max-height: 120px;
    opacity: 1;
    padding: 6px 10px 8px;
    pointer-events: auto;
}

.meta-hover b a { color: var(--text); font-weight: 600; }
.meta-hover b a:hover { color: var(--accent); }
.meta-hover a { color: var(--text-meta); }
.meta-hover a:hover { color: var(--accent); }
.meta-hover .muted { color: var(--text-muted); font-size: 11px; }

.meta-hover-actions {
    display: flex;
    flex-direction: row;
    gap: 4px;
    margin-top: 6px;
}
.meta-hover-actions .edit-btn,
.meta-hover-actions .regen-img-btn,
.meta-hover-actions .delete-img-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    font-size: 14px;
    border-radius: 4px;
    background: rgba(0,0,0,0.45);
}

.muted { color: var(--text-muted); font-size: 11px; }

/* ── Checkbox overlay ───────────────────────────────────────────────────── */
.thumb .checkbox-wrap {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 5px;
    border-radius: 6px;
    z-index: 20;
    display: none;
}

/* Show checkbox on hover for discoverability */
.thumb:hover .checkbox-wrap, .thumb.is-hovered .checkbox-wrap { display: block; }

/* Show all checkboxes once any image is selected */
body.has-selection .thumb .checkbox-wrap { display: block; }

.thumb .checkbox-wrap input[type=checkbox] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination .spacer { flex: 1; }

/* ── Image view page ────────────────────────────────────────────────────── */
.image-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.image-view img {
    max-width: min(880px, 92vw);
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.nav-buttons {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Lightbox ───────────────────────────────────────────────────────────── */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2,5,18,0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9900;
}

.lightbox-overlay.active { display: flex; }

.lightbox-card {
    position: relative;
    max-width: 88vw;
    max-height: 88vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #04080f;
    box-shadow: var(--shadow-xl);
}

.lightbox-card img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 88vh;
    transition: opacity .2s ease;
    opacity: 1;
}

.lightbox-card img.failed {
    filter: grayscale(60%) opacity(.6);
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 14px;
    line-height: 1;
    z-index: 10;
    transition: background .12s;
    font-family: inherit;
}

.lightbox-close:hover { background: rgba(0,0,0,0.88); }

.lightbox-nav {
    position: absolute;
    background: rgba(0,0,0,0.68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9950;
    box-shadow: var(--shadow-md);
    transition: background .12s, transform .12s;
    top: 50%;
    transform: translateY(-50%);
    font-family: inherit;
}

.lightbox-nav:hover {
    background: rgba(0,0,0,0.9);
    transform: translateY(-50%) scale(1.08);
}

.lightbox-nav:disabled {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
}

.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }

/* Lightbox spinner */
.lightbox-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.lightbox-spinner.visible { display: flex; }

.lightbox-spinner .dot {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: rgba(255,255,255,0.85);
    animation: lb-spin 0.85s linear infinite;
}

@keyframes lb-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Combine bar ────────────────────────────────────────────────────────── */
.combine-button { transition: all .18s ease; }

.combine-button.active { animation: pulse 1.2s infinite; }

@keyframes pulse {
    0%, 100% { transform: translateY(-1px) scale(1.01); }
    50%       { transform: translateY(-3px) scale(1.03); }
}

.combine-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 24px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 9800;
    pointer-events: auto;
}

/* floating combine button always visible */
#floatingCombineBtn { display: inline-flex; }

/* ── Shows overlay ──────────────────────────────────────────────────────── */
.shows-overlay { z-index: 9900; }

.shows-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-h);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    max-width: 660px;
    width: 92%;
    box-shadow: var(--shadow-xl);
    max-height: 82vh;
    overflow-y: auto;
}

.shows-card h3 {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.shows-card ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}

.shows-card ul li a {
    display: block;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    transition: background .12s, border-color .12s, color .12s;
}

.shows-card ul li a:hover {
    background: var(--bg-card-h);
    border-color: var(--accent);
    color: var(--accent);
}

.shows-card-close {
    float: right;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: color .12s, background .12s;
    font-family: inherit;
}

.shows-card-close:hover {
    color: var(--text);
    background: var(--bg-card);
}

/* ── Admin edit/delete buttons ──────────────────────────────────────────── */
.edit-btn {
    display: inline-block;
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    transition: color .12s, background .12s;
}

.edit-btn:hover { color: #fff; background: #335599; }

.regen-img-btn { display: inline-block; font-size: 13px; color: var(--text-muted); text-decoration: none; padding: 1px 4px; border-radius: 3px; margin-left: 4px; vertical-align: middle; transition: color .12s, background .12s; }
.regen-img-btn:hover { color: #fff; background: #335599; }
.regen-img-btn.spinning { display: inline-block; animation: regen-spin 0.7s linear infinite; pointer-events: none; opacity: 0.6; }
@keyframes regen-spin { to { transform: rotate(360deg); } }

.thumb-regen-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 5;
    pointer-events: none;
}
.thumb-regen-overlay .dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: rgba(255, 255, 255, 0.85);
    animation: regen-spin 0.7s linear infinite;
}

.delete-img-btn {
    display: inline-block;
    font-size: 11px;
    color: var(--danger);
    text-decoration: none;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 2px;
    vertical-align: middle;
    transition: color .12s, background .12s;
}

.delete-img-btn:hover { color: #fff; background: var(--danger); }

.delete-selected-btn {
    background: var(--danger) !important;
    color: #fff !important;
}

.delete-selected-btn:hover:not([aria-disabled="true"]) { opacity: 0.85; }

.delete-selected-btn[aria-disabled="true"] {
    opacity: 0.38;
    cursor: not-allowed;
}

/* ── Episode combined images section ────────────────────────────────────── */
.combined-section { margin-top: 32px; }
.combined-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 12px;
}
.combined-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.combined-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 300px;
}
.combined-card img.combined-thumb {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: opacity .15s;
}
.combined-card img.combined-thumb:hover { opacity: .82; }
.combined-comps { display: flex; flex-wrap: wrap; gap: 4px; }
.combined-comp-thumb {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    transition: border-color .12s;
}
.combined-comp-thumb:hover { border-color: var(--border-h); }
.combined-delete-btn {
    align-self: flex-start;
    background: none;
    border: 1px solid var(--border-h);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: .8rem;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .12s, color .12s;
}
.combined-delete-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 600px) {
    .main-container { padding: 0.9rem 1rem; }

    .result-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    input[type=text] {
        width: 100%;
        max-width: 100%;
    }

    form.controls { padding: 12px; gap: 8px; }

    h1 { font-size: 1.4rem; }
}

/* ── Dashboard widget system (admin) ────────────────────────────────────── */
.panel {
  background: #161a20;
  border: 1px solid #2a2f38;
  border-radius: 10px;
  margin-top: 1.25rem;
  overflow: hidden;
}
.panel-header {
  background: #1b212b;
  border-bottom: 1px solid #2a2f38;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.panel-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8f96a2;
}
.panel-body { padding: 1rem; }
.panel-collapse-btn {
  background: none;
  border: none;
  color: #6a7280;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.panel.collapsed .panel-collapse-btn { transform: rotate(-90deg); }
.panel.collapsed > .panel-body { display: none; }
.panel.collapsed .panel-header { border-bottom-color: transparent; }

.panel-drag-handle {
  cursor: grab;
  color: #2e3440;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
  padding-right: 0.1rem;
}
.panel-drag-handle:hover { color: #666; }
.panel-drag-handle:active { cursor: grabbing; }

.panel-summary {
  font-size: 0.75rem;
  color: #555;
  flex: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel.collapsed .panel-summary { opacity: 1; }

.panel.panel-dragging { opacity: 0.4; }
.panel.panel-drop-before { box-shadow: 0 -3px 0 0 #5b8dd9; }
.panel.panel-drop-after  { box-shadow: 0  3px 0 0 #5b8dd9; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.65rem;
}
.stat-card {
  background: #1b212b;
  border: 1px solid #2d3542;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  text-align: center;
}
.stat-value { font-size: 1.2rem; font-weight: 700; color: #edf2f7; }
.stat-label {
  color: #8b93a3;
  font-size: 0.72rem;
  text-transform: uppercase;
  margin-top: 0.15rem;
}

.job-card {
  background: #1e1e1e;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
}

.empty-state {
  color: #444;
  font-size: 0.88rem;
  padding: 2rem 0;
  text-align: center;
  border: 1px dashed #2a2a2a;
  border-radius: 8px;
}

.ws-indicator {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #555;
  display: inline-block;
}

.tool-card {
  background: #1e1e1e;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  padding: 1.4rem 1.2rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
  display: block;
}
.tool-card:hover { border-color: #5b8dd9; background: #1a2233; }
.tool-card .icon { font-size: 1.8rem; margin-bottom: 0.7rem; }
.tool-card .title { font-size: 1rem; font-weight: 600; color: #fff; margin-bottom: 0.3rem; }
.tool-card .desc { font-size: 0.82rem; color: #777; line-height: 1.4; }
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.back-link {
  display: inline-block;
  margin-top: 2.5rem;
  font-size: 0.83rem;
  color: #555;
  text-decoration: none;
}
.back-link:hover { color: #aaa; }
