/* ============================================
   AD CRAFT AI v3 — Premium Ad Creative Studio UI
   Uses portfolio CSS variables from style.css
   Dark = green/cyan · Light = orange
   Canvas-based bg with floating ad frames (both themes)
   ============================================ */

/* ---- Hero — Uses portfolio's hero-bg, hero-gradient, hero-grid from style.css ---- */
/* Prevent layout shift when scrollbar appears/disappears on app section toggle */
html:has(.ac-hero) {
    scrollbar-gutter: stable;
}

.ac-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding-top: 100px;
}

/* Particles (matches ATS Forge / Sheet Insight) */
.ac-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.ac-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    animation: acParticleFloat 8s ease-in-out infinite;
}
@keyframes acParticleFloat {
    0%, 100% { opacity: 0; transform: translateY(100vh) scale(0); }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-20vh) scale(1); }
}

/* Orbs (matches Sheet Insight) */
.ac-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    animation: acOrbFloat 25s ease-in-out infinite;
    pointer-events: none;
}
.ac-orb-1 { width: 400px; height: 400px; background: rgba(0, 255, 136, 0.08); top: 20%; right: 10%; }
.ac-orb-2 { width: 300px; height: 300px; background: rgba(139, 92, 246, 0.06); bottom: 20%; left: 10%; animation-delay: -10s; }
.ac-orb-3 { width: 250px; height: 250px; background: rgba(0, 212, 255, 0.05); top: 60%; right: 30%; animation-delay: -18s; }

[data-theme="light"] .ac-orb-1 { background: rgba(217, 119, 6, 0.06); }
[data-theme="light"] .ac-orb-2 { background: rgba(234, 88, 12, 0.05); }
[data-theme="light"] .ac-orb-3 { background: rgba(217, 119, 6, 0.04); }

@keyframes acOrbFloat {
    0%, 100% { transform: translateY(0) translateX(0); }
    33% { transform: translateY(-20px) translateX(15px); }
    66% { transform: translateY(15px) translateX(-10px); }
}

/* Pulse dot */
.ac-pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: acPulse 2s ease-in-out infinite;
    vertical-align: middle;
}
@keyframes acPulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); } 50% { box-shadow: 0 0 0 8px transparent; } }

/* ---- Hero Layout — Grid like Sheet Insight ---- */
.ac-hero-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4xl);
    align-items: center;
    position: relative;
    z-index: 1;
}

.ac-hero-content { z-index: 1; }

#acAuthArea {
    display: inline-block;
    max-width: 100%;
}

.ac-hero-title {
    font-size: clamp(2.5rem, 5.5vw, 4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: var(--space-lg);
}

.ac-hero-desc {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 520px;
    line-height: 1.8;
    margin-bottom: var(--space-xl);
}
.ac-hero-desc em { color: var(--accent-primary); font-style: normal; font-weight: 600; }

/* Chips — matches ATS Forge feature-chip */
.ac-hero-chips {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-2xl);
}
.ac-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition-base);
}
.ac-chip:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.ac-chip svg { color: var(--accent-primary); }

/* Start button — uses portfolio btn-primary btn-large */
/* Start button — uses portfolio btn-primary btn-large */
.ac-start-btn {
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

/* Auth Area — matches Sheet Insight pattern */
.ac-auth-status { margin-bottom: var(--space-md); }
.ac-badge-ready {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.ac-badge-connected {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    animation: acBadgePop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes acBadgePop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.ac-auth-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.ac-privacy-note {
    font-size: 0.72rem;
    opacity: 0.7;
    margin-top: 4px;
}
/* Stop Creating button — matches Sheet Insight disconnect pattern */
.ac-disconnect-btn {
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.ac-disconnect-btn:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    border: 1px solid #ef4444 !important;
    color: #ef4444 !important;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
    transform: scale(1.02);
}
.ac-disconnect-btn:hover svg {
    transform: none !important;
}
.ac-pulse-dot-sm {
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: inline-block;
    animation: acPulse 2s ease-in-out infinite;
}

/* ---- Hero Visual (Preview Stack) ---- */
.ac-hero-visual {
    position: relative;
}
.ac-preview-stack {
    position: relative;
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ac-preview-card {
    position: absolute;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-slow);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.ac-preview-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-muted);
}
.ac-preview-ratio {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-primary);
    background: var(--accent-glow);
    padding: 2px 10px;
    border-radius: var(--radius-full);
}
.ac-preview-1 { width: 200px; height: 200px; z-index: 3; transform: rotate(-3deg); animation: acFloat1 6s ease-in-out infinite; }
.ac-preview-2 { width: 140px; height: 250px; right: 10%; z-index: 2; transform: rotate(5deg); animation: acFloat2 7s ease-in-out infinite; }
.ac-preview-3 { width: 250px; height: 140px; left: 5%; bottom: 10%; z-index: 1; transform: rotate(-2deg); animation: acFloat3 8s ease-in-out infinite; }
@keyframes acFloat1 { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(-3deg) translateY(-12px); } }
@keyframes acFloat2 { 0%, 100% { transform: rotate(5deg) translateY(0); } 50% { transform: rotate(5deg) translateY(-8px); } }
@keyframes acFloat3 { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-10px); } }

/* ---- Creative Mode Toggle ---- */
.ac-mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 5px;
    margin-bottom: var(--space-sm);
    overflow: hidden;
}
.ac-mode-slider {
    position: absolute;
    top: 5px;
    left: 5px;
    width: calc(50% - 7.5px);
    height: calc(100% - 10px);
    background: var(--bg-card);
    border: 1.5px solid var(--accent-primary);
    border-radius: calc(var(--radius-lg) - 3px);
    box-shadow: 0 0 20px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 0;
    pointer-events: none;
}
.ac-mode-slider.slide-right {
    transform: translateX(calc(100% + 5px));
}
[data-theme="light"] .ac-mode-slider {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 16px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.08);
}

