/* ============================================
   YouTube Thumbnail Maker - Enhanced Styling
   Dark mode support with light mode default
   No border-left: 4px patterns
   FAQ uses .faq-item.open
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --transition-speed: 0.25s;
    
    /* Primary Colors */
    --primary: #e64e4e;
    --primary-light: #fef2f2;
    --primary-dark: #dc2626;
    --accent: #3399cc;
    --accent-light: #e0f2fe;
    --secondary: #339966;
    --secondary-light: #dcfce7;
    
    /* Status Colors */
    --success: #339966;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #e64e4e;
    --danger-light: #fef2f2;
    --info: #3399cc;
    --info-light: #e0f2fe;
    
    /* Background Colors */
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    
    /* Text Colors */
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    /* Border Colors */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --shadow-primary: 0 4px 14px rgba(230, 78, 78, 0.25);
    --shadow-primary-hover: 0 6px 20px rgba(230, 78, 78, 0.35);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Checkerboard */
    --checker-light: #f0f0f0;
    --checker-dark: #e0e0e0;
    
    /* Input */
    --input-bg: #ffffff;
    --input-border: #e2e8f0;
    
    /* Canvas */
    --canvas-bg: #374151;
    
    /* Scrollbar */
    --scrollbar-track: var(--bg);
    --scrollbar-thumb: var(--text-muted);
    --scrollbar-thumb-hover: var(--text-secondary);
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --primary: #f87171;
    --primary-light: rgba(248, 113, 113, 0.15);
    --primary-dark: #ef4444;
    --accent: #38bdf8;
    --accent-light: rgba(56, 189, 248, 0.15);
    --secondary: #4ade80;
    --secondary-light: rgba(74, 222, 128, 0.15);
    
    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --info: #38bdf8;
    --info-light: rgba(56, 189, 248, 0.15);
    
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;
    
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border: #334155;
    --border-light: #475569;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5);
    --shadow-primary: 0 4px 14px rgba(248, 113, 113, 0.2);
    --shadow-primary-hover: 0 6px 20px rgba(248, 113, 113, 0.3);
    
    --checker-light: #334155;
    --checker-dark: #475569;
    
    --input-bg: #334155;
    --input-border: #475569;
    
    --canvas-bg: #1e293b;
    
    --scrollbar-track: var(--bg-elevated);
    --scrollbar-thumb: var(--text-muted);
    --scrollbar-thumb-hover: var(--text-secondary);
}

/* Base Styles */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Container */
.tool-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
.tool-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.tool-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.tool-icon-wrapper {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-primary);
    flex-shrink: 0;
    transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
}

.tool-icon-wrapper svg,
.tool-icon-wrapper i {
    width: 26px;
    height: 26px;
}

.tool-title {
    font-size: clamp(1.5rem, 3.5vw, 2.25rem);
    font-weight: 700;
    margin: 0;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.tool-description {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ==================== Quick Start Presets ==================== */
.quick-start {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    overflow-x: auto;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.quick-start-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}

.quick-start-label svg {
    width: 16px;
    height: 16px;
    color: var(--warning);
}

.quick-start-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.preset-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: #1a1a2e;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preset-preview {
    display: block;
    line-height: 1.3;
    white-space: nowrap;
}

/* ==================== Main Tool Area ==================== */
.tool-main {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: visible !important;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

/* Editor Toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
    position: sticky;
    top: 0;
    z-index: 10;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.toolbar-right {
    margin-left: auto;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.5rem;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.toolbar-btn svg { width: 18px; height: 18px; }

.toolbar-btn:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text);
}

.toolbar-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

.toolbar-btn:focus-visible,
.panel-btn:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.zoom-level {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 50px;
    text-align: center;
}

/* Editor Layout */
.editor-layout {
    display: flex;
    flex-direction: column;
}

/* Canvas Area */
.canvas-area {
    background: var(--canvas-bg);
    padding: 1rem 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed);
    overflow: auto;
    min-height: 300px;
}

.canvas-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    max-width: 100%;
    padding: 1rem;
}

.canvas-container {
    position: relative;
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-sm);
    overflow: visible;
    /* width/height driven by JS via canvas.style.width – no transform needed */
}

#thumbnailCanvas {
    display: block;
    cursor: crosshair;
    /* width/height set dynamically by updateZoom() */
    max-width: 100%;
}

.canvas-info {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    justify-content: center;
}

