/**
 * Maher Photo Editor - Redesigned UI (Fotor-style)
 * Modern, clean interface with collapsible panels
 */

/* ==================== CSS Variables ==================== */
:root {
    /* Colors */
    --color-bg-dark: #1a1a1a;
    --color-bg-darker: #0f0f0f;
    --color-bg-panel: #2a2a2a;
    --color-bg-light: #ffffff;
    --color-bg-canvas: #f5f5f5;
    --color-border: #3a3a3a;
    --color-border-light: #e5e5e5;

    /* Accent colors (Fotor-style gradient) */
    --color-primary: #00d4b4;
    --color-primary-hover: #00bfa0;
    --color-secondary: #0091ff;
    --color-gradient-start: #00d4b4;
    --color-gradient-end: #0091ff;

    /* Text colors */
    --color-text-primary: #ffffff;
    --color-text-secondary: #b0b0b0;
    --color-text-muted: #808080;
    --color-text-dark: #1a1a1a;

    /* Layout dimensions */
    --toolbar-width: 72px;
    --panel-width: 320px;
    --panel-width-collapsed: 0px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ==================== Global Reset ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--color-bg-canvas);
    color: var(--color-text-dark);
    overflow: hidden;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

input,
select,
textarea {
    font-family: inherit;
}

/* ==================== Top Header ==================== */
.top-header {
    height: var(--header-height);
    background: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-dark);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-dark);
    transition: var(--transition-fast);
}

.header-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.header-btn-primary {
    background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-end) 100%);
    color: white;
}

.header-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Header keyboard shortcuts button */
.header-shortcuts-btn {
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.6);
    color: var(--color-text-dark);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.header-shortcuts-btn svg {
    color: #4b5563;
}

.header-shortcuts-btn:hover {
    background: rgba(15, 23, 42, 0.06);
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

/* ==================== Auto-Save Banner ==================== */
.auto-save-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 14px;
    z-index: 99;
}

.auto-save-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.auto-save-icon {
    font-size: 20px;
}

.auto-save-actions {
    display: flex;
    gap: 8px;
}

.btn-restore,
.btn-discard {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.btn-restore {
    background: white;
    color: #667eea;
}

.btn-discard {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ==================== Main Layout ==================== */
.editor-layout {
    display: flex;
    height: calc(100vh - var(--header-height));
    position: relative;
}

/* ==================== Left Vertical Toolbar ==================== */
.left-toolbar {
    width: var(--toolbar-width);
    background: var(--color-bg-dark);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 50;
}

.toolbar-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    height: 100%;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    color: var(--color-text-secondary);
    transition: var(--transition-fast);
    position: relative;
}

.tool-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
}

.tool-btn.active {
    color: var(--color-primary);
    background-color: rgba(0, 212, 180, 0.1);
}

.tool-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
}

.tool-icon {
    width: 24px;
    height: 24px;
}

.tool-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

.toolbar-spacer {
    flex: 1;
}

/* More menu dropdown (desktop) */
.more-menu {
    position: absolute;
    left: calc(var(--toolbar-width) - 4px);
    bottom: 16px;
    background: #f9fafb;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border-light);
    padding: 8px 0;
    min-width: 190px;
    z-index: 80;
    display: none;
}

.more-menu.visible {
    display: flex;
    flex-direction: column;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    color: #111827;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.more-menu-item:hover {
    background: #e5e7eb;
    color: #000000;
}

.more-menu-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
}

.more-menu-icon svg {
    width: 18px;
    height: 18px;
}

.more-menu-label {
    flex: 1;
    text-align: left;
}

/* ===== Rotate & Straighten UI ===== */

.rotate-straighten {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.rotate-straighten-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #e5e7eb;
}

.rotate-straighten-header span:first-child {
    font-weight: 500;
}

.straighten-value {
    font-variant-numeric: tabular-nums;
    color: #9ca3af;
}

.straighten-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right,
            #4b5563 0%,
            #22c55e 50%,
            #4b5563 100%);
    outline: none;
    margin-bottom: 6px;
}

/* Slider thumb */
.straighten-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #e5e7eb;
    border: 2px solid #22c55e;
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.9);
}

.straighten-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #e5e7eb;
    border: 2px solid #22c55e;
    cursor: pointer;
}

/* Ticks under the slider */
.straighten-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6b7280;
    padding: 0 2px;
}

@media (max-width: 767px) {
    .more-menu {
        display: none !important;
    }
}

/* ==================== Tools Panel (Collapsible) ==================== */
.tools-panel {
    width: var(--panel-width);
    background: var(--color-bg-panel);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal), transform var(--transition-normal);
    position: relative;
    z-index: 40;
}

.tools-panel.collapsed {
    width: 0;
    transform: translateX(-100%);
}

.tools-panel.collapsed .tools-panel-header {
    opacity: 0;
    pointer-events: none;
}

.tools-panel.collapsed .tools-panel-content {
    opacity: 0;
    pointer-events: none;
}

.tools-panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: opacity var(--transition-fast);
}

.tools-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.panel-collapse-btn {
    position: absolute;
    right: -18px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 88px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    background-color: #111827;
    border: 1px solid #111827;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    z-index: 50;
    cursor: pointer;
}

.panel-collapse-btn:hover {
    background-color: #020617;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

.tools-panel.collapsed .panel-collapse-btn {
    right: -18px;
}

.tools-panel.collapsed .panel-collapse-btn svg {
    transform: rotate(180deg);
}

.tools-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar for Tools Panel */
.tools-panel-content::-webkit-scrollbar {
    width: 8px;
}

.tools-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.tools-panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.tools-panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== Panel Sections ==================== */
.panel-section {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 16px;
}

.panel-section h5 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 10px;
}

.panel-section p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 8px 0;
}

.panel-section p strong {
    color: var(--color-text-primary);
}

.panel-section a {
    color: var(--color-primary);
    text-decoration: none;
}

.panel-section a:hover {
    text-decoration: underline;
}

.panel-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.panel-subsection {
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.45);
}

.panel-subsection+.panel-subsection {
    margin-top: 12px;
}

/* Collapsible Section Groups */
.section-group {
    border-bottom: 1px solid var(--color-border);
}

.section-group:last-child {
    border-bottom: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.section-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.section-toggle {
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
    transition: transform var(--transition-fast);
}

.section-group.collapsed .section-toggle {
    transform: rotate(-90deg);
}

/* ==================== Accordion Sections ==================== */
.accordion-section {
    border-bottom: 1px solid var(--color-border-light);
}

.accordion-section:last-child {
    border-bottom: none;
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: left;
}

.accordion-header:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.accordion-icon {
    flex-shrink: 0;
    color: var(--color-text-secondary);
}

.accordion-title {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.accordion-arrow {
    flex-shrink: 0;
    color: var(--color-text-secondary);
    transition: transform 0.3s ease;
}

.accordion-section.collapsed .accordion-arrow {
    transform: rotate(-90deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 0 20px;
}

.accordion-section.expanded .accordion-content {
    max-height: 1000px;
    opacity: 1;
    padding: 0 20px 20px 20px;
}

/* Crop Options Grid */
.crop-options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.crop-ratio-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--color-bg-panel);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.crop-ratio-btn:hover {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.1);
}

.crop-ratio-btn.active {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.15);
}

.crop-ratio-btn svg {
    color: var(--color-text-secondary);
}

.crop-ratio-btn.active svg {
    color: var(--color-primary);
}

.crop-ratio-btn span {
    font-size: 11px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.crop-ratio-btn.active span {
    color: var(--color-primary);
}

.crop-actions {
    display: flex;
    gap: 8px;
}

.crop-actions button {
    flex: 1;
}

/* Tools Grid (for Rotate & Flip) */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.tool-grid-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-grid-btn:hover {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.1);
}

