:root {
    --bg-color: #0f172a; /* Deep Navy/Black */
    --card-bg: rgba(30, 41, 59, 0.7); /* Translucent Navy */
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --accent-banana: #fbbf24; /* Rich Banana Yellow */
    --accent-guava: #22c55e;  /* Vibrant Guava Green */
    --accent-pink: #f43f5e;   /* Guava Flesh Pink */
    --border-color: rgba(255, 255, 255, 0.1);
    --container-width: 1200px;
    --glass-bg: rgba(15, 23, 42, 0.8);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(251, 191, 36, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(34, 197, 94, 0.05) 0%, transparent 50%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

header {
    padding: 60px 0 40px;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-banana) 30%, var(--accent-guava) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.tagline-sub {
    font-size: 0.95rem;
    opacity: 0.7;
    margin-top: 8px;
    font-weight: 500;
}

.tribute-banner {
    background: rgba(251, 191, 36, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.1);
    border-radius: 12px;
    padding: 12px 24px;
    margin-bottom: 30px;
    text-align: center;
    font-size: 0.9rem;
}

.tribute-banner p {
    color: var(--text-muted);
    margin: 0;
}

.tribute-banner a {
    color: var(--accent-banana);
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
    transition: all 0.2s;
}

.tribute-banner a:hover {
    color: var(--accent-guava);
    text-decoration: underline;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    padding: 20px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.search-box {
    flex-grow: 1;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.5);
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-banana);
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.1);
}

.filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Preview Toggle Styles */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 8px;
    background: rgba(15, 23, 42, 0.4);
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.toggle-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-banana);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-banana);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Preview Card Styling */
.card.is-preview {
    opacity: 0.6;
    border-style: dashed;
    position: relative;
}

.card.is-preview:hover {
    opacity: 0.9;
}

.preview-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-pink);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 10;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

select {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.5);
    color: var(--text-color);
    cursor: pointer;
    font-weight: 500;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    gap: 8px;
}

.btn-primary {
    background: rgba(15, 23, 42, 0.8);
    color: var(--accent-banana);
    border: 1px solid var(--accent-guava);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--accent-banana);
    color: var(--accent-banana);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.stats-bar {
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.items-per-page-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.items-per-page-control select {
    padding: 6px 12px;
    font-size: 0.9rem;
    background-color: rgba(15, 23, 42, 0.6);
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 60px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(251, 191, 36, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.card-image {
    width: 100%;
    height: 200px;
    background-color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.card:hover .card-image img {
    transform: scale(1.1);
}

.card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 12px;
}

.card-category-tag {
    display: inline-flex;
    padding: 6px 14px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--accent-guava);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    align-self: flex-start;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.hashtag {
    color: var(--accent-banana);
    font-size: 0.8rem;
    font-weight: 500;
    margin-right: 12px;
    opacity: 0.7;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    margin-top: auto;
}

.card-content {
    background-color: rgba(15, 23, 42, 0.4);
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #94a3b8;
}

/* Modal Styles Core */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 5vh auto;
    width: 95%;
    max-width: 1100px;
    max-height: 90vh; /* Use max-height instead of fixed height */
    height: auto;
    border-radius: 24px;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.close-button {
    position: absolute;
    right: 24px;
    top: 20px;
    color: var(--text-muted);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
    transition: color 0.2s;
}

/* Single scroll container for the entire modal content */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 45px;
    display: block; /* Use block for natural flow */
    scroll-behavior: smooth;
}

/* Scrollbar styling for a cleaner look */
.modal-body::-webkit-scrollbar {
    width: 8px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-banana);
}

/* Top section: Image and Meta Info */
.modal-header-section {
    display: flex;
    gap: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.modal-left {
    flex: 1;
    min-width: 300px;
    max-height: 450px;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.modal-left img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-right {
    flex: 1.2;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Bottom section: Expanded Prompt Content */
.modal-content-section {
    width: 100%;
    border-top: 1px solid var(--border-color);
    padding-top: 40px;
}

.modal-info {
    display: flex;
    flex-direction: column;
    gap: 32px; /* Large gap between major sections */
}

.info-group {
    display: flex;
    flex-direction: column;
    gap: 12px; /* Gap between label and content */
}

.info-group label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-guava);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.info-value {
    color: #e2e8f0;
    line-height: 1.8;
}

.prompt-container-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

.btn-copy-floating {
    position: absolute;
    right: 12px;
    top: 12px;
    padding: 6px 16px;
    font-size: 0.8rem;
    z-index: 5;
    background: var(--accent-banana);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    color: #000;
}

.info-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 8px;
}

#modalCopyBtn {
    background: rgba(251, 191, 36, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--accent-banana);
    padding: 6px 16px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#modalCopyBtn:hover {
    background: rgba(251, 191, 36, 0.15);
    border-color: var(--accent-banana);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
    transform: translateY(-1px);
}

#modalCopyBtn.copied {
    background: var(--accent-guava);
    border-color: var(--accent-guava);
    color: white;
}