.canvas-size,
.canvas-ratio {
    background: rgba(0,0,0,0.3);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.75);
    font-size: 0.8rem;
}

/* Center Guides */
.center-guide {
    position: absolute;
    z-index: 90;
    pointer-events: none;
}

.center-guide-h {
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(230, 78, 78, 0.6);
    box-shadow: 0 0 4px rgba(230, 78, 78, 0.4);
}

.center-guide-v {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: rgba(230, 78, 78, 0.6);
    box-shadow: 0 0 4px rgba(230, 78, 78, 0.4);
}

/* Controls Row (Below Canvas) */
.controls-row {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 1px;
    background: var(--border);
    border-top: 1px solid var(--border);
}

.controls-row .panel-section {
    background: var(--bg-elevated);
    padding: 1rem 1.25rem;
    transition: background-color var(--transition-speed);
    max-height: 320px;
    overflow-y: auto;
}

.controls-row .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.controls-row .panel-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.controls-row .panel-header h3 i,
.controls-row .panel-header h3 svg {
    color: var(--primary);
    width: 18px;
    height: 18px;
}

.panel-actions {
    display: flex;
    gap: 0.25rem;
}

.panel-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.panel-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.panel-btn i,
.panel-btn svg { width: 14px; height: 14px; }

/* Properties Panel - Prop Grid */
.prop-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.prop-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.prop-row-2 .form-group {
    margin-bottom: 0;
}

.properties-content {
    overflow-y: visible;
}

/* No Selection */
.no-selection {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem;
}

.no-selection svg,
.no-selection i { width: 28px; height: 28px; opacity: 0.5; flex-shrink: 0; }
.no-selection p { font-size: 0.9rem; margin: 0; }

/* Drag and Drop */
.canvas-wrapper.drag-over {
    outline: 3px dashed var(--primary);
    outline-offset: -3px;
}

.canvas-wrapper.drag-over::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(230, 78, 78, 0.1);
    pointer-events: none;
    z-index: 50;
}

[data-theme="dark"] .canvas-wrapper.drag-over::after {
    background: rgba(248, 113, 113, 0.15);
}

.drop-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 3rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 60;
    pointer-events: none;
}

.drop-indicator i,
.drop-indicator svg { width: 48px; height: 48px; color: var(--primary); }
.drop-indicator span { font-size: 1.1rem; font-weight: 600; color: var(--text); }

.canvas-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(0,0,0,0.3);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
}

.canvas-hint i,
.canvas-hint svg { color: var(--primary); width: 14px; height: 14px; }

/* Element Handles */
.element-handles {
    position: absolute;
    border: 2px solid var(--primary);
    pointer-events: none;
    z-index: 100;
    overflow: visible;
}

.handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 2px;
    pointer-events: auto;
    cursor: pointer;
    /* Extend clickable area without changing visual size */
    box-sizing: content-box;
    padding: 4px;
    margin: -4px;
    z-index: 110;
}

.handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.handle.n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.handle.s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.handle.e { right: -5px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.handle.w { left: -5px; top: 50%; transform: translateY(-50%); cursor: w-resize; }

.rotate-handle {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: grab;
    pointer-events: auto;
    z-index: 110;
    box-shadow: var(--shadow-md);
}

.rotate-handle svg { width: 14px; height: 14px; }

/* Layers List */
.layers-list {
    max-height: 200px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
}

.layer-item:hover { background: var(--bg-secondary); }
.layer-item.selected { background: var(--primary-light); }
.layer-icon { width: 16px; height: 16px; color: var(--text-muted); }

.layer-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-visibility {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0;
}

.layer-visibility:hover { background: var(--bg-tertiary); }
.layer-visibility svg { width: 14px; height: 14px; }
.layer-visibility[data-visible="false"] { opacity: 0.4; }

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-wrap: wrap;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.action-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.export-options {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

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

.export-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-select:focus { outline: none; border-color: var(--primary); }

.quality-slider {
    width: 80px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--border);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

#qualityValue {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 35px;
}

.quality-label { display: none; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary-hover);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
    transition: background-color var(--transition-speed);
}

.modal-content.modal-sm { max-width: 400px; }
.modal-content.modal-lg { max-width: 700px; }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    transition: border-color var(--transition-speed);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.modal-header h3 svg { width: 20px; height: 20px; color: var(--primary); }

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    padding: 0;
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-close svg { width: 20px; height: 20px; }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* ==================== Preview Modal ==================== */
.preview-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.preview-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