.tool-grid-btn svg {
    color: var(--color-text-secondary);
}

.tool-grid-btn:hover svg {
    color: var(--color-primary);
}

.tool-grid-btn span {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
    text-align: center;
}

.tool-grid-btn:hover span {
    color: var(--color-primary);
}

/* Resize Inputs */
.resize-inputs {
    margin-top: 8px;
}

.resize-inputs .input-group {
    margin-bottom: 12px;
}

.resize-inputs .checkbox-control {
    margin-top: 8px;
}

/* ==================== Frames Panel Styles ==================== */
.frames-tabs {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--color-bg-secondary);
    border-radius: 8px;
    margin-bottom: 16px;
}

.frames-tab {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.frames-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
}

.frames-tab.active {
    background: var(--color-primary);
    color: white;
}

.frames-tab-content {
    display: none;
}

.frames-tab-content.active {
    display: block;
}

.frame-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Inline Frame Gallery (expandable) */
.frame-gallery-inline {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 12px;
    margin: 8px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.frame-item-inline {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
    background: var(--color-bg-panel);
    border-radius: 8px;
    padding: 8px;
    border: 2px solid transparent;
}

.frame-item-inline:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

.frame-item-name {
    margin-top: 6px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.frame-fav-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: #fbbf24;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 1;
}

.frame-item-inline:hover .frame-fav-btn {
    opacity: 1;
}

.frame-fav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.15);
}

.frame-fav-btn.active {
    opacity: 1;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.2);
}

.frame-category-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.frame-category-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-primary);
    transform: translateX(4px);
}

.frame-category-btn.active {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.15);
    color: var(--color-primary);
}

/* New frames panel styles */
.frame-section {
    border-bottom: 1px solid var(--color-border);
}

.frame-section:last-child {
    border-bottom: none;
}

.frame-section-header {
    width: 100%;
    padding: 12px 12px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s ease;
}

.frame-section-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.frame-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.frame-section-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.15);
    font-size: 0.75rem;
}

.frame-section-arrow {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
    transition: transform 0.2s ease;
}

.frame-section.collapsed .frame-section-arrow {
    transform: rotate(-90deg);
}

.frame-style-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 0 12px 12px;
}

/* Hide frames grid content when section is collapsed */
.frame-section.collapsed .frame-style-grid {
    display: none;
}

.frame-style-btn {
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.frame-style-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    background: #020617;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.85);
    position: relative;
    overflow: hidden;
}

.frame-style-btn:hover .frame-style-preview,
.frame-style-btn:focus-visible .frame-style-preview {
    box-shadow: 0 0 0 2px var(--color-primary), 0 10px 20px rgba(0, 0, 0, 0.6);
}

