:root {
    --bd-bg: radial-gradient(circle at 15% 20%, #2e2ce0 0%, #0b0b1b 35%, #03030b 100%);
    --panel-bg: rgba(10, 11, 22, 0.95);
    --panel-backdrop: rgba(6, 7, 20, 0.5);
    --border-color: rgba(255, 255, 255, 0.12);
    --text-primary: #f5f5f5;
    --text-secondary: #cbd5f5;
    --accent-color: #fbbf24;
    --accent-hover: #fcd34d;
    --danger-color: #ff4444;
    --input-bg: rgba(255, 255, 255, 0.06);
    --card-bg: rgba(6, 7, 23, 0.8);
    --shadow-glow: 0 20px 45px rgba(251, 191, 36, 0.25);
}

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

body {
    font-family: 'Be Vietnam Pro', sans-serif;
    background: var(--bd-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: stretch;
    background-attachment: fixed;
    transition: background 0.6s ease;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    gap: 0;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    width: 450px;
    background: var(--panel-backdrop);
    background-image: radial-gradient(circle at 20% -20%, rgba(251, 191, 36, 0.15), transparent 45%);
    /* border-right: 1px solid var(--border-color); */
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    flex-shrink: 0;
    /* box-shadow: inset -1px 0 0 var(--border-color); */
    backdrop-filter: blur(24px);
    border-radius: 1rem;
}

.sidebar-resize-handle {
    width: 4px;
    flex-shrink: 0;
    cursor: ew-resize;
    position: relative;
    display: flex;
    align-self: stretch;
}

.sidebar-resize-handle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
}

.content-area {
    flex: 1;
    margin-left: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    overflow: hidden;
    padding: 0;
    min-height: 0;
}

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    .sidebar {
        width: 100%;
        border-radius: 1rem;
        margin-bottom: 0;
        min-height: calc(100vh - 3rem);
        height: auto;
    }

    .sidebar-resize-handle {
        display: none;
    }

    .content-area {
        margin-left: 0;
        margin-top: 0;
    }
}

.toolbar-info-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    padding: 0.35rem 0.6rem;
    border-radius: 0;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-info-btn:hover:not(:disabled) {
    border-color: var(--accent-color);
    color: #111;
    background: rgba(251, 191, 36, 0.18);
    box-shadow: 0 15px 35px rgba(251, 191, 36, 0.15);
}

.toolbar-info-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 32px;
    margin-top: 30px;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.info-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    min-width: 36px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
}


.brand {
    margin-bottom: 0;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    font-family: 'Playwrite AU SA', cursive;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge {
    font-size: 0.5rem;
    /* background-color: rgba(245, 197, 24, 0.15); */
    color: var(--accent-color);
    padding: 0.2rem 0.3rem;
    /* border-radius: 999px; */
    font-weight: 600;
}

.controls-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

.controls-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-top: 1rem;
    padding-right: 10px;
    margin-right: -10px;
}

.controls-footer {
    display: flex;
    justify-content: flex-end;
}

.controls-footer #generate-btn {
    padding: 0.4rem 1rem;
    font-size: 0.95rem;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.45rem;
    min-width: 90px;
    flex:1;
}

.controls-footer #generate-btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    line-height: 1.1;
}

.api-settings-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.65rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    line-height: 1.4;
}