.preview-size {
    text-align: center;
}

.preview-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.preview-frame {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: #000;
}

.preview-frame canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* ==================== Shortcuts Modal ==================== */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}

.shortcut-row kbd {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    font-family: monospace;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-weight: 600;
}

.shortcut-row span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==================== Toast Messages ==================== */
.toast-message {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-error { border-color: var(--danger); }
.toast-error svg { color: var(--danger); width: 20px; height: 20px; flex-shrink: 0; }
.toast-success { border-color: var(--success); }
.toast-success svg { color: var(--success); width: 20px; height: 20px; flex-shrink: 0; }
.toast-message span { font-size: 0.9rem; color: var(--text); }
.toast-body { display: flex; flex-direction: column; gap: 0.25rem; }
.toast-contact {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}
.toast-contact:hover { opacity: 0.8; }

/* Form Elements */
.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

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

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Color Input */
.color-input-wrapper { display: flex; gap: 0.5rem; }

input[type="color"] {
    width: 44px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

.color-hex { flex: 1; text-transform: uppercase; font-family: monospace; }

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

/* Scoped checkbox override - avoids custom_styles.css global override */
.ytm-checkbox-wrap input[type="checkbox"],
.checkbox-label input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    border: 1px solid var(--border) !important;
    background: var(--bg-elevated) !important;
    margin-right: 0 !important;
    accent-color: var(--primary);
}

.ytm-checkbox-wrap input[type="checkbox"]:checked,
.checkbox-label input[type="checkbox"]:checked {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    accent-color: var(--primary) !important;
}

/* Align Buttons */
.align-buttons,
.style-buttons { display: flex; gap: 0.25rem; }

.align-btn,
.style-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.align-btn svg,
.style-btn svg { width: 16px; height: 16px; }

.align-btn:hover,
.style-btn:hover { border-color: var(--primary); color: var(--primary); }

.align-btn.active,
.style-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* Outline & Shadow Options */
.outline-options,
.shadow-options {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-top: 0.75rem;
    transition: background-color var(--transition-speed);
}

/* Shape Grid */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.shape-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.shape-option svg { width: 28px; height: 28px; color: var(--text-secondary); }
.shape-option span { font-size: 0.8rem; color: var(--text-muted); }
.shape-option:hover { border-color: var(--primary); }
.shape-option.selected { background: var(--primary-light); border-color: var(--primary); }
.shape-option.selected svg { color: var(--primary); }

/* Color Presets */
.color-presets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.color-preset {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-preset:hover { transform: scale(1.1); }
.color-preset.selected { box-shadow: 0 0 0 3px var(--primary); }

/* Gradient Presets */
.gradient-section { margin-bottom: 1.5rem; }
.gradient-section label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.75rem; }
.gradient-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

.gradient-preset {
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.gradient-preset:hover { border-color: var(--primary); }

.gradient-preset[data-gradient="linear-gradient(135deg, #667eea 0%, #764ba2 100%)"] { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.gradient-preset[data-gradient="linear-gradient(135deg, #f093fb 0%, #f5576c 100%)"] { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.gradient-preset[data-gradient="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"] { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.gradient-preset[data-gradient="linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)"] { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.gradient-preset[data-gradient="linear-gradient(135deg, #fa709a 0%, #fee140 100%)"] { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.gradient-preset[data-gradient="linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)"] { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }

/* Template Modal */
.template-categories {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.template-cat {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-cat:hover { border-color: var(--primary); color: var(--primary); }
.template-cat.active { background: var(--primary); border-color: var(--primary); color: white; }

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    aspect-ratio: 16/9;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.template-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.template-item canvas { width: 100%; height: 100%; }

.template-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.75rem;
    text-align: center;
}

/* Related Tools */
.related-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.related-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

.related-label svg { color: var(--primary); width: 16px; height: 16px; }

.related-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.related-link:hover { background: var(--primary); color: white; border-color: var(--primary); transform: translateY(-2px); }
.related-link svg { width: 16px; height: 16px; }

/* Info Sections */
.info-sections { display: flex; flex-direction: column; gap: 1.5rem; }

.info-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.info-card h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    color: var(--text);
    margin: 0 0 1.5rem;
}

.info-card h2 svg { color: var(--primary); flex-shrink: 0; width: 24px; height: 24px; }

/* Steps List */
.steps-list { counter-reset: step; list-style: none; padding: 0; margin: 0; }

.steps-list li {
    position: relative;
    padding-left: 3.25rem;
    margin-bottom: 1rem;
    counter-increment: step;
    color: var(--text-secondary);
    line-height: 1.6;
}

.steps-list li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: calc(1rem - 1px);
    top: 2rem;
    bottom: 0;
    width: 2px;
    background: var(--primary-light);
}

.steps-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 1;
}

.steps-list li:last-child { margin-bottom: 0; }
.steps-list li a { color: var(--primary); text-decoration: none; }
.steps-list li a:hover { text-decoration: underline; }

/* Tips Grid */
.tips-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }

.tip-item { display: flex; gap: 1rem; }

.tip-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color var(--transition-speed);
}

.tip-icon svg { width: 22px; height: 22px; color: var(--primary); }
.tip-content h4 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0 0 0.25rem; }
.tip-content p { font-size: 0.9rem; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.tip-content a { color: var(--primary); text-decoration: none; }
.tip-content a:hover { text-decoration: underline; }

/* Specs Table */
.specs-table {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-speed);
}

.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: border-color var(--transition-speed);
}

.spec-row:last-child { border-bottom: none; }
.spec-row:nth-child(odd) { background: var(--bg-secondary); }
.spec-label { font-weight: 600; color: var(--text); }
.spec-value { color: var(--text-secondary); }
.spec-value a { color: var(--primary); text-decoration: none; }
.spec-value a:hover { text-decoration: underline; }

/* FAQ - Uses .faq-item.open (global from _footer.php) */
.faq-list { display: flex; flex-direction: column; gap: 0.75rem; }

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-speed);
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    transition: all 0.2s ease;
}

