/* Version 1.0.9 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
    /* Unified light theme */
    --bg-primary: #f4f7fb;
    --bg-secondary: #ffffff;
    --border: rgba(148, 163, 184, 0.25);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent: #f97316;
    --brand: #a5dc92;
    --brand-strong: #ea580c;
    --surface-border: rgba(148, 163, 184, 0.22);
    --surface-radius: 18px;
    --surface-shadow: 0 20px 45px rgba(15, 23, 42, 0.12), 0 8px 24px rgba(15, 23, 42, 0.1);
    --surface-glass: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.82));
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: radial-gradient(900px 620px at 12% 0%, rgba(37, 99, 235, 0.08), transparent 60%),
        radial-gradient(640px 480px at 90% 8%, rgba(14, 165, 233, 0.08), transparent 65%),
        var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

body.nav-open {
    overflow: hidden;
}

header {
    background: var(--brand);
    padding: 12px 24px;
    border-bottom: 1px solid var(--surface-border);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
}

body > header {
    position: relative;
    z-index: 2000;
}

header .container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 32px;
}

.app-name {
    margin: 0;
}

.app-name a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 24px;
    display: inline-flex;
    align-items: center;
}

.app-logo {
    display: block;
    height: 48px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1 1 auto;
    min-width: 0;
    position: relative;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 8px;
    margin: 0;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.close-nav {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    cursor: pointer;
}

.close-nav:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
    background-color: rgba(0, 0, 0, 0.05);
    outline: none;
}

.menu-toggle:focus-visible {
    box-shadow: 0 0 0 2px var(--accent);
}

.menu-toggle-icon {
    position: relative;
    display: block;
    width: 20px;
    height: 2px;
    background-color: currentColor;
    border-radius: 1px;
    transition: background-color 0.2s ease;
}

.menu-toggle-icon::before,
.menu-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    border-radius: 1px;
    transition: transform 0.2s ease, top 0.2s ease, bottom 0.2s ease, opacity 0.2s ease;
}

.menu-toggle-icon::before {
    top: -6px;
}

.menu-toggle-icon::after {
    bottom: -6px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon {
    background-color: transparent;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon::after {
    bottom: 0;
    transform: rotate(-45deg);
}

.main-nav {
    margin-right: auto;
    min-width: 0;
}

.main-nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.main-nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

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

.user-menu {
    position: relative;
    margin-left: auto;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Unified button system */
.btn,
form input[type="submit"],
form button[type="submit"],
.update-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 18px 38px rgba(249, 115, 22, 0.28);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    white-space: nowrap;
}

.btn:hover,
.btn:focus-visible,
form input[type="submit"]:hover,
form input[type="submit"]:focus-visible,
form button[type="submit"]:hover,
form button[type="submit"]:focus-visible,
.update-button:hover,
.update-button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 24px 48px rgba(249, 115, 22, 0.32);
    filter: brightness(1.03);
    outline: none;
}

.btn:focus-visible,
form input[type="submit"]:focus-visible,
form button[type="submit"]:focus-visible,
.update-button:focus-visible {
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.28), 0 22px 45px rgba(249, 115, 22, 0.3);
}

.btn--ghost,
form input[type="submit"].btn--ghost,
form button[type="submit"].btn--ghost,
.update-button.btn--ghost {
    background: rgba(249, 115, 22, 0.12);
    color: var(--brand-strong);
    border-color: rgba(249, 115, 22, 0.24);
    box-shadow: 0 16px 28px rgba(249, 115, 22, 0.18);
}

.btn--ghost:hover,
.btn--ghost:focus-visible,
form input[type="submit"].btn--ghost:hover,
form input[type="submit"].btn--ghost:focus-visible,
form button[type="submit"].btn--ghost:hover,
form button[type="submit"].btn--ghost:focus-visible,
.update-button.btn--ghost:hover,
.update-button.btn--ghost:focus-visible {
    background: rgba(249, 115, 22, 0.18);
}