.ac-mode-tab {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-lg) - 3px);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-muted);
    text-align: left;
    font-family: inherit;
}
.ac-mode-tab:hover:not(.active) {
    color: var(--text-secondary);
}
.ac-mode-tab.active {
    color: var(--text-primary);
}
.ac-mode-tab-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.ac-mode-tab.active .ac-mode-tab-icon {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}
.ac-mode-tab-icon svg {
    transition: color 0.3s ease;
}
.ac-mode-tab.active .ac-mode-tab-icon svg {
    color: var(--accent-primary);
}
.ac-mode-tab-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.ac-mode-tab-title {
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-mode-tab-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
    transition: color 0.3s ease;
}
.ac-mode-tab.active .ac-mode-tab-desc {
    color: var(--text-secondary);
}

/* Recreation mode info note — no green shade */
/* Mode info note — theme-aware bg + dashed border */
.ac-mode-recreation-note {
    display: none;
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1.5px dashed var(--accent-primary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.ac-mode-recreation-note strong {
    color: var(--accent-primary);
    font-weight: 600;
}

.ac-mode-recreation-note.visible {
    display: block;
    animation: acFadeIn 0.4s ease forwards;
}

/* Dark mode */
[data-theme="dark"] .ac-mode-recreation-note {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

/* Light mode */
[data-theme="light"] .ac-mode-recreation-note {
    background: #ffffff;
    border-color: var(--accent-primary);
}

/* ---- Usage Limits — contextual inline bar ---- */
.ac-usage-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: var(--space-md);
    padding: 0 2px;
    min-height: 22px;
}

.ac-usage-mode-tag {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent-primary);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    line-height: 1;
}

.ac-usage-remaining {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.ac-usage-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.ac-usage-dot.ac-usage-dot-ok {
    background: var(--accent-primary);
    box-shadow: 0 0 5px var(--accent-glow);
}

.ac-usage-dot.ac-usage-dot-out {
    background: #ef4444;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.3);
}

.ac-usage-reset {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}

.ac-usage-reset svg {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.7;
}

/* Mobile */
@media (max-width: 600px) {
    .ac-usage-bar {
        justify-content: center;
        gap: 8px;
        margin-bottom: var(--space-sm);
    }
    .ac-usage-mode-tag {
        font-size: 0.62rem;
        padding: 2px 6px;
    }
    .ac-usage-remaining {
        font-size: 0.65rem;
    }
    .ac-usage-reset {
        font-size: 0.62rem;
        padding-left: 6px;
    }
}

@media (max-width: 380px) {
    .ac-usage-mode-tag {
        font-size: 0.58rem;
    }
    .ac-usage-remaining {
        font-size: 0.6rem;
    }
    .ac-usage-reset {
        font-size: 0.58rem;
    }
    .ac-usage-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px 8px;
    }
    .ac-usage-reset {
        border-left: none;
        padding-left: 0;
    }
}

/* Responsive mode toggle */
@media (max-width: 600px) {
    .ac-mode-toggle {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .ac-mode-slider {
        width: calc(100% - 10px);
        height: calc(50% - 7.5px);
        transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .ac-mode-slider.slide-right {
        transform: translateY(calc(100% + 5px));
    }
    .ac-mode-tab {
        padding: var(--space-sm) var(--space-md);
    }
    .ac-mode-tab-icon {
        width: 34px;
        height: 34px;
    }
    .ac-mode-tab-icon svg {
        width: 18px;
        height: 18px;
    }
    .ac-mode-tab-title {
        font-size: 0.82rem;
    }
    .ac-mode-tab-desc {
        font-size: 0.65rem;
    }
}

@media (max-width: 380px) {
    .ac-mode-tab-desc {
        display: none;
    }
    .ac-mode-tab {
        gap: var(--space-sm);
    }
}

/* ---- App Section — bg from hero-bg persists (position: fixed) ---- */
.ac-app-section {
    padding: var(--space-3xl) 0 var(--space-4xl);
    position: relative;
}

/* ---- Stepper ---- */
.ac-stepper {
    max-width: 700px;
    margin: 0 auto var(--space-2xl);
    position: relative;
}
.ac-stepper-track {
    position: absolute;
    top: 18px;
    left: 40px;
    right: 40px;
    height: 3px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    z-index: 0;
}
.ac-stepper-progress {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.ac-stepper-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}
.ac-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.ac-step-indicator {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}
.ac-step.active .ac-step-indicator {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
    color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
}
.ac-step.completed .ac-step-indicator {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: var(--bg-primary);
}
.ac-step-check { display: none; width: 16px; height: 16px; }
.ac-step.completed .ac-step-number { display: none; }
.ac-step.completed .ac-step-check { display: block; }
.ac-step-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
    transition: color var(--transition-base);
}
.ac-step.active .ac-step-label { color: var(--text-primary); }
.ac-step.completed .ac-step-label { color: var(--accent-primary); }

/* ---- Container & Panels ---- */
.ac-container {
    max-width: 960px;
    margin: 0 auto;
}

.ac-step-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    animation: acFadeIn 0.4s ease forwards;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] .ac-step-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ac-step-panel.hidden { display: none; }

@keyframes acFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ac-step-header {
    margin-bottom: var(--space-xl);
}
.ac-step-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.ac-step-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ---- Form Grid ---- */
.ac-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.ac-form-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}
.ac-form-section-title svg { color: var(--accent-primary); flex-shrink: 0; }

/* AI Badge */
.ac-ai-badge {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-left: auto;
}

/* ---- Inputs ---- */
.ac-input-group {
    margin-bottom: var(--space-md);
}
.ac-input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.ac-optional { color: var(--text-muted); font-weight: 400; }

