/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    --bg-primary: #07070f;
    --bg-secondary: #0d0d1a;
    --bg-tertiary: #141425;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.055);
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.13);
    --border-strong: rgba(255, 255, 255, 0.2);
    --text-primary: #eeeef8;
    --text-contrast: #000000;
    --text-secondary: #7878a0;
    --text-muted: #484870;
    --accent: #7c6de8;
    --accent-hover: #9185ee;
    --accent-light: #b5adf5;
    --accent-glow: rgba(124, 109, 232, 0.2);
    --accent-glow-strong: rgba(124, 109, 232, 0.32);
    --accent-subtle: rgba(124, 109, 232, 0.08);
    --gradient-accent: linear-gradient(135deg, #7c6de8, #a78bfa);
    --success: #20d4a0;
    --success-subtle: rgba(32, 212, 160, 0.08);
    --error: #f87171;
    --error-subtle: rgba(248, 113, 113, 0.08);
    --warning: #fbbf24;
    --warning-subtle: rgba(251, 191, 36, 0.08);
    --sidebar-width: 252px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-full: 9999px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 4px 20px rgba(124, 109, 232, 0.28);
    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    background-image:
        radial-gradient(ellipse 70% 50% at 15% -5%, rgba(124, 109, 232, 0.07) 0%, transparent 60%),
        radial-gradient(ellipse 55% 45% at 85% 105%, rgba(124, 109, 232, 0.05) 0%, transparent 55%);
}

a {
    text-decoration: none;
    color: inherit;
}

input,
button,
textarea,
select {
    font-family: inherit;
    border: none;
    outline: none;
}

/* ============================================
   Custom Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 18px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.logo svg {
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-glow));
    flex-shrink: 0;
}

.logo span {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.855rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    border-left: 2px solid transparent;
}

.nav-item svg {
    flex-shrink: 0;
    transition: color var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-left-color: var(--border-hover);
}

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent-light);
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-item.active svg {
    color: var(--accent);
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.user-name {
    font-size: 0.855rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.logout-btn:hover {
    background: var(--error-subtle);
    color: var(--error);
}

/* ============================================
   Layout
   ============================================ */
.content-with-sidebar {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 40px 48px;
}

.content-full {
    flex: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* ============================================
   Flash Messages
   ============================================ */
.flash-container {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.87rem;
    font-weight: 500;
    backdrop-filter: blur(20px);
    animation: flashSlide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-md);
}

.flash-success {
    background: rgba(32, 212, 160, 0.1);
    border: 1px solid rgba(32, 212, 160, 0.2);
    color: var(--success);
}

.flash-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--error);
}

.flash-close {
    background: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity var(--transition);
    padding: 0 2px;
    flex-shrink: 0;
}

.flash-close:hover {
    opacity: 1;
}