.btn--sm,
.update-button {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    box-shadow: 0 14px 28px rgba(249, 115, 22, 0.25);
}

.sort-order-input {
    width: 5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
    transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sort-order-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
    outline: none;
    background: #ffffff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.is-hidden {
    display: none !important;
}

.user-icon {
    font-size: 28px;
    cursor: pointer;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 48px;
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
    width: 220px;
    border-radius: 16px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.close-dropdown {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.close-dropdown:hover,
.close-dropdown:focus-visible {
    color: var(--brand-strong);
    outline: none;
}

.user-dropdown .email {
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(255, 255, 255, 0.82);
}

.user-dropdown .credits {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px 14px;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(255, 255, 255, 0.75);
}

.user-dropdown .credits .add-credits-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand-strong);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-dropdown .credits .add-credits-link:hover,
.user-dropdown .credits .add-credits-link:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.35);
    outline: none;
}

.user-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.user-dropdown ul li a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.user-dropdown ul li a:hover,
.user-dropdown ul li a:focus-visible {
    background: rgba(249, 115, 22, 0.16);
    color: var(--brand-strong);
    padding-left: 1.15rem;
    outline: none;
}

#main {
    display: flex;
    min-height: calc(100vh - 60px);
    gap: 24px;
    padding: 24px 32px 48px;
    box-sizing: border-box;
}

#content {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 32px;
    align-items: stretch;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.card {
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(10px);
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

#sidebar-left,
#sidebar-right {
    width: 260px;
    background: var(--surface-glass);
    padding: 24px;
    box-sizing: border-box;
    overflow: auto;
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(10px);
}

#sidebar-left {
    margin: 0 0 0 16px;
}

#sidebar-right {
    margin: 0 16px 0 0;
}

@media (max-width: 1024px) {
    #main {
        flex-direction: column;
        padding: 24px 20px 40px;
    }

    #sidebar-left,
    #sidebar-right {
        width: 100%;
        margin: 0;
    }
}

.sidebar h3 {
    margin-top: 20px;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar ul li a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.6rem 0.75rem;
    display: block;
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar ul li a:hover {
    background: rgba(249, 115, 22, 0.16);
    color: var(--brand-strong);
    transform: translateX(2px);
}

form {
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(10px);
    padding: 24px;
    max-width: 640px;
    width: min(100%, 640px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card form {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: none;
    width: 100%;
    backdrop-filter: none;
}

.card form label {
    font-weight: 600;
}

form label {
    font-weight: 600;
    color: var(--text-primary);
}

form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="number"],
form select,
form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-sizing: border-box;
}

form textarea {
    resize: vertical;
    min-height: 140px;
}

form input[type="text"]:focus,
form input[type="password"]:focus,
form input[type="email"]:focus,
form input[type="number"]:focus,
form select:focus,
form textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
    outline: none;
    background: #ffffff;
}

#chat-loading {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#chat-loading .spinner {
    width: 24px;
    height: 24px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#chat-loading .loading-text {
    margin-bottom: 8px;
    color: var(--text-primary);
}

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

#message p {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-weight: 600;
    margin: 0 0 1rem;
}

#message p.success {
    background: rgba(22, 163, 74, 0.16);
    color: #166534;
    border: 1px solid rgba(22, 163, 74, 0.35);
}

#message p.error {
    background: rgba(248, 113, 113, 0.15);
    color: #991b1b;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
}

table th,
table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-primary);
}

table th {
    background: rgba(37, 99, 235, 0.12);
    text-align: left;
    font-weight: 600;
}

table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.92);
}

table tr:hover td {
    background: rgba(249, 115, 22, 0.12);
}