.ac-input, .ac-textarea, .ac-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.92rem;
    transition: all var(--transition-base);
    outline: none;
}
.ac-input:focus, .ac-textarea:focus, .ac-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.ac-textarea { resize: vertical; min-height: 80px; }
.ac-select { cursor: pointer; }

/* Field auto-fill flash */
.ac-field-filled {
    animation: acFieldFlash 1.5s ease;
}
@keyframes acFieldFlash {
    0% { box-shadow: 0 0 0 3px var(--accent-glow); border-color: var(--accent-primary); }
    100% { box-shadow: none; border-color: var(--border-color); }
}

/* ---- AI Fill Button ---- */
.ac-input-with-ai {
    position: relative;
}
.ac-ai-fill-btn {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    color: var(--accent-primary);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ac-ai-fill-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
    transform: none;
}
.ac-ai-fill-btn svg { flex-shrink: 0; }
.ac-ai-fill-btn.ac-ai-loading {
    pointer-events: none;
    opacity: 0.6;
    animation: acPulse 1s ease-in-out infinite;
}

/* Enhance variant — wider */
.ac-enhance-btn {
    padding: 3px 14px;
}

/* ---- URL Section ---- */
.ac-url-section {
    margin-bottom: var(--space-xl);
}

.ac-url-input-row {
    display: flex;
    gap: var(--space-sm);
}
.ac-url-input {
    flex: 1;
}
.ac-url-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-width: 110px;
    justify-content: center;
}
.ac-url-btn-loading {
    display: flex;
    gap: 4px;
    align-items: center;
}
.ac-url-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---- Extracted Products ---- */
.ac-extracted-products {
    margin-bottom: var(--space-xl);
}
.ac-products-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.ac-extracted-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    position: relative;
    transition: all var(--transition-base);
    animation: acFadeIn 0.3s ease forwards;
}
.ac-extracted-card:hover {
    border-color: var(--accent-primary);
}
.ac-extracted-info { flex: 1; min-width: 0; }
.ac-extracted-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}
.ac-extracted-brand {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.ac-extracted-features {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.ac-extracted-url {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Use button for extracted products */
.ac-extracted-use-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
}
.ac-extracted-use-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
    transform: scale(1.1);
}

/* ---- Divider ---- */
.ac-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-xl) 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.ac-divider::before, .ac-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ---- Campaign Intelligence Section ---- */
.ac-campaign-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* ---- Extra Fields ---- */
.ac-extra-fields {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* ---- Upload Zones ---- */
.ac-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-bottom: var(--space-md);
    position: relative;
    overflow: hidden;
}
.ac-upload-zone:hover, .ac-upload-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}
.ac-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.ac-upload-icon { color: var(--text-muted); transition: color var(--transition-base); }
.ac-upload-zone:hover .ac-upload-icon { color: var(--accent-primary); }
.ac-upload-title { font-weight: 600; font-size: 0.95rem; }
.ac-upload-hint { font-size: 0.8rem; color: var(--text-muted); max-width: 300px; line-height: 1.5; }
.ac-upload-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--accent-primary);
    background: var(--accent-glow);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    margin-top: 4px;
}
.ac-upload-badge svg { flex-shrink: 0; }

/* Logo Preview */
.ac-upload-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.ac-upload-preview img {
    max-height: 100px;
    max-width: 200px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

/* Product Thumbs */
.ac-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--space-sm);
    padding: var(--space-sm);
}
.ac-product-thumb {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
}
.ac-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Remove button */
.ac-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    z-index: 5;
}
.ac-remove-btn:hover { background: rgba(239, 68, 68, 1); transform: scale(1.1); }
.ac-extracted-card .ac-remove-btn {
    position: relative;
    top: auto;
    right: auto;
    flex-shrink: 0;
}

.ac-add-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-base);
}
.ac-add-more-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

/* ---- Style Cards ---- */
.ac-style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
}
.ac-style-card {
    position: relative;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}
.ac-style-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.ac-style-card.selected {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
    box-shadow: 0 0 20px var(--accent-glow);
}
.ac-style-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: var(--bg-primary);
    display: none;
    align-items: center;
    justify-content: center;
}
.ac-style-card.selected .ac-style-check { display: flex; }
.ac-style-name { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.ac-style-desc { display: block; font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }

/* ---- Ratio Cards ---- */
.ac-ratio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: var(--space-sm);
}
.ac-ratio-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--space-sm) var(--space-xs);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
}
.ac-ratio-card:hover { border-color: var(--border-hover); }
.ac-ratio-card.selected {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}
.ac-ratio-preview {
    background: var(--border-color);
    border-radius: 3px;
    border: 1px solid var(--text-muted);
    transition: all var(--transition-base);
}
.ac-ratio-card.selected .ac-ratio-preview {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}
.ac-ratio-label { font-weight: 600; font-size: 0.8rem; }
.ac-ratio-use { font-size: 0.65rem; color: var(--text-muted); line-height: 1.3; }

/* ---- Platform Chips ---- */
.ac-platform-grid { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.ac-platform-chip {
    padding: 5px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}
.ac-platform-chip:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.ac-platform-chip.selected {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
    font-weight: 600;
}

/* ---- AI Image Suggestions ---- */
.ac-image-direction-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}
.ac-image-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    min-height: 40px;
}
.ac-suggestion-chip {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: left;
    line-height: 1.4;
}
.ac-suggestion-chip:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
}
.ac-suggestion-chip.selected {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
    color: var(--accent-primary);
    font-weight: 500;
}
.ac-suggestions-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 8px 0;
}
.ac-suggestions-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 8px 0;
}

/* ---- Layout Row ---- */
.ac-layout-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