@keyframes flashSlide {
    from {
        transform: translateX(calc(100% + 24px));
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 40px 36px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(124, 109, 232, 0.06) inset;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: var(--gradient-accent);
    opacity: 0.6;
}

.auth-card::after {
    content: '';
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(124, 109, 232, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    z-index: 1;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    background: var(--accent-subtle);
    border-radius: 16px;
    color: var(--accent);
    margin-bottom: 18px;
    border: 1px solid rgba(124, 109, 232, 0.2);
    box-shadow: 0 0 24px var(--accent-glow);
}

.auth-header h1 {
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.form-group input {
    padding: 11px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-tertiary);
}

.auth-footer {
    margin-top: 22px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.auth-footer a {
    color: var(--accent-light);
    font-weight: 600;
    transition: color var(--transition);
}

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

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}

.btn:active {
    transform: scale(0.96) !important;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

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

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

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

.btn-accent {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-accent:hover {
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.btn-accent:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
    filter: none;
}

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

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-full {
    width: 100%;
    padding: 13px 20px;
    font-size: 0.9rem;
}

/* ============================================
   Dashboard
   ============================================ */
.dashboard {
    max-width: 1200px;
    width: 100%;
}

.dashboard-header {
    margin-bottom: 28px;
}

.page-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
    display: block;
    opacity: 0.85;
}

.dashboard-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--text-primary) 30%, rgba(150, 150, 200, 0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================
   Scraper Input
   ============================================ */
.scraper-input-section {
    margin-bottom: 28px;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 5px 5px 14px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.input-group:focus-within {
    border-color: rgba(124, 109, 232, 0.5);
    box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
}

.input-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    margin-right: 10px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.input-group:focus-within .input-icon {
    color: var(--accent);
}

.input-group input {
    flex: 1;
    padding: 11px 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.925rem;
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group .btn {
    flex-shrink: 0;
    padding: 11px 22px;
}

/* ============================================
   Loading & States
   ============================================ */
.loading-state,
.error-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
    gap: 14px;
    color: var(--text-muted);
}

.spinner {
    width: 34px;
    height: 34px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.error-state {
    color: var(--error);
}

.error-state p,
.empty-state p {
    font-size: 0.9rem;
    text-align: center;
    max-width: 360px;
    line-height: 1.65;
    color: var(--text-secondary);
}

.empty-state svg {
    opacity: 0.3;
}

/* ============================================
   Results
   ============================================ */
.results-section {
    animation: fadeUp 0.3s ease-out;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.results-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.results-info .separator {
    margin: 0 8px;
    opacity: 0.3;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   Image Grid
   ============================================ */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.image-card {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}

.image-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.image-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow-strong);
}

.image-card .card-image {
    width: 100%;
    height: 168px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.image-card .card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.35s ease;
}

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

.image-card .card-info {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-top: 1px solid var(--border);
}

.image-card .card-checkbox {
    width: 17px;
    height: 17px;
    border: 1.5px solid var(--border-hover);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.image-card.selected .card-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}

.image-card.selected .card-checkbox::after {
    content: '';
    width: 9px;
    height: 6px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) translate(1px, -1px);
    display: block;
}

.image-card .card-filename {
    font-size: 0.775rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   AI Image Page
   ============================================ */
.ai-image-page {
    max-width: 1200px;
    width: 100%;
}

.ai-credits-bar {
    margin-bottom: 20px;
}

.credits-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    background: rgba(124, 109, 232, 0.07);
    border: 1px solid rgba(124, 109, 232, 0.18);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.credits-badge strong {
    color: var(--accent-light);
    font-weight: 700;
    font-size: 0.95rem;
}

.credits-badge svg {
    color: var(--accent);
}

/* API Key Banner */
.api-key-banner {
    background: var(--bg-secondary);
    border: 1px solid rgba(124, 109, 232, 0.22);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 24px;
    animation: fadeIn 0.4s ease-out;
}

.api-key-banner-content {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.api-key-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--accent-subtle);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    border: 1px solid rgba(124, 109, 232, 0.18);
}

.api-key-text h3 {
    font-size: 0.975rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.api-key-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.6;
}

.api-key-text ol {
    padding-left: 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.9;
}

.api-key-text a {
    color: var(--accent-light);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.api-key-text a:hover {
    color: var(--accent-hover);
}

.api-key-input-row {
    display: flex;
    gap: 8px;
}

.api-key-input-row input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition);
}

.api-key-input-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.api-key-input-row input::placeholder {
    color: var(--text-muted);
}

/* API Key Manage (when already set) */
.api-key-manage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--success-subtle);
    border: 1px solid rgba(32, 212, 160, 0.15);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 500;
}

.api-key-update {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: -14px;
    margin-bottom: 20px;
}

.api-key-update input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.api-key-update input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Password visibility toggle */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.password-toggle:hover {
    color: var(--text-secondary);
}

/* Billing summary bar */
.billing-summary-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.billing-summary-bar .credits-badge {
    font-size: 0.85rem;
}

/* Pack card improvements */
.billing-pack-card {
    text-align: center;
    align-items: center;
}

.billing-pack-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.billing-pack-card .pack-credits {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-light);
    letter-spacing: -0.03em;
    line-height: 1;
}

.billing-pack-card .pack-credits-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Plan card header badge */
.plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--gradient-accent);
    color: white;
    margin-bottom: 4px;
}

.plan-badge--current {
    background: var(--success-subtle);
    color: var(--success);
    border: 1px solid rgba(32, 212, 160, 0.2);
}

.btn-danger-hover:hover {
    color: var(--error) !important;
    border-color: rgba(248, 113, 113, 0.3) !important;
    background: var(--error-subtle) !important;
}

/* Prompt Section */
.prompt-section {
    margin-bottom: 32px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.prompt-section h2,
.section-title h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.prompt-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}

.prompt-card:focus-within {
    border-color: rgba(124, 109, 232, 0.38);
    box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
}

.prompt-card textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.925rem;
    font-family: inherit;
    resize: vertical;
    min-height: 72px;
    line-height: 1.65;
}

.prompt-card textarea::placeholder {
    color: var(--text-muted);
}

.prompt-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    gap: 14px;
    flex-wrap: wrap;
}

.variations-selector {
    display: flex;
    align-items: center;
    gap: 9px;
}

