/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #121212;
    --surface:      #1e1e1e;
    --surface-2:    #2a2a2a;
    --surface-3:    #333;
    --accent:       #5c6bc0;
    --accent-light: #7986cb;
    --accent-dark:  #3949ab;
    --text:         #e0e0e0;
    --text-muted:   #757575;
    --text-hint:    #9e9e9e;
    --error:        #ef5350;
    --success:      #66bb6a;
    --warning:      #ffa726;
    --radius:       12px;
    --radius-sm:    6px;
    --shadow:       0 2px 8px rgba(0,0,0,.5);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.7);
    --transition:   .2s ease;
}

html { scroll-behavior: smooth; }

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

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ─── Typography ────────────────────────────────────────────────────────────── */
h1, h2, h3 { font-weight: 700; line-height: 1.3; }
p { color: var(--text-hint); }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--surface-3);
    padding: .75rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.header-brand .brand-icon {
    color: var(--accent-light);
    font-size: 1.4rem;
}

.header-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.header-search {
    flex: 1;
    min-width: 180px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: .45rem .8rem .45rem 2.2rem;
    background: var(--surface-2);
    border: 1px solid var(--surface-3);
    border-radius: 24px;
    color: var(--text);
    font-size: .9rem;
    outline: none;
    transition: border-color var(--transition);
}

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

.header-search .search-icon {
    position: absolute;
    left: .65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .9rem;
    pointer-events: none;
}

.header-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-shrink: 0;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .9rem;
    border-radius: var(--radius-sm);
    border: none;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition), transform .1s;
    white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--accent);    color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--surface-3); }
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost    { background: transparent; color: var(--accent-light); }
.btn-ghost:hover { background: rgba(92,107,192,.12); }

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

.btn-icon {
    padding: .4rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: color var(--transition), background var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { color: var(--text); background: var(--surface-2); }

.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ─── Main Layout ───────────────────────────────────────────────────────────── */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ─── Stats bar ─────────────────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    font-size: .85rem;
    color: var(--text-muted);
    align-items: center;
}

.stats-bar strong { color: var(--text); }

/* ─── Masonry Grid ──────────────────────────────────────────────────────────── */
.phrases-grid {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.phrases-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.phrase-card {
    break-inside: avoid;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.phrase-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.phrase-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .5rem;
}

.phrase-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    word-break: break-word;
}

.phrase-title.no-title { color: var(--text-muted); font-style: italic; font-weight: 400; }