.api-settings-note-icon {
    font-weight: 700;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.api-settings-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.api-settings-warning {
    font-size: 0.9rem;
    color: #ffd166;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 209, 102, 0.4);
    padding: 0.75rem 1rem;
    background: rgba(255, 209, 102, 0.08);
    line-height: 1.4;
}

.api-settings-input-group {
    margin: 0;
}

.api-key-field {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
}

.api-key-toggle-btn {
    width: 43.5px;
    height: 43.5px;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    padding: 0;
}

.api-key-toggle-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.api-key-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.api-key-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

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

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

input[type="text"],
input[type="password"],
textarea,
select {
    padding: 0.75rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
    backdrop-filter: blur(6px);
    appearance: none;
    -webkit-appearance: none;
}

input[type="password"], input[type="text"] {
    width: 100%;}
select {
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(15, 15, 25, 0.3)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 8'%3E%3Cpath fill='rgba(249, 203, 42, 0.85)' d='M7 8L0.928 0.5h12.144L7 8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-size: 100% 100%, 0.75rem 0.4rem;
    background-position: center, right 0.75rem center;
    padding-right: 2.5rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(6, 7, 20, 0.95);
    /* box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.3), 0 10px 25px rgba(0, 0, 0, 0.25); */
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

select:focus,
select:hover {
    border-color: var(--accent-color);
    background-color: rgba(6, 7, 20, 0.9);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.5), 0 15px 35px rgba(0, 0, 0, 0.35);
}

select option {
    background-color: rgba(3, 3, 10, 0.95);
    color: var(--text-primary);
    padding: 0.35rem 0.75rem;
}

select option:checked,
select option:hover,
select option:focus {
    background-color: rgba(251, 191, 36, 0.25);
    color: #111;
}

select::-ms-expand {
    display: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

textarea {
    resize: vertical;
    min-height: 30px;
}

/* Theme overrides driven from index.css gradients */
body.theme-sdvn { --bd-bg: radial-gradient(circle at 15% 20%, #2e2ce0 0%, #0b0b1b 35%, #03030b 100%); }
body.theme-vietnam { --bd-bg: radial-gradient(ellipse at bottom, #c62921, #a21a14); }
body.theme-skyline { --bd-bg: linear-gradient(to left, #6FB1FC, #4364F7, #0052D4); }
body.theme-hidden-jaguar { --bd-bg: linear-gradient(to bottom, #0fd850 0%, #f9f047 100%); }
body.theme-wide-matrix { --bd-bg: linear-gradient(to top, #fcc5e4 0%, #fda34b 15%, #ff7882 35%, #c8699e 52%, #7046aa 71%, #0c1db8 87%, #020f75 100%); }
body.theme-rainbow { --bd-bg: linear-gradient(to right, #0575E6, #00F260); }
body.theme-soundcloud { --bd-bg: linear-gradient(to right, #f83600, #fe8c00); }
body.theme-amin { --bd-bg: linear-gradient(to right, #4A00E0, #8E2DE2); }

.prompt-wrapper {
    position: relative;
    width: 100%;
}

.prompt-wrapper textarea {
    width: 100%;
}

.prompt-wrapper.prompt-highlighting {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    /* background-color: var(--input-bg); */
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.prompt-wrapper.prompt-highlighting:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.prompt-highlight {
    position: absolute;
    inset: 0;
    padding: 0.75rem 0.75rem 2.25rem 0.75rem;
    overflow: auto;
    pointer-events: none;
    white-space: pre-wrap;
    word-break: break-word;
    z-index: 1;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    scrollbar-width: none;
}

.prompt-highlight::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.prompt-highlight-segment {
    font-weight: 700;
}

.prompt-highlight .prompt-placeholder {
    color: var(--text-secondary);
}

.prompt-wrapper.prompt-highlighting textarea {
    position: relative;
    z-index: 2;
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: var(--accent-color);
    padding: 0.75rem 0.75rem 2.25rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    resize: vertical;
    width: 100%;
    height: 100%;
    opacity:0.3
}

.note-wrapper.note-highlighting {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    /* background-color: var(--input-bg); */
    backdrop-filter: blur(6px);
}

.note-highlight {
    position: absolute;
    inset: 0;
    padding: 0.75rem 0.75rem 2.25rem 0.75rem;
    overflow: auto;
    pointer-events: none;
    white-space: pre-wrap;
    word-break: break-word;
    z-index: 1;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
}

.note-highlight::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.note-highlight .note-placeholder {
    color: var(--text-secondary);
}

.note-highlight .note-line {
    display: inline;
}

.note-wrapper.note-highlighting textarea {
    position: relative;
    z-index: 2;
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: var(--accent-color);
    padding: 0.75rem 0.75rem 2.25rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    resize: vertical;
    opacity: 0.3;
    width: 100%;
    height: 100%;
}

.field-action-buttons {
    position: absolute;
    right: 0.35rem;
    bottom: 0.35rem;
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.1rem;
    border-radius: 0.5rem;
    z-index: 3;
    background: transparent;
}

.field-action-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.field-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent-color);
}

.field-action-btn:active {
    transform: translateY(1px);
}

.theme-option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.4rem;
}

.theme-option {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1rem;
    padding: 0.6rem;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-position 0.4s ease;
    text-align: left;
    height: 40px;
    overflow: hidden;
}

.theme-option::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top right, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.05));
    pointer-events: none;
}

.theme-option .theme-option-name {
    position: relative;
    z-index: 1;
    font-weight: 700;
    letter-spacing: 0.3px;
    font-size: 0.85rem;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.theme-option:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.theme-option:hover {
    transform: translateY(-1px);
    border-color: var(--accent-color);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
    background-position: 80% 20%;
}

.theme-option.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.5), 0 12px 28px rgba(251, 191, 36, 0.18);
}

.prompt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.prompt-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.prompt-action-btn:hover {
    background: rgba(251, 191, 36, 0.25);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(251, 191, 36, 0.3);
    text-decoration: none;
}

.prompt-action-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

.prompt-action-btn span {
    display: none;
}

#confirm-refine-btn {
    padding: 0.4rem 1rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #111;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(245, 197, 24, 0.3);
    transition: transform 0.1s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex:1;
}

#confirm-refine-btn:hover {
    box-shadow: 0 6px 16px rgba(245, 197, 24, 0.4);
    transform: translateY(-1px);
}

#confirm-refine-btn:active {
    transform: translateY(1px);
}

.rotating-icon {
    animation: spin 1s linear infinite;
}

/* Reference image input grid */

/* Reference image input grid */
.image-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.image-input-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.image-input-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.image-slot {
    border: 1px dashed var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    background-color: rgba(15, 23, 42, 0.8);
    color: var(--text-secondary);
    font-size: 0.75rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    overflow: hidden;
}

.image-slot:hover {
    border-color: var(--accent-color);
}

.image-slot.drag-over {
    border-color: var(--accent-hover);
    background-color: rgba(99, 102, 241, 0.1);
}

.image-slot.empty .slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.image-slot .slot-icon {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.slot-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.image-slot.filled {
    border-style: solid;
    background-color: transparent;
}

.image-slot .slot-placeholder {
    z-index: 1;
}

.slot-preview.hidden,
.slot-edit.hidden,
.slot-remove.hidden,
.slot-placeholder.hidden {
    display: none;
}

.slot-edit {
    position: absolute;
    top: 0.35rem;
    right: 2.25rem;
    background: rgba(15, 23, 42, 0.85);
    border: none;
    border-radius: 999px;
    color: var(--text-primary);
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    z-index: 3;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.slot-edit:hover {
    background: rgba(251, 191, 36, 0.25);
    color: var(--accent-color);
    transform: scale(1.05);
}

.slot-remove {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: rgba(15, 23, 42, 0.85);
    border: none;
    border-radius: 999px;
    color: var(--text-primary);
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
            cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    z-index: 3;
}

.slot-input {
    display: none;
}

button#generate-btn {
    position: relative;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #111;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 10px 15px rgba(245, 197, 24, 0.25);
    transition: transform 0.1s, filter 0.2s;
}

button#generate-btn:active {
    transform: scale(0.98);
}

button#generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: var(--text-primary);
    border-radius: 1.25rem;
    /* padding: 0.75rem; */
    height: 100%;
    min-height: 0;
    overflow: hidden;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
}

.image-display-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
    position: relative;
    background: var(--panel-backdrop);
    border-radius: 1.5rem;
    cursor: grab;
    user-select: none;
    touch-action: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 60px rgba(9, 5, 25, 0.65), inset 0 0 40px rgba(251, 191, 36, 0.1);
    min-height: 0;
}

.image-display-area.drag-over {
    border-color: rgba(251, 191, 36, 0.8);
    box-shadow: 0 30px 60px rgba(9, 5, 25, 0.7), inset 0 0 60px rgba(250, 204, 21, 0.25);
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.08), rgba(6, 6, 18, 0.95));
    backdrop-filter: blur(8px);
}

.state-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hidden {
    display: none !important;
}

.icon-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 0.75rem;
    border: 1px dashed rgba(251, 191, 36, 0.6);
    background: radial-gradient(circle at center, rgba(251, 191, 36, 0.15), transparent 60%);
    margin-bottom: 0;
}

#generated-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: none;
    transition: transform 0.2s;
    pointer-events: none;
    transform-origin: center center;
    display: block;
    margin: 0 auto;
}

.image-actions {
    margin-top: 1rem;
}

.action-btn {
    display: inline-block;
    background-color: rgba(245, 197, 24, 0.1);
    color: var(--accent-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: background-color 0.2s, color 0.2s;
}

.action-btn:hover {
    background-color: rgba(245, 197, 24, 0.25);
    color: #111;
}

.canvas-toolbar {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.35rem;
    background: rgba(15, 15, 15, 0.9);
    padding: 0.35rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    z-index: 10;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
}

.canvas-btn {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: var(--accent-color);
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 0.9rem;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.canvas-btn:hover {
    background: rgba(245, 197, 24, 0.35);
}

.canvas-btn svg {
    width: 16px;
    height: 16px;
    color: inherit;
}

.canvas-btn svg {
    width: 16px;
    height: 16px;
    color: inherit;
}

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 10, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.popup-card {
    width: min(520px, 100%);
    background: rgba(10, 11, 22, 0.96);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
    padding: 1.25rem;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.popup-header h2 {
    font-size: 1rem;
    letter-spacing: 0.3px;
    color: var(--text-primary);
}

.popup-close {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.18);
}

.popup-body {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.popup-section h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.popup-section ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-left: 0;
}

.popup-section li {
    font-size: 0.8rem;
    color: var(--text-primary);
    padding-left: 1rem;
    position: relative;
}

.popup-section li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent-color);
}

/* Gallery Section */
.history-section {
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: 180px;
    flex-shrink: 0;
    width: 100%;
    background: var(--panel-backdrop);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.history-source-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.history-source-btn {
    padding: 0.4rem 0.9rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-source-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
}

.history-source-btn.active {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #111;
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.35);
    border-color: transparent;
}

.history-filter-group {
    display: flex;
    gap: 0.15rem;
    padding: 0.25rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
}

.history-search-input {
    padding: 0.35rem 0.75rem;
    min-width: 120px;
    background: transparent;
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    color: var(--text-primary);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.2s;
    height:10px;
    margin-right:5px;
}

.history-search-input::placeholder {
    color: var(--text-secondary);
    font-weight: 500;
}

.history-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
}

.history-filter-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

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

.history-filter-btn.active {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #111;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}



.gallery-grid {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    height: 100%;
}

.gallery-item {
    height: 100%;
    aspect-ratio: 1;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.02);
    box-shadow: 0 0px 0px rgba(0, 0, 0, 0.5);
}

.gallery-item:hover {
    transform: translateY(-2px);
}

.gallery-item.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

/* New styles start here */
.gallery-item-toolbar {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.gallery-item:hover .gallery-item-toolbar {
    opacity: 1;
}

.gallery-item .favorite-btn,
.gallery-item .delete-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.gallery-item .favorite-btn svg {
    width: 12px;
    height: 12px;
}

.gallery-item .favorite-btn {
    color: rgba(255, 255, 255, 0.7);
}

.gallery-item .favorite-btn.active {
    color: #ff6b6b;
}

.gallery-item .favorite-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.gallery-item .delete-btn:hover {
    background: var(--danger-color);
    transform: scale(1.1);
}

.history-favorites-btn {
    min-width: 36px !important;
    padding: 0 8px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24.19px;
}

.history-favorites-btn.active {
    background: var(--accent-color) !important;
    height: 24.19px;
}

.history-favorites-btn.active svg {
    fill: currentColor;
}
/* New styles end here */

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Template Browser Box */
.template-browser-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05));
    border: 2px dashed rgba(251, 191, 36, 0.6);
    position: relative;
    overflow: visible;
}