.variations-selector label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.variation-btns {
    display: flex;
    gap: 3px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.var-btn {
    width: 30px;
    height: 27px;
    border-radius: 5px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.var-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.var-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 4px var(--accent-glow);
}

.cost-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Generation Results */
.gen-results {
    margin-bottom: 32px;
    animation: fadeUp 0.4s ease-out;
}

.gen-results h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.gen-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.gen-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeUp 0.4s ease-out;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.gen-result-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.gen-result-card img {
    width: 100%;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gen-result-card img:hover {
    transform: scale(1.02);
}

.gen-result-label {
    padding: 9px 13px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
}

.gen-result-label .var-badge {
    background: var(--accent-subtle);
    color: var(--accent-light);
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.74rem;
    border: 1px solid rgba(124, 109, 232, 0.15);
}

.gen-result-error {
    padding: 28px 20px;
    text-align: center;
    color: var(--error);
    font-size: 0.875rem;
}

/* Prompt History */
.prompt-history {
    margin-top: 8px;
}

.prompt-history h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 14px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.prompts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prompt-history-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.prompt-history-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.prompt-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.prompt-text-content {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.55;
    flex: 1;
}

.prompt-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.prompt-date {
    display: block;
    margin-top: 5px;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.prompt-images-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.prompt-thumb {
    width: 108px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.prompt-thumb:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.prompt-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prompt-thumb-failed {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: var(--bg-tertiary);
    color: var(--error);
    cursor: default;
}

.prompt-thumb-failed:hover {
    border-color: var(--border);
    transform: none;
    box-shadow: none;
}

.thumb-error-text {
    font-size: 0.68rem;
    font-weight: 600;
}

/* Image Upload */
.image-upload-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.image-upload-header {
    margin-bottom: 8px;
}

.image-upload-header label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.upload-hint {
    color: var(--text-muted);
    font-weight: 400;
}

.upload-drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 16px;
    margin-top: 6px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.upload-drop-zone:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-subtle);
}

.image-previews {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.upload-preview {
    position: relative;
    width: 96px;
    height: 76px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    line-height: 1;
}

.upload-preview-remove:hover {
    background: var(--error);
}

.upload-preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 5px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: fadeUp 0.2s ease-out;
}

.modal-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7);
}

.modal-close {
    position: absolute;
    top: -44px;
    right: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1.35rem;
    cursor: pointer;
    opacity: 0.8;
    transition: all var(--transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.14);
}

/* ============================================
   Products & Placeholders
   ============================================ */
.products-page,
.placeholder-page {
    max-width: 1200px;
    width: 100%;
}

.products-page-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.add-product-panel {
    margin-bottom: 20px;
    animation: fade-in 0.18s ease;
}

.product-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.products-table-section {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 32px;
}

.products-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.products-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.products-tools-section {
    margin-top: 8px;
}

.tools-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.tool-card {
    flex: 1;
    min-width: 280px;
    max-width: 480px;
}

.tool-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.tool-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.product-form-card,
.product-row,
.placeholder-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.product-form-card,
.placeholder-card {
    padding: 22px;
}

.section-heading {
    margin-bottom: 16px;
}

.section-heading h2,
.placeholder-card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.section-heading p,
.placeholder-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.product-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.remove-bg-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.remove-bg-card .btn {
    align-self: flex-start;
}