/* ---- Per-Concept Layout Blocks ---- */
.ac-layout-concept {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    transition: border-color 0.2s;
}
.ac-layout-concept:first-child {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(0,255,136,0.04) 0%, transparent 60%);
}
.ac-layout-concept-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}
.ac-concept-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
}
.ac-concept-badge.ac-concept-primary {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}
.ac-concept-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ---- Color Preview Swatches ---- */
.ac-color-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding: 0;
}
.ac-color-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    height: 34px;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: monospace;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15), inset 0 0 0 1px rgba(255,255,255,0.1);
    cursor: default;
    transition: transform 0.15s;
}
.ac-color-swatch:hover {
    transform: scale(1.08);
}

/* ---- Color Picker Row ---- */
.ac-color-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.ac-color-picker-input {
    width: 40px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}
.ac-color-picker-input::-webkit-color-swatch-wrapper { padding: 1px; }
.ac-color-picker-input::-webkit-color-swatch { border-radius: 5px; border: none; }
.ac-color-picker-input::-moz-color-swatch { border-radius: 5px; border: none; }
.ac-color-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.ac-color-add-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}
.ac-color-quick-picks {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}
.ac-quick-color {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    padding: 0;
}
.ac-quick-color:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* ---- Step Actions ---- */
.ac-step-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* ---- Override portfolio .btn radius for all Ad Craft buttons ---- */
/* ---- Override portfolio .btn radius for all Ad Craft buttons ---- */
.ac-hero .btn,
.ac-app-section .btn,
.ac-modal-actions .btn {
    border-radius: 16px !important;
    transition: transform var(--transition-base), border-color var(--transition-base), background var(--transition-base);
}

/* Button should pop/lift a bit, but not move upward */
.ac-hero .btn:hover,
.ac-app-section .btn:hover,
.ac-modal-actions .btn:hover {
    transform: scale(1.025) !important;
}

/* SVG + text vertical alignment fix for buttons with inline icons */
.ac-btn .btn-text,
.ac-start-btn,
.ac-url-btn .ac-url-btn-text,
.ac-generate-btn .btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Smooth icon animation */
.ac-hero .btn svg,
.ac-app-section .btn svg,
.ac-modal-actions .btn svg {
    transition: transform 0.22s ease;
}

/* Keep existing arrow animation untouched */
/* Only raise/pop the first icon at the start, like a star */
.ac-hero .btn:hover svg:first-child,
.ac-app-section .btn:hover svg:first-child,
.ac-modal-actions .btn:hover svg:first-child {
    transform: scale(1.12);
}

@media (max-width: 768px) {
    .ac-hero .btn,
    .ac-app-section .btn {
        border-radius: 12px !important;
    }
    .ac-result-actions .btn {
        border-radius: 6px !important;
    }
}

@media (max-width: 480px) {
    .ac-hero .btn,
    .ac-app-section .btn {
        border-radius: 10px !important;
    }
    .ac-result-actions .btn {
        border-radius: 6px !important;
    }
}

.ac-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.92rem;
}
.btn-ghost:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(1.025);
}
/* Generate button */
.ac-generate-btn {
    font-size: 1.05rem;
    padding: 12px 28px;
}
.ac-generate-btn .btn-loader {
    display: flex;
    gap: 4px;
    align-items: center;
}
.loader-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: acLoaderBounce 1.2s ease-in-out infinite;
}
.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes acLoaderBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---- Results ---- */
.ac-results-meta {
    margin-bottom: var(--space-lg);
}
.ac-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.ac-meta-item strong { color: var(--text-primary); }
.ac-meta-stats {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}
.ac-meta-cost, .ac-meta-remaining, .ac-meta-mode, .ac-meta-score {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 2px 10px;
    background: var(--accent-glow);
    border-radius: var(--radius-full);
    color: var(--accent-primary);
}
.ac-meta-mode {
    font-weight: 700;
}
.ac-meta-score {
    font-weight: 700;
}

.ac-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.ac-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
    animation: acCardIn 0.5s ease forwards;
    opacity: 0;
}
.ac-result-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}
@keyframes acCardIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ac-result-img-wrap {
    aspect-ratio: auto;
    overflow: hidden;
    background: var(--bg-tertiary);
    position: relative;
}
.ac-result-img-wrap img {
    width: 100%;
    height: auto;
    display: block;
}

/* Concept label — inline tag above download button */
.ac-result-concept-tag {
    display: inline-block;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}
.ac-result-concept-tag.ac-result-concept-primary {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

.ac-result-info {
    padding: var(--space-md);
}

/* Creative approach badge */
.ac-result-approach {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    background: var(--accent-glow);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-bottom: 6px;
}

.ac-result-info h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.ac-result-headline {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.ac-result-tagline {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: var(--space-sm);
}
.ac-result-palette {
    display: flex;
    gap: 6px;
    margin-bottom: var(--space-md);
}
.ac-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: help;
}
.ac-result-actions {
    display: flex;
    gap: var(--space-sm);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}
.ac-result-actions .btn {
    border-radius: 6px !important;
}

/* ---- Guardrails Notice ---- */
.ac-guardrails-notice {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-lg);
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}
.ac-guardrail-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.ac-guardrail-item svg { color: var(--accent-primary); flex-shrink: 0; }

/* ---- Toast ---- */
.ac-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 0.9rem;
    z-index: 10000;
    box-shadow: var(--shadow-md);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90vw;
}
.ac-toast.visible { transform: translateX(-50%) translateY(0); }
.ac-toast-error { border-color: #ef4444; }
.ac-toast-error span:first-child { color: #ef4444; }
.ac-toast-success { border-color: var(--accent-primary); }
.ac-toast-success span:first-child { color: var(--accent-primary); }
.ac-toast button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}

/* ---- Shake Animation ---- */
.ac-shake {
    animation: acShake 0.5s ease;
    border-color: #ef4444 !important;
}
@keyframes acShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ---- Stale Field Indicator (v4 dependency tracking) ---- */
.ac-field-stale {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.05) !important;
}
.ac-stale-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    top: 0;
    right: 60px;
    padding: 2px 8px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid #f59e0b;
    border-radius: var(--radius-full);
    color: #f59e0b;
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    z-index: 2;
}
.ac-stale-badge:hover {
    background: #f59e0b;
    color: var(--bg-primary);
}