.template-browser-box:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(251, 191, 36, 0.1));
    border-color: var(--accent-color);
}

.template-browser-box.active {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(251, 191, 36, 0.15));
    border-color: var(--accent-color);
    border-style: solid;
}

.template-box-icon {
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-box-icon svg {
    width: 48px;
    height: 48px;
}

.template-box-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-color);
    text-align: center;
    letter-spacing: 0.5px;
}

/* Template Gallery */
.template-gallery-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.template-gallery-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.template-gallery-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.template-gallery-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-gallery-search-row,
.template-gallery-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.template-gallery-filter-row {
    justify-content: flex-start;
}

.template-gallery-search-row {
    width: 100%;
}

.template-gallery-search-row .template-search-container {
    width: 100%;
}

@media (min-width: 1025px) {
    .template-gallery-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .template-gallery-search-row {
        flex: 1 1 320px;
    }

    .template-gallery-filter-row {
        flex: 0 1 auto;
        justify-content: flex-end;
        overflow: visible;
    }
}

.template-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.template-search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.template-category-select {
    min-width: 150px;
}

/* Canvas Language Toggle (Top-Left Corner) */
.canvas-lang-toggle {
    position: absolute;
    top: 1.2rem;
    left: 2rem;
    z-index: 20;
}

.canvas-lang-switch {
    display: inline-block;
    cursor: pointer;
}