.copy-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: .1rem .25rem;
    border-radius: 4px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
}
.phrase-card:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); background: var(--surface-2); }
.copy-btn--ok { color: #4caf50 !important; opacity: 1 !important; }

.phrase-body {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: .35rem;
}
.phrase-body .phrase-text { flex: 1; }
.copy-btn--text { align-self: flex-start; margin-top: .1rem; }

.phrase-text {
    font-size: .9rem;
    color: var(--text-hint);
    word-break: break-word;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.phrase-text.expanded {
    -webkit-line-clamp: unset;
}

.phrase-meta {
    font-size: .78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .4rem;
}

.phrase-actions {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    padding-top: .4rem;
    border-top: 1px solid var(--surface-3);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    padding: .15rem .45rem;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
}

.badge.has-images { background: rgba(92,107,192,.2); color: var(--accent-light); }
.badge.has-articles { background: rgba(102,187,106,.15); color: var(--success); }

/* ─── Empty & Loading States ───────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: 1rem; }

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 3rem;
    color: var(--text-muted);
}

/* ─── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--surface-3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

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

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

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

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-in .2s ease;
}

.modal-lg { max-width: 780px; }

@keyframes modal-in {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    padding: 1rem 1.25rem .75rem;
    border-bottom: 1px solid var(--surface-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 { font-size: 1rem; color: var(--text); }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--surface-3);
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    flex-shrink: 0;
}

/* ─── Form Controls ─────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .85rem;
    color: var(--text-hint);
    margin-bottom: .35rem;
}

.form-control {
    width: 100%;
    padding: .5rem .75rem;
    background: var(--surface-2);
    border: 1px solid var(--surface-3);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .9rem;
    outline: none;
    transition: border-color var(--transition);
}

.form-control:focus { border-color: var(--accent); }
select.form-control option { background: var(--surface); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

/* ─── Prompt Preview ────────────────────────────────────────────────────────── */
.prompt-preview {
    background: var(--bg);
    border: 1px solid var(--surface-3);
    border-radius: var(--radius-sm);
    padding: .75rem;
    font-size: .8rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
}

/* ─── Image Result ──────────────────────────────────────────────────────────── */
.image-result {
    text-align: center;
    margin-top: .75rem;
}

.image-result img {
    max-width: 100%;
    max-height: 420px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: block;
    margin: 0 auto;
}

.image-meta {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .4rem;
}

/* ─── Image Gallery ─────────────────────────────────────────────────────────── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .75rem;
}

.gallery-item {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform var(--transition);
}

.gallery-item:hover { transform: scale(1.03); }

.gallery-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.gallery-item-meta {
    padding: .4rem .5rem;
    font-size: .72rem;
    color: var(--text-muted);
}

.gallery-item-actions {
    position: absolute;
    top: .3rem;
    right: .3rem;
    display: flex;
    gap: .2rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.gallery-item:hover .gallery-item-actions { opacity: 1; }

.gallery-item-actions button {
    background: rgba(0,0,0,.7);
    border: none;
    color: #fff;
    border-radius: 4px;
    padding: .25rem .35rem;
    cursor: pointer;
    font-size: .75rem;
    line-height: 1;
}

.gallery-item-actions button:hover { background: rgba(0,0,0,.9); }

/* ─── Article Content ───────────────────────────────────────────────────────── */
.article-content {
    background: var(--bg);
    border: 1px solid var(--surface-3);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    font-size: .9rem;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 420px;
    overflow-y: auto;
}

.article-list-item {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    margin-bottom: .5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .5rem;
}

.article-list-item .article-preview {
    font-size: .85rem;
    color: var(--text-hint);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-list-item .article-date {
    font-size: .75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── Progress / Status ─────────────────────────────────────────────────────── */
.progress-section {
    text-align: center;
    padding: 2rem 1rem;
}

.progress-section p {
    margin-top: .75rem;
    font-size: .9rem;
    color: var(--text-muted);
}

/* ─── Login overlay ─────────────────────────────────────────────────────────── */
.login-form {
    max-width: 320px;
    margin: 0 auto;
}

.login-form h3 { margin-bottom: 1rem; color: var(--text); }

/* ─── Alert / Toast ─────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    padding: .6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    color: #fff;
    box-shadow: var(--shadow-lg);
    animation: toast-in .25s ease, toast-out .3s ease 3s forwards;
    pointer-events: all;
    max-width: 320px;
}

.toast.success { background: #2e7d32; }
.toast.error   { background: #c62828; }
.toast.info    { background: var(--accent-dark); }

@keyframes toast-in  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; pointer-events: none; } }

/* ─── Filter Chips ──────────────────────────────────────────────────────────── */
.filter-chips {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.filter-chip {
    padding: .25rem .65rem;
    border-radius: 16px;
    border: 1px solid var(--surface-3);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .78rem;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.filter-chip:hover {
    border-color: var(--accent);
    color: var(--text);
}

.filter-chip.active {
    background: rgba(92,107,192,.2);
    border-color: var(--accent);
    color: var(--accent-light);
    font-weight: 600;
}

/* ─── Gen Steps ─────────────────────────────────────────────────────────────── */
.gen-steps {
    list-style: none;
    padding: 0;
    margin: 1rem auto 0;
    max-width: 320px;
    text-align: left;
}

.gen-step {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 0;
    position: relative;
}

.gen-step + .gen-step::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 0;
    height: .55rem;
    width: 2px;
    background: var(--surface-3);
    transform: translateY(-100%);
}

.gen-step.done + .gen-step::before { background: var(--success); }

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 2px solid var(--surface-3);
    background: var(--surface-2);
    color: var(--text-muted);
    transition: all .3s ease;
}

.gen-step.active .step-dot {
    border-color: var(--accent);
    background: rgba(92,107,192,.2);
    color: var(--accent-light);
    animation: step-pulse 1.5s ease infinite;
}

.gen-step.done .step-dot {
    border-color: var(--success);
    background: rgba(102,187,106,.2);
    color: transparent;
    font-size: 0;
}

.gen-step.done .step-dot::after {
    content: '✓';
    font-size: .8rem;
    color: var(--success);
}

.step-label {
    font-size: .88rem;
    color: var(--text-muted);
    transition: color .3s ease;
}

.gen-step.active .step-label { color: var(--text); }
.gen-step.done  .step-label  { color: var(--text-hint); text-decoration: line-through; }

@keyframes step-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(92,107,192,.3); }
    50%       { box-shadow: 0 0 0 5px rgba(92,107,192,0); }
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .phrases-grid { flex-direction: column; }
    .phrases-col { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .header-inner { gap: .5rem; }
    .header-brand h1 { font-size: .95rem; }
    .filter-chips { margin-left: 0; }
}

/* ─── Galeria Global ─────────────────────────────────────────────────────────── */
#gallery-section {
    min-height: calc(100svh - var(--header-height, 64px));
    padding: 0 0 4rem;
    background: var(--bg-primary);
}

.gallery-section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem var(--content-pad, 1rem);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: var(--header-height, 64px);
    z-index: 100;
}

#gallery-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.gallery-global-grid {
    columns: 2;
    column-gap: .5rem;
    padding: 1rem var(--content-pad, 1rem);
}

@media (min-width: 480px) { .gallery-global-grid { columns: 3; } }
@media (min-width: 768px)  { .gallery-global-grid { columns: 4; } }
@media (min-width: 1100px) { .gallery-global-grid { columns: 5; } }

