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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #1e1e1e;
    color: #e5e5e5;
    min-height: 100vh;
    font-size: 14px;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #2d2d2d 0%, #252525 100%);
    border-bottom: 1px solid #3a3a3a;
    padding: 0 20px;
    height: 52px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-brand svg {
    color: #0071e3;
    filter: drop-shadow(0 0 8px rgba(0, 113, 227, 0.3));
}

.navbar-menu {
    display: flex;
    gap: 6px;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    color: #ccc;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-color: #444;
}

.dropdown-toggle svg:not(.chevron) {
    opacity: 0.8;
}

.dropdown-toggle:hover svg:not(.chevron) {
    opacity: 1;
}

.chevron {
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.dropdown:hover .dropdown-toggle .chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 12px;
    padding: 6px;
    min-width: 240px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown:hover .dropdown-menu,
.dropdown-toggle:focus + .dropdown-menu,
.dropdown-menu:hover,
.dropdown-menu.open {
    display: block;
}

/* Click-based dropdown (for mode selector) */
.dropdown-click .dropdown-menu {
    display: none;
}

/* Keep dropdown open when hovering menu */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    color: #ddd;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.dropdown-menu button:hover {
    background: linear-gradient(135deg, #383838 0%, #333 100%);
    color: #fff;
}

.dropdown-menu button svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.dropdown-menu button:hover svg {
    opacity: 1;
    color: #0071e3;
}

.dropdown-divider {
    height: 1px;
    background: #3a3a3a;
    margin: 6px 8px;
    border-radius: 1px;
}

.shortcut {
    margin-left: auto;
    font-size: 0.75rem;
    color: #666;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
}

.dropdown-menu button:hover .shortcut {
    color: #888;
    background: rgba(255, 255, 255, 0.1);
}

/* Menu item with toggle */
.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.menu-item-btn {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
}

.menu-item-btn:hover {
    background: rgba(255, 255, 255, 0.03);
}

.folder-input {
    width: 100%;
    padding: 8px 10px;
    background: #1f1f1f;
    border: 1px solid #444;
    border-radius: 6px;
    color: #ddd;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.folder-input:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.folder-input::placeholder {
    color: #666;
}

.menu-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ddd;
    font-size: 0.9rem;
}

.menu-item-content svg {
    opacity: 0.7;
}

.menu-item:hover .menu-item-content svg {
    opacity: 1;
    color: #0071e3;
}

.menu-item-value {
    font-size: 0.8rem;
    color: #888;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
}

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

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #888;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, #0071e3 0%, #0056b3 100%);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.container {
    padding: 16px 20px;
}

header {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #333;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: #777;
    font-size: 0.9rem;
}

main {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 16px;
}

@media (max-width: 1200px) {
    main {
        grid-template-columns: 260px 1fr 280px;
    }
}

@media (max-width: 1050px) {
    main {
        grid-template-columns: 240px 1fr;
    }

    .right-sidebar {
        display: none;
    }
}

@media (max-width: 650px) {
    main {
        grid-template-columns: 1fr;
    }

    .left-sidebar {
        order: 2;
    }

    .editor-section {
        order: 1;
    }
}

/* Left Sidebar */
.left-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Right Sidebar */
.right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    gap: 4px;
    background: #252525;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid #3a3a3a;
}

.sidebar-tabs .tab-btn {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #888;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.sidebar-tabs .tab-btn:hover {
    color: #ddd;
    background: #2a2a2a;
}