.frame-fav-toggle {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(248, 250, 252, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: rgba(248, 250, 252, 0.7);
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.2s ease;
    pointer-events: auto;
}

.frame-style-preview:hover .frame-fav-toggle {
    opacity: 1;
    transform: scale(1);
}

.frame-fav-toggle.active {
    opacity: 1;
    background: #fbbf24;
    color: #111827;
    border-color: #f59e0b;
}

/* Simple frames */
.frame-style-simple-clean::before {
    content: '';
    position: absolute;
    inset: 10%;
    border-radius: 6px;
    box-shadow: 0 0 0 3px #f9fafb;
}

.frame-style-simple-soft::before {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: 14px;
    box-shadow: 0 0 0 2px rgba(249, 250, 251, 0.7);
}

.frame-style-simple-vignette::before {
    content: '';
    position: absolute;
    inset: 10%;
    border-radius: 12px;
    background: radial-gradient(circle at center, #111827 40%, #020617 100%);
}

.frame-style-simple-rounded::before {
    content: '';
    position: absolute;
    inset: 9%;
    border-radius: 999px;
    box-shadow: 0 0 0 3px #f9fafb;
}

.frame-style-simple-film::before {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 4px;
    box-shadow: 0 0 0 4px #111827;
    background: repeating-linear-gradient(to bottom,
            #020617 0,
            #020617 6px,
            #0f172a 6px,
            #0f172a 8px);
}

.frame-style-simple-shadow::before {
    content: '';
    position: absolute;
    inset: 14%;
    border-radius: 8px;
    background: #111827;
    box-shadow: 8px 8px 18px rgba(0, 0, 0, 0.9);
}

/* Border frames */
.frame-style-border-corner::before,
.frame-style-border-solid::before,
.frame-style-border-dashed::before,
.frame-style-border-double::before,
.frame-style-border-inner::before,
.frame-style-border-deco::before {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 6px;
    border: 3px solid #e5e7eb;
}

.frame-style-border-corner::before {
    clip-path: polygon(0 0, 25% 0, 25% 6%, 6% 6%, 6% 25%, 0 25%, 0 0,
            75% 0, 100% 0, 100% 25%, 94% 25%, 94% 6%, 75% 6%, 75% 0,
            100% 75%, 100% 100%, 75% 100%, 75% 94%, 94% 94%, 94% 75%, 100% 75%,
            0 75%, 6% 75%, 6% 94%, 25% 94%, 25% 100%, 0 100%, 0 75%);
}

.frame-style-border-dashed::before {
    border-style: dashed;
}

.frame-style-border-double::before {
    box-shadow: 0 0 0 3px #e5e7eb, 0 0 0 7px #020617;
}

.frame-style-border-inner::before {
    inset: 10%;
    box-shadow: 0 0 0 2px #e5e7eb, inset 0 0 0 2px #e5e7eb;
}

.frame-style-border-deco::before {
    border-radius: 10px;
    box-shadow:
        0 0 0 3px #e5e7eb,
        inset 8px 8px 0 0 #020617,
        inset -8px -8px 0 0 #020617;
}

/* Wooden frames */
.frame-style-wood-light::before,
.frame-style-wood-warm::before,
.frame-style-wood-dark::before,
.frame-style-wood-red::before,
.frame-style-wood-gold::before,
.frame-style-wood-vintage::before {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: 4px;
    background: #292524;
}

.frame-style-wood-light::before {
    box-shadow: 0 0 0 12px #eabf7a, inset 0 0 0 3px rgba(0, 0, 0, 0.35);
}

.frame-style-wood-warm::before {
    box-shadow: 0 0 0 12px #c26a34, inset 0 0 0 3px rgba(0, 0, 0, 0.45);
}

.frame-style-wood-dark::before {
    box-shadow: 0 0 0 12px #4b2b16, inset 0 0 0 3px rgba(0, 0, 0, 0.5);
}

.frame-style-wood-red::before {
    box-shadow: 0 0 0 12px #b45309, inset 0 0 0 3px rgba(0, 0, 0, 0.5);
}

.frame-style-wood-gold::before {
    box-shadow:
        0 0 0 10px #fbbf24,
        0 0 0 14px #78350f,
        inset 0 0 0 3px rgba(0, 0, 0, 0.45);
}

.frame-style-wood-vintage::before {
    box-shadow:
        0 0 0 10px #a16207,
        0 0 0 14px #fef3c7,
        inset 0 0 0 3px rgba(0, 0, 0, 0.5);
}

/* Classy frames */
.frame-style-classy-glass::before {
    content: '';
    position: absolute;
    inset: 10%;
    border-radius: 8px;
    background: #0b1120;
    box-shadow:
        0 0 0 6px rgba(248, 250, 252, 0.9),
        0 0 30px rgba(148, 163, 184, 0.8);
}

.frame-style-classy-glass::after {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent 55%);
}

.frame-style-classy-bevel::before {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 6px;
    background: #111827;
    box-shadow:
        0 0 0 4px #e5e7eb,
        0 0 0 8px #9ca3af,
        inset 0 0 0 3px rgba(0, 0, 0, 0.4);
}

.frame-style-classy-matte::before {
    content: '';
    position: absolute;
    inset: 14%;
    border-radius: 4px;
    background: #020617;
    box-shadow:
        0 0 0 16px #e5e7eb,
        0 0 0 20px #111827;
}

.frame-style-classy-vintage::before {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 4px;
    background: #111827;
    box-shadow:
        0 0 0 12px #f97316,
        0 0 0 16px #7c2d12;
    filter: sepia(0.6);
}

.frame-style-classy-brown::before {
    content: '';
    position: absolute;
    inset: 10%;
    border-radius: 4px;
    background: #111827;
    box-shadow:
        0 0 0 12px #92400e,
        0 0 0 16px #451a03;
}

/* Modern frames */
.frame-style-modern-minimal::before,
.frame-style-modern-outline::before,
.frame-style-modern-shadow::before,
.frame-style-modern-gradient::before {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 10px;
    background: #020617;
}

.frame-style-modern-minimal::before {
    box-shadow: 0 0 0 2px rgba(248, 250, 252, 0.9);
}

.frame-style-modern-outline::before {
    box-shadow:
        0 0 0 2px rgba(148, 163, 184, 0.9),
        0 0 0 8px rgba(15, 23, 42, 1);
}

.frame-style-modern-shadow::before {
    box-shadow:
        0 0 0 3px rgba(15, 23, 42, 1),
        0 14px 30px rgba(0, 0, 0, 0.85);
}

.frame-style-modern-gradient::before {
    background: linear-gradient(135deg, #0f172a, #1d4ed8, #22c55e);
    box-shadow:
        0 0 0 3px rgba(15, 23, 42, 1),
        0 10px 24px rgba(15, 23, 42, 0.9);
}

/* Neon & Glow frames */
.frame-style-neon-cyan::before,
.frame-style-neon-magenta::before,
.frame-style-neon-purple::before,
.frame-style-neon-sunset::before {
    content: '';
    position: absolute;
    inset: 14%;
    border-radius: 12px;
    background: #020617;
}

.frame-style-neon-cyan::before {
    box-shadow:
        0 0 0 3px rgba(34, 211, 238, 0.9),
        0 0 24px rgba(34, 211, 238, 0.85);
}

.frame-style-neon-magenta::before {
    box-shadow:
        0 0 0 3px rgba(236, 72, 153, 0.9),
        0 0 24px rgba(236, 72, 153, 0.85);
}

.frame-style-neon-purple::before {
    box-shadow:
        0 0 0 3px rgba(168, 85, 247, 0.9),
        0 0 24px rgba(168, 85, 247, 0.85);
}

.frame-style-neon-sunset::before {
    box-shadow:
        0 0 0 3px rgba(249, 115, 22, 0.9),
        0 0 24px rgba(244, 63, 94, 0.9);
}

.featured-icon {
    flex-shrink: 0;
    margin-right: 8px;
    color: #f59e0b;
}

/* Layout Grid */
.layout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.layout-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
    background: var(--color-bg-panel);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layout-btn:hover {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.layout-btn.active {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.15);
    color: var(--color-primary);
}

.layout-btn svg {
    width: 48px;
    height: 48px;
}

.color-swatches-large {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.color-swatch-gradient {
    position: relative;
    overflow: hidden;
}

.color-swatch-gradient::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.color-swatch-gradient.active::after {
    border-color: white;
}

/* Empty Favorites State */
.empty-favorites {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--color-text-secondary);
}

.empty-favorites svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-favorites p {
    margin: 0;
    font-size: 0.95rem;
}

.section-content {
    padding: 0 20px 16px;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height var(--transition-normal), padding var(--transition-normal);
}

.section-group.collapsed .section-content {
    max-height: 0;
    padding: 0 20px;
}

/* ==================== Form Controls ==================== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.input-group input[type="text"],
.input-group input[type="number"],
.input-group input[type="email"],
.input-group input[type="password"],
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Form groups */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

/* Form control elements (.form-control) */
.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Select controls */
.select-control {
    margin-bottom: 16px;
}

.select-control label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.select-control select {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

/* ==================== Stickers Grid (compact) ==================== */
.stickers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 8px;
    align-items: center;
}

.sticker-item {
    width: 40px;
    height: 40px;
    padding: 6px;
    border-radius: 8px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sticker-item:disabled,
.sticker-item[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.sticker-item:hover:not([disabled]) {
    transform: translateY(-3px);
    border-color: var(--color-primary);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.sticker-fav {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    transform: scale(0.95);
    transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.sticker-item {
    position: relative;
}

.sticker-item .sticker-fav:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.85);
}

.sticker-item.favorited {
    border-color: #fbbf24;
    box-shadow: 0 8px 20px rgba(251, 191, 36, 0.12);
}

.sticker-item.favorited .sticker-fav {
    background: #fbbf24;
    color: #111827;
}

/* Collapsible sections styling for More panel */
.collapsible-section {
    border-bottom: 1px solid var(--color-border);
}

.collapsible-section:last-child {
    border-bottom: none;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition-fast);
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.collapsible-header h3,
.collapsible-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.collapsible-toggle {
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
    transition: transform var(--transition-fast);
}

.collapsible-section.collapsed .collapsible-toggle {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-section.collapsed .collapsible-content {
    max-height: 0;
}

/* Panel section info/tips */
.panel-info {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.panel-info p {
    margin: 4px 0;
    line-height: 1.5;
}

.panel-info strong {
    color: var(--color-text-primary);
}

/* Slider Controls */
.slider-control {
    margin-bottom: 16px;
}

.slider-control label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.slider-value {
    color: var(--color-text-secondary);
    font-weight: 400;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--color-bg-darker);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Color Picker */
.color-control {
    margin-bottom: 16px;
}

.color-control label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-wrapper input[type="color"] {
    width: 48px;
    height: 48px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.color-picker-wrapper span {
    font-size: 14px;
    color: var(--color-text-primary);
    font-family: 'Courier New', monospace;
    background: var(--color-bg-darker);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-end) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-bg-darker);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: #facc15;
    color: #422006;
}

.btn-warning:hover {
    background: #eab308;
    transform: translateY(-1px);
}

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.tools-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tools-row button {
    flex: 1;
}

/* Icon Buttons */
.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--color-text-dark);
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==================== Canvas Area ==================== */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-canvas);
    position: relative;
}

.canvas-toolbar {
    height: 56px;
    background: white;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.canvas-toolbar-left,
.canvas-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-dark);
}

.pan-indicator {
    font-size: 13px;
    color: var(--color-text-muted);
    padding: 6px 12px;
    background: rgba(0, 212, 180, 0.1);
    border-radius: 6px;
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

#photoCanvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    background: transparent;
}

/* ==================== Empty State ==================== */
.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: opacity 0.3s ease;
    cursor: pointer;
    padding: 40px;
}

.empty-state-content {
    text-align: center;
    width: 100%;
    max-width: 600px;
    padding: 60px 40px;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    background: rgba(249, 250, 251, 0.5);
    transition: all 0.3s ease;
}

.empty-state-icon {
    margin-bottom: 24px;
}

.empty-state-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-text-dark);
    margin-bottom: 24px;
    line-height: 1.3;
}

.btn-upload-primary {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--color-gradient-start) 0%, var(--color-gradient-end) 100%);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    transition: var(--transition-fast);
    margin-bottom: 32px;
    overflow: visible;
}

.btn-upload-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-upload-main {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 14px 32px;
    background: transparent;
    color: inherit;
    border: none;
    cursor: pointer;
}