table tr:last-child td {
    border-bottom: none;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.action-buttons a,
.action-buttons button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(249, 115, 22, 0.24);
    background: rgba(249, 115, 22, 0.12);
    color: var(--brand-strong);
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 14px 30px rgba(249, 115, 22, 0.2);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.action-buttons a:hover,
.action-buttons a:focus-visible,
.action-buttons button:hover,
.action-buttons button:focus-visible {
    background: rgba(249, 115, 22, 0.18);
    color: var(--brand-strong);
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(249, 115, 22, 0.24);
    outline: none;
}

.action-buttons .delete-button {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.12);
    color: #b91c1c;
    box-shadow: 0 14px 30px rgba(248, 113, 113, 0.25);
}

.action-buttons .delete-button:hover,
.action-buttons .delete-button:focus-visible {
    background: rgba(248, 113, 113, 0.18);
    color: #b91c1c;
    box-shadow: 0 18px 36px rgba(248, 113, 113, 0.28);
    transform: translateY(-1px);
}

.pagination {
    display: flex;
    justify-content: center;
    margin: 24px 0;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 0.45rem 0.9rem;
    color: var(--brand-strong);
    text-decoration: none;
    border: 1px solid rgba(249, 115, 22, 0.24);
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.12);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    font-weight: 600;
    box-shadow: 0 14px 30px rgba(249, 115, 22, 0.2);
}

.pagination a:hover,
.pagination a:focus-visible {
    background: rgba(249, 115, 22, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(249, 115, 22, 0.24);
    outline: none;
}

.pagination .current {
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 20px 42px rgba(249, 115, 22, 0.32);
}

/* Package listing cards */
.packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1000px;
}

.package-card {
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    padding: 24px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
}

.package-card::before {
    content: '🎁';
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
}

.package-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 42px rgba(15, 23, 42, 0.16);
}

.package-card h3 {
    margin-top: 0;
}

.start-btn,
.buy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.8rem 1.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 18px 38px rgba(249, 115, 22, 0.28);
}

.start-btn {
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    color: #ffffff;
}

.buy-btn {
    background: rgba(249, 115, 22, 0.12);
    color: var(--brand-strong);
    border-color: rgba(249, 115, 22, 0.24);
    box-shadow: 0 14px 28px rgba(249, 115, 22, 0.22);
}

.start-btn:hover,
.start-btn:focus-visible,
.buy-btn:hover,
.buy-btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 24px 48px rgba(249, 115, 22, 0.34);
    filter: brightness(1.03);
    outline: none;
}

footer {
    background: var(--surface-glass);
    color: var(--text-primary);
    padding: 24px;
    text-align: center;
    border-top: 1px solid var(--surface-border);
    box-shadow: 0 -10px 26px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(10px);
}

footer .container {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-copy {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.footer-links ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    align-items: center;
}

.footer-links li {
    margin: 0;
}

.footer-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
    text-decoration-color: transparent;
}

.footer-links a:hover,
.footer-links a:focus {
    color: var(--brand-strong);
    text-decoration: underline;
    text-decoration-color: currentColor;
    outline: none;
}

@media (max-width: 768px) {
    header {
        padding: 3px 10px;
    }

    header .container {
        justify-content: space-between;
        gap: 12px;
    }

    .app-name a {
        font-size: 12px;
    }

    .user-icon {
        font-size: 20px;
    }

    .header-right {
        gap: 12px;
        justify-content: flex-end;
    }

    .menu-toggle {
        display: inline-flex;
        order: 2;
    }

    .user-menu {
        margin-left: 0;
        order: 1;
    }

    .main-nav {
        position: fixed;
        inset: 0;
        margin-right: 0;
        background: var(--surface-glass);
        display: none;
        z-index: 1200;
        padding: 64px 24px 24px;
        flex-direction: column;
        align-items: stretch;
        gap: 32px;
        overflow-y: auto;
        border-left: 1px solid var(--surface-border);
        backdrop-filter: blur(12px);
        box-shadow: var(--surface-shadow);
    }

    .main-nav.is-open {
        display: flex;
    }

    .main-nav ul {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .main-nav li {
        width: 100%;
    }

    .main-nav a {
        display: block;
        width: 100%;
        font-size: 18px;
    }

    .close-nav {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 28px;
        margin-left: auto;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        transition: background-color 0.2s ease;
    }

    .close-nav:hover,
    .close-nav:focus-visible {
        background-color: rgba(0, 0, 0, 0.05);
    }

    .user-dropdown {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 0;
    }

    .close-dropdown {
        display: block;
    }

    #main {
        flex-direction: column;
    }

    #sidebar-left,
    #sidebar-right {
        width: 100%;
        border: none;
        order: 2;
    }

    #content {
        order: 1;
    }
}
/* Chat options styles */
#upload-button, #options-toggle {
    background-color: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    cursor: pointer;
    user-select: none;
    transition: background-color 1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
}