.remove-bg-status {
    min-height: 20px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.remove-bg-status.is-success {
    color: var(--success);
}

.remove-bg-status.is-error {
    color: var(--error);
}

.form-group textarea,
.form-group input[type="file"] {
    width: 100%;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.form-group textarea {
    padding: 11px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    min-height: 130px;
    line-height: 1.6;
}

.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

.form-group input[type="file"] {
    padding: 11px;
    background: var(--bg-tertiary);
    border: 1.5px dashed var(--border-hover);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.field-hint {
    font-size: 0.775rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.products-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.products-list-head,
.product-row-summary {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) 110px 110px 68px 28px;
    align-items: center;
    column-gap: 14px;
}

.products-list-head {
    padding: 0 12px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* "Product" header spans the image + name columns so it aligns with thumbnails */
.products-head-product {
    grid-column: 1 / 3;
}

.product-row-summary {
    min-height: 72px;
}

.product-row {
    transition: border-color var(--transition), box-shadow var(--transition);
    overflow: hidden;
}

.product-row:hover,
.product-row[open] {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.product-row-summary {
    list-style: none;
    cursor: pointer;
    padding: 0 12px;
}

.product-row-summary::-webkit-details-marker {
    display: none;
}

.product-row-summary::marker {
    content: '';
}

.product-row-summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.product-row-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.product-row-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.product-row-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-row-price {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-row-preview {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-row-date {
    font-size: 0.74rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.product-image-count,
.placeholder-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.product-image-count {
    background: var(--accent-subtle);
    color: var(--accent-light);
    border: 1px solid rgba(124, 109, 232, 0.15);
}

.product-row-chevron {
    justify-self: end;
    width: 18px;
    height: 18px;
    position: relative;
    color: var(--text-muted);
}

.product-row-chevron::after {
    content: '';
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    transition: transform var(--transition);
}

.product-row[open] .product-row-chevron::after {
    transform: translate(-50%, -30%) rotate(-135deg);
}

.product-row-details {
    border-top: 1px solid var(--border);
    padding: 16px 78px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(255, 255, 255, 0.01);
}

.product-context {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 0;
    white-space: pre-wrap;
}

.product-info-block {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.product-info-block p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.84rem;
    line-height: 1.55;
}

.product-info-block strong {
    color: var(--text-primary);
    font-weight: 600;
}

.product-images-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    max-width: 480px;
}

.product-image-thumb {
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    transition: transform var(--transition);
}

.product-image-thumb:hover {
    transform: scale(1.02);
}

.product-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-empty-images {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
}

.product-empty-state {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.placeholder-card {
    max-width: 680px;
}

.placeholder-badge {
    margin-bottom: 14px;
    background: var(--warning-subtle);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

/* ── Product edit / action UI ─────────────────────────────────────── */
.product-row-btns {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.inline-form {
    display: inline;
}

.btn-sm {
    padding: 5px 14px;
    font-size: 0.8rem;
    min-height: 0;
}

.btn-danger-ghost {
    color: var(--error);
    border-color: transparent;
}

.btn-danger-ghost:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--error);
}

.product-edit-imgs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.product-edit-img-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.product-edit-img-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-edit-img-del {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity var(--transition);
}

.product-edit-img-item:hover .product-edit-img-del {
    opacity: 1;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .product-form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .content-with-sidebar {
        margin-left: 0;
        padding: 24px 16px;
    }

    .results-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .results-actions {
        flex-wrap: wrap;
    }

    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .image-card .card-image {
        height: 130px;
    }

    .api-key-banner-content {
        flex-direction: column;
    }

    .api-key-input-row {
        flex-direction: column;
    }

    .prompt-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .gen-results-grid {
        grid-template-columns: 1fr;
    }

    .products-list-head {
        display: none;
    }

    .product-row-summary {
        grid-template-columns: 48px minmax(0, 1fr) 28px;
        row-gap: 4px;
    }

    .product-row-price,
    .product-row-date,
    .product-image-count {
        display: none;
    }

    .product-row-details {
        padding-left: 16px;
        padding-right: 16px;
    }

    .product-images-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ============================================
   Remix Toggle & OpenAI
   ============================================ */
.api-key-banner-openai {
    border-color: rgba(16, 163, 127, 0.22);
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.04), transparent);
}

.optional-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background: rgba(16, 163, 127, 0.12);
    color: #22c49a;
    vertical-align: middle;
    margin-left: 7px;
}

.remix-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.remix-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.remix-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.remix-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.remix-description {
    font-size: 0.775rem;
    color: var(--text-muted);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 22px;
    transition: all var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(18px);
    background: white;
}

/* Remix options */
.remix-options {
    margin-top: 12px;
}

.remix-options label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
    display: block;
}

.remix-options textarea {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--transition);
}

.remix-options textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

/* ============================================
   Avatars Page
   ============================================ */
.avatar-generator-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.avatar-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.avatar-field>label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.avatar-select,
.avatar-text-input {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

.avatar-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236060a0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
    cursor: pointer;
}

.avatar-select:focus,
.avatar-text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

.avatar-text-input::placeholder {
    color: var(--text-muted);
}

/* Persona Chips */
.persona-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.persona-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 13px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.persona-chip:hover {
    border-color: rgba(124, 109, 232, 0.35);
    color: var(--text-primary);
    background: var(--accent-subtle);
}

.persona-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.persona-chip.custom::after {
    content: '×';
    margin-left: 5px;
    font-size: 0.72rem;
    opacity: 0.75;
}

.custom-persona-row {
    display: flex;
    gap: 7px;
    margin-top: 4px;
}

.custom-persona-input {
    flex: 1;
}

/* Avatar results grid */
.avatar-results-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 14px;
}

.avatar-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    animation: fadeUp 0.4s ease-out;
}

.avatar-persona-label {
    font-size: 0.855rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
    text-transform: capitalize;
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-persona-label::before {
    content: '';
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: var(--gradient-accent);
    flex-shrink: 0;
    display: inline-block;
}

.avatar-ba-pair {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar-ba-img {
    flex: 1;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.avatar-ba-img:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.avatar-ba-img img {
    width: 100%;
    display: block;
    aspect-ratio: 3 / 4;
    object-fit: cover;
}

.avatar-ba-arrow {
    flex-shrink: 0;
    color: var(--accent);
    display: flex;
    align-items: center;
    opacity: 0.65;
}

.ba-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    backdrop-filter: blur(4px);
}

.ba-before {
    background: rgba(215, 55, 45, 0.8);
    color: white;
}

.ba-after {
    background: rgba(32, 212, 160, 0.85);
    color: white;
}

.avatar-failed {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.85rem;
}

/* Avatar history mini previews */
.avatar-history-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.avatar-pair-mini {
    display: flex;
    gap: 3px;
}

.avatar-mini-img {
    position: relative;
    width: 56px;
    height: 74px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.avatar-mini-img:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.avatar-mini-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-mini-img .ba-label {
    bottom: 3px;
    left: 3px;
    padding: 1px 5px;
    font-size: 0.58rem;
}

@media (max-width: 768px) {
    .avatar-ba-pair {
        flex-direction: column;
    }

    .avatar-ba-arrow {
        transform: rotate(90deg);
    }
}

/* ── AI Creatives ──────────────────────────────────────────────────── */
.creatives-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.creatives-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Inspiration upload zone */
.inspiration-upload-zone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 22px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}

.inspiration-upload-zone:hover,
.inspiration-upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--text-primary);
}

.inspiration-upload-zone p {
    margin: 0;
    font-size: 0.875rem;
}

/* Inspiration grid */
.inspirations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
}

.inspiration-card {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
    aspect-ratio: 1 / 1;
}

.inspiration-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.inspiration-card:hover {
    transform: scale(1.04);
    border-color: var(--accent);
}

.inspiration-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.inspiration-overlay {
    position: absolute;
    inset: 0;
    background: rgba(124, 109, 232, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.inspiration-card.selected .inspiration-overlay {
    opacity: 1;
}

.inspiration-card .check-icon {
    color: #fff;
}

.inspiration-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    z-index: 10;
}

.inspiration-card:hover .inspiration-delete-btn {
    opacity: 1;
}

.inspiration-delete-btn:hover {
    background: var(--error);
}

/* Selection summary bar */
.selection-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Creatives results grid (live results) */
.creatives-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

.creative-result-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.creative-result-image {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.creative-result-image:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.creative-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}

.creative-result-image:hover img {
    transform: scale(1.04);
}

.creative-download-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 5px 7px;
    text-decoration: none;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.creative-result-image:hover .creative-download-btn {
    opacity: 1;
}

.creative-prompt-excerpt {
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Batch history grid */
.creatives-history-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.creative-history-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: 150px;
}

.creative-pair {
    display: flex;
    gap: 3px;
}

.creative-mini-img {
    position: relative;
    width: 68px;
    height: 76px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: all var(--transition);
}

.creative-mini-img:hover {
    border-color: var(--accent);
    transform: scale(1.04);
}

.creative-mini-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.creative-mini-img .ba-label {
    bottom: 3px;
    left: 3px;
    padding: 1px 5px;
    font-size: 0.58rem;
}

.creative-failed {
    color: var(--error);
}

@media (max-width: 900px) {
    .creatives-layout {
        grid-template-columns: 1fr;
    }
}

/* Billing */
.sidebar-billing-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 11px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(124, 109, 232, 0.06);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    text-decoration: none;
}

.sidebar-billing-pill:hover {
    background: rgba(124, 109, 232, 0.12);
    border-color: rgba(124, 109, 232, 0.3);
}

.sidebar-billing-pill .billing-plan {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--accent-light);
    font-weight: 700;
}

