/* ==========================================================================
   AskiPaint 3.0 Plus — Creative Hub Stylesheet
   Modern, Professional Creative Application Design
   ========================================================================== */

:root {
    --bg-main: #0c1017;
    --bg-surface: #141b26;
    --bg-surface-alt: #1c2636;
    --bg-sidebar: #090d13;
    --bg-sidebar-hover: #131c2a;
    --bg-sidebar-active: #1e2d42;
    
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-purple: #8b5cf6;
    --accent-indigo: #6366f1;
    --accent-amber: #f59e0b;
    --accent-emerald: #10b981;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #8092a8;

    --border-color: #233044;
    --border-subtle: #192332;
    --card-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);

    --font-ui: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    --font-heading: "Inter", "Segoe UI", sans-serif;
}

body.light-mode {
    --bg-main: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-alt: #e2e8f0;
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: #e2e8f0;
    --bg-sidebar-active: #dbeafe;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-subtle: #e2e8f0;
    --card-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

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

body.askipaint-plus-body {
    display: flex;
    min-height: 100vh;
    height: 100vh;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
    user-select: none;
}

/* ==========================================================================
   1. CREATIVE SIDEBAR
   ========================================================================== */

.plus-sidebar {
    width: 220px;
    min-width: 220px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 12px;
    z-index: 20;
    overflow-y: auto;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Brand Link */
.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    transition: background 0.15s;
}

.brand-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.brand-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.35);
    flex-shrink: 0;
}

.brand-logo-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.brand-fallback-icon {
    font-size: 18px;
}

.brand-text-block {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.brand-version-badge {
    font-size: 9px;
    font-weight: 800;
    color: #93c5fd;
    letter-spacing: 0.5px;
}

/* Navigation Items */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--bg-sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

.nav-svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--accent-blue);
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.settings-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(4px);
}

.settings-modal-overlay[hidden] {
    display: none;
}

.settings-modal {
    width: min(100%, 360px);
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
}

.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.settings-modal-header h2 {
    font-size: 18px;
}

.settings-modal-header button {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-options button {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.settings-options button:hover {
    border-color: var(--accent-blue);
    background: var(--bg-sidebar-active);
}

.open-editor-link {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #93c5fd;
    font-weight: 600;
}

.open-editor-link:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    color: #ffffff;
}

/* ==========================================================================
   2. MAIN WORKSPACE CONTAINER
   ========================================================================== */

.plus-main-content {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    overflow: hidden;
}

.plus-scrollable-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 40px;
}

/* Custom Scrollbar */
.plus-scrollable-body::-webkit-scrollbar {
    width: 8px;
}
.plus-scrollable-body::-webkit-scrollbar-track {
    background: var(--bg-main);
}
.plus-scrollable-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
.plus-scrollable-body::-webkit-scrollbar-thumb:hover {
    background: #3a4c66;
}

/* ==========================================================================
   3. HERO HEADER
   ========================================================================== */

.creative-hero {
    background: linear-gradient(135deg, #0d1527 0%, #1a1b3a 45%, #0e121b 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 24px 38px 30px 38px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hero-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hero-badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 12px;
}

.editor-quick-btn {
    background: var(--accent-blue);
    color: #ffffff;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    transition: background 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.editor-quick-btn:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
}

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

.hero-main-title {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 720px;
    line-height: 1.5;
}

/* Prompt Bar */
.hero-prompt-bar {
    width: min(780px, 100%);
    height: 48px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 0 6px 0 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-top: 4px;
}

.hero-prompt-bar:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25), 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.prompt-icon {
    font-size: 18px;
    margin-right: 10px;
}

#heroPromptInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 13.5px;
}

#heroPromptInput::placeholder {
    color: #64748b;
}

.prompt-start-btn {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-indigo) 100%);
    color: #ffffff;
    border: none;
    border-radius: 18px;
    padding: 8px 20px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.prompt-start-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

/* ==========================================================================
   4. SECTION CONTAINERS & CARDS
   ========================================================================== */