.btn-upload-dropdown {
    padding: 14px 12px;
    background: rgba(0, 0, 0, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-upload-dropdown:hover {
    background: rgba(0, 0, 0, 0.2);
}

.upload-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.upload-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.upload-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--color-text-dark);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.upload-dropdown-item:hover {
    background: var(--color-bg-light);
}

.upload-dropdown-item svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.empty-state-samples {
    margin-top: 32px;
}

.samples-text {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

.sample-images {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.sample-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--color-border-light);
    transition: var(--transition-fast);
}

.sample-img:hover {
    transform: scale(1.05);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.sample-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hide empty state when canvas has image */
.canvas-container.has-image .empty-state {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.canvas-container.has-image #photoCanvas {
    z-index: 2;
}

.empty-state:hover .empty-state-content {
    border-color: var(--color-primary);
    background: rgba(249, 250, 251, 0.8);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.empty-state.drag-over .empty-state-content {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.1);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
    transform: scale(1.02);
}

/* Drag and drop styles */
.canvas-container.drag-over,
.empty-state.drag-over {
    background-color: rgba(0, 212, 180, 0.05);
    border: 2px dashed var(--color-primary);
    border-radius: 12px;
}

.canvas-container.drag-over::after {
    content: 'Drop image here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 600;
    color: var(--color-primary);
    pointer-events: none;
    z-index: 1000;
    background: white;
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ==================== Mini Toolbar ==================== */
.mini-toolbar {
    position: absolute;
    background: var(--color-bg-dark);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.mini-toolbar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--color-text-primary);
    transition: var(--transition-fast);
}

.mini-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mini-toolbar-color {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.mini-toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 4px;
}

.mini-toolbar-danger {
    color: #ef4444;
}

/* ==================== Context Menu ==================== */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 10000;
    padding: 6px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--color-text-dark);
    cursor: pointer;
    transition: var(--transition-fast);
}

.context-menu-item:hover {
    background: rgba(0, 212, 180, 0.1);
}

.context-menu-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.context-menu-icon {
    font-size: 16px;
}

.context-menu-shortcut {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-text-muted);
    font-family: 'Courier New', monospace;
}

.context-menu-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: 4px 0;
}

/* ==================== Modals ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active,
.modal.visible {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.modal-content.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-light);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 24px;
    color: var(--color-text-muted);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.modal-body {
    padding: 24px;
}

/* Keyboard Shortcuts Modal */
#shortcutsModal .modal-content {
    background: #020617;
    color: #e5e7eb;
    max-width: 720px;
}

#shortcutsModal .modal-header {
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
}

#shortcutsModal .modal-header h2 {
    font-size: 18px;
    letter-spacing: 0.02em;
}

#shortcutsModal .modal-body {
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.15), transparent 55%),
        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.12), transparent 55%);
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px 24px;
}

.shortcut-section {
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.85);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.shortcut-section h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin-bottom: 8px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(55, 65, 81, 0.7);
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-item span {
    font-size: 13px;
    color: #e5e7eb;
}

.shortcut-item kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 4px 6px;
    margin-right: 4px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.9);
    background: radial-gradient(circle at top, #111827, #020617);
    font-size: 11px;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.9);
    color: #f9fafb;
}

/* Frame Gallery */
.frame-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.frame-item {
    aspect-ratio: 1;
    border: 2px solid var(--color-border-light);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.frame-item:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.frame-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.frame-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.75rem;
    text-align: center;
}

.frame-favorite-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: #fbbf24;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.frame-item:hover .frame-favorite-btn {
    opacity: 1;
}