.sidebar-tabs .tab-btn.active {
    background: #383838;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Collapsible Section */
.collapsible-section {
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.collapsible-section:hover {
    border-color: #444;
}

.collapsible-section.open {
    border-color: #0071e3;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.collapsible-header:hover {
    background: #2a2a2a;
}

.collapsible-header .section-title {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 0.85rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.collapsible-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.collapsible-section.open .collapsible-toggle {
    transform: rotate(180deg);
    color: #0071e3;
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
}

.collapsible-section.open .collapsible-content {
    max-height: 500px;
    padding: 0 14px 14px;
}

.collapsible-content .form-group {
    margin-bottom: 10px;
}

.collapsible-content .form-group:last-child {
    margin-bottom: 0;
}

.collapsible-content .form-row {
    margin-bottom: 10px;
}

/* Panel */
.panel {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #3a3a3a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.panel h2 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: #bbb;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #1f1f1f;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.form-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #444;
    appearance: none;
    cursor: pointer;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0071e3, #0056b3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 113, 227, 0.3);
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0, 113, 227, 0.4);
}

.form-group input[type="color"] {
    width: 100%;
    height: 38px;
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    padding: 4px;
    background: #1f1f1f;
    transition: all 0.2s ease;
}

.form-group input[type="color"]:hover {
    border-color: #555;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.value-label {
    display: block;
    font-size: 0.75rem;
    color: #0071e3;
    text-align: right;
    margin-top: 4px;
    font-weight: 500;
}

.color-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-group input[type="color"] {
    flex: 1;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #0071e3, #0056b3);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #0077ed, #0062c4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.35);
}

.btn-secondary {
    background: #383838;
    color: #e5e5e5;
    border: 1px solid #444;
}

.btn-secondary:hover:not(:disabled) {
    background: #424242;
    border-color: #555;
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #d93025, #b5221f);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #e0352a, #c5221f);
}

.btn-success {
    background: linear-gradient(135deg, #34c759, #28a745);
    color: #fff;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.25);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #3ddc84, #30b350);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.35);
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid #444;
    border-radius: 8px;
    background: #383838;
    color: #999;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #424242;
    color: #fff;
    border-color: #555;
    transform: scale(1.05);
}

/* Toggle button (for Bold, Italic, Underline) */
.btn-toggle {
    flex: 1;
    height: 40px;
    border: 1px solid #444;
    border-radius: 8px;
    background: #383838;
    color: #aaa;
    cursor: pointer;
    font-size: 1rem;
    font-family: serif;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle:first-child {
    margin-left: 0;
}

.btn-toggle:last-child {
    margin-right: 0;
}

.btn-toggle:hover {
    background: #424242;
    color: #fff;
    border-color: #555;
    transform: translateY(-1px);
}

.btn-toggle.active {
    background: linear-gradient(135deg, #0071e3, #0056b3);
    border-color: #0071e3;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.style-buttons {
    display: flex;
    gap: 8px;
}

.align-buttons {
    display: flex;
    gap: 8px;
}

.button-group {
    display: flex;
    gap: 8px;
}

.button-group .btn {
    flex: 1;
}

/* Upload Zone */
.upload-zone {
    background: #2a2a2a;
    border: 2px dashed #444;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 12px;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #0071e3;
    background: rgba(0, 113, 227, 0.1);
    transform: scale(1.01);
}

.upload-content svg {
    color: #555;
    margin-bottom: 10px;
    transition: transform 0.3s ease;
}

.upload-zone:hover .upload-content svg {
    transform: scale(1.1);
    color: #0071e3;
}

.upload-content p {
    color: #888;
    font-size: 0.95rem;
}

/* Canvas */
#previewCanvas {
    max-width: 100%;
    border-radius: 8px;
}

/* Canvas Wrapper */
.canvas-wrapper {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid #3a3a3a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #3a3a3a;
}

.canvas-toolbar .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
}

.canvas-toolbar #zoomLevel {
    font-size: 0.9rem;
    color: #888;
    min-width: 55px;
    text-align: center;
    font-weight: 600;
    background: #1f1f1f;
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
}

.zoom-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.zoom-progress-bar {
    width: 70px;
    height: 4px;
    background: #3a3a3a;
    border-radius: 2px;
    overflow: hidden;
}

.zoom-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0071e3, #34c759);
    width: 25%;
    transition: width 0.2s ease;
    border-radius: 2px;
}

.ctrl-pressed {
    cursor: zoom-in !important;
}

.ctrl-pressed #previewCanvas {
    cursor: zoom-in !important;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #3a3a3a;
    margin: 0 5px;
}

.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 600px;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 16px;
    overflow: auto;
    max-height: 80vh;
}

#previewCanvas {
    max-width: 100%;
    transition: transform 0.3s ease;
    transform-origin: center center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
}

/* Layers List */
.layers-list {
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 12px;
    background: #1f1f1f;
    border-radius: 8px;
    padding: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #2a2a2a;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.layer-item:last-child {
    margin-bottom: 0;
}

.layer-item:hover {
    background: #353535;
    transform: translateX(3px);
}

.layer-item.selected {
    background: linear-gradient(135deg, #0071e3, #0056b3);
    border-color: #0077ed;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.layer-item .layer-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #777;
    background: #1f1f1f;
    border-radius: 4px;
}

.layer-item.selected .layer-icon {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.layer-item .layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #ddd;
}

.layer-item.selected .layer-name {
    color: #fff;
    font-weight: 600;
}

.layer-item .layer-visibility {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    color: #777;
    cursor: pointer;
    font-size: 0.9rem;
    margin-right: 4px;
    opacity: 0.7;
    transition: all 0.15s ease;
    border-radius: 4px;
}

.layer-item .layer-visibility:hover {
    opacity: 1;
    background: #444;
}

.layer-item .layer-visibility.hidden {
    opacity: 0.3;
}

.layer-item .layer-delete {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.15s ease;
    border-radius: 4px;
}

.layer-item:hover .layer-delete {
    opacity: 0.7;
}

.layer-item .layer-delete:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.15);
}