.prompt-display {
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.8;
    color: #cbd5e1;
    max-height: 450px;
    overflow-y: auto;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    white-space: pre-wrap;
}

#modalNotes {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
    color: #94a3b8;
}

.modal-footer-actions {
    margin-top: 10px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
}

.btn-banana {
    background: linear-gradient(135deg, var(--accent-banana) 0%, #f59e0b 100%);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
    color: #000;
}

.btn-guava {
    background: transparent;
    color: var(--accent-guava);
    border: 1px solid var(--accent-guava);
    box-shadow: none;
    font-weight: 700;
}

.btn-guava:hover {
    transform: translateY(-2px);
    background: rgba(34, 197, 94, 0.1);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.2);
    color: var(--accent-guava);
}

.info-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.info-header .btn {
    width: 130px;       /* Fixed width for identical size */
    height: 40px;       /* Fixed height */
    padding: 0;         /* Clear padding to ensure width is exact */
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.info-header .spacer {
    display: none; /* No longer needed if full width */
}

.modal-footer-actions {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

@media (max-width: 1024px) {
    :root {
        --container-width: 95%;
    }
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    header {
        padding: 40px 0 20px;
    }

    header h1 {
        font-size: 2.5rem;
    }

    header p {
        font-size: 1rem;
        padding: 0 20px;
    }

    .toolbar {
        padding: 15px;
        margin-bottom: 20px;
    }

    .filters {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .filters select, .filters .btn {
        width: 100%;
    }

    .toggle-container {
        justify-content: space-between;
        margin-right: 0;
    }

    .prompt-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-body {
        padding: 20px;
        padding-top: 60px;
    }

    .modal-header-section {
        flex-direction: column;
        gap: 20px;
    }

    .modal-left {
        max-height: 300px;
        min-width: unset;
    }

    .modal-right {
        min-width: unset;
    }

    .modal-action-buttons {
        flex-direction: column;
    }

    .modal-action-buttons .btn {
        width: 100%;
    }

    .info-header {
        flex-direction: column;
        align-items: stretch;
    }

    .info-header .btn {
        width: 100%;
    }

    .close-button {
        top: 10px;
        right: 15px;
        background: rgba(15, 23, 42, 0.8);
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 24px;
    }

    /* Submission Form mobile adjustments */
    .form-row-2col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    header h1 {
        font-size: 2rem;
    }

    .tagline-sub {
        font-size: 0.85rem;
    }

    .category-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px 20px -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .category-badge {
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .stats-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .items-per-page-control {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 600px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Category Filters (Badges/Shields) */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding: 0 4px;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 50px; /* Pill shape */
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.category-badge:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    color: var(--text-color);
}

.category-badge.active {
    background: var(--accent-guava);
    color: #fff;
    border-color: var(--accent-guava);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    margin-bottom: 60px;
    flex-wrap: wrap;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    width: auto;
    padding: 0 15px;
    height: 40px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.page-btn.active {
    background: var(--accent-banana);
    color: #0f172a;
    border-color: var(--accent-banana);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn span {
    font-size: 1.2rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.page-btn span:first-child {
    margin-right: 4px;
}

.page-btn span:last-child {
    margin-left: 4px;
}

.page-dots {
    color: var(--text-muted);
    margin: 0 4px;
}

/* Suggestions Dropdown */
.suggestions-dropdown {
    position: absolute;
    background: #1e293b;
    border: 1px solid var(--accent-banana);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    width: 300px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    .suggestions-dropdown {
        max-height: 200px;
        width: 250px;
    }
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    color: white;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover, .suggestion-item.active {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-banana);
}

/* Variable Placeholder & Popover */
.variable-placeholder {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 2px;
    background-color: rgba(34, 197, 94, 0.15); /* Guava green tint */
    border: 1px dashed var(--accent-guava);
    border-radius: 6px;
    color: var(--accent-guava);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.variable-placeholder:hover {
    background-color: rgba(34, 197, 94, 0.25);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
    transform: translateY(-1px);
}

.variable-placeholder.filled {
    border-style: solid;
    background-color: var(--accent-guava);
    color: #000;
    font-weight: 600;
}

.variable-popover {
    position: absolute; /* Will be overridden to fixed by JS but good fallback */
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2000;
    min-width: 200px;
    max-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
    animation: fadeIn 0.15s ease-out;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    .variable-popover {
        max-height: 250px;
        min-width: 200px;
        max-width: 85vw;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.popover-header {
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 4px;
}

.popover-option {
    padding: 10px 16px;
    cursor: pointer;
    color: #fff;
    transition: background 0.1s;
    font-size: 0.95rem;
}

.popover-option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-banana);
}

.popover-input-wrapper {
    padding: 12px;
    display: flex;
    gap: 8px;
}

.popover-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid #475569;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
}

.popover-btn {
    padding: 6px 12px;
    background: var(--accent-guava);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}