.frame-favorite-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* ==================== Notifications ==================== */
.notification-area {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* Toast notifications used by editor.js */
.toast {
    min-width: 220px;
    max-width: 320px;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(17, 24, 39, 0.97);
    color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: toast-in 0.2s ease-out;
    pointer-events: auto;
}

.toast-success {
    border-color: rgba(34, 197, 94, 0.6);
}

.toast-error {
    border-color: rgba(239, 68, 68, 0.7);
}

.toast-info {
    border-color: rgba(59, 130, 246, 0.7);
}

.toast.fade-out {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification.warning {
    border-left: 4px solid #f59e0b;
}

.notification.info {
    border-left: 4px solid #3b82f6;
}

/* ==================== Responsive Design ==================== */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
    :root {
        --toolbar-width: 60px;
        --panel-width: 280px;
        --header-height: 56px;
    }

    .tool-label {
        display: none;
    }

    .tools-panel-content {
        font-size: 13px;
    }

    .logo-text {
        font-size: 16px;
    }

    .panel-section {
        padding: 16px;
    }

    .accordion-content {
        padding: 0 16px 16px 16px;
    }
}

/* Mobile (≤767px) - Fotor-style redesign */
@media (max-width: 767px) {
    :root {
        --header-height: 56px;
        --toolbar-height: 64px;
        --panel-width: 100%;
    }

    html,
    body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

    .editor-layout {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Modern header with better mobile spacing */
    .top-header {
        padding: 0 16px;
        width: 100%;
        max-width: 100vw;
        height: var(--header-height);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .header-brand {
        gap: 8px;
    }

    .logo-text {
        display: none;
    }

    .header-btn span {
        display: none;
    }

    .header-shortcuts-btn {
        padding-inline: 10px;
    }

    /* Move toolbar to bottom on mobile with Fotor-style design */
    .left-toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: var(--toolbar-height);
        border-right: none;
        border-top: 1px solid var(--color-border);
        order: 3;
        z-index: 50;
        background: rgba(26, 26, 26, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .toolbar-nav {
        flex-direction: row;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: space-around;
        height: 100%;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .toolbar-nav::-webkit-scrollbar {
        display: none;
    }

    .tool-btn {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        flex: 0 0 auto;
        white-space: nowrap;
        min-width: 60px;
        transition: all 0.2s ease;
    }

    .tool-btn:hover {
        background-color: rgba(255, 255, 255, 0.08);
    }

    .tool-btn.active {
        color: var(--color-primary);
        background-color: rgba(0, 212, 180, 0.15);
    }

    .tool-btn.active::before {
        left: 10px;
        right: 10px;
        top: 0;
        bottom: auto;
        width: auto;
        height: 3px;
        border-radius: 0 0 3px 3px;
    }

    .tool-label {
        display: block;
        font-size: 10px;
        font-weight: 500;
        margin-top: 2px;
    }

    .toolbar-spacer {
        display: none;
    }

    /* Tools panel becomes bottom sheet on mobile with Fotor-style design */
    .tools-panel {
        position: fixed;
        bottom: var(--toolbar-height);
        left: 0;
        right: 0;
        width: 100%;
        height: 70vh;
        max-height: 70vh;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        z-index: 60;
        border-right: none;
        border-top: 1px solid var(--color-border);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        background: #2a2a2a;
    }

    .tools-panel.active {
        transform: translateY(0);
    }

    .tools-panel.collapsed {
        transform: translateY(100%);
    }

    /* Improved panel header with drag handle */
    .tools-panel-header {
        display: flex;
        padding: 12px 16px;
        border-bottom: 1px solid var(--color-border);
        position: relative;
    }

    .tools-panel-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--color-text-muted);
        border-radius: 2px;
    }

    .tools-panel-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--color-text-primary);
        margin: 8px auto 0;
    }

    .panel-collapse-btn {
        display: none;
    }

    /* Canvas area with better mobile handling */
    .canvas-area {
        order: 1;
        height: auto;
        max-width: 100%;
        overflow-x: hidden;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .canvas-container {
        padding: 16px;
        max-width: 100%;
        overflow-x: hidden;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #photoCanvas {
        max-width: 100%;
        max-height: 100%;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }

    .canvas-toolbar {
        padding: 0 16px;
        height: 48px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }

    .zoom-controls {
        gap: 6px;
        background: rgba(0, 0, 0, 0.05);
        padding: 6px 10px;
        border-radius: 20px;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
        border-radius: 16px;
        transition: all 0.2s ease;
    }

    .icon-btn:hover {
        background: rgba(0, 0, 0, 0.08);
        transform: scale(1.05);
    }

    /* Improved empty state */
    .empty-state-title {
        font-size: 20px;
        font-weight: 600;
        margin-bottom: 16px;
    }

    .btn-upload-primary {
        padding: 12px 24px;
        font-size: 14px;
        border-radius: 24px;
        box-shadow: 0 4px 12px rgba(0, 212, 180, 0.3);
        transition: all 0.3s ease;
    }

    .btn-upload-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0, 212, 180, 0.4);
    }

    .sample-img {
        width: 64px;
        height: 64px;
        border-radius: 12px;
        overflow: hidden;
    }

    /* Improved panel content */
    .tools-panel-content {
        max-height: calc(70vh - 60px);
        padding-bottom: 0;
        overflow-y: auto;
    }

    /* Better form controls */
    .panel-section {
        padding: 16px;
        border-bottom: 1px solid var(--color-border);
        margin-bottom: 0;
    }

    .panel-section:last-child {
        border-bottom: none;
        padding-bottom: 20px;
    }

    .panel-section h4 {
        font-size: 15px;
        margin-bottom: 12px;
        font-weight: 600;
    }

    .accordion-header {
        padding: 14px 16px;
        border-radius: 8px;
        margin: 0;
    }

    .accordion-header:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .accordion-content {
        padding: 0 16px 16px 16px;
        margin-bottom: 0;
    }

    /* Remove gaps in adjust panel */
    .adjust-panel .panel-section {
        padding: 16px 0;
        margin-bottom: 0;
    }

    .adjust-panel .panel-section:first-child {
        padding-top: 0;
    }

    .adjust-panel .panel-section:last-child {
        padding-bottom: 20px;
        border-bottom: none;
    }

    /* Compact resize layout inside Adjust panel */
    .resize-inputs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "w h"
            "ratio ratio"
            "apply apply";
        column-gap: 8px;
        row-gap: 8px;
        padding-top: 8px;
    }

    .resize-inputs .input-group {
        margin-bottom: 0;
    }

    .resize-inputs .input-group:nth-child(1) {
        grid-area: w;
    }

    .resize-inputs .input-group:nth-child(2) {
        grid-area: h;
    }

    .resize-inputs .input-group label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .resize-inputs .input-group input[type="number"] {
        padding: 6px 8px;
        font-size: 13px;
    }

    .resize-inputs .checkbox-control {
        grid-area: ratio;
        margin-top: 0;
    }

    .resize-inputs #applyResizeBtn {
        grid-area: apply;
        margin-top: 4px !important;
        padding: 8px 16px;
        font-size: 13px;
        width: auto;
        justify-self: flex-start;
    }

    /* Remove gaps in text panel */
    .text-panel .panel-section {
        padding: 16px 0;
        margin-bottom: 0;
    }

    .text-panel .panel-section:first-child {
        padding-top: 0;
    }

    .text-panel .panel-section:last-child {
        padding-bottom: 20px;
        border-bottom: none;
    }

    /* Fix accordion gaps */
    .accordion-section {
        margin-bottom: 0;
    }

    .accordion-section:last-child {
        margin-bottom: 0;
    }

    .accordion-content {
        padding: 0 16px 12px 16px;
        margin-bottom: 0;
    }

    /* Improved slider controls */
    input[type="range"] {
        height: 6px;
        border-radius: 3px;
        background: rgba(255, 255, 255, 0.1);
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: var(--color-primary);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        transition: all 0.2s ease;
    }

    input[type="range"]::-webkit-slider-thumb:hover {
        transform: scale(1.2);
        box-shadow: 0 2px 8px rgba(0, 212, 180, 0.4);
    }

    /* Better buttons */
    .btn {
        padding: 10px 16px;
        border-radius: 8px;
        font-weight: 500;
        transition: all 0.2s ease;
    }

    .btn-primary {
        background: var(--color-primary);
        box-shadow: 0 2px 8px rgba(0, 212, 180, 0.3);
    }

    .btn-primary:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 212, 180, 0.4);
    }

    /* Compact Rotate & Flip controls */
    .tools-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-top: 6px;
    }

    .tool-grid-btn {
        padding: 10px 4px;
        border-radius: 10px;
    }

    .tool-grid-btn span {
        display: none;
    }

    /* Improved crop options */
    .crop-options-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        margin-top: 8px;
        padding: 0 8px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .crop-options-grid::-webkit-scrollbar {
        display: none;
    }

    .crop-ratio-btn {
        flex: 0 0 auto;
        min-width: 70px;
        padding: 12px 8px;
        border-radius: 12px;
        transition: all 0.2s ease;
    }

    .crop-ratio-btn:hover {
        transform: translateY(-2px);
    }

    /* Mobile bottom toolbar for crop mode */
    .mobile-crop-toolbar {
        position: fixed;
        bottom: var(--toolbar-height);
        left: 0;
        right: 0;
        background: rgba(26, 26, 26, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid var(--color-border);
        z-index: 100;
        display: flex;
        padding: 16px;
        flex-direction: column;
        gap: 16px;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .mobile-crop-toolbar.active {
        transform: translateY(0);
    }

    .mobile-crop-actions {
        display: flex;
        justify-content: center;
        gap: 20px;
    }

    .mobile-crop-action-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--color-bg-panel);
        border: 2px solid var(--color-border);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--color-text-primary);
        transition: all 0.2s;
    }

    .mobile-crop-action-btn.mobile-crop-apply {
        background: var(--color-primary);
        border-color: var(--color-primary);
    }

    .mobile-crop-ratios {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 4px 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .mobile-crop-ratios::-webkit-scrollbar {
        display: none;
    }

    .mobile-crop-ratio-btn {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 10px 12px;
        background: var(--color-bg-panel);
        border: 2px solid transparent;
        border-radius: 12px;
        color: var(--color-text-secondary);
        transition: all 0.2s;
        min-width: 72px;
    }

    .mobile-crop-ratio-btn.active {
        border-color: var(--color-primary);
        background: rgba(0, 212, 180, 0.1);
        color: var(--color-primary);
    }

    /* Improved frames panel */
    .frames-tabs {
        display: flex;
        gap: 8px;
        padding: 8px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 12px;
        margin-bottom: 16px;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .frames-tabs::-webkit-scrollbar {
        display: none;
    }

    .frames-tab {
        flex: 0 0 auto;
        padding: 8px 16px;
        background: transparent;
        border: none;
        border-radius: 8px;
        color: var(--color-text-secondary);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
    }

    .frames-tab:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .frames-tab.active {
        background: var(--color-primary);
        color: white;
    }

    .frame-style-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 12px;
        padding: 0 8px 16px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .frame-style-grid::-webkit-scrollbar {
        display: none;
    }

    .frame-style-btn {
        flex: 0 0 auto;
        min-width: 80px;
    }

    .frame-style-preview {
        width: 80px;
        height: 80px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        transition: all 0.2s ease;
    }

    .frame-style-btn:hover .frame-style-preview {
        transform: translateY(-4px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    }

    /* Improved effects panel */
    .effects-accordion {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 12px;
        padding: 8px 8px 16px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .effects-accordion::-webkit-scrollbar {
        display: none;
    }

    .effect-category {
        flex: 0 0 auto;
        min-width: 120px;
        border-radius: 12px;
        overflow: hidden;
        background: rgba(255, 255, 255, 0.05);
    }

    .effect-category-btn {
        padding: 12px;
        border-radius: 12px;
        font-size: 14px;
    }

    /* Improved elements panel */
    .elements-accordion {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 12px;
        padding: 8px 8px 16px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .elements-accordion::-webkit-scrollbar {
        display: none;
    }

    .element-category {
        flex: 0 0 auto;
        min-width: 120px;
        border-radius: 12px;
        overflow: hidden;
        background: rgba(255, 255, 255, 0.05);
    }

    .element-category-btn {
        padding: 12px;
        border-radius: 12px;
        font-size: 14px;
    }

    .element-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .element-item {
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .element-item:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    }

    /* Improved text controls */
    .text-input-control input[type="text"] {
        padding: 12px;
        border-radius: 8px;
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--color-border);
        font-size: 14px;
        transition: all 0.2s ease;
    }

    .text-input-control input[type="text"]:focus {
        border-color: var(--color-primary);
        background: rgba(0, 0, 0, 0.3);
    }

    .select-control select {
        padding: 12px;
        border-radius: 8px;
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--color-border);
        font-size: 14px;
        transition: all 0.2s ease;
    }

    .select-control select:focus {
        border-color: var(--color-primary);
        background: rgba(0, 0, 0, 0.3);
    }

    /* Improved color swatches */
    .color-swatches {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .color-swatches::-webkit-scrollbar {
        display: none;
    }

    .color-swatch {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: 2px solid transparent;
        flex-shrink: 0;
        transition: all 0.2s ease;
    }

    .color-swatch:hover {
        transform: scale(1.1);
        border-color: var(--color-text-primary);
    }

    .color-swatch.active {
        border-color: var(--color-primary);
        border-width: 3px;
        transform: scale(1.1);
    }

    /* Improved layer items */
    .layer-item {
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .layer-item:hover {
        background: rgba(255, 255, 255, 0.08);
        transform: translateY(-1px);
    }

    .layer-item.active {
        background: rgba(0, 212, 180, 0.15);
        border-color: var(--color-primary);
    }

    .layer-thumb {
        border-radius: 6px;
    }

    .layer-btn {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        transition: all 0.2s ease;
    }

    .layer-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.1);
        transform: scale(1.1);
    }

    /* Improved modals */
    .modal-content {
        border-radius: 16px;
        max-height: 85vh;
        overflow: hidden;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    }

    .modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid var(--color-border-light);
    }

    .modal-body {
        padding: 20px;
        max-height: calc(85vh - 120px);
        overflow-y: auto;
    }

    /* Improved notifications */
    .toast {
        padding: 12px 16px;
        border-radius: 24px;
        font-size: 14px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }

    /* Improved empty state */
    .empty-state-content {
        border-radius: 16px;
        border: 2px dashed #d1d5db;
        background: rgba(249, 250, 251, 0.7);
        transition: all 0.3s ease;
    }

    .empty-state:hover .empty-state-content {
        border-color: var(--color-primary);
        background: rgba(249, 250, 251, 0.9);
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
        transform: scale(1.01);
    }

    .empty-state.drag-over .empty-state-content {
        border-color: var(--color-primary);
        background: rgba(102, 126, 234, 0.1);
        box-shadow: 0 12px 32px rgba(102, 126, 234, 0.25);
        transform: scale(1.02);
    }

    /* Improved context menu */
    .context-menu {
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        overflow: hidden;
    }

    .context-menu-item {
        padding: 12px 16px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .context-menu-item:hover {
        background: rgba(0, 212, 180, 0.1);
        transform: translateX(4px);
    }

    /* Improved mini toolbar */
    .mini-toolbar {
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .mini-toolbar-btn {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .mini-toolbar-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(1.1);
    }

    /* Improved checkbox controls */
    .checkbox-control label {
        padding: 8px 12px;
        border-radius: 8px;
        transition: all 0.2s ease;
        cursor: pointer;
    }

    .checkbox-control label:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .checkbox-control input[type="checkbox"] {
        width: 20px;
        height: 20px;
        border-radius: 4px;
        transition: all 0.2s ease;
    }

    /* Improved form controls */
    .form-control {
        padding: 12px;
        border-radius: 8px;
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--color-border);
        font-size: 14px;
        transition: all 0.2s ease;
    }

    .form-control:focus {
        border-color: var(--color-primary);
        background: rgba(0, 0, 0, 0.3);
    }

    /* Improved slider controls */
    .slider-control {
        margin-bottom: 20px;
    }

    .slider-control label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 10px;
    }

    .slider-value {
        font-weight: 600;
        color: var(--color-primary);
    }

    /* Improved color controls */
    .color-control {
        margin-bottom: 20px;
    }

    .color-control label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 10px;
    }

    .color-picker-wrapper input[type="color"] {
        width: 56px;
        height: 56px;
        border-radius: 12px;
        border: 2px solid var(--color-border);
    }

    /* Improved buttons */
    .btn {
        padding: 12px 20px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        transition: all 0.2s ease;
    }

    .btn-primary {
        background: var(--color-primary);
        box-shadow: 0 4px 12px rgba(0, 212, 180, 0.3);
    }

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0, 212, 180, 0.4);
    }

    .btn-secondary {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid var(--color-border);
    }

    .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.15);
        transform: translateY(-1px);
    }

    .btn-danger {
        background: #ef4444;
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    }

    .btn-danger:hover {
        background: #dc2626;
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
    }

    .btn-warning {
        background: #facc15;
        color: #422006;
        box-shadow: 0 4px 12px rgba(250, 204, 21, 0.3);
    }

    .btn-warning:hover {
        background: #eab308;
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(250, 204, 21, 0.4);
    }

    .tools-row {
        display: flex;
        gap: 12px;
        margin-bottom: 16px;
    }

    .tools-row button {
        flex: 1;
    }

    /* Improved icon buttons */
    .icon-btn {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        transition: all 0.2s ease;
    }

    .icon-btn:hover {
        background: rgba(0, 0, 0, 0.08);
        transform: scale(1.05);
    }

    .icon-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
}