.ac-result-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.ac-result-score {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
}
.ac-result-layout {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: var(--space-sm);
    font-style: italic;
}

.ac-result-strategy {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: var(--space-xs);
    padding: 6px 8px;
    background: var(--glass-bg);
    border-radius: 6px;
    border-left: 2px solid var(--accent-primary);
}

/* ---- Intent Summary Tags ---- */
.ac-intent-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-sm);
}
.ac-intent-tag {
    display: inline-flex;
    padding: 2px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 900px) {
    .ac-hero-inner {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-2xl);
    }
    .ac-hero-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .ac-hero-desc { max-width: 100%; }
    .ac-hero-chips { justify-content: center; }

    .ac-hero-visual {
        position: relative;
        display: flex;
        justify-content: center;
        width: 100%;
        margin-top: var(--space-lg);
    }

    .ac-hero-title {
        font-size: clamp(2rem, 6vw, 3rem);
    }
    .ac-form-grid {
        grid-template-columns: 1fr;
    }
    .ac-layout-row {
        grid-template-columns: 1fr;
    }
    .ac-layout-concept .ac-layout-row {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .ac-color-swatch {
        min-width: 60px;
        height: 30px;
        font-size: 0.62rem;
    }
    .ac-step-panel {
        padding: var(--space-lg);
    }
    .ac-ratio-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    .ac-preview-stack {
        width: 100%;
        max-width: 320px;
        height: 260px;
        margin: 0 auto;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .ac-hero {
        padding-top: 80px;
        min-height: auto;
        padding-bottom: var(--space-2xl);
    }
    .ac-hero-title {
        font-size: clamp(1.6rem, 8vw, 2.5rem);
    }
    .ac-hero-desc {
        font-size: 0.95rem;
    }
    .ac-hero-visual {
        max-width: 100%;
    }
    .ac-preview-stack {
        height: 180px;
    }
    .ac-preview-1 { width: 100px; height: 100px; }
    .ac-preview-2 { width: 70px; height: 124px; }
    .ac-preview-3 { width: 124px; height: 70px; }
    .ac-start-btn,
    .ac-disconnect-btn {
        width: 100%;
        justify-content: center;
        font-size: 1rem;
        padding: 14px 24px;
    }
    .ac-auth-note { font-size: 0.7rem; text-align: center; }
    .ac-privacy-note { font-size: 0.68rem; }
    .ac-auth-status { text-align: center; }
    .ac-stepper-steps { gap: 0; }
    .ac-step-label { font-size: 0.6rem; max-width: 60px; }
    .ac-step-indicator { width: 28px; height: 28px; font-size: 0.72rem; }
    .ac-stepper-track { left: 20px; right: 20px; }
    .ac-style-grid { grid-template-columns: 1fr 1fr; }
    .ac-ratio-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .ac-step-actions {
        flex-direction: column;
    }
    .ac-step-actions .btn,
    .ac-step-actions .ac-btn {
        width: 100%;
        justify-content: center;
    }
    .ac-results-grid { grid-template-columns: 1fr; }
    .ac-meta-row { flex-direction: column; gap: var(--space-sm); }
    .ac-guardrails-notice { flex-direction: column; align-items: center; text-align: center; }
    .ac-url-input-row { flex-direction: column; }
    .ac-url-btn { width: 100%; }
    .ac-chip {
        font-size: 0.75rem;
        padding: 5px 10px;
    }
    .ac-hero-chips {
        gap: 6px;
    }
    .ac-platform-grid {
        gap: 4px;
    }
    .ac-platform-chip {
        padding: 4px 10px;
        font-size: 0.72rem;
    }
    .ac-generate-btn {
        width: 100%;
        justify-content: center;
        font-size: 0.95rem;
        padding: 12px 20px;
    }
    .ac-step-panel {
        padding: var(--space-md);
    }
    .ac-step-header h2 {
        font-size: 1.2rem;
    }
    .ac-form-section-title {
        font-size: 0.9rem;
    }
    .ac-ai-fill-btn {
        font-size: 0.6rem;
        padding: 2px 8px;
    }
    .ac-extracted-card {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    .ac-suggestion-chip {
        padding: 6px 12px;
        font-size: 0.78rem;
    }
    .ac-app-section {
        padding: var(--space-xl) 0 var(--space-2xl);
    }
}

/* Small phones */
@media (max-width: 380px) {
    .ac-style-grid { grid-template-columns: 1fr; }
    .ac-ratio-grid { grid-template-columns: 1fr 1fr; }
    .ac-hero-title {
        font-size: 1.5rem;
    }
    .ac-preview-stack {
        height: 140px;
    }
    .ac-preview-1 { width: 80px; height: 80px; }
    .ac-preview-2 { width: 56px; height: 100px; }
    .ac-preview-3 { width: 100px; height: 56px; }
}
/* ============================================
   AC Confirm Modal (renamed from si-modal-*)
   ============================================ */
.ac-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: background var(--transition-smooth), backdrop-filter var(--transition-smooth);
    padding: var(--space-lg);
    pointer-events: none;
}

.ac-modal-overlay.ac-modal-visible {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: all;
}

.ac-modal-overlay.ac-modal-exiting {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

.ac-modal-card {
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px 36px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-card);
    transform: scale(0.88) translateY(30px);
    opacity: 0;
    transition: all var(--transition-smooth);
}

.ac-modal-visible .ac-modal-card {
    transform: scale(1) translateY(0);
    opacity: 1;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.ac-modal-exiting .ac-modal-card {
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    border-color: var(--border-color);
    box-shadow: var(--shadow-card);
}

.ac-modal-accent-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform var(--transition-smooth);
}

.ac-modal-visible .ac-modal-accent-bar {
    transform: scaleX(1);
}

.ac-modal-exiting .ac-modal-accent-bar {
    transform: scaleX(0);
}

.ac-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    margin-bottom: var(--space-md);
    transition: transform var(--transition-smooth);
}