.canvas-lang-switch input {
    display: none;
}

.canvas-lang-slider {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(10, 15, 50, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 3px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.canvas-lang-option {
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
    color: rgba(255, 255, 255, 0.5);
}

.canvas-lang-option.active {
    background: linear-gradient(135deg, #FBC02D, #F9A825);
    color: #0A0F32;
    box-shadow: 0 2px 8px rgba(251, 192, 45, 0.4);
}

.canvas-lang-switch:hover .canvas-lang-option:not(.active) {
    color: rgba(255, 255, 255, 0.8);
}

.template-results-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

.template-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding: 0.5rem;
    flex: 1;
}

.template-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.template-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    height: 220px;
}

.template-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px rgba(251, 191, 36, 0.3);
}

.template-card-preview {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    position: relative;
}

.template-card-preview-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    flex-direction: row;
    gap: 0.35rem;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.template-card-preview-actions button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, border 0.2s, background 0.2s;
}

.template-card-preview-actions button:hover {
    transform: scale(1.05);
}

.template-card-favorite-btn {
    color: var(--accent-color);
    border-color: rgba(251, 191, 36, 0.45);
    background: rgba(0, 0, 0, 0.75);
}

.template-card-favorite-btn.active {
    background: rgba(251, 191, 36, 0.9);
    color: #0a0f32;
    border-color: transparent;
}