.section-container {
    padding: 24px 38px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-heading-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.heading-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.heading-left h2 {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.section-hint {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ==========================================================================
   5. QUICK ACTION CARDS (Blank Canvas, Modify Image, Templates)
   ========================================================================== */

.action-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.action-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.action-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-blue);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent-blue);
}

.action-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.action-icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.action-icon-circle.blue {
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.action-icon-circle.purple {
    background: rgba(139, 92, 246, 0.18);
    border: 1px solid rgba(139, 92, 246, 0.35);
}

.action-icon-circle.orange {
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.card-badge {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.6px;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.primary-card .card-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.accent-card .card-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
}

.card-footer {
    padding-top: 6px;
}

.card-action-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-blue);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-card:hover .card-action-link {
    color: #93c5fd;
    text-decoration: underline;
}

/* ==========================================================================
   6. TEMPLATES GALLERY
   ========================================================================== */

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

.template-item {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.template-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent-blue);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.template-preview-box {
    width: 100%;
    height: 100px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.template-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-dim {
    font-size: 11px;
    color: var(--text-muted);
}

/* Specific Previews */
.blank-preview {
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-center-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
}

.plus-sign {
    font-size: 22px;
    line-height: 1;
}

.landscape-preview {
    background: linear-gradient(180deg, #1e293b 55%, #0f172a 55%);
    position: relative;
}
.art-horizon-line {
    position: absolute;
    top: 55%;
    left: 0;
    right: 0;
    height: 1px;
    background: #38bdf8;
    opacity: 0.6;
}
.art-sun-circle {
    position: absolute;
    top: 30%;
    left: 45%;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f59e0b;
    opacity: 0.8;
}

.portrait-preview {
    background: #182232;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}
.art-portrait-oval {
    width: 32px;
    height: 42px;
    border: 2px dashed #64748b;
    border-radius: 50%;
}
.art-portrait-neck {
    width: 14px;
    height: 12px;
    border-left: 2px dashed #64748b;
    border-right: 2px dashed #64748b;
}

.comic-preview {
    background: #0f172a;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 6px;
}
.comic-panel {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 3px;
}

.pixel-preview {
    background-color: #111827;
    background-image: linear-gradient(45deg, #1f2937 25%, transparent 25%),
                      linear-gradient(-45deg, #1f2937 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #1f2937 75%),
                      linear-gradient(-45deg, transparent 75%, #1f2937 75%);
    background-size: 14px 14px;
}

.isometric-preview {
    background: #131d2b;
    display: flex;
    align-items: center;
    justify-content: center;
}
.iso-cube {
    width: 30px;
    height: 30px;
    border: 2px solid #38bdf8;
    transform: rotate(45deg);
    opacity: 0.7;
}

.square-preview {
    background: #192434;
    display: flex;
    align-items: center;
    justify-content: center;
}
.square-inner-frame {
    width: 55px;
    height: 55px;
    border: 2px dashed #818cf8;
    border-radius: 4px;
}

/* ==========================================================================
   7. AI CREATIVE STUDIO
   ========================================================================== */

.ai-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
}

.ai-tool-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--card-shadow);
}

.ai-tool-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ai-tool-icon {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-tool-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
}

.ai-tool-header p {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.ai-tool-panel textarea {
    width: 100%;
    min-height: 76px;
    background-color: #0b0f16;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}

.ai-tool-panel textarea:focus {
    border-color: var(--accent-blue);
}

.ai-tool-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-run-btn {
    background: var(--accent-blue);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-run-btn:hover {
    background: var(--accent-blue-hover);
}

.ai-paint-btn {
    background: var(--accent-emerald);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.ai-paint-btn:hover {
    opacity: 0.9;
}

.ai-result-box {
    background-color: #090e16;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 14px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    min-height: 60px;
    white-space: pre-wrap;
}

/* ==========================================================================
   8. RECENT PROJECTS
   ========================================================================== */

.recents-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 4px 12px;
    width: 240px;
}

.recents-search-wrap:focus-within {
    border-color: var(--accent-blue);
}

.search-svg {
    color: var(--text-muted);
}

#recentsSearchInput {
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 12px;
    font-family: inherit;
    width: 100%;
}

.recents-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.recent-project-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

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

.recent-thumb-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.recent-card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-card-date {
    font-size: 11px;
    color: var(--text-muted);
}

.empty-recents-notice {
    grid-column: 1 / -1;
    padding: 30px;
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ==========================================================================
   9. RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
    .plus-sidebar {
        width: 64px;
        min-width: 64px;
        padding: 12px 6px;
    }
    .brand-text-block, .nav-item span {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 10px 0;
    }
    .creative-hero {
        padding: 20px 20px;
    }
    .hero-main-title {
        font-size: 22px;
    }
    .section-container {
        padding: 18px 20px;
    }
    .ai-tools-grid {
        grid-template-columns: 1fr;
    }
}

/* AI Ideas Pills */
.ideas-pills-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.idea-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.idea-pill:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: #3b82f6;
    color: #ffffff;
    transform: translateX(3px);
}

.idea-emoji {
    font-size: 15px;
}

/* ==========================================================================
   6. IMAGE CROP MODAL & INTERACTIVE CROPPER
   ========================================================================== */

.crop-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 12, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.crop-modal-overlay[hidden] {
    display: none !important;
}

.crop-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 940px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.crop-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.crop-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crop-header-icon {
    font-size: 22px;
}

.crop-modal-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.crop-header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.crop-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.crop-dim-badge {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #60a5fa;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    font-family: monospace;
}

.crop-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.15s;
}

.crop-close-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

/* Crop Toolbar */
.crop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 20px;
    background: #0d131d;
    border-bottom: 1px solid var(--border-color);
}

.crop-tool-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.crop-tool-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

.crop-ratio-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.crop-ratio-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.crop-ratio-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.crop-action-icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.crop-action-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* Workspace & Viewport */
.crop-workspace-container {
    flex: 1;
    min-height: 280px;
    max-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #080c12;
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
    overflow: hidden;
    position: relative;
    user-select: none;
}

.crop-viewport {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    overflow: hidden;
}

#cropBaseCanvas {
    display: block;
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: #000000;
}

.crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Dark masks surrounding the crop box */
.crop-shade {
    position: absolute;
    background: rgba(5, 8, 15, 0.68);
    pointer-events: none;
}

/* Interactive Crop Box */
.crop-box {
    position: absolute;
    border: 2px solid #3b82f6;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 4px 20px rgba(0, 0, 0, 0.5);
    cursor: move;
    pointer-events: auto;
    touch-action: none;
}

/* Rule of Thirds Guides */
.crop-grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

.crop-grid-h1 {
    top: 33.333%;
    left: 0;
    right: 0;
    height: 1px;
}

.crop-grid-h2 {
    top: 66.666%;
    left: 0;
    right: 0;
    height: 1px;
}

.crop-grid-v1 {
    left: 33.333%;
    top: 0;
    bottom: 0;
    width: 1px;
}

.crop-grid-v2 {
    left: 66.666%;
    top: 0;
    bottom: 0;
    width: 1px;
}

/* 8 Resize Handles */
.crop-handle {
    position: absolute;
    width: 11px;
    height: 11px;
    background: #ffffff;
    border: 2px solid #2563eb;
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
    z-index: 10;
}

.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-n  { top: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 5px); right: -6px; cursor: ew-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle-s  { bottom: -6px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 5px); left: -6px; cursor: ew-resize; }

/* Footer */
.crop-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
}

.crop-footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crop-btn-cancel {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.crop-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.crop-btn-skip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.crop-btn-skip:hover {
    background: rgba(255, 255, 255, 0.14);
}

.crop-btn-apply {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border: none;
    color: #ffffff;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: all 0.15s;
}

.crop-btn-apply:hover {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.5);
}