.ac-modal-icon.ac-modal-icon-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.ac-modal-visible .ac-modal-icon {
    transform: scale(1);
}

.ac-modal-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.ac-modal-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: var(--space-xl);
    white-space: pre-line;
}

.ac-modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

.ac-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.ac-modal-btn-confirm {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    border: none;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.ac-modal-btn-confirm:hover { transform: scale(1.03); box-shadow: var(--shadow-glow); }
.ac-modal-btn-confirm:active { transform: scale(0.97); }

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

.ac-modal-btn-cancel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.ac-modal-btn-cancel:hover::before { transform: translateX(100%); }
.ac-modal-btn-cancel:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(1.025);
}
.ac-modal-btn-cancel:active { transform: scale(0.97); }

/* ---- Rate Limit Modal ---- */
.ac-ratelimit-card .ac-modal-text { margin-bottom: var(--space-md); }
.ac-ratelimit-timer {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: inline-block;
    text-align: center;
}
.ac-ratelimit-countdown {
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 0.95rem;
}
.ac-ratelimit-alt {
    font-size: 0.84rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-glow);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    line-height: 1.4;
}
.ac-ratelimit-both {
    margin-bottom: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.ac-ratelimit-both .ac-ratelimit-row {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    line-height: 1.4;
}
.ac-ratelimit-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.ac-ratelimit-dot-on {
    background: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-glow);
}
.ac-ratelimit-dot-off {
    background: var(--text-muted);
    opacity: 0.35;
}
.ac-ratelimit-contact {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
    line-height: 1.6;
    text-align: center;
}
.ac-ratelimit-email {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.ac-ratelimit-email:hover { text-decoration: underline; }

@media (max-width: 768px) {
    .ac-modal-overlay { padding: var(--space-md); }
    .ac-modal-card {
        padding: 36px 28px 28px;
        max-width: 380px;
        border-radius: var(--radius-lg);
    }
}

@media (max-width: 480px) {
    .ac-modal-card {
        padding: 28px 20px 22px;
        margin: 0 var(--space-xs);
        max-width: calc(100vw - var(--space-lg));
        border-radius: var(--radius-md);
    }
    .ac-modal-icon { width: 44px; height: 44px; }
    .ac-modal-icon svg { width: 22px; height: 22px; }
    .ac-modal-title { font-size: 1.05rem; }
    .ac-modal-text { font-size: 0.83rem; margin-bottom: var(--space-lg); }
    .ac-modal-actions { flex-direction: column; align-items: stretch; }
    .ac-modal-btn {
        min-width: 110px;
        font-size: 0.88rem;
        padding: 10px 20px;
        border-radius: 8px;
    }
    .ac-ratelimit-alt {
        font-size: 0.78rem;
        flex-wrap: wrap;
    }
    .ac-ratelimit-both .ac-ratelimit-row {
        font-size: 0.76rem;
    }
    .ac-ratelimit-timer { font-size: 0.78rem; }
    .ac-ratelimit-contact { font-size: 0.75rem; }
    .ac-ratelimit-email { font-size: 0.72rem; }
    .ac-ratelimit-countdown { font-size: 0.85rem; }
}


/* ============================================
   GENERATION PROGRESS MODAL v4
   z-index 9999 — below custom-cursor (10000/10001)
   CRITICAL FIX: timeline line uses fixed height,
   NOT flex:1 which caused it to stretch on mobile.
   ============================================ */

.ac-gen-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                backdrop-filter 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    padding: var(--space-lg);
    pointer-events: none;
    opacity: 0;
}

.ac-gen-overlay.ac-gen-visible {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    pointer-events: all;
    opacity: 1;
}

.ac-gen-overlay.ac-gen-exiting {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ac-gen-card {
    position: relative;
    overflow: hidden;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 0;
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    box-shadow: var(--shadow-card);
    transform: scale(0.88) translateY(40px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ac-gen-visible .ac-gen-card {
    transform: scale(1) translateY(0);
    opacity: 1;
    border-color: var(--accent-primary);
    box-shadow: 0 0 60px -10px var(--accent-glow), var(--shadow-card);
}

.ac-gen-exiting .ac-gen-card {
    transform: scale(0.92) translateY(30px);
    opacity: 0;
    border-color: var(--border-color);
}

/* --- Progress top bar --- */
.ac-gen-topbar {
    position: sticky;
    top: 0;
    height: 4px;
    background: var(--bg-elevated, var(--bg-tertiary));
    overflow: hidden;
    z-index: 2;
}

.ac-gen-topbar-fill {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 0 2px 2px 0;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 12px var(--accent-glow);
}

.ac-gen-topbar-fill::after {
    content: '';
    position: absolute;
    right: 0; top: 0;
    width: 40px; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4));
    animation: acGenBarShimmer 1.5s ease-in-out infinite;
}

@keyframes acGenBarShimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* --- Header --- */
.ac-gen-header {
    padding: 28px 28px 0;
    text-align: center;
}

.ac-gen-orb-ring {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px; height: 64px;
    margin-bottom: var(--space-md);
}

.ac-gen-orb-outer {
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent-primary);
    border-right-color: var(--accent-primary);
    animation: acGenOrbSpin 2s linear infinite;
    opacity: 0.6;
}

.ac-gen-orb-inner {
    position: absolute; inset: 7px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-bottom-color: var(--accent-primary);
    border-left-color: var(--accent-primary);
    animation: acGenOrbSpin 1.4s linear infinite reverse;
    opacity: 0.4;
}