#options-toggle.open {
    background-color: #e5e7eb;
}

#chat-form .chat-form-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

#options-container {
    display: none;
    margin-top: 10px;
}

.option-group {
    margin-bottom: 10px;
}

.option-label {
    display: block;
    margin: 6px 0 4px;
    font-weight: 600;
}

.option-bubble {
    display: inline-block;
    padding: 4px 10px;
    margin: 2px;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    user-select: none;
}

.option-bubble.selected {
    background-color: var(--accent);
    color: #fff;
}

#chat-box {
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 20px auto 0;
}

#preset-queries {
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.chat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    --card-action-size: 32px;
    --card-action-gap: 10px;
    --card-action-offset: 8px;
    max-width: 1024px;
}

.chat-card img {
    max-width: 100%;
    display: block;
}

.chat-card .magic-icon,
.chat-card .download-icon,
.chat-card .upscale-icon,
.chat-card .gallery-add-icon,
.chat-card .gallery-remove-icon {
    position: absolute;
    top: var(--card-action-offset);
    background: #fff;
    color: var(--text-primary);
    width: var(--card-action-size);
    height: var(--card-action-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 6px;
    text-decoration: none;
    font-size: 16px;
    border: 1px solid rgba(0, 0, 0, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
    cursor: pointer;
}

.chat-card .upscale-icon.is-loading {
    color: transparent;
    pointer-events: none;
}

.chat-card .upscale-icon.is-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--text-primary);
    border-top-color: transparent;
    border-right-color: transparent;
    animation: chat-upscale-spin 0.75s linear infinite;
}

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

.chat-card .magic-icon,
.chat-card .download-icon,
.chat-card .upscale-icon,
.chat-card .gallery-add-icon,
.chat-card .gallery-remove-icon {
    z-index: 2;
}

.chat-card .download-icon,
.chat-card .upscale-icon { right: var(--card-action-offset); }
.chat-card .magic-icon { right: calc(var(--card-action-offset) + var(--card-action-size) + var(--card-action-gap)); }
.chat-card .gallery-add-icon { right: calc(var(--card-action-offset) + (var(--card-action-size) + var(--card-action-gap)) * 2); }
.chat-card .gallery-remove-icon { right: calc(var(--card-action-offset) + var(--card-action-size) + var(--card-action-gap)); }

.chat-card .gallery-remove-icon {
    background: #fee2e2;
    color: #991b1b;
    border-color: rgba(220, 38, 38, 0.35);
}

.chat-card .gallery-remove-icon:hover {
    background: #fecaca;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.chat-card .gallery-add-icon.added {
    background: #dcfce7;
    color: #15803d;
    border-color: rgba(22, 163, 74, 0.35);
}