.template-card-favorite-btn svg {
    display: block;
}

.template-card:hover .template-card-preview-actions {
    opacity: 1;
}

.template-card-preview-actions button {
    width: 28px;
    height: 28px;
}

.template-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.template-card:hover .template-card-preview img {
    transform: scale(1.05);
}

.template-card-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.template-card-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: left;
}

.template-category-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-self: flex-start;
}

.template-card-author {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: auto;
}

@media (max-width: 768px) {
    .template-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .template-card {
        height: 180px;
    }
    
    .template-card-preview {
        height: 120px;
    }
    
}

/* Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.08);
    border-left-color: var(--accent-hover);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 0.75rem 1.5rem;
        gap: 0.75rem;
    }

    .sidebar {
        width: 100%;
        border-radius: 1rem;
        max-height: 420px;
        padding: 1.25rem;
    }

    .content-area {
        flex: none;
        width: 100%;
        padding: 0;
    }

    .main-content {
        padding: 0.5rem;
    }

    .image-display-area {
        padding: 1.25rem;
        min-height: 320px;
        max-height: min(70vh, 520px);
        flex: none;
    }

    .canvas-toolbar {
        bottom: 0.75rem;
        right: 0.75rem;
    }

    .toolbar-info {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

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

    #template-gallery-state {
        align-items: stretch;
        justify-content: flex-start;
    }

    #template-gallery-state .template-gallery-container {
        max-height: min(70vh, 520px);
        min-height: 320px;
    }

    #template-gallery-state .template-gallery-container,
    #template-gallery-state .template-card-grid {
        min-height: 0;
    }

    .template-gallery-controls {
        gap: 0.5rem;
    }

    .template-gallery-search-row {
        order: 0;
    }

    .template-gallery-filter-row {
        order: 1;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .template-gallery-filter-row > * {
        flex: 0 0 auto;
    }
}

@media (max-width: 640px) {
    .sidebar {
        padding: 1rem;
    }

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

    .top-toolbar {
        gap: 0.5rem;
    }

    .toolbar-generate {
        width: 100%;
        justify-content: flex-end;
    }

    .history-section {
        height: auto;
        padding: 0.75rem;
    }

    .gallery-grid {
        gap: 0.5rem;
    }

    button#generate-btn {
        width: 100%;
        justify-content: center;
    }

    .canvas-toolbar {
        position: static;
        margin-top: 1rem;
    }

    .image-display-area {
        padding: 1rem;
    }

    .history-section .gallery-item {
        max-height: 140px;
    }
}

/* Template Create Modal */
.template-form-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.form-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.template-tag-control {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    min-height: 44px;
    padding: 0.35rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.02);
}