.gallery-tile {
    break-inside: avoid;
    page-break-inside: avoid;
    display: block;
    margin-bottom: .5rem;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    aspect-ratio: 3 / 4; /* padrão skeleton; substituído inline por JS */
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.gallery-tile:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    z-index: 1;
    position: relative;
}

.tile-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.tile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity .3s;
}

/* skeleton pulse */
.gallery-tile--skeleton .tile-img {
    opacity: 0;
}

.gallery-tile--skeleton .tile-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        var(--bg-card) 25%, var(--bg-secondary) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.4s infinite;
}

@keyframes skeleton-pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.gallery-tile--loaded .tile-inner::before { display: none; }
.gallery-tile--error { opacity: .4; }
.gallery-tile--error .tile-inner::before { display: none; }

.tile-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem .6rem .5rem;
    background: linear-gradient(to top, rgba(0,0,0,.8) 0%, transparent 100%);
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.tile-label {
    font-size: .72rem;
    color: rgba(255,255,255,.9);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tile-badges {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
}

.tile-badge {
    font-size: .6rem;
    background: rgba(92,107,192,.55);
    color: #c5cae9;
    padding: .1em .4em;
    border-radius: 3px;
    white-space: nowrap;
}

.tile-badge--fin {
    background: rgba(38,166,154,.45);
    color: #b2dfdb;
}

.gallery-loader {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.gallery-loader.hidden { display: none; }

.gallery-end {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: .82rem;
}

.gallery-end.hidden { display: none; }

/* Lightbox da galeria (id=glb) — herda estilos do #lightbox */
#glb {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,.95);
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
}

#glb.open { display: flex; }

/* área da imagem principal ocupa todo espaço disponível */
#glb .lb-img-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    padding: 3rem 3.5rem .5rem;
}

#glb #glb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 40px rgba(0,0,0,.8);
    user-select: none;
    -webkit-user-drag: none;
    display: block;
}

#glb .lb-meta {
    flex-shrink: 0;
    color: rgba(255,255,255,.75);
    font-size: .8rem;
    text-align: center;
    padding: .3rem 3rem .1rem;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#glb .lb-counter {
    flex-shrink: 0;
    color: rgba(255,255,255,.35);
    font-size: .72rem;
    text-align: center;
    padding-bottom: .3rem;
}

/* ─── Strip de thumbnails ───────────────────────────────────────────────── */
.lb-thumbs {
    flex-shrink: 0;
    display: flex;
    gap: .3rem;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding: .4rem .6rem .6rem;
    background: rgba(0,0,0,.6);
    border-top: 1px solid rgba(255,255,255,.08);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

.lb-thumbs::-webkit-scrollbar { height: 4px; }
.lb-thumbs::-webkit-scrollbar-track { background: transparent; }
.lb-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.lb-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-card);
    cursor: pointer;
    border: 2px solid transparent;
    opacity: .45;
    transition: opacity .2s, border-color .2s, transform .15s;
}

.lb-thumb:hover  { opacity: .8;  transform: scale(1.06); }
.lb-thumb.active { border-color: var(--primary, #5c6bc0); opacity: 1; }

.lb-thumb.lb-thumb--empty {
    background-image: none;
    background-color: var(--bg-secondary);
    position: relative;
}
.lb-thumb.lb-thumb--empty::after {
    content: '🖼️';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    opacity: .4;
}

@media (max-width: 480px) {
    .lb-thumb { width: 42px; height: 42px; }
}

.lb-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    position: absolute;
}

/* btn-gallery ativo */
#btn-gallery.active {
    color: var(--primary-light, #9fa8da);
    border-color: var(--primary-light, #9fa8da);
}

/* ─── Lightbox ──────────────────────────────────────────────────────────────── */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,.92);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1rem;
}

#lightbox.open { display: flex; }

.lb-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: calc(100svh - 5rem);
    width: 100%;
}

#lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 40px rgba(0,0,0,.8);
    user-select: none;
    -webkit-user-drag: none;
}

.lb-close {
    position: fixed;
    top: .75rem;
    right: .75rem;
    background: rgba(0,0,0,.6);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    z-index: 2010;
}

.lb-close:hover { background: rgba(255,255,255,.2); }

.lb-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,.5);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    font-size: 2.5rem;
    line-height: 1;
    width: 2.75rem;
    height: 4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    z-index: 2010;
    padding: 0;
}

.lb-nav:hover { background: rgba(255,255,255,.15); }

.lb-prev { left: .5rem; }
.lb-next { right: .5rem; }

.lb-meta {
    color: rgba(255,255,255,.7);
    font-size: .82rem;
    text-align: center;
    max-width: 90%;
}

.lb-counter {
    color: rgba(255,255,255,.4);
    font-size: .75rem;
    text-align: center;
}

@media (max-width: 640px) {
    .lb-nav { width: 2.25rem; height: 3.25rem; font-size: 2rem; }
    .lb-prev { left: .2rem; }
    .lb-next { right: .2rem; }
}