.ac-gen-orb-core {
    position: relative;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    display: flex;
    align-items: center; justify-content: center;
    color: var(--accent-primary);
    animation: acGenOrbPulse 2s ease-in-out infinite;
    z-index: 1;
}
.ac-gen-orb-core svg { width: 16px; height: 16px; }

@keyframes acGenOrbSpin { to { transform: rotate(360deg); } }
@keyframes acGenOrbPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow), 0 0 16px var(--accent-glow); }
    50% { box-shadow: 0 0 0 6px transparent, 0 0 24px var(--accent-glow); }
}

.ac-gen-overlay.ac-gen-complete .ac-gen-orb-outer,
.ac-gen-overlay.ac-gen-complete .ac-gen-orb-inner {
    animation: none;
    border-color: var(--accent-primary);
    opacity: 0.3;
    transition: all 0.5s ease;
}

.ac-gen-overlay.ac-gen-complete .ac-gen-orb-core {
    background: var(--accent-primary);
    color: var(--bg-primary);
    animation: acGenOrbComplete 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes acGenOrbComplete {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.ac-gen-title {
    font-family: var(--font-heading, var(--font-display));
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.ac-gen-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-height: 18px;
}

/* --- Pipeline Steps ---
   LAYOUT KEY: Each stage is a simple vertical stack.
   The rail (dot + line) sits in col 1.
   The line is a FIXED-HEIGHT connector, NOT flex-grown.
   This prevents the stretching bug on mobile.
   -------------------------------------------- */
.ac-gen-pipeline {
    padding: 20px 28px 12px;
}

.ac-gen-stage {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 0 10px;
    align-items: start;
}

.ac-gen-stage + .ac-gen-stage {
    margin-top: 0;
}

.ac-gen-stage {
    opacity: 0.3;
    transform: translateX(-6px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ac-gen-stage.ac-gen-stage-active {
    opacity: 1;
    transform: translateX(0);
}

.ac-gen-stage.ac-gen-stage-done {
    opacity: 0.5;
    transform: translateX(0);
}

.ac-gen-stage-rail {
    grid-row: 1;
    grid-column: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ac-gen-stage-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--bg-elevated, var(--bg-tertiary));
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center; justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ac-gen-stage-dot svg { width: 11px; height: 11px; stroke-width: 2.5; }

.ac-gen-stage-active .ac-gen-stage-dot {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-glow);
    animation: acGenDotPulse 1.5s ease-in-out infinite;
}

@keyframes acGenDotPulse {
    0%, 100% { box-shadow: 0 0 12px var(--accent-glow); }
    50% { box-shadow: 0 0 20px var(--accent-glow), 0 0 4px var(--accent-primary); }
}

.ac-gen-stage-done .ac-gen-stage-dot {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
    box-shadow: none; animation: none;
}

/* THE FIX: fixed height, not flex:1 */
.ac-gen-stage-line {
    width: 2px;
    height: 14px;
    background: var(--border-color);
    transition: background 0.4s ease;
    flex-shrink: 0;
}

.ac-gen-stage-done .ac-gen-stage-line {
    background: var(--accent-primary);
    opacity: 0.4;
}

.ac-gen-stage-content {
    grid-row: 1;
    grid-column: 2;
    padding: 2px 0 10px;
}

.ac-gen-stage-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 24px;
}

.ac-gen-stage-desc {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1.3;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.ac-gen-stage-active .ac-gen-stage-desc { max-height: 36px; opacity: 1; }

.ac-gen-stage-meta {
    grid-row: 1;
    grid-column: 3;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding-top: 4px;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    line-height: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ac-gen-stage-active .ac-gen-stage-meta { opacity: 1; }
.ac-gen-stage-done .ac-gen-stage-meta { opacity: 0.6; color: var(--accent-primary); }

/* --- Concept slots --- */
.ac-gen-concepts-row {
    display: flex;
    gap: var(--space-sm);
    padding: 4px 28px 6px;
    justify-content: center;
}

.ac-gen-concept-slot {
    width: 56px; height: 56px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated, var(--bg-tertiary));
    border: 1.5px solid var(--border-color);
    display: flex;
    align-items: center; justify-content: center;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.ac-gen-concept-slot::before {
    content: attr(data-label);
    font-size: 0.6rem; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    position: absolute; bottom: 3px; left: 50%;
    transform: translateX(-50%);
    z-index: 2; opacity: 0.6;
}

.ac-gen-concept-slot.ac-gen-concept-active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow);
}

.ac-gen-concept-slot.ac-gen-concept-active::after {
    content: '';
    position: absolute; inset: 0;
    background: var(--accent-glow);
    animation: acGenConceptPulse 1.2s ease-in-out infinite;
}

@keyframes acGenConceptPulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.35; }
}

.ac-gen-concept-slot.ac-gen-concept-done {
    border-color: var(--accent-primary); box-shadow: none;
}
.ac-gen-concept-slot.ac-gen-concept-done::after { display: none; }
.ac-gen-concept-slot.ac-gen-concept-done::before { display: none; }

.ac-gen-concept-check {
    color: var(--accent-primary);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ac-gen-concept-done .ac-gen-concept-check {
    opacity: 1;
    animation: acGenCheckPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes acGenCheckPop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* --- Footer --- */
.ac-gen-footer {
    padding: 10px 28px 20px;
    text-align: center;
}

.ac-gen-elapsed {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}

.ac-gen-elapsed-time {
    color: var(--text-secondary);
    font-weight: 600;
}

.ac-gen-tip {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.7;
    min-height: 14px;
    transition: opacity 0.3s ease;
    margin-bottom: 10px;
}

/* --- Stop Button --- */
.ac-gen-stop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.ac-gen-stop-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
    transform: scale(1.02);
}

.ac-gen-stop-btn:active { transform: scale(0.98); }
.ac-gen-stop-btn svg { flex-shrink: 0; }

/* --- Error Actions (Retry + Cancel) --- */
.ac-gen-error-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    padding: 0 28px 24px;
}