/* Very small screens (≤480px) */
@media (max-width: 480px) {
    :root {
        --header-height: 52px;
        --toolbar-height: 60px;
    }

    .top-header {
        padding: 0 12px;
    }

    .header-actions {
        gap: 8px;
    }

    .header-btn {
        padding: 6px 12px;
    }

    .canvas-container {
        padding: 12px;
    }

    .empty-state-title {
        font-size: 18px;
    }

    .btn-upload-primary {
        padding: 10px 20px;
        font-size: 14px;
    }

    .sample-images {
        gap: 8px;
    }

    .sample-img {
        width: 56px;
        height: 56px;
    }

    .tool-btn {
        min-width: 50px;
        padding: 6px 8px;
    }

    .tool-label {
        font-size: 9px;
    }

    .tools-panel {
        height: 75vh;
        max-height: 75vh;
    }

    .tools-panel-content {
        max-height: calc(75vh - 60px);
    }

    .panel-section {
        padding: 12px;
    }

    .accordion-header {
        padding: 12px 14px;
    }

    .accordion-content {
        padding: 0 14px 14px 14px;
    }

    .crop-ratio-btn {
        min-width: 60px;
        padding: 10px 6px;
    }

    .frame-style-preview {
        width: 70px;
        height: 70px;
    }

    .element-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .color-swatch {
        width: 32px;
        height: 32px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }
}

/* Landscape mobile */
@media (max-width: 767px) and (orientation: landscape) {
    :root {
        --toolbar-height: 56px;
    }

    .tools-panel {
        max-height: 65vh;
        height: 65vh;
    }

    .canvas-area {
        height: calc(100vh - var(--header-height) - var(--toolbar-height));
    }

    .tools-panel-content {
        max-height: calc(65vh - 60px);
    }

    .mobile-crop-toolbar {
        max-height: 50vh;
    }
}

/* ==================== Text Panel Controls ==================== */
.text-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.text-input-control {
    margin-bottom: 16px;
}

.text-input-control label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.text-input-control input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.text-input-control input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.select-control {
    margin-bottom: 16px;
}

.select-control label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.select-control select {
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.select-control select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Color Swatches */
.color-swatches {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--color-text-primary);
}