.template-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    flex: 1 1 auto;
    min-height: 26px;
}

.template-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-color);
    font-size: 0.75rem;
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.template-tag-chip-text {
    line-height: 1.2;
}

.template-tag-remove {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.template-tag-control input {
    flex: 1 1 150px;
    min-width: 120px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 0.2rem 0;
}

.template-tag-control input:focus {
    outline: none;
}

.template-preview-dropzone {
    width: 100%;
    height: 150px;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-preview-dropzone:hover {
    border-color: var(--accent-color);
    background: rgba(251, 191, 36, 0.05);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.1);
}

.template-preview-dropzone.drag-over {
    border-color: var(--accent-hover);
    background: rgba(251, 191, 36, 0.1);
    transform: scale(0.99);
}

.template-preview-dropzone img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
}

.dropzone-placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.dropzone-placeholder::before {
    content: '+';
    font-size: 2rem;
    color: var(--accent-color);
    opacity: 0.5;
}

#queue-btn {
    position: relative;
    padding: 1rem;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 10px 15px rgba(59, 130, 246, 0.25);
    transition: transform 0.1s, filter 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#queue-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 15px 25px rgba(59, 130, 246, 0.35);
}

#queue-btn:active {
    transform: scale(0.98);
}

#queue-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.queue-counter {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.queue-counter.hidden {
    display: none;
}

.queue-icon {
    display: flex;
    align-items: center;
    color: var(--accent-color);
}

.queue-spinner {
    display: flex;
    align-items: center;
    color: var(--accent-color);
    animation: spin 1s linear infinite;
}

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

.controls-footer {
    display: flex;
    gap: 0.75rem;
}

.category-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#create-template-modal .popup-card {
    background: rgba(10, 11, 22, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#create-template-modal .popup-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.25rem;
    margin-right: -0.25rem; /* allow scrollbar without shifting content */
}

#save-template-btn {
    padding: 0.6rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #000;
    font-weight: 700;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#save-template-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.3);
}

#save-template-btn:active {
    transform: translateY(0);
}

#save-api-settings-btn {
    padding: 0.6rem 1.25rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #000;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

#save-api-settings-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.3);
}

#save-api-settings-btn:active {
    transform: translateY(0);
}

.template-preview-url-input {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    padding: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--accent-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    z-index: 10;
}

.template-preview-url-input:focus {
    outline: none;
    border-color: var(--accent-hover);
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.2);
}

.template-edit-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, border 0.2s, background 0.2s;
}

.template-edit-btn:hover {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.template-edit-btn svg {
    width: 16px;
    height: 16px;
}

.template-create-btn {
    width:43.5px;
    height: 43.5px;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #000;
    border: none;
    border-radius: 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.1s, box-shadow 0.2s;
}

.template-create-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.3);
}

.template-create-btn svg {
    width: 16px;
    height: 16px;
}

.template-favorites-toggle {
    width: 43.5px;
    height: 43.5px;
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.55);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.template-favorites-toggle.active {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #0a0f32;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

.template-favorites-toggle:hover {
    transform: translateY(-1px) scale(1.02);
}

.template-favorites-toggle-icon svg {
    width: 20px;
    height: 20px;
}

.template-user-toggle {
    width: 43.5px;
    height: 43.5px;
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.55);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;}

.template-user-toggle.active {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #0a0f32;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

.template-user-toggle svg {
    width: 18px;
    height: 18px;
}