.layer-item.selected .layer-delete {
    color: #ff9999;
}

.layer-actions {
    display: flex;
    gap: 8px;
}

.layer-actions .btn {
    padding: 10px 14px;
    font-size: 0.85rem;
}

/* Images List */
.images-list {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 12px;
    background: #1f1f1f;
    border-radius: 8px;
    padding: 8px;
}

.image-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #2a2a2a;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.image-item:last-child {
    margin-bottom: 0;
}

.image-item:hover {
    background: #353535;
    transform: translateX(3px);
}

.image-item.selected {
    background: linear-gradient(135deg, #0071e3, #0056b3);
    border-color: #0077ed;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.image-item .image-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #ddd;
}

.image-item.selected .image-name {
    color: #fff;
    font-weight: 600;
}

.image-item .image-delete {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.15s ease;
    border-radius: 4px;
}

.image-item:hover .image-delete {
    opacity: 0.7;
}

.image-item .image-delete:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.15);
}

/* Layer Params */
#layerParams {
    min-height: 100px;
}

#layerParams .form-group {
    margin-bottom: 10px;
}

#layerParams .hint {
    color: #777;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

/* Parameter Sections (legacy - keep for backward compat) */
.params-section {
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.params-section:hover {
    border-color: #444;
}

.params-section .form-group:last-child {
    margin-bottom: 0;
}

/* Section title (used in collapsible and legacy) */
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Empty Message */
.empty-message {
    text-align: center;
    color: #666;
    padding: 16px;
    font-size: 0.85rem;
    font-style: italic;
}

.hint {
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 10px;
}

/* Progress Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

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

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

.progress-content {
    background: #2a2a2a;
    padding: 30px 40px;
    border-radius: 16px;
    text-align: center;
    min-width: 200px;
    border: 1px solid #3a3a3a;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #3a3a3a;
    border-top-color: #0071e3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.progress-content p {
    margin-bottom: 16px;
    color: #e5e5e5;
    font-size: 1rem;
}

.progress-bar {
    height: 8px;
    background: #3a3a3a;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0071e3, #34c759);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 4px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Selection highlight */
::selection {
    background: rgba(0, 113, 227, 0.3);
    color: #fff;
}

/* Focus visible outline */
:focus-visible {
    outline: 2px solid #0071e3;
    outline-offset: 2px;
}

/* Batch Generation */
.layers-checkboxes {
    max-height: 150px;
    overflow-y: auto;
    background: #1f1f1f;
    border-radius: 8px;
    padding: 10px;
}

.layer-checkbox {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: #2a2a2a;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layer-checkbox:last-child {
    margin-bottom: 0;
}

.layer-checkbox:hover {
    background: #353535;
}

.layer-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    accent-color: #0071e3;
    cursor: pointer;
}

.layer-checkbox .layer-checkbox-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #777;
    background: #1f1f1f;
    border-radius: 4px;
}

.layer-checkbox .layer-checkbox-name {
    flex: 1;
    font-size: 0.85rem;
    color: #ddd;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.batch-texts-container {
    max-height: 250px;
    overflow-y: auto;
    background: #1f1f1f;
    border-radius: 8px;
    padding: 10px;
}

.batch-image-section {
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.batch-image-section:last-child {
    margin-bottom: 0;
}

.batch-image-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0071e3;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.batch-text-input {
    margin-bottom: 8px;
}

.batch-text-input:last-child {
    margin-bottom: 0;
}

.batch-text-input label {
    display: block;
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 4px;
}

.batch-text-input input {
    width: 100%;
    padding: 8px 10px;
    background: #1f1f1f;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
}

.batch-text-input input:focus {
    outline: none;
    border-color: #0071e3;
}

/* Custom Dialog Modal */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: dialogFadeIn 0.2s ease;
}

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

@keyframes dialogFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog-modal {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 16px;
    padding: 28px;
    min-width: 360px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: dialogSlideIn 0.3s ease;
}

@keyframes dialogSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.dialog-icon.info {
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.15), rgba(0, 113, 227, 0.05));
    color: #0071e3;
}

.dialog-icon.success {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.15), rgba(52, 199, 89, 0.05));
    color: #34c759;
}

.dialog-icon.warning {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.15), rgba(255, 149, 0, 0.05));
    color: #ff9500;
}

.dialog-icon.error {
    background: linear-gradient(135deg, rgba(255, 59, 48, 0.15), rgba(255, 59, 48, 0.05));
    color: #ff3b30;
}