.color-swatch.active {
    border-color: var(--color-primary);
    border-width: 3px;
}

/* ==================== Filters Panel Styling ==================== */
.filters-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filters-actions button {
    flex: 1;
    min-width: 80px;
}

.filters-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-control {
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.checkbox-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    cursor: pointer;
}

.checkbox-control input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.checkbox-control input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Collapsible Sections in Filters Panel */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-fast);
}

.collapsible-header:hover {
    color: var(--color-primary);
}

.collapse-icon {
    font-size: 12px;
    color: var(--color-text-secondary);
    transition: transform var(--transition-fast);
    margin-left: 8px;
}

.collapsible-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ==================== Layers Panel Styling ==================== */
#layersList {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-text-secondary);
}

.layer-item.active {
    background: rgba(0, 212, 180, 0.1);
    border-color: var(--color-primary);
}

.layer-thumb {
    width: 56px;
    height: 40px;
    border-radius: 4px;
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.layer-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-info {
    font-size: 11px;
    color: var(--color-text-muted);
}

.layer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.layer-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.layer-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.layer-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==================== Utilities ==================== */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== Canvas States ==================== */
.canvas-container.cropping #photoCanvas {
    border-color: var(--color-primary);
    border-style: solid;
    cursor: crosshair !important;
}

#photoCanvas.cropping {
    cursor: crosshair !important;
}

.canvas-container.dragging {
    cursor: grabbing;
}

/* Eyedropper cursor */
#photoCanvas.eyedropper {
    cursor: crosshair !important;
}

.canvas-container.eyedropper-active #photoCanvas {
    cursor: crosshair !important;
}

/* ==================== Loading States ==================== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 212, 180, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== Compatibility Elements ==================== */
/* Legacy placeholder message (for backwards compatibility) */
.placeholder-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.placeholder-message:not(.hidden) {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.placeholder-icon {
    font-size: 48px;
    margin: 0;
}

.placeholder-text {
    font-size: 18px;
    color: var(--color-text-dark);
    margin: 0;
}

/* Sidebar overlay (for mobile/compatibility) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Floating sidebar (for original index.php compatibility) */
.floating-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.floating-sidebar.active {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.btn-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 24px;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Mobile bottom tools panel overrides and icon layout */
@media (max-width: 767px) {

    /* Show panel header and use collapse button as a close control on the bottom sheet */
    .tools-panel-header {
        display: flex;
    }

    .panel-collapse-btn {
        display: flex;
        position: absolute;
        right: 16px;
        top: 12px;
        width: 32px;
        height: 32px;
        border-radius: 999px;
        transform: none;
        box-shadow: var(--shadow-md);
    }

    /* Icon-based mobile tools panel layout */
    .mobile-panel-wrapper {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .mobile-panel-sections-container {
        flex: 1;
        overflow-y: auto;
        padding: 12px 16px 8px;
    }

    .mobile-panel-section {
        padding: 8px 0;
        border-bottom: none;
    }

    .mobile-panel-section h4 {
        font-size: 13px;
        margin-bottom: 10px;
    }

    .mobile-panel-icons-row {
        display: flex;
        gap: 12px;
        padding: 8px 16px 12px;
        border-top: 1px solid var(--color-border);
        background: var(--color-bg-darker);
        overflow-x: auto;
    }

    .mobile-panel-icon-btn {
        flex: 0 0 auto;
        min-width: 70px;
        padding: 8px 10px;
        border-radius: 12px;
        background: #151515;
        color: var(--color-text-secondary);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        border: 1px solid transparent;
        transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    }

    .mobile-panel-icon-btn:hover {
        background: #1e1e1e;
    }

    .mobile-panel-icon-btn.active {
        background: #111827;
        border-color: var(--color-primary);
        color: var(--color-primary);
        transform: translateY(-1px);
    }

    .mobile-panel-icon {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-panel-icon svg {
        width: 22px;
        height: 22px;
    }

    .mobile-panel-label {
        font-size: 11px;
        font-weight: 500;
        text-align: center;
        white-space: nowrap;
    }

    /* Frames panel mobile adjustments */
    .frames-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .frames-tab {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .layout-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .layout-btn svg {
        width: 40px;
        height: 40px;
    }

    .frame-category-btn {
        padding: 14px 16px;
    }

    .frame-preview-icon {
        width: 48px;
        height: 48px;
    }

    .color-swatches-large {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Frames panel: make frame presets horizontally scrollable like the crop menu */
    .frame-style-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 0 12px 12px;
        -webkit-overflow-scrolling: touch;
    }

    .frame-style-grid::-webkit-scrollbar {
        display: none;
    }

    .frame-style-btn {
        flex: 0 0 auto;
        min-width: 80px;
    }

    /* Effects panel: show categories as horizontal cards */
    .effects-accordion {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 8px 16px 12px;
        -webkit-overflow-scrolling: touch;
    }

    .effects-accordion::-webkit-scrollbar {
        display: none;
    }

    .effect-category {
        flex: 0 0 72%;
    }

    /* Elements panel: show categories as horizontal cards */
    .elements-accordion {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 8px 16px 12px;
        -webkit-overflow-scrolling: touch;
    }

    .elements-accordion::-webkit-scrollbar {
        display: none;
    }

    .element-category {
        flex: 0 0 72%;
    }

    /* Prevent page-level horizontal scrolling on small screens */
    html,
    body,
    .editor-layout,
    .canvas-area,
    .canvas-container,
    .tools-panel,
    .left-toolbar {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Tighten crop options vertical spacing on mobile */
    .crop-options-grid {
        margin-top: 4px;
        padding-top: 4px;
        padding-bottom: 2px;
        gap: 8px;
    }

    .crop-ratio-btn {
        padding: 8px 6px;
    }

    .crop-ratio-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* ==================== Print Styles ==================== */
@media print {

    .top-header,
    .left-toolbar,
    .tools-panel,
    .canvas-toolbar,
    .mini-toolbar,
    .context-menu,
    .modal,
    .notification-area,
    .sidebar-overlay,
    .floating-sidebar {
        display: none !important;
    }

    .canvas-area {
        width: 100%;
        height: 100%;
    }

    #photoCanvas {
        max-width: 100%;
        border: none;
        box-shadow: none;
    }
}

/* ==================== Effects Panel Accordion Styles ==================== */
.effects-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.effect-category {
    background: var(--color-bg-panel);
    border-radius: 8px;
    overflow: hidden;
}

.effect-category-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.effect-category-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-primary);
}

.effect-category-btn.active {
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--color-primary);
}

.effect-category-btn .category-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.effect-category-btn .category-name {
    flex: 1;
    text-align: left;
}

.effect-category-btn .favorite-icon {
    color: #fbbf24;
    font-size: 16px;
    margin-right: 4px;
}

.effect-category-btn .category-arrow {
    transition: transform 0.3s ease;
}

.effect-category-btn.active .category-arrow {
    transform: rotate(180deg);
}

.effect-gallery {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
}

.effect-gallery.show {
    display: grid;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.effect-item {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--color-bg-hover);
}

.effect-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.effect-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.effect-item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    font-size: 0.75rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.effect-item:hover .effect-item-name {
    opacity: 1;
}

.effect-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.effect-loading::after {
    content: '...';
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* ===============================================
   Elements Panel Styles
   =============================================== */

.elements-header {
    margin-bottom: 20px;
}

.search-elements {
    width: 100%;
    padding: 12px 16px;
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.search-elements:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.05);
}

.search-elements::placeholder {
    color: var(--color-text-secondary);
}

.elements-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--color-border);
}

.elements-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.elements-tab:hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.elements-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.elements-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.element-category {
    background: var(--color-bg-panel);
    border-radius: 8px;
    overflow: hidden;
}

.element-category-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.element-category-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-primary);
}

