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

:root {
    --bg: #0a0a0a;
    --surface: #1a1a1a;
    --surface-hover: #252525;
    --accent: #4a9eff;
    --text: #e0e0e0;
    --text-dim: #888;
    --warning-bg: #1a1a00;
    --warning-border: #b8860b;
    --warning-text: #d4a843;
    --radius: 8px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 0 20px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.tagline {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Disclaimer banner */
.banner {
    background: var(--warning-bg);
    border-left: 3px solid var(--warning-border);
    padding: 12px 16px;
    margin-bottom: 24px;
    font-size: 0.85rem;
    color: var(--warning-text);
    border-radius: 0 var(--radius) var(--radius) 0;
    line-height: 1.6;
}

.banner a {
    color: var(--accent);
    text-decoration: none;
}

.banner a:hover {
    text-decoration: underline;
}

/* Controls */
#controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
}

.control-label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.filter-group,
.sort-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-btn {
    background: transparent;
    border: 1px solid #333;
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

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

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    font-weight: 600;
}

#sort-select {
    background: var(--bg);
    border: 1px solid #333;
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

#sort-select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

#count-display {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Gallery */
#gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s;
}

.card:hover {
    background: var(--surface-hover);
}

.card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.card .label {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.card .label strong {
    color: var(--text);
    font-weight: 600;
}

/* Empty state */
#empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* Lightbox modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    z-index: 1;
}

.modal-close:hover {
    color: var(--accent);
}

/* Windowing toolbar */
.windowing-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    width: 100%;
}

.windowing-toolbar button,
.preset-btn {
    background: var(--surface);
    border: 1px solid #333;
    color: var(--text-dim);
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.15s;
}

.windowing-toolbar button:hover {
    border-color: var(--accent);
    color: var(--text);
}

.windowing-toolbar button.active,
.preset-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    font-weight: 600;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: #333;
    margin: 0 4px;
}

/* Canvas */
#lightbox-canvas {
    max-width: 85vw;
    max-height: 72vh;
    border-radius: var(--radius);
    cursor: crosshair;
    display: block;
}

/* Windowing status */
.windowing-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 8px;
    padding: 0 4px;
}

#wl-display {
    font-size: 0.8rem;
    color: var(--accent);
    font-family: 'Courier New', Courier, monospace;
}

.windowing-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin: 0;
}

.modal-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    margin-top: 8px;
    padding: 0 4px;
}

#lightbox-meta {
    font-size: 0.9rem;
    color: var(--text);
}

.btn-report {
    font-size: 0.8rem;
    color: var(--warning-text);
    text-decoration: none;
    border: 1px solid var(--warning-border);
    padding: 6px 12px;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-report:hover {
    background: var(--warning-bg);
    color: #fff;
}

/* Feedback Section */
#feedback-section {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius);
}

.feedback-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#upvote-btn {
    background: #1a3a1a;
    border: 1px solid #2d5a2d;
    color: #6fbf6f;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

#upvote-btn:hover {
    background: #2d5a2d;
    border-color: #4a8a4a;
}

#upvote-btn.voted {
    background: #2d5a2d;
    border-color: #4a8a4a;
    cursor: default;
}

#upvote-count {
    font-size: 0.8rem;
    color: var(--text-dim);
}

#report-toggle {
    background: transparent;
    border: 1px solid var(--warning-border);
    color: var(--warning-text);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: auto;
    transition: all 0.15s;
}

#report-toggle:hover {
    background: var(--warning-bg);
}

/* Report Form */
#report-form {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #333;
}

#report-form select,
#report-form textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid #333;
    color: var(--text);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    margin-bottom: 10px;
}

#report-form select:focus,
#report-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

#report-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* Honeypot - hidden from humans */
#hp-field {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Turnstile widget */
.cf-turnstile {
    margin-bottom: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
}

#submit-report-btn {
    background: var(--accent);
    border: none;
    color: #000;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: opacity 0.15s;
}

#submit-report-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#submit-report-btn:not(:disabled):hover {
    opacity: 0.9;
}

#cancel-report-btn {
    background: transparent;
    border: 1px solid #333;
    color: var(--text-dim);
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

#cancel-report-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* Footer */
footer {
    margin-top: 60px;
    padding-top: 32px;
    border-top: 1px solid #222;
}

.disclaimer-section h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text);
}

.disclaimer-section h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-top: 20px;
    margin-bottom: 6px;
}

.disclaimer-section p {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.7;
}

.disclaimer-section a {
    color: var(--accent);
    text-decoration: none;
}

.disclaimer-section a:hover {
    text-decoration: underline;
}

.footer-bottom {
    margin-top: 32px;
    padding: 16px 0;
    border-top: 1px solid #222;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Responsive */
@media (max-width: 600px) {
    header {
        padding: 24px 0 16px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    #controls {
        flex-direction: column;
        align-items: flex-start;
    }

    #count-display {
        margin-left: 0;
    }

    #gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .modal-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .windowing-toolbar {
        gap: 4px;
    }

    .windowing-toolbar button,
    .preset-btn {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .windowing-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .feedback-row {
        flex-direction: column;
        align-items: stretch;
    }

    #report-toggle {
        margin-left: 0;
    }

    .form-actions {
        flex-direction: column;
    }

    #submit-report-btn,
    #cancel-report-btn {
        width: 100%;
    }
}