.dialog-icon svg {
    width: 32px;
    height: 32px;
}

.dialog-content {
    margin-bottom: 24px;
}

.dialog-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 10px 0;
}

.dialog-message {
    font-size: 0.95rem;
    color: #aaa;
    line-height: 1.6;
    margin: 0;
    white-space: pre-line;
}

.dialog-actions .btn {
    min-width: 120px;
    padding: 12px 28px;
}

/* Preview Modal */
.preview-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.preview-modal-content {
    background: #1a1a1a;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
}

.preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #333;
}

.preview-modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #fff;
}

.preview-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.preview-modal-close:hover {
    background: #333;
    color: #fff;
}

.preview-modal-body {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.preview-card {
    background: #252525;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #3a3a3a;
    transition: transform 0.2s, box-shadow 0.2s;
}

.preview-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.preview-card-image {
    width: 100%;
    aspect-ratio: 16/10;
    object-fit: contain;
    background: #1a1a1a;
    display: block;
}

.preview-card-footer {
    padding: 12px;
    border-top: 1px solid #3a3a3a;
}

.preview-card-title {
    font-size: 0.85rem;
    color: #ddd;
    font-weight: 500;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #333;
}

.preview-modal-footer .btn {
    min-width: 120px;
}

/* Empty state */
.preview-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.preview-empty p {
    margin: 0 0 16px 0;
    font-size: 1rem;
}

/* Mode Button Styles */
.mode-btn {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 12px !important;
    text-align: left;
}

.mode-btn.active {
    background: linear-gradient(135deg, #383838 0%, #333 100%) !important;
    color: #fff !important;
}

.mode-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #0071e3;
    border-radius: 0 2px 2px 0;
}

.mode-btn-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-btn-desc {
    font-size: 0.75rem;
    color: #888;
    font-weight: normal;
}

/* Image Edit Section */
.image-edit-section {
    display: none;
    height: calc(100vh - 52px);
    background: #1a1a1a;
}

.image-edit-section.active,
.image-edit-section:not([hidden]) {
    display: flex;
}

.image-edit-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.image-edit-sidebar {
    width: 300px;
    background: #222;
    border-right: 1px solid #333;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

.image-edit-sidebar h2 {
    font-size: 1.1rem;
    color: #fff;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.image-edit-panel {
    background: #282828;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #333;
}

.image-edit-panel h3 {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 12px;
    font-weight: 500;
}

.image-edit-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.image-edit-info p {
    font-size: 0.85rem;
    color: #aaa;
    margin: 0;
}

.edit-tool-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.edit-tool-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.edit-tool-section h4 {
    font-size: 0.85rem;
    color: #ccc;
    margin-bottom: 10px;
    font-weight: 500;
}

.crop-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.crop-preset-btn {
    background: #333;
    border: 1px solid #444;
    color: #aaa;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
}

.crop-preset-btn:hover {
    background: #404040;
    color: #fff;
    border-color: #555;
}

#toggleManualCropBtn.active {
    background: #0071e3;
    color: #fff;
    border-color: #0071e3;
}

#imageEditSection .hint {
    font-size: 0.8rem;
    color: #4caf50;
    margin-top: 8px;
}

/* Manual Crop Overlay */
.crop-overlay-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.crop-overlay-container.active {
    display: block;
}

.crop-overlay-wrapper {
    position: relative;
    display: inline-block;
}

.crop-overlay-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 150px);
}

.crop-box {
    position: absolute;
    border: 2px solid #0071e3;
    background: rgba(0, 113, 227, 0.1);
    cursor: move;
    top: 0;
    left: 0;
    width: 60%;
    height: 60%;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #0071e3;
    border-radius: 2px;
    z-index: 10;
}

.crop-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle-n { top: -6px; left: 50%; margin-left: -6px; cursor: n-resize; }
.crop-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle-e { top: 50%; right: -6px; margin-top: -6px; cursor: e-resize; }
.crop-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle-s { bottom: -6px; left: 50%; margin-left: -6px; cursor: s-resize; }
.crop-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle-w { top: 50%; left: -6px; margin-top: -6px; cursor: w-resize; }

.crop-dim {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

.image-edit-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #151515;
    position: relative;
    overflow: hidden;
}

.image-edit-canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
}

#imageEditCanvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.image-edit-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #555;
    gap: 16px;
}

.image-edit-placeholder svg {
    opacity: 0.5;
}

.image-edit-placeholder p {
    font-size: 1rem;
}

.image-edit-placeholder:not([hidden]) {
    display: flex;
}

.image-edit-placeholder[hidden] {
    display: none;
}

/* Show/hide main editor */
.container.hidden {
    display: none;
}