.chat-card .magic-icon:hover,
.chat-card .download-icon:hover,
.chat-card .upscale-icon:hover,
.chat-card .gallery-add-icon:hover {
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

.gallery-filter {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.gallery-filter label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.gallery-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.gallery-filter-controls input {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-filter-controls input:focus-visible {
    outline: none;
    border-color: rgba(79, 70, 229, 0.45);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

.gallery-filter-controls .btn {
    flex: 0 0 auto;
}

.gallery-tag-cloud {
    margin: 1rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.gallery-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.85rem;
    line-height: 1.1;
}

.gallery-tag:hover,
.gallery-tag:focus-visible {
    background: rgba(79, 70, 229, 0.12);
    color: var(--brand-strong);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.18);
    outline: none;
}

.gallery-tag.is-active {
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    color: #ffffff;
    border-color: rgba(249, 115, 22, 0.4);
    box-shadow: 0 8px 18px rgba(249, 115, 22, 0.28);
}

.gallery-tag-count {
    font-size: 0.75rem;
    opacity: 0.75;
}

.gallery-card-tags {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.gallery-card-tags .gallery-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
}

.gallery-active-summary {
    margin: 0.5rem 0 1.5rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.gallery-active-summary .gallery-tag {
    font-size: 0.8rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.gallery-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(10px);
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
}

.gallery-description {
    color: var(--text-secondary);
}

.gallery-tags-line {
    margin: 1rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    color: var(--text-secondary);
}

.gallery-tags-line strong {
    color: var(--text-primary);
}

.gallery-tags-line .gallery-tag {
    font-size: 0.8rem;
}

.gallery-empty {
    padding: 24px;
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    max-width: 640px;
    margin: 0 auto;
    backdrop-filter: blur(10px);
}

.gallery-full-card {
    margin: 24px auto;
    max-width: 720px;
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    box-shadow: var(--surface-shadow);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.gallery-full-card img {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-meta {
    color: var(--text-secondary);
    margin-top: 12px;
    text-align: center;
}

.gallery-admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

.gallery-admin-table th,
.gallery-admin-table td {
    vertical-align: top;
    padding: 0.75rem 0.6rem;
    text-align: left;
}

.gallery-admin-select {
    width: 48px;
    text-align: center;
}

.gallery-admin-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.gallery-admin-thumb {
    width: 140px;
}

.gallery-admin-thumb img {
    max-width: 120px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.gallery-admin-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.gallery-admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
}

.gallery-admin-links .button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.gallery-tag-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-tag-filter select {
    min-width: 200px;
}

.gallery-tag-filter-summary {
    margin-bottom: 1rem;
    font-style: italic;
}

.gallery-admin-actions form {
    display: inline;
}

.gallery-admin-actions .button-link {
    text-decoration: none;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.gallery-admin-actions button.button-link {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: inherit;
}

.gallery-admin-actions button.button-link:hover,
.gallery-admin-actions button.button-link:focus-visible {
    color: var(--brand-strong);
    outline: none;
}

.gallery-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.gallery-selection-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.gallery-admin-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 140px;
}

.gallery-admin-tags .gallery-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
}

.gallery-tag-table .gallery-tag-edit-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.gallery-tag-table .tag-prefix {
    font-weight: 600;
}

.gallery-tag-table input[type="text"] {
    min-width: 160px;
}

.gallery-tag-table button {
    padding: 0.25rem 0.75rem;
}

.gallery-admin-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-top: 1.5rem;
}

.gallery-admin-preview {
    flex: 0 1 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 1.5rem;
    background: rgba(2, 32, 44, 0.35);
    border-radius: 12px;
    text-align: center;
}

.gallery-admin-preview img {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.gallery-admin-preview-empty {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.gallery-admin-form {
    flex: 1 1 320px;
    display: grid;
    gap: 1rem;
}

.gallery-admin-form input,
.gallery-admin-form textarea {
    width: 100%;
}

.gallery-admin-form .form-help {
    margin-top: -0.35rem;
    margin-bottom: 1.1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.gallery-admin-form .form-actions {
    display: flex;
    justify-content: flex-start;
    gap: 1rem;
}

#image-url-indicator {
    margin-left: 8px;
    opacity: 0;
    display: none;
    transition: opacity 1s;
}
#image-url-indicator.visible {
    display: inline;
    opacity: 1;
}
#image-url-indicator span { cursor: pointer; }

.preset-card {
    cursor: pointer;
    padding: 20px;
}

.results-separator {
    display: flex;
    align-items: center;
    margin-top: 20px;
}

.results-separator::before,
.results-separator::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.results-separator span {
    margin: 0 10px;
    font-weight: bold;
    color: var(--text-primary);
}

#history-list {
    list-style: none;
    padding: 0;
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.history-item {
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--surface-radius);
    padding: 18px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(10px);
}

.history-item:hover,
.history-item:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
    outline: none;
}

.history-item a {
    color: inherit;
    text-decoration: none;
    display: block;
}

.history-thumb-wrapper {
    margin-bottom: 10px;
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--bg-primary);
}

.history-thumb {
    display: block;
    width: 100%;
    height: auto;
}

@supports (aspect-ratio: 4 / 3) {
    .history-thumb-wrapper {
        aspect-ratio: 4 / 3;
    }

    .history-thumb {
        height: 100%;
        object-fit: cover;
    }
}

#history-results {
    width: 100%;
    max-width: 1000px;
    display: none;
}

#history-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

#history-cards .chat-card {
    font-size: 1.1em;
}