.faq-question:hover { background: var(--bg-tertiary); }

.faq-question svg {
    flex-shrink: 0;
    color: var(--primary);
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.faq-item.open .faq-question svg { transform: rotate(180deg); }

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.open .faq-answer { max-height: 300px; }

.faq-answer p {
    padding: 1rem 1.25rem;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.faq-answer a { color: var(--primary); text-decoration: none; }
.faq-answer a:hover { text-decoration: underline; }

/* ==================== Responsive ==================== */
@media (max-width: 1000px) {
    /* JS fitToScreen handles sizing; just ensure it never overflows */
    #thumbnailCanvas { max-width: 100%; }
}

@media (max-width: 900px) {
    .controls-row { grid-template-columns: 1fr; }
    .layers-list { max-height: 150px; }
}

@media (max-width: 768px) {
    .tool-container { padding: 1rem; }
    .tool-title-row { gap: 0.75rem; }
    .tool-icon-wrapper { width: 48px; height: 48px; }
    .tool-icon-wrapper svg { width: 22px; height: 22px; }
    
    .quick-start { flex-direction: column; align-items: flex-start; }
    .quick-start-presets { width: 100%; overflow-x: auto; padding-bottom: 0.5rem; }
    
    .editor-toolbar { padding: 0.5rem; }
    .toolbar-divider { display: none; }
    .toolbar-right { width: 100%; justify-content: center; margin-top: 0.5rem; margin-left: 0; }
    
    #thumbnailCanvas { max-width: 100%; }
    
    .action-bar { flex-direction: column; align-items: stretch; }
    .action-right { flex-direction: column; }
    .export-options { justify-content: center; }
    .quality-label { display: inline; }
    .btn { width: 100%; }
    
    .template-grid { grid-template-columns: repeat(2, 1fr); }
    .tips-grid { grid-template-columns: 1fr; }
    .related-tools { flex-direction: column; align-items: flex-start; }
    .info-card { padding: 1.5rem; }
    .form-row { grid-template-columns: 1fr; }
    .prop-row-2 { grid-template-columns: 1fr; }
    
    .preview-sizes { flex-direction: column; align-items: center; }
}

@media (max-width: 480px) {
    .tool-title-row { flex-direction: column; gap: 0.5rem; }
    .template-grid { grid-template-columns: 1fr; }
    .shape-grid { grid-template-columns: repeat(2, 1fr); }
    .tip-item { flex-direction: column; }
    .tip-icon { width: 40px; height: 40px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* Selection */
::selection { background: rgba(230, 78, 78, 0.2); color: var(--text); }
[data-theme="dark"] ::selection { background: rgba(248, 113, 113, 0.3); }

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