.ac-gen-retry-btn,
.ac-gen-cancel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
}

.ac-gen-retry-btn {
    background: var(--gradient-primary);
    color: var(--bg-primary);
    border: none;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.ac-gen-retry-btn:hover { transform: scale(1.03); box-shadow: var(--shadow-glow); }
.ac-gen-retry-btn:active { transform: scale(0.97); }

.ac-gen-cancel-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.ac-gen-cancel-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.ac-gen-cancel-btn:hover::before {
    transform: translateX(100%);
}

.ac-gen-cancel-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(1.025);
}
.ac-gen-cancel-btn:active { transform: scale(0.97); }

/* --- Error state orb --- */
.ac-gen-overlay.ac-gen-error .ac-gen-orb-outer,
.ac-gen-overlay.ac-gen-error .ac-gen-orb-inner {
    border-color: #ef4444; animation: none; opacity: 0.3;
}
.ac-gen-overlay.ac-gen-error .ac-gen-orb-core {
    background: rgba(239, 68, 68, 0.15); color: #ef4444; animation: none;
}

/* --- Responsive: Tablet --- */
@media (max-width: 768px) {
    .ac-gen-overlay { padding: var(--space-md); }
    .ac-gen-card { max-width: 420px; border-radius: var(--radius-lg); }
}

/* --- Responsive: Phone --- */
@media (max-width: 480px) {
    .ac-gen-overlay { padding: 8px; }
    .ac-gen-card {
        margin: 0;
        max-width: 100%;
        border-radius: var(--radius-md);
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }

    .ac-gen-header { padding: 18px 18px 0; }
    .ac-gen-orb-ring { width: 48px; height: 48px; margin-bottom: 8px; }
    .ac-gen-orb-core { width: 24px; height: 24px; }
    .ac-gen-orb-core svg { width: 12px; height: 12px; }
    .ac-gen-orb-outer { border-width: 1.5px; }
    .ac-gen-orb-inner { inset: 5px; border-width: 1.5px; }
    .ac-gen-title { font-size: 1.05rem; }
    .ac-gen-subtitle { font-size: 0.75rem; }

    .ac-gen-pipeline { padding: 12px 16px 6px; }
    .ac-gen-stage {
        grid-template-columns: 20px 1fr auto;
        gap: 0 8px;
    }
    .ac-gen-stage-dot { width: 20px; height: 20px; border-width: 1.5px; }
    .ac-gen-stage-dot svg { width: 9px; height: 9px; }
    .ac-gen-stage-line { height: 10px; }
    .ac-gen-stage-content { padding: 0 0 8px; }
    .ac-gen-stage-label { font-size: 0.76rem; line-height: 20px; }
    .ac-gen-stage-desc { font-size: 0.66rem; }
    .ac-gen-stage-meta { font-size: 0.64rem; line-height: 20px; }

    .ac-gen-concepts-row { padding: 2px 16px 4px; gap: 6px; }
    .ac-gen-concept-slot { width: 44px; height: 44px; border-radius: 6px; }
    .ac-gen-concept-slot::before { font-size: 0.52rem; bottom: 2px; }
    .ac-gen-concept-check { width: 16px; height: 16px; }

    .ac-gen-footer { padding: 6px 16px 14px; }
    .ac-gen-elapsed { font-size: 0.68rem; margin-bottom: 3px; }
    .ac-gen-tip { font-size: 0.63rem; margin-bottom: 8px; }
    .ac-gen-stop-btn { font-size: 0.76rem; padding: 7px 14px; }

    .ac-gen-error-actions { padding: 0 16px 16px; }
    .ac-gen-retry-btn,
    .ac-gen-cancel-btn { font-size: 0.8rem; padding: 9px 16px; min-width: 90px; }
}

/* --- Responsive: Tiny (SE, 320px) --- */
@media (max-width: 375px) {
    .ac-gen-header { padding: 14px 14px 0; }
    .ac-gen-orb-ring { width: 40px; height: 40px; }
    .ac-gen-orb-core { width: 20px; height: 20px; }
    .ac-gen-orb-core svg { width: 10px; height: 10px; }
    .ac-gen-title { font-size: 0.95rem; }

    .ac-gen-pipeline { padding: 10px 12px 4px; }
    .ac-gen-stage-line { height: 8px; }
    .ac-gen-stage-label { font-size: 0.72rem; }

    .ac-gen-concepts-row { padding: 2px 12px 4px; gap: 4px; }
    .ac-gen-concept-slot { width: 38px; height: 38px; }

    .ac-gen-footer { padding: 4px 12px 12px; }
    .ac-gen-error-actions { padding: 0 12px 12px; flex-direction: column; }
    .ac-gen-retry-btn,
    .ac-gen-cancel-btn { width: 100%; }
}

/* Fix: preview stack on mobile */
@media (max-width: 600px) {
    .ac-preview-stack {
        height: 200px; /* give more room */
        max-width: 280px;
    }

    /* Scale cards proportionally and tighten positions */
    .ac-preview-1 { width: 110px; height: 110px; }
    .ac-preview-2 { width: 76px; height: 134px; right: 8%; }
    .ac-preview-3 { width: 134px; height: 76px; left: 4%; bottom: 8%; }

    /* Shrink the ratio badge so it fits small cards */
    .ac-preview-ratio {
        font-size: 0.6rem;
        padding: 1px 7px;
    }
}

@media (max-width: 380px) {
    .ac-preview-stack {
        height: 160px;
        max-width: 240px;
    }

    .ac-preview-1 { width: 88px; height: 88px; }
    .ac-preview-2 { width: 62px; height: 110px; right: 6%; }
    .ac-preview-3 { width: 110px; height: 62px; left: 3%; bottom: 6%; }

    .ac-preview-ratio {
        font-size: 0.55rem;
        padding: 1px 5px;
    }
}