.history-link {
    margin-top: 10px;
}

.buy-credits-link {
    margin-left: 10px;
}

/* Landing page */
body.landing-body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
    background: radial-gradient(1600px 820px at 80% -10%, rgba(59, 130, 246, 0.18), transparent 60%),
        radial-gradient(1200px 720px at -10% 20%, rgba(14, 165, 233, 0.14), transparent 65%),
        linear-gradient(180deg, #f8fafc, #eef2ff 45%, #e0f2fe 100%);
}

body.landing-body header.hero {
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    backdrop-filter: blur(12px);
}

body.landing-body header .container {
    align-items: flex-start;
    padding-top: 16px;
    padding-bottom: 16px;
}

body.landing-body .main-nav a {
    color: #1f2937;
}

body.landing-body .main-nav a:hover,
body.landing-body .main-nav a:focus {
    color: var(--brand-strong);
}

body.landing-body .menu-toggle,
body.landing-body .close-nav,
body.landing-body .user-icon {
    color: #1f2937;
}

body.landing-body .menu-toggle:hover,
body.landing-body .menu-toggle:focus-visible {
    background-color: rgba(249, 115, 22, 0.16);
}

body.landing-body #main {
    display: block;
    min-height: 0;
}

#content.landing-content {
    display: block;
    padding: 0;
}


.landing-page {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #1e293b;
    --muted: #475569;
    --brand: #fb923c;
    --brand-strong: #ea580c;
    --accent: #f97316;
    --ok: #16a34a;
    --warn: #f59e0b;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.06);
    --radius: 18px;
    position: relative;
    width: 100%;
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding-bottom: 120px;
    background: radial-gradient(900px 620px at 12% 0%, rgba(37, 99, 235, 0.12), transparent 60%),
        radial-gradient(640px 480px at 90% 8%, rgba(14, 165, 233, 0.1), transparent 65%), var(--bg);
}

.landing-page a {
    color: var(--brand);
}

.landing-page .container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

.landing-hero {
    position: relative;
    overflow: hidden;
}

.landing-page .hero__inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 72px 0 52px;
}

.landing-page .hero h1 {
    font: 800 56px/1.05 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
    color: var(--ink);
}

.landing-page .hero h1 .serif {
    font-family: 'DM Serif Display', Georgia, serif;
    font-weight: 400;
    font-style: italic;
}

.landing-page .hero p.sub {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 1.125rem;
}

.landing-page .hero__cta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.landing-page .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.2rem;
    border-radius: 999px;
    text-decoration: none;
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.2px;
    box-shadow: 0 16px 32px rgba(249, 115, 22, 0.3);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.landing-page .btn:hover,
.landing-page .btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 20px 38px rgba(249, 115, 22, 0.36);
}