.sidebar-billing-pill .billing-credits {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 600;
}

.ai-credits-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.credits-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.billing-plan-grid,
.billing-pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 16px 0 24px;
}

.billing-plan-card,
.billing-pack-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.billing-plan-card:hover,
.billing-pack-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.billing-plan-card.is-current {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(124, 109, 232, 0.35), var(--shadow-sm);
}

.billing-plan-card.is-current::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-accent);
}

.plan-price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.plan-price span {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0;
}

.plan-features {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.875rem;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-features li::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background: var(--success-subtle);
    border: 1px solid rgba(32, 212, 160, 0.2);
    border-radius: 50%;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2320d4a0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: 10px;
    background-position: center;
    background-repeat: no-repeat;
}

@media (max-width: 860px) {
    .credits-actions {
        width: 100%;
        margin-left: 0;
    }
}

/* ============================================
   Product Images / Lacy
   ============================================ */
.product-images-page {
    max-width: 1280px;
    width: 100%;
}

.product-images-shell {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 24px;
}

.product-images-agent-menu,
.product-images-agent-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.product-images-agent-menu {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 20px;
}

.agent-menu-heading h2,
.product-images-panel-header h2 {
    color: var(--text-primary);
    font-size: 1.05rem;
    margin: 4px 0 0;
}