.element-category-btn.active {
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--color-primary);
}

.element-category-btn .category-name {
    flex: 1;
    text-align: left;
}

.element-category-btn .category-arrow {
    transition: transform 0.3s ease;
}

.element-category-btn.active .category-arrow {
    transform: rotate(180deg);
}

.element-category-btn .category-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(0, 212, 180, 0.2), rgba(0, 145, 255, 0.2));
    border: 1px solid rgba(0, 212, 180, 0.6);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
    margin-right: 8px;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.element-category-btn .category-more-btn:hover,
.element-category-btn .category-more-btn:focus {
    background: linear-gradient(135deg, rgba(0, 212, 180, 0.32), rgba(0, 145, 255, 0.32));
    color: #ffffff;
    border-color: rgba(0, 212, 180, 0.85);
    transform: translateX(2px);
    box-shadow: 0 6px 14px rgba(0, 212, 180, 0.18);
    outline: none;
}

.element-gallery {
    display: none;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
}

.element-gallery.show {
    display: grid;
}

.element-item {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    overflow: visible;
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.element-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    background: rgba(79, 70, 229, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
}

.element-item img,
.element-item svg {
    max-width: 75%;
    max-height: 75%;
    object-fit: contain;
    color: #e5e7eb;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.element-item svg * {
    stroke: currentColor !important;
}

/* ==================== Mobile Crop Toolbar ==================== */
.mobile-crop-toolbar {
    position: fixed;
    bottom: var(--toolbar-height, 64px);
    left: 0;
    right: 0;
    background: var(--color-bg-dark);
    border-top: 1px solid var(--color-border);
    z-index: 100;
    display: none;
    padding: 12px;
    flex-direction: column;
    gap: 12px;
}

.mobile-crop-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.mobile-crop-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-bg-panel);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-primary);
    transition: all 0.2s;
}

.mobile-crop-action-btn:active {
    transform: scale(0.95);
}

.mobile-crop-action-btn.mobile-crop-apply {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.mobile-crop-action-btn.mobile-crop-apply:active {
    background: var(--color-primary-hover);
}

.mobile-crop-ratios {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.mobile-crop-ratios::-webkit-scrollbar {
    display: none;
}

.mobile-crop-ratio-btn {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--color-bg-panel);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--color-text-secondary);
    transition: all 0.2s;
    min-width: 72px;
}

.mobile-crop-ratio-btn.active {
    border-color: var(--color-primary);
    background: rgba(0, 212, 180, 0.1);
    color: var(--color-primary);
}

.mobile-crop-ratio-btn span {
    font-size: 11px;
    white-space: nowrap;
}

@media (max-width: 767px) {

    /* On mobile we control visibility via JS; keep desktop crop buttons hidden */
    #cropActions {
        display: none !important;
    }

    /* Turn desktop crop grid into a horizontal, scrollable strip on mobile */
    .crop-options-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px;
        margin-top: 4px;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }

    .crop-options-grid::-webkit-scrollbar {
        display: none;
    }

    .crop-ratio-btn {
        min-width: 72px;
        flex: 0 0 auto;
        padding: 8px 6px;
    }
}

.element-item .favorite-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #9ca3af;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

.element-item:hover .favorite-badge {
    opacity: 1;
}

.element-item .favorite-badge.active {
    opacity: 1;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.2);
}

.element-item .favorite-badge:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.15);
    color: #fbbf24;
}

/* ===== Mobile fine-tuning for bottom tools panel & effects ===== */
@media (max-width: 767px) {

    /* 1) Let the bottom sheet height follow the content (max 70vh)
       -> removes the big empty gap when there are few options       */
    .tools-panel {
        height: auto !important;
        max-height: 70vh !important;
    }

    /* Slightly reduce top padding inside the panel */
    #toolsPanelContent {
        padding-top: 4px !important;
    }

    /* Remove extra top spacing for the very first section */
    #toolsPanelContent .panel-section:first-child,
    #toolsPanelContent .accordion-section:first-child {
        margin-top: 0 !important;
        padding-top: 8px !important;
    }

    /* 2) Effects panel – show categories as horizontal cards
          that you can scroll left/right                        */
    .effects-accordion {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 10px !important;
        padding: 8px 12px 12px !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .effects-accordion::-webkit-scrollbar {
        display: none !important;
    }

    .effect-category {
        flex: 0 0 75% !important;
        /* width of each category card, adjust if needed */
    }

    /* Inside each category, show the effect thumbnails horizontally
       and make them scrollable as well                                */
    .effect-gallery {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 10px !important;
        padding: 12px 8px 16px !important;
    }

    .effect-gallery.show {
        display: flex !important;
        /* override the default .show = grid */
    }

    .effect-gallery::-webkit-scrollbar {
        display: none !important;
    }

    .effect-item {
        flex: 0 0 90px !important;
        /* width of each effect thumbnail */
    }
}

/* ===== Mobile horizontal layout for Effects / Elements / Frames ===== */
@media (max-width: 767px) {

    /* Hide "show more" buttons on mobile */
    .category-more-btn {
        display: none !important;
    }

    /* --- Effects panel: categories row + horizontal gallery --- */
    .effects-accordion {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 8px 12px 12px;
        -webkit-overflow-scrolling: touch;
    }

    .effects-accordion::-webkit-scrollbar {
        display: none;
    }

    .effect-category {
        flex: 0 0 50%;
        /* smaller cards - 2 visible at once */
        min-width: 50%;
    }

    /* Effect thumbnails scroll horizontally instead of grid */
    .effect-gallery {
        display: none;
        /* default hidden; JS adds .show */
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 12px 8px 16px;
        -webkit-overflow-scrolling: touch;
    }

    .effect-gallery.show {
        display: flex;
    }

    .effect-gallery::-webkit-scrollbar {
        display: none;
    }

    .effect-item {
        flex: 0 0 80px;
        /* smaller preview tiles */
        max-width: 80px;
    }

    /* --- Elements panel: categories row + horizontal gallery --- */
    .elements-accordion {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 8px 12px 12px;
        -webkit-overflow-scrolling: touch;
    }

    .elements-accordion::-webkit-scrollbar {
        display: none;
    }

    .element-category {
        flex: 0 0 50%;
        /* smaller cards - 2 visible at once */
        min-width: 50%;
    }

    .element-gallery {
        display: none;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 12px 8px 16px;
        -webkit-overflow-scrolling: touch;
    }

    .element-gallery.show {
        display: flex;
    }

    .element-gallery::-webkit-scrollbar {
        display: none;
    }

    .element-item {
        flex: 0 0 60px;
        /* smaller element items */
        max-width: 60px;
    }

    /* --- Frames panel: Simple / Borders / Wooden / Classy horizontally --- */
    .frames-tab-content[data-content="frames"] .panel-section {
        padding-inline: 12px;
    }

    .frames-tab-content[data-content="frames"] .frame-category {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .frames-tab-content[data-content="frames"] .frame-category::-webkit-scrollbar {
        display: none;
    }

    .frames-tab-content[data-content="frames"] .frame-category-btn {
        flex: 0 0 50%;
        /* smaller cards - 2 visible at once */
        min-width: 50%;
    }
}

/* ===== Mobile: make Frames main categories horizontal & scrollable ===== */
@media (max-width: 767px) {

    /* "Simple / Borders / Wooden / Classy" row */
    .frames-tab-content[data-content="frames"] .frame-category {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 12px;
        padding: 8px 8px 16px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .frames-tab-content[data-content="frames"] .frame-category::-webkit-scrollbar {
        display: none;
    }

    /* Each category card width (like crop buttons) */
    .frames-tab-content[data-content="frames"] .frame-category-btn {
        flex: 0 0 80%;
        min-width: 80%;
    }
}