.landing-page .btn--ghost {
    background: rgba(249, 115, 22, 0.12);
    color: var(--brand-strong);
    border: 1px solid rgba(249, 115, 22, 0.26);
    box-shadow: none;
}

.landing-page .btn--ghost:hover,
.landing-page .btn--ghost:focus-visible {
    box-shadow: 0 18px 30px rgba(249, 115, 22, 0.22);
}

.tag {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    letter-spacing: 0.3px;
    background: rgba(249, 115, 22, 0.16);
    color: var(--brand-strong);
}

.landing-page .glass {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78));
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.landing-page .keypoints {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin: 28px 0 0;
    width: 100%;
}

.landing-page .hero-features {
    margin-top: 32px;
    width: 100%;
}

.landing-page .hero-features h2 {
    margin-top: 0;
}

.landing-page .kp {
    padding: 18px;
}

.landing-page .kp h4 {
    margin: 6px 0 6px;
    font-size: 1rem;
}

.landing-page .kp p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.landing-page .icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--brand-strong);
}

.landing-page .landing-main {
    display: flex;
    flex-direction: column;
    gap: 48px;
    align-items: center;
}

.landing-page .landing-main > .container {
    width: 100%;
}

.landing-page .landing-main > .cta-bar {
    align-self: stretch;
}

.landing-page .panel {
    margin: 0;
    padding: 24px;
}

.landing-page .panel + .panel {
    margin-top: 32px;
}

.landing-page .panel h2 {
    font-size: 2rem;
    line-height: 1.2;
    margin: 0.4rem 0 1rem;
    letter-spacing: -0.02em;
}

.landing-page .lead {
    color: var(--muted);
}

.landing-page .split {
    display: grid;
    gap: 24px;
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
}

.landing-page .glass-card {
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
    box-shadow: var(--shadow);
}

.landing-page .feature-grid {
    display: grid;
    gap: clamp(20px, 3vw, 28px);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: 16px;
}

.landing-page .feature-grid h3 {
    margin: 0.2rem 0 0.4rem;
}

.landing-page .feature-grid p,
.landing-page .audiences p,
.landing-page .audiences li,
.landing-page .split li {
    color: var(--muted);
}

.landing-page .audiences {
    display: grid;
    gap: clamp(20px, 3vw, 28px);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.landing-page .audiences h3 {
    margin: 0.2rem 0 0.4rem;
}

.landing-page .mock {
    aspect-ratio: 16 / 10;
    border-radius: 16px;
    background: radial-gradient(260px 220px at 20% 60%, rgba(56, 189, 248, 0.18), transparent 60%),
        radial-gradient(260px 220px at 80% 30%, rgba(251, 191, 36, 0.18), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72));
    border: 1px solid rgba(148, 163, 184, 0.2);
    position: relative;
    overflow: hidden;
}

.landing-page .mock__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.landing-page .mock::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent 0 39px, rgba(37, 99, 235, 0.08) 39px 40px),
        repeating-linear-gradient(0deg, transparent 0 39px, rgba(14, 165, 233, 0.08) 39px 40px);
    mix-blend-mode: screen;
    opacity: 0.3;
}

.landing-page .badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--muted);
}

.landing-page ul {
    padding-left: 1.2rem;
}

.landing-page .cta-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.landing-page .cta-bar {
    position: sticky;
    bottom: 12px;
    z-index: 50;
    display: flex;
    justify-content: center;
    padding: 0 12px;
    pointer-events: none;
}

.landing-page .cta-bar .inner {
    pointer-events: auto;
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: var(--shadow);
}

.landing-page .divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    margin: 36px 0;
}

@media (max-width: 900px) {
    .landing-page .split {
        grid-template-columns: 1fr;
    }

    body.landing-body header .container {
        align-items: center;
    }
}

@media (max-width: 640px) {
    .landing-page .hero h1 {
        font-size: 42px;
        line-height: 1.1;
    }

    .landing-page .hero__inner {
        padding: 56px 0 40px;
    }
}