.product-agent-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    width: 100%;
    padding: 15px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
}

.product-agent-card.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.product-agent-badge,
.product-images-agent-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: 3px 8px;
    background: var(--accent-subtle);
    color: var(--accent-light);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.product-agent-name {
    font-size: 1rem;
    font-weight: 700;
}

.product-agent-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
}

.product-images-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 2px;
}

.lacy-source-mode {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--bg-tertiary);
}

.product-images-page .avatar-textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.product-images-page .avatar-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

.product-images-page .prompt-textarea {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    resize: vertical;
}

.lacy-upload-zone.drag-over {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-subtle);
}

.lacy-source-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.lacy-source-thumb {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-secondary);
    min-height: 104px;
}

.lacy-source-thumb img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.lacy-source-thumb-label {
    display: block;
    padding: 6px 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lacy-source-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    cursor: pointer;
    line-height: 1;
    z-index: 2;
}

.product-images-actions {
    justify-content: space-between;
    gap: 12px;
}

.lacy-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.lacy-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.lacy-result-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 230px;
}

.lacy-result-image {
    position: relative;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.lacy-result-image img {
    width: 100%;
    height: 100%;
    min-height: 230px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.lacy-image-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 3px 7px;
    text-transform: uppercase;
}

.lacy-result-footer {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.lacy-result-footer .var-badge {
    background: var(--accent-subtle);
    color: var(--accent-light);
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.74rem;
    border: 1px solid rgba(124, 109, 232, 0.15);
}

.lacy-prompt-preview {
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.5;
    margin: 0;
    padding: 10px 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.lacy-result-error {
    padding: 18px;
    color: var(--error);
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    .product-images-shell {
        grid-template-columns: 1fr;
    }

    .product-images-agent-menu {
        position: static;
    }

    .lacy-result-pair {
        grid-template-columns: 1fr;
    }
}

/* Product Images: Step-based redesign */

.pi-step-hidden {
    display: none !important;
}

@keyframes pi-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pi-step {
    margin-bottom: 24px;
    animation: pi-fade-up 0.2s ease both;
}

/* Step 1 - Agent selection */
.pi-step-intro {
    margin-bottom: 20px;
}

.pi-step-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-light);
    background: var(--accent-subtle);
    border-radius: 999px;
    padding: 3px 10px;
    margin-bottom: 8px;
}

.pi-step-intro h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.pi-step-intro p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin: 0;
}

.pi-agents-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 680px;
}

.pi-agent-card {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    padding: 20px 22px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    position: relative;
    z-index: 1;
}

.pi-agent-card:hover,
.pi-agent-card.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
    transform: translateY(-1px);
}

.pi-agent-card:hover .pi-agent-arrow {
    color: var(--accent-light);
    transform: translateX(3px);
}

.pi-agent-icon-wrap {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent-subtle);
    border: 1px solid rgba(124, 109, 232, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
}

.pi-agent-body {
    flex: 1;
    min-width: 0;
}

.pi-agent-avail-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.pi-agent-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 5px;
}

.pi-agent-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.55;
    margin: 0 0 10px;
}

.pi-agent-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pi-agent-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 9px;
    font-weight: 500;
}

.pi-agent-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color var(--transition), transform var(--transition);
    margin-left: 4px;
}

/* Step 2 - Config */
.pi-config-breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.pi-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.pi-back-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-secondary);
}

.pi-breadcrumb-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.pi-breadcrumb-current {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pi-breadcrumb-agent-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.pi-breadcrumb-agent-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.pi-breadcrumb-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Config card */
.pi-config-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
    max-width: 720px;
}

.pi-config-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--border);
}

.pi-config-card-iconwrap {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-subtle);
    border: 1px solid rgba(124, 109, 232, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
    margin-top: 2px;
}

.pi-config-card-title {
    flex: 1;
}

.pi-config-card-title h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 4px 0 0;
}

.pi-output-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    background: var(--accent-subtle);
    color: var(--accent-light);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Numbered form sections */
.pi-form-section {
    border-bottom: 1px solid var(--border);
}

.pi-form-section:last-of-type {
    border-bottom: none;
}

.pi-form-section-hd {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.pi-section-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-subtle);
    border: 1px solid rgba(124, 109, 232, 0.25);
    color: var(--accent-light);
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pi-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pi-form-section-body {
    padding: 18px 24px;
}

.pi-form-section-body .avatar-field {
    margin-bottom: 0;
}

/* Run bar */
.pi-run-bar {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 0;
    margin: 0;
}

@media (max-width: 640px) {
    .pi-agent-card {
        flex-wrap: wrap;
        gap: 14px;
    }

    .pi-agent-arrow {
        display: none;
    }

    .pi-config-breadcrumb {
        flex-wrap: wrap;
    }

    .pi-breadcrumb-desc {
        display: none;
    }

    .pi-config-card-header {
        flex-wrap: wrap;
    }

    .pi-output-pill {
        order: 3;
    }
}

/* ============================================
   Prompt Library
   ============================================ */
.prompt-library-page {
    max-width: 1200px;
    width: 100%;
}

.prompt-library-intro-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 22px;
}

.prompt-library-form-panel,
.prompt-guide-panel,
.prompt-library-toolbar,
.prompt-target-group,
.prompt-library-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.prompt-library-form-panel,
.prompt-guide-panel {
    padding: 22px;
}

.prompt-library-form-panel.is-collapsed {
    display: none;
}

.prompt-library-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.prompt-library-target-grid {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1.2fr);
    gap: 14px;
}

.prompt-library-select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.prompt-library-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.prompt-upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.prompt-upload-preview {
    min-width: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.prompt-upload-preview img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    background: #0b0b16;
}

.prompt-upload-preview span {
    display: block;
    padding: 7px 8px;
    color: var(--text-secondary);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-guide-panel {
    position: relative;
    border-color: rgba(32, 212, 160, 0.18);
    background:
        linear-gradient(135deg, rgba(32, 212, 160, 0.065), transparent 58%),
        var(--bg-secondary);
}

.prompt-guide-dismiss {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.prompt-guide-dismiss:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.07);
}

.prompt-guide-kicker {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    background: rgba(32, 212, 160, 0.1);
    color: var(--success);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.prompt-guide-panel h2 {
    margin: 0 34px 10px 0;
    color: var(--text-primary);
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.prompt-guide-panel ol {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 0.84rem;
    line-height: 1.7;
}

.prompt-library-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px;
    margin-bottom: 22px;
}

.prompt-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.prompt-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    transition: all var(--transition);
}

.prompt-filter-pill span {
    color: var(--text-muted);
    font-size: 0.74rem;
}

.prompt-filter-pill:hover,
.prompt-filter-pill.active {
    color: var(--text-primary);
    border-color: rgba(124, 109, 232, 0.35);
    background: var(--accent-subtle);
}

.prompt-filter-pill.active span {
    color: var(--accent-light);
}

.prompt-library-search {
    width: min(420px, 100%);
}

.prompt-library-search .input-group {
    margin: 0;
}

.prompt-groups-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.prompt-target-group {
    padding: 18px;
}

.prompt-target-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.prompt-target-type {
    display: block;
    margin-bottom: 4px;
    color: var(--accent-light);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.prompt-target-heading h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    margin: 0;
    overflow-wrap: anywhere;
}

.prompt-target-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.prompt-target-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--success);
    background: var(--success-subtle);
    border: 1px solid rgba(32, 212, 160, 0.18);
    border-radius: var(--radius-full);
    padding: 4px 9px;
}

.prompt-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.prompt-library-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.prompt-library-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.prompt-thumb-strip {
    display: grid;
    gap: 4px;
    height: 184px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.prompt-thumb-count-1 {
    grid-template-columns: 1fr;
}

.prompt-thumb-count-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prompt-thumb-count-3 {
    grid-template-columns: 1.15fr 0.85fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.prompt-thumb-count-3 .prompt-library-thumb:first-child {
    grid-row: 1 / 3;
}

.prompt-library-thumb,
.prompt-thumb-empty {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 6px;
    background: #0b0b16;
}

.prompt-library-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prompt-thumb-empty {
    height: 184px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent),
        var(--bg-tertiary);
}

.prompt-library-card-body {
    padding: 14px 14px 10px;
    flex: 1;
    min-height: 0;
}

.prompt-library-text {
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.65;
}

.prompt-library-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px 14px;
    border-top: 1px solid var(--border);
}

.prompt-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 980px) {
    .prompt-library-intro-grid {
        grid-template-columns: 1fr;
    }

    .prompt-library-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .prompt-library-search {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .prompt-library-target-grid,
    .prompt-upload-preview-grid {
        grid-template-columns: 1fr;
    }

    .prompt-target-heading,
    .prompt-library-card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .prompt-target-meta,
    .prompt-card-actions {
        justify-content: flex-start;
    }

    .prompt-library-grid {
        grid-template-columns: 1fr;
    }

    .prompt-thumb-strip,
    .prompt-thumb-empty {
        height: 168px;
    }
}

/* ============================================
   Prompt Menu Redesign
   ============================================ */
.prompt-menu-page {
    width: 100%;
    max-width: 1220px;
    padding-bottom: 88px;
}

.prompt-menu-header {
    margin-bottom: 18px;
}

.prompt-menu-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.prompt-menu-row {
    min-height: 108px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.prompt-menu-row-main {
    min-width: 0;
}

.prompt-menu-row h2 {
    margin: 0 0 5px;
    color: var(--text-primary);
    font-size: 1.08rem;
    font-weight: 750;
    letter-spacing: 0;
}

.prompt-menu-row p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.5;
}

.prompt-menu-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.prompt-menu-chip {
    min-width: 0;
    max-width: 210px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 9px 4px 5px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 650;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.prompt-menu-chip img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #0b0b16;
}

.prompt-menu-chip strong {
    margin-left: auto;
    color: var(--accent-light);
    font-size: 0.72rem;
    font-weight: 800;
}

.prompt-row-add,
.prompt-floating-add,
.prompt-overlay-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
}

.prompt-row-add {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.13);
    box-shadow: 0 6px 20px rgba(124, 109, 232, 0.28);
}

.prompt-row-add:hover,
.prompt-floating-add:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.prompt-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.prompt-section-title h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.04rem;
    letter-spacing: 0;
}

.prompt-section-title span {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.prompt-recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.prompt-recent-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.prompt-recent-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.prompt-preview-strip {
    width: 100%;
    max-height: 480px;
    height: 172px;
    display: grid;
    gap: 4px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.prompt-preview-count-1 {
    grid-template-columns: 1fr;
}

.prompt-preview-count-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prompt-preview-count-3 {
    grid-template-columns: 1.12fr 0.88fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.prompt-preview-count-3 .prompt-preview-image:first-child {
    grid-row: 1 / 3;
}

.prompt-preview-image,
.prompt-preview-empty {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 6px;
    background: #0b0b16;
}

.prompt-preview-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.prompt-preview-empty {
    height: 172px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent),
        var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.prompt-recent-body {
    min-width: 0;
    flex: 1;
    padding: 12px 13px 10px;
}

.prompt-link-pill {
    width: fit-content;
    max-width: 100%;
    margin-bottom: 8px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--accent-subtle);
    color: var(--accent-light);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.prompt-recent-body h3 {
    margin: 0 0 7px;
    color: var(--text-primary);
    font-size: 0.94rem;
    font-weight: 750;
    letter-spacing: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.prompt-recent-body p {
    max-height: 150px;
    margin: 0;
    overflow: auto;
    color: var(--text-secondary);
    font-size: 0.84rem;
    line-height: 1.58;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.prompt-card-link-form {
    display: grid;
    grid-template-columns: minmax(96px, 0.8fr) minmax(0, 1.35fr) auto;
    align-items: end;
    gap: 8px;
    padding: 10px 13px;
    border-top: 1px solid var(--border);
    background: rgba(124, 109, 232, 0.035);
}

.prompt-card-link-form .prompt-menu-select {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.78rem;
}

.prompt-card-link-panel {
    display: none;
    min-width: 0;
}

.prompt-recent-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 13px 13px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.prompt-recent-actions > span {
    margin-right: auto;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 650;
}

.prompt-recent-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.025);
}

.prompt-recent-empty p {
    margin: 0;
    font-size: 0.9rem;
}

.prompt-floating-add {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 58px;
    height: 58px;
    z-index: 120;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: var(--accent);
    color: white;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), 0 8px 28px rgba(124, 109, 232, 0.32);
}

.prompt-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.prompt-overlay.is-open {
    display: flex;
}

.prompt-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(10px);
}

.prompt-overlay-panel {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 22px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.prompt-overlay-panel h2 {
    margin: 0 42px 18px 0;
    color: var(--text-primary);
    font-size: 1.14rem;
    letter-spacing: 0;
}

.prompt-overlay-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.prompt-overlay-close:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.06);
}

.prompt-modal-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.prompt-menu-select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.prompt-menu-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.prompt-link-box,
.prompt-target-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.prompt-link-panel {
    display: none;
}

@media (max-width: 760px) {
    .prompt-menu-row {
        grid-template-columns: minmax(0, 1fr) 42px;
        padding: 14px;
    }

    .prompt-menu-chip {
        max-width: 160px;
    }

    .prompt-recent-grid {
        grid-template-columns: 1fr;
    }

    .prompt-link-box,
    .prompt-target-grid,
    .prompt-card-link-form {
        grid-template-columns: 1fr;
    }

    .prompt-floating-add {
        right: 18px;
        bottom: 18px;
    }